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

crc config get returns an error code when the setting has a default value #3678

Closed
gbraad opened this issue May 24, 2023 · 5 comments · Fixed by #3694
Closed

crc config get returns an error code when the setting has a default value #3678

gbraad opened this issue May 24, 2023 · 5 comments · Fixed by #3694

Comments

@gbraad
Copy link
Contributor

gbraad commented May 24, 2023

image

@cfergeau
Copy link
Contributor

2.18.0 and 2.10.0 both have the same behaviour, so if this is a regression it's not a recent one.

@cfergeau
Copy link
Contributor

if v.IsDefault {
return fmt.Errorf("Configuration property '%s' is not set. Default value is '%s'", key, v.AsString())

@gbraad
Copy link
Contributor Author

gbraad commented May 24, 2023

This seems to be an inconsistency. Defaults are not an error IMNSHO ;-)

@jsliacan
Copy link
Contributor

2.18.0 and 2.10.0 both have the same behaviour, so if this is a regression it's not a recent one.

@cfergeau I think back then it was less obvious. It wouldn't have happened if you did this I think.

$ crc config set preset openshift
$ echo $?
0
$ crc config get preset
Configuration property 'preset' is not set. Default value is 'openshift'
$ echo $?
1

@gbraad
Copy link
Contributor Author

gbraad commented May 24, 2023

It is maybe not a regression, but an inconsistency; it makes no sense to error out when it is the default

cfergeau added a commit to cfergeau/crc that referenced this issue Jun 1, 2023
`crc config get xxx` prints:
```
Configuration property 'xxx' is not set. Default value is 'yyy'
```
when its value is not set, but the command exit code is 1.

Since '1' is returned for errors (`crc config get invalid-prop`), this
is not the correct exit code. This commit changes it to 0, which is the
same as successful `crc config get` calls when the value is not the
default one.

This fixes crc-org#3678
openshift-merge-robot pushed a commit that referenced this issue Jun 2, 2023
`crc config get xxx` prints:
```
Configuration property 'xxx' is not set. Default value is 'yyy'
```
when its value is not set, but the command exit code is 1.

Since '1' is returned for errors (`crc config get invalid-prop`), this
is not the correct exit code. This commit changes it to 0, which is the
same as successful `crc config get` calls when the value is not the
default one.

This fixes #3678
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants