Skip to content
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

Merged
merged 7 commits into from
Jul 26, 2018

Conversation

kytrinyx
Copy link
Member

@kytrinyx kytrinyx commented Jul 24, 2018

Right now the output of troubleshoot is a bit unhelpful when the CLI is unconfigured.

Configuration
----------------
Home:      
Workspace: 
Config:    
API key:   <not configured>
Find your API key at https://exercism.io/my/settings

API Reachability
----------------
Exercism:
    * /ping
    * [Get /ping: unsupported protocol scheme &#34;&#34;]
    * 52.222µs

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:

Configuration
----------------
Home:      /Users/kytrinyx
Workspace: /Users/kytrinyx/Test-On-Branch (default)
Config:    /Users/kytrinyx/.config/test-on-branch
API key:   <not configured>
Find your API key at https://exercism.io/my/settings

API Reachability
----------------
Exercism:
    * https://api.exercism.io/v1/ping
    * [connected]
    * 663.848701ms

It is probably easiest to review commit-by-commit.

Closes #671

Katrina Owen added 7 commits July 24, 2018 14:41
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.
@kytrinyx kytrinyx requested a review from nywilken July 24, 2018 22:00
@nywilken
Copy link
Contributor

nywilken commented Jul 24, 2018

Is the <not configured> for the API token enough to denote that the CLI was never configured? Or should we be a bit more explicit with something like the following

Workspace:  <not configured>  (default /Users/kytrinyx/Test-On-Branch)

Copy link
Contributor

@nywilken nywilken left a 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)
Copy link
Contributor

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?

Copy link
Member Author

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).

@kytrinyx
Copy link
Member Author

Is the <not configured> for the API token enough to denote that the CLI was never configured?

The <not configured> for the API token means that the API token is not configured. It doesn't speak for the rest of the values.

I went with (default) because if you don't explicitly overwrite the workspace, that is what will be written, but I think that your suggestion would be fine as well. I don't have very strong feelings either way. Which do you prefer?

@nywilken
Copy link
Contributor

I went with (default) because if you don't explicitly overwrite the workspace, that is what will be written, but I think that your suggestion would be fine as well. I don't have very strong feelings either way. Which do you prefer?

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)

Copy link
Contributor

@nywilken nywilken left a 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).

@nywilken nywilken merged commit 41999e7 into master Jul 26, 2018
@nywilken nywilken deleted the unconfigured-troubleshoot branch July 26, 2018 03:16
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.

Clarify configuration status in troubleshoot command
2 participants