-
-
Notifications
You must be signed in to change notification settings - Fork 362
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tweak output of troubleshoot command when the CLI is unconfigured #675
Conversation
Instead of passing just the viper config, which could be empty, pass the full config.Configuration value, which has access to defaults. This will let us give better debugging output.
The home directory is never written to the viper config, we get it from the environment, which is stored in the config.Configuration value.
Rather than providing an empty string for the workspace in the troubleshoot command when the CLI is unconfigured, this now says Workspace: /the/actual/path (default)
In the old CLI we had a single config file. Now we potentially have several. They will all live in the config directory. The troubleshoot command now outputs the directory instead of the file. If the troubleshoot command is unconfigured, this would previously have given an empty string for the config file. Now it will always print the default config directory, unless the user has specifically defined an override using environment variables.
It was unnecessary to have an additional local variable.
The config package has logic for the settings URL, we shouldn't be hard-coding it here.
Is the
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left a couple of questions for you. But this is otherwise good.
@@ -112,7 +114,7 @@ func (status *Status) check() (string, error) { | |||
status.Version = newVersionStatus(status.cli) | |||
status.System = newSystemStatus() | |||
status.Configuration = newConfigurationStatus(status) | |||
status.APIReachability = newAPIReachabilityStatus(status.cfg.GetString("apibaseurl")) | |||
status.APIReachability = newAPIReachabilityStatus(status.cfg) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Passing the config here seems a bit heavy handed. What if instead of the original value you passed config.InferSiteURL(v.GetString("apibaseurl"))
? Would that not achieve the same thing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, the site URL is not the same as the API, so it would call https://exercism.io/ping (which would fail with a 404).
The I went with |
If you modify the config file and remove only the workspace config the CLI reports that the API token is also not configured even if it is part of the config. It appears to me that we should should report for the Workspace so that if a user opens an issue we can quickly see that their CLI is entirely unconfigured (I.e missing the most important part the workspace) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I think what you have is better. It is easy to see that workspace is not configured because of the string (default).
Right now the output of troubleshoot is a bit unhelpful when the CLI is unconfigured.
The configuration section should be able to tell us what the home directory is, no matter what (that should not rely on configuring the CLI).
We can output what the default workspace would be, as long as we clarify that it's not actually configured.
The
Config
field should show the default config directory, even if we haven't create it.Lastly, we should use the default site URL for ping.
This PR fixes all of the above:
It is probably easiest to review commit-by-commit.
Closes #671