Skip to content

refactor: code quality improvements and bug fixes#12

Merged
veerendra2 merged 6 commits intomainfrom
refactor/code-quality-improvements
Apr 4, 2026
Merged

refactor: code quality improvements and bug fixes#12
veerendra2 merged 6 commits intomainfrom
refactor/code-quality-improvements

Conversation

@veerendra2
Copy link
Copy Markdown
Owner

@veerendra2 veerendra2 commented Apr 2, 2026

Summary

Bug fixes:

  • Fix LabelAppVersion stamping containerd version instead of app version
  • Fix 7-char SHA used for equality comparison (full hash for correctness, short for logs)
  • Fix Infisical SecretPath help text copy-paste error
  • Unify label namespace under composeflux.* (composeflux.managed: true)

Code improvements:

  • Eliminate double LoadProject per stack in Sync()
  • Move dClient.Prune into reconciler's Prune() method
  • Remove SecretsCollection wrapper — FetchAll() returns []Secret
  • Deduplicate cmd boilerplate via CommonConfig.Setup()
  • Extract isManagedStack() helper for label checks
  • Split utils.go into focused files (discover.go, etc.)
  • Unexport internal cache methods and package-only constants
  • Fix IdID naming in secrets package
  • Clean up zero-value inits and verbose returns

Dependency bumps (supersedes #10):

  • docker/cli v29.2.1 → v29.3.1
  • docker/compose v5.1.0 → v5.1.1
  • containerd v2.2.1 → v2.2.2
  • infisical/go-sdk v0.6.8 → v0.6.9
  • moby/moby/client v0.2.2 → v0.3.0
  • Fix deprecated Secrets().List()Secrets().ListSecrets()

Test plan

  • go vet ./... passes
  • go build ./... passes
  • Manual deploy test with existing stacks (label migration on redeploy)

🤖 Generated with Claude Code

veerendra2 and others added 2 commits April 2, 2026 17:22
Bug fixes:
- Fix LabelAppVersion stamping containerd version instead of app version
- Fix 7-char SHA used for equality comparison (now compares full hash)
- Fix Infisical SecretPath help text copy-paste error
- Unify label namespace under composeflux.*

Code improvements:
- Eliminate double LoadProject per stack in Sync()
- Move dClient.Prune into reconciler's Prune method
- Remove unnecessary SecretsCollection wrapper struct
- Deduplicate cmd boilerplate via CommonConfig.Setup()
- Extract isManagedStack helper for label checks
- Split utils.go into focused files (discover.go, etc.)
- Unexport internal cache methods and package-only constants
- Fix Id vs ID naming convention in secrets package
- Clean up zero-value inits and verbose returns

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Bump docker/cli v29.3.1, docker/compose v5.1.1, containerd v2.2.2,
infisical/go-sdk v0.6.9, moby/moby/client v0.3.0.

Replace deprecated Secrets().List() with Secrets().ListSecrets()
to fix staticcheck SA1019 lint failure.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Fix label names: compose.stack.* → composeflux.* namespace
- Fix docker ps filter example to use new label format
- Update AGENTS.md naming examples (CacheGet→Sync, LabelManagedBy→LabelManaged)
- Fix Go version references (1.26.0→1.26.1, 1.25+→1.26+)
- Update cacheClear reference to unexported form
- Add missing "Automatic Image Updates" feature to docs/index.md

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@veerendra2 veerendra2 added the build Builds dev docker image label Apr 2, 2026
@veerendra2 veerendra2 marked this pull request as ready for review April 3, 2026 19:07
@veerendra2 veerendra2 requested a review from Copilot April 3, 2026 19:07
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors ComposeFlux internals to simplify reconciliation flow, unify label semantics under composeflux.*, and modernize secrets fetching APIs, while also bumping several Docker/Compose-related dependencies.

Changes:

  • Standardize stack management labels (composeflux.managed=true, composeflux.stack-hash) and fix app version labeling.
  • Refactor reconciler to avoid redundant project loads, centralize pruning logic, and unexport internal cache helpers.
  • Simplify secrets clients by removing SecretsCollection and returning []Secret directly; bump Docker/Compose/containerd/Infisical/moby dependencies.

Reviewed changes

Copilot reviewed 21 out of 22 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
pkg/source/git.go Uses full SHAs for comparisons and short SHAs for logging; unexports git constants.
pkg/secrets/infisical.go Fixes config field naming/help text; updates SDK call and returns []Secret.
pkg/secrets/client.go Removes SecretsCollection; changes FetchAll() to return []Secret.
pkg/secrets/bitwarden.go Renames ID fields to OrgID/ProjectID; returns []Secret.
internal/reconcile/sync.go Avoids double LoadProject; calls reconciler Prune(); unexports cache clear.
internal/reconcile/run.go Removes Timers type (moved to reconcile.go); unchanged loop behavior.
internal/reconcile/reconcile.go Hosts Timers and removes explicit zero-value initializations.
internal/reconcile/prune.go Adds isManagedStack() and moves getStackStates() here; prunes Docker resources.
internal/reconcile/discover.go Uses unexported cache accessor; removes moved checksum/state logic.
internal/reconcile/deploy.go Unifies label namespace and fixes app version source; adds checksum helper.
internal/reconcile/cache.go Unexports cache methods and relocates loadCache() into cache module.
go.mod Bumps docker/cli, docker/compose, infisical/go-sdk, moby client; containerd becomes indirect.
go.sum Updates sums for dependency bumps.
docs/Introduction.md Updates documented hash label to composeflux.stack-hash.
docs/index.md Adds feature bullet for scheduled image updates.
docs/GettingStarted.md Updates docker label filter to composeflux.managed=true.
docs/Development.md Updates Go prerequisite to 1.26+.
compose-dev.yml Expands env var documentation/comments; aligns with new config surface.
cmd/composeflux/sync.go Uses shared CommonConfig.Setup() instead of duplicating signal/version boilerplate.
cmd/composeflux/run.go Uses shared CommonConfig.Setup() instead of duplicating signal/version boilerplate.
cmd/composeflux/common.go Adds Setup() helper; updates validations to renamed ID fields; improves logging.
AGENTS.md Updates Go version and reflects renamed labels/cache methods in conventions section.
Comments suppressed due to low confidence (1)

internal/reconcile/discover.go:48

  • Comment grammar: discoverComposeStack is singular, but the sentence reads awkwardly. Consider rewording to e.g. “discoverComposeStack finds directories containing Docker Compose files.”

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread internal/reconcile/prune.go Outdated
Comment thread internal/reconcile/prune.go Outdated
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@veerendra2 veerendra2 merged commit 48cbf7d into main Apr 4, 2026
2 checks passed
@veerendra2 veerendra2 deleted the refactor/code-quality-improvements branch April 4, 2026 19:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build Builds dev docker image

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants