Repository navigation
Explain credentials file and profile errors for new users - #319
Merged
Merged
Conversation
Errors about the credentials file and its profiles now say which profile and file are involved, what the setting is for, and the line or command that fixes it, instead of terse fragments like "config: profile is missing client_name". Load records each profile's section name, file and server URL key, so Profile.Validate can name them without the command layer passing context down. Wrapped errors still match ErrMissingServerURL, fs.ErrNotExist and toml.ParseError with errors.Is/As. Covers missing client_name/client_key, a server URL with no organization or no scheme, unknown profiles (listing the ones that exist and the env var that picked the name), missing/unreadable/malformed credentials files (with the TOML line at fault), write failures, config create's missing flags, the no-credentials-yet message, config validate's check details, knife credentials migration, and explore's unknown --profile. behStderrLine now allows a multi-line message, still failing on a second "Error:" or a usage dump. Signed-off-by: Tim Smith <tsmith84@proton.me>
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.
Errors about the credentials file and its profiles now name the profile and file involved, say what the setting is for, and show the line or command that fixes it. Same approach as #317, scaled to each problem: a missing flag gets a sentence and an example; a concept (client name, organization, credentials file) gets a short explanation and the fix.
How
config.Loadrecords each profile's section name, file path and which server URL key it used (cinc_server_urlorchef_server_url) in unexported fields, soProfile.Validatecan name them without the command layer threading context through. A profile built in memory falls back to "this profile". The messages live incli/config/errors.go. Wrapped errors still matchErrMissingServerURL,fs.ErrNotExist,fs.ErrPermissionandtoml.ParseErrorviaerrors.Is/As.behStderrLine(integration) now accepts a multi-line message. It still fails on a secondError:or a usage dump.make test-integrationpasses.Before / after
Missing client_name:
Server URL with no organization (names the key the file actually uses):
Malformed file:
Unknown profile:
When the name came from
CINC_PROFILE/CHEF_PROFILE, the message says so and suggests changing that variable.Missing
--configfile:No credentials yet, no terminal:
config createflags:config validatecheck details:A multi-line detail, such as a parse error, is indented under its check.
Also changed
ValidateSiteURL, Supermarket identity (dropped an em dash), empty profile name, home directory lookup, unreadable file (chmod 600hint), and write/stat/mkdir/chmod/encode failures inWriteProfile.CheckChefnames the bad line.cinc explore --profile <unknown>lists the profiles there are.config validatedetails: client_name, client_key, endpoint, ssl_verify_mode (shows the bad value and the leading colon), DNS failure, empty file.