refactor: move chefignore + ACL merge logic into cinc-api#155
Merged
Conversation
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>
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
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.go—path.Matchagainst the full path, basename, and ancestor directories.cli/policyfile/resolver/chefignore.go— aFile.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.fnmatchcopy 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.kitchenexcluding 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 methodsExpandPerm,ACL.ACEFor, andACE.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,
LocalCookbookFromDirnow 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 .cleango vet ./...cleango test ./...passing — incl. resolver golden-lock tests (TestResolveMatchesChefGoldens,TestComputeIdentifierGoldenValues) byte-identical, and all ACL unit tests incl. the friendly no-opgo test -tags acceptance ./test/...(ACL + Policy + Cookbook subset) passing against cinc-zeromake docs— no changes (no help surface changed)🤖 Generated with Claude Code