Refactor CLI to modular architecture, add linted CI, multi-arch builds, and tag-based releases#3
Open
Refactor CLI to modular architecture, add linted CI, multi-arch builds, and tag-based releases#3
Conversation
test on: push
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the CLI from a monolithic procedural design into a modular, testable architecture while maintaining the same command-line interface. It introduces robust CI/CD pipelines with linting, multi-architecture builds, and automated tag-based releases.
Key changes:
- Restructured code into separate packages (
app/,app/commands/,app/services/,app/environment/,app/client/,app/models/) for better separation of concerns - Replaced manual HTTP handling with the
restylibrary for cleaner HTTP client implementation - Changed from implicit path derivation (from executable directory) to explicit
VAULT_PATHenvironment variable requirement - Added comprehensive CI workflows including linting, dependency review, multi-arch binary builds, and GoReleaser-based releases
Reviewed Changes
Copilot reviewed 19 out of 25 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| go.mod | Updated Go version to 1.22 and added resty dependency |
| dcs.go | Refactored from monolithic main to modular service orchestration |
| app/app.go | New application orchestration layer with command routing |
| app/commands/commands.go | Command execution logic with docker compose integration |
| app/services/secrets.go | Secret retrieval service with Vault KV v2 API integration |
| app/models/get_secrets_result.go | Typed models for Vault API responses |
| app/environment/environment.go | Environment variable validation and accessor service |
| app/client/http_client.go | HTTP client wrapper using resty with header management |
| README.md | Added comprehensive usage documentation with examples |
| .goreleaser.yaml | GoReleaser configuration for release automation |
| .golangci.yml | Linter configuration with enabled rules |
| .github/workflows/go.yml | CI workflow for build, test, and lint |
| .github/workflows/release.yml | Tag-based release workflow |
| .github/workflows/slsa-goreleaser.yml | Multi-arch binary builds on main branch |
| .github/workflows/dependency-review.yml | Dependency security scanning for pull requests |
| .slsa-goreleaser/*.yml | SLSA build configurations for various OS/arch combinations |
Files not reviewed (4)
- .idea/.gitignore: Language not supported
- .idea/docker-compose-secrets.iml: Language not supported
- .idea/modules.xml: Language not supported
- .idea/vcs.xml: Language not supported
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
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
This PR refactors the CLI from a single procedural
maininto a modular, testable design and introduces robust CI/release automation. It keeps the same CLI surface (start|stop|restart|update), but significantly improves structure, error handling, and security posture.Key Go code changes
app/top-level application orchestration (Application).app/commands/command routing and execution of docker compose.app/services/secret retrieval and response parsing.app/environment/environment variable validation and accessors.app/client/HTTP client (resty) with typed header constants.app/models/typed models for Vault KV v2 responses.dcs.godid argument parsing, HTTP calls, JSON parsing, anddocker composeexecution inline.dcs.gowires services;Applicationdelegates tocommands.Service; secrets fetched viaSecretServiceand injected intoexec.Cmdenv.environment.Service.VAULT_PATHinstead of deriving the path from the binary’s directory name.restyto simplify HTTP requests and headers management.HeaderVaultTokenNameconstant; guarded with//nolint:gosecas it’s not a credential.app/modelsand dedicated JSON parsing with semantic error handling (errors array, missing data).exec.Cmd, inject env, and run with inherited stdio.updatepulls images, thenrestartis executed automatically at the application level.log.Fatalon irrecoverable states, clear messages when no secrets found.fmt.Errorfused instead oferrors.New(fmt.Sprintf(...)).Behavior changes (user-facing)
VAULT_ADDR,VAULT_TOKEN, and now explicitlyVAULT_PATH(previously the path was implicitly derived from executable directory name). This is a deliberate change for clarity and portability.updateperformsdocker compose pulland then restarts the stack.CI and release automation
.github/workflows/go.yml):golangci-lintonpushandpull_request.pull_requestto avoid base/head ref errors onpush.main:slsa-goreleaser.ymlbuilds matrix artifacts forlinux/darwinonamd64/arm64and uploads them as workflow artifacts..goreleaser.yaml(not a workflow) withCGO_ENABLED=0,-trimpath,-s -w, archives and checksums.release.yml) on tagsv*, GoReleaser action pinned tov1.26.2.Why
Risks and mitigations
VAULT_PATHrequired. Mitigated with README Usage docs and clear error message.resty: mature, widely used; impact limited to HTTP client.update: aligns with operational expectations; documented.How to test
main→ check “Build binaries on master” artifacts.v1.1(orvX.Y.Z) → GoReleaser publishes archives and checksums.Docs
VAULT_ADDR,VAULT_TOKEN,VAULT_PATH), commands, and examples (export and one-liner).