fix(cli): skip version check on install#5046
Conversation
9385d56 to
8cea6b3
Compare
cli/cmd/root.go
Outdated
There was a problem hiding this comment.
PersistentPreRun cannot be skipped conditionally based on the subcomand.
Codecov Report
@@ Coverage Diff @@
## master #5046 +/- ##
==========================================
- Coverage 52.19% 51.71% -0.48%
==========================================
Files 298 292 -6
Lines 17568 17309 -259
Branches 690 690
==========================================
- Hits 9170 8952 -218
+ Misses 7536 7501 -35
+ Partials 862 856 -6
|
Signed-off-by: Suraj Banakar (vadasambar) <[email protected]>
8cea6b3 to
1b076ed
Compare
- `panic`'ing right now Signed-off-by: Suraj Banakar (vadasambar) <[email protected]>
|
Hello @vadasambar, |
Signed-off-by: Suraj Banakar (vadasambar) <[email protected]>
f1da7a1 to
e8d29ee
Compare
|
Hey @johannes-b, thank you for the comment. I have fixed the test. |
| func runVersionCheck(vChecker *version.VersionChecker, flags []string) { | ||
| // Server version won't be available during `install` | ||
| // because the Server is not installed yet | ||
| if isInstallSubCommand(flags) { |
There was a problem hiding this comment.
Doing this in runVersionCheck instead of PersistentRun because it is easier to test runVersionCheck (we already have code for doing this here)
cli/cmd/root.go
Outdated
| } | ||
| } | ||
|
|
||
| func isInstallSubCommand(flags []string) bool { |
There was a problem hiding this comment.
TODO: Use a different variable name here. flags here means flags like -q and subcommands like install in a slice e.g., []string{"-q", "install"}
cli/cmd/root_test.go
Outdated
| metadataStatus int | ||
| metadataResponse keptnapimodels.Metadata | ||
| cliVersion string | ||
| flags []string |
There was a problem hiding this comment.
TODO: Use a different variable name here. flags here means flags like -q and subcommands like install in a slice e.g., []string{"-q", "install"}
| wantOutput: "* Warning: could not check Keptn server version: received invalid response from Keptn API\n", | ||
| }, | ||
| { | ||
| name: "skip version check for 'keptn install'", |
There was a problem hiding this comment.
I am writing unit tests related keptn install in root_test.go because the code to skip version check on install subcommand is in root.go.
|
|
||
| out := r.revertStdErr() | ||
| if !strings.Contains(out, tt.wantOutput) { | ||
| if tt.wantOutput != "" && !strings.Contains(out, tt.wantOutput) { |
There was a problem hiding this comment.
Check if tt.wantOutput is empty here because some tests have wantOutput as empty. They use doNotWantOutput instead.
- because `flags` does not include subcommands Signed-off-by: Suraj Banakar (vadasambar) <[email protected]>
- exclude `keptn` from args Signed-off-by: Suraj Banakar (vadasambar) <[email protected]>
- this is an attempt to fix reviewdog complaining about `shellwords` not being used Signed-off-by: Suraj Banakar (vadasambar) <[email protected]>
8bc5b41 to
96a01e6
Compare
|
Kudos, SonarCloud Quality Gate passed!
|








This PR
keptn installRelated Issues
Fixes #3158
How to test
keptn installlocally without a cluster running. You should not see aWarningmessage like this.keptn authorkeptn uninstallwithout a cluster running and you should see aWarningmessage like this.