fix(supermarket): honor a profile's supermarket_site in the read commands - #191
Merged
Conversation
…ands supermarket.New, used only by `share`, fell back to the profile's supermarket_site. NewAnonymous, used by list, search, show, download, install and explore, did not. So a user with a private Supermarket configured published to it and read from the public one, unless they repeated --supermarket-site on every invocation. The split showed in the help text itself: `share` documented "default: profile supermarket_site, then https://supermarket.chef.io" while the other six claimed only the public default. `install` was the clearest case. It already calls resolveClient and has the profile in hand, then built the Supermarket half anonymously anyway, so it would fetch a public cookbook and upload it to the user's server when they meant their own. resolveSupermarketSite resolves flag, then profile, then the public default, sharing the profile-selection rules `share` already uses ([supermarket] preferred over [default]). It deliberately never triggers the first-run flow and never fails: these commands need no credentials, so a missing config is an absent preference, not an error. Help strings and docs/commands are regenerated to match. Signed-off-by: Tim Smith <tim@mondoo.com>
tas50
force-pushed
the
fix/supermarket-site-from-profile
branch
from
September 8, 2026 15:16
971c47d to
f3bfd73
Compare
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.
The defect
supermarket.New— used only byshare— falls back to the profile'ssupermarket_site.NewAnonymous— used bylist,search,show,download,install, andexplore— does not.So a user with a private Supermarket configured publishes to it and reads from the public one, unless they remember to repeat
--supermarket-siteon every single invocation.supermarket_siteis a key this CLI writes itself duringconfig create, validates inconfig validate, and carries across during chef migration, so it is reasonable to expect it to be honoured.The split was visible in the help text itself:
installis the clearest case. It already callsresolveClientand has the profile in hand, then builds the Supermarket half anonymously anyway — so it fetches a public cookbook and uploads it to the user's server when they meant their own.The fix
resolveSupermarketSite(cmd, siteFlag)resolves flag, then profile, then the public default, reusing the profile-selection rulessharealready applies (explicit--profile/$CINC_PROFILE/$CHEF_PROFILE, then the conventional[supermarket]section, then[default]). That selection logic is factored out intoselectSupermarketProfileand shared, rather than duplicated.Two properties it deliberately keeps:
cinc supermarket downloadwould be much worse than the bug being fixed. It reads the file directly rather than going throughloadCredentials.""and the caller uses the public default.Help strings and
docs/commands/are regenerated to match.Tests
TestSupermarketReadCommandsUseProfileSitedrivesdownload,show,search, andlistagainst a recording server named only in the profile. All four fail without the wiring:That 63 seconds is itself the evidence: the commands were making real calls to supermarket.chef.io. With the fix the same test runs in 0.77s and makes no external call, so the committed suite stays network-free.
Plus unit coverage for the precedence: flag beats profile,
[supermarket]beats[default], a profile without the key falls back, and no credentials file at all falls back rather than erroring.go test ./...,go vet ./..., andgofmt -l .are clean. Allsupermarketcommands are alreadyexemptin the coverage manifest (they need the external service), so it is unchanged.