Skip to content

refactor: move chefignore + ACL merge logic into cinc-api#155

Merged
tas50 merged 1 commit into
mainfrom
refactor/move-domain-helpers-to-api
Jun 27, 2026
Merged

refactor: move chefignore + ACL merge logic into cinc-api#155
tas50 merged 1 commit into
mainfrom
refactor/move-domain-helpers-to-api

Conversation

@tas50

@tas50 tas50 commented Jun 27, 2026

Copy link
Copy Markdown
Owner

Summary

Honor the architecture seam — cinc-api owns the Chef API object model and Chef-domain/format helpers; cinc-cli owns cobra and presentation. Two pieces of Chef-domain logic that lived duplicated in this repo now live in cinc-api and are consumed from there.

Companion cinc-api PR: tas50/cinc-api#35, merged and released as v0.11.0.

chefignore (consolidate two copies → one)

This repo had two chefignore implementations:

  • cli/cookbook/chefignore.gopath.Match against the full path, basename, and ancestor directories.
  • cli/policyfile/resolver/chefignore.go — a File.fnmatch-with-default-flags translation matching only the full relative path.

Both are deleted and all callers — the cookbook archive/build path and the policyfile resolver's identifier computation — now route through cinc-api's canonical Chefignore (LoadChefignore / Ignores).

Reconciliation: the canonical matcher keeps the cookbook copy's full-path/basename/ancestor-directory semantics. That is a superset of the resolver's old File.fnmatch copy for the patterns cookbooks actually use (*.bak, *.tmp, spec/*, bare directory names), so the resolver's cookbook content identifiers — and therefore the golden Policyfile locks — remain byte-identical. The only difference between the two old copies (a bare directory name like .kitchen excluding its descendants) doesn't affect any identifier golden, because the resolver's own walk already skips top-level dot-directories. The cookbook archive relies on that subtree exclusion, so keeping the superset preserves both behaviors.

ACL ACE merge

apps/cinc/cmd/acl.go's grant/revoke read-modify-write internals (aclPerms, aclPermsFor, aclACE, aclApply) are replaced by the cinc-api methods ExpandPerm, ACL.ACEFor, and ACE.AddMembers/RemoveMembers. The cobra flags (--user/--client/--group), help text, success/error messages, and the friendly no-op output are unchanged.

Behavior note (from cinc-api v0.11.0)

With the cinc-api fix, LocalCookbookFromDir now excludes chefignored files from cookbook uploads (previously it uploaded everything). cinc-cli picks this up by upgrading the dependency.

Dependency

go.mod: github.com/tas50/cinc-api v0.11.0 (no replace directive). Requires cinc-api ≥ v0.11.0, which is already released — mergeable as-is.

Test plan

  • gofmt -l . clean
  • go vet ./... clean
  • go test ./... passing — incl. resolver golden-lock tests (TestResolveMatchesChefGoldens, TestComputeIdentifierGoldenValues) byte-identical, and all ACL unit tests incl. the friendly no-op
  • go test -tags acceptance ./test/... (ACL + Policy + Cookbook subset) passing against cinc-zero
  • make docs — no changes (no help surface changed)

🤖 Generated with Claude Code

Honor the architecture seam: cinc-api owns the Chef API object model and
Chef-domain/format helpers; cinc-cli owns cobra and presentation. Two pieces
of Chef-domain logic that lived (duplicated) here now live in cinc-api
(github.com/tas50/cinc-api#35, released as v0.11.0) and are consumed instead.

chefignore: delete the two duplicate copies — cli/cookbook/chefignore.go and
cli/policyfile/resolver/chefignore.go — and route the cookbook archive/build
path and the policyfile resolver's identifier computation through cinc's
canonical Chefignore (LoadChefignore / Ignores). The canonical matcher keeps
the cookbook copy's full-path/basename/ancestor-directory semantics, which is
a superset of the resolver's old File.fnmatch copy for the patterns cookbooks
use, so the resolver's content identifiers — and thus the golden Policyfile
locks — stay byte-identical.

acl: replace acl.go's aclPerms/aclPermsFor/aclACE/aclApply internals with the
cinc-api methods ExpandPerm, ACL.ACEFor, and ACE.AddMembers/RemoveMembers. The
cobra flags (--user/--client/--group), messages, and friendly no-op output are
unchanged.

Requires cinc-api >= v0.11.0 (pinned). Note: with the cinc-api fix,
LocalCookbookFromDir now excludes chefignored files from uploads.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@tas50 tas50 merged commit b536081 into main Jun 27, 2026
3 checks passed
@tas50 tas50 deleted the refactor/move-domain-helpers-to-api branch June 27, 2026 20:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant