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

fix tsh config test #11603

Merged
merged 2 commits into from
Apr 1, 2022
Merged

fix tsh config test #11603

merged 2 commits into from
Apr 1, 2022

Conversation

marcoandredinis
Copy link
Contributor

The last PR on those tests had a bug
As discussed here:
#11571 (comment)

@github-actions github-actions bot added the tsh tsh - Teleport's command line tool for logging into nodes running Teleport. label Mar 31, 2022
@github-actions github-actions bot requested review from greedy52 and zmb3 March 31, 2022 08:01
tool/tsh/tshconfig_test.go Outdated Show resolved Hide resolved
@marcoandredinis marcoandredinis force-pushed the marco/fix_tshconfig_test branch from ef479fb to 56672f0 Compare April 1, 2022 08:14
@marcoandredinis marcoandredinis merged commit 1aadd4a into master Apr 1, 2022
@marcoandredinis marcoandredinis deleted the marco/fix_tshconfig_test branch April 1, 2022 08:41
marcoandredinis added a commit that referenced this pull request Apr 1, 2022
check for error when writing to a file
marcoandredinis added a commit that referenced this pull request Apr 4, 2022
check for error when writing to a file
marcoandredinis added a commit that referenced this pull request Apr 5, 2022
check for error when writing to a file
marcoandredinis added a commit that referenced this pull request Apr 5, 2022
* tsh: ignore empty or non-existing config files (#11495)

If the newly created config.yaml didnt exist we would load the default
values and continue the flow
However, we were not resetting the `err`'s value and would have an ERROR
message at the end and an invalid exit code

Most of the commands would reset that variable to the output of the
command's execution
One of them was not: `tsh version`
The version command has no return value, so the program would execute
as expected until the last statement: `trace.Wrap(error)` which would
re-use the `err` variable whose value is the result of the `loadConfig`
method.

We could either reset the `err`s value inside the `PrintVersion` switch
case block or reset it right after we check for `IsNotFound`.

We ended up picking the first option as it seems cleaner

```
 # before
$ make full > /dev/null; build/tsh version
Teleport v10.0.0-dev git:v8.0.0-alpha.1-899-g335adf1f4 go1.18
ERROR: open /home/marco/.tsh/config/config.yaml: no such file or directory

 # after
$ make full > /dev/null; build/tsh version
Teleport v10.0.0-dev git:v8.0.0-alpha.1-899-g335adf1f4 go1.18
```

* fix tsh config test (#11603)

check for error when writing to a file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tsh tsh - Teleport's command line tool for logging into nodes running Teleport.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants