feat: add update and cleanup lifecycle subcommands - #27
Merged
Conversation
Mirror apple/container's update-container.sh / uninstall-container.sh so the whole stack can be updated or torn down with one command. `update` resolves the target release (latest, or --version), downloads it from GitHub, verifies the sha256 from checksums.txt, replaces the running binary in place (atomic rename, with a sudo-install fallback for a root-owned prefix), and re-runs setup so the service restarts on the new binary. --all also updates OpenShell (brew) and apple/container via its own updater; --no-setup replaces the binary only. `cleanup` layers like apple/container's uninstaller: the bare command removes only the driver service and gateway.env wiring; -d/--delete-data also removes the driver's state dir, socket dir, vmnet network and pulled images (-k/--keep-data is the default); --all also removes the prerequisites (brew uninstall openshell, then apple/container's own uninstaller, which needs sudo). uninstall becomes an alias for cleanup. The Homebrew probe, the apple/container uninstaller path, and the OpenShell var dir are injectable, so cleanup is unit-tested without touching real system paths; update's checksum verification and tar extraction are covered too. Signed-off-by: Vyncint Ng <vyncint@users.noreply.github.com>
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.
Adds one-command lifecycle management for the whole stack, mirroring apple/container's own
update-container.sh/uninstall-container.sh -k|-dscripts (which is what prompted this).updateResolves the target tag (GitHub
releases/latestor--version), downloads the darwin/arm64 asset, verifies its sha256 againstchecksums.txt, extracts the binary, and replaces the running one in place — atomic rename within the prefix dir (works while the old binary is still running), with asudo installfallback for a root-owned prefix. Then re-runssetupso the launchd service restarts on the new binary.--alladditionally runsbrew upgrade openshelland apple/container'supdate-container.sh.cleanup(uninstallis now an alias)Layers exactly like apple/container's uninstaller:
-k/--keep-datais the default; a bare command never touches apple/container. apple/container's uninstaller needssudo, so it (andbrew) run attached to the terminal to prompt.Design notes
Uninstall()becameCleanup(CleanupOptions); the CLIuninstallsubcommand delegates to it, so existing behavior (driver-only, data kept) is unchanged./opt/homebrew/var/openshell).Verification
-d/--all/--all -d, and the OpenShell-absent path) +update's checksum verification and tar.gz extraction.go test -race ./...,golangci-lint(0 issues),make sec(govulncheck + gosec + gitleaks) all clean.update --version v0.2.3 --no-setuppipeline against the actual GitHub release — downloaded, checksum-verified, extracted, and replaced a throwaway binary successfully (Go's HTTP client had no trouble with the GitHub CDN). The running gateway/driver was left untouched. Destructive cleanup paths are covered by the command-issuance unit tests rather than a live teardown, to preserve the working install.