Repository navigation
Make kcvm reliable - #1
Merged
Merged
Conversation
- install: download next to the final binary and rename into place, which fixes cross-device rename failures when /tmp is a separate filesystem and never leaves partial downloads behind - install: verify the published sha256 checksum, create ~/.kcvm/bin when missing, skip already installed versions unless --force is given - install/use: switch the kubectl symlink atomically, which also fixes switching away from a version whose binary was deleted - validate and normalize version arguments (1.20.0 -> v1.20.0) - list remote: list tags with a single git ls-refs request instead of a dozen rate limited GitHub API calls, report errors, sort by version - list local: skip unexpected files instead of panicking, mark the active version, explain how to initialize kcvm when needed - resolve --dir to an absolute path so the symlink stays valid - tests run against local fake servers instead of the real network
Every run publishes a release with the hardcoded release-tag. Only allow manual runs until releases are reworked.
Set the version to v0.3.0. The binary embeds the file, so kcvm --version is correct for go install builds too, and the release workflow tags releases with it instead of a hardcoded release-tag.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the bugs and fragile spots in kcvm's commands. The CI workflow is unchanged.
Bug fixes
~/.kcvm/binand renames the file into place once complete. This fixes cross-device rename failures when/tmpis a separate filesystem, and failed downloads no longer leave files behind.kubectlsymlink in a single atomic step. This also fixes switching away from a version whose binary was deleted, which used to fail with "file exists".bin/instead of crashing.--diris made absolute, so a relative path no longer creates a symlink that only works from one directory.Reliability
ls-refsrequest, the same onegit ls-remote --tagsmakes, instead of 13 paginated GitHub API calls. That avoids the 60 requests/hour unauthenticated limit. Errors are reported instead of producing a partial list, and versions are sorted newest first.1.20.0is accepted asv1.20.0.Other
installcreates~/.kcvm/binwhen missing. Already-installed versions are skipped unless--forceis given.initwarns when~/.kcvmisn't on$PATH.go.modrequires Go 1.16 instead of 1.14.go installoption and a working download link.Behavior changes
list localmarks the active version with*and indents the others by two spaces.list remotelists newest first.--forcedownloads it again.Testing
go test ./test/kcvm/runs 17 tests against local fake servers, with no network needed.list remote(575 stable versions), installing v1.31.0 and v1.30.2 with checksum checks,use,list local, and installing a version that doesn't exist.Versioning and CI
VERSIONfile holds the version, nowv0.3.0; bump it for every new version. The binary reads it at build time, sokcvm --versionis correct forgo installbuilds too, and a test checks the file contains a valid version.v0.2.2-beta1release, including on pull requests. When run by hand, it now takes the release tag fromVERSION.