Skip to content
This repository was archived by the owner on Dec 21, 2023. It is now read-only.

fix(cli): skip version check on install#5046

Merged
bacherfl merged 6 commits intokeptn:masterfrom
vadasambar:fix/3158/skip-version-check-for-install
Sep 10, 2021
Merged

fix(cli): skip version check on install#5046
bacherfl merged 6 commits intokeptn:masterfrom
vadasambar:fix/3158/skip-version-check-for-install

Conversation

@vadasambar
Copy link
Copy Markdown
Member

@vadasambar vadasambar commented Aug 25, 2021

This PR

  • skips version check on keptn install

Related Issues

Fixes #3158

How to test

  1. Run keptn install locally without a cluster running. You should not see a Warning message like this.
  2. Run any other command like keptn auth or keptn uninstall without a cluster running and you should see a Warning message like this.

@vadasambar vadasambar force-pushed the fix/3158/skip-version-check-for-install branch from 9385d56 to 8cea6b3 Compare August 25, 2021 16:09
cli/cmd/root.go Outdated
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PersistentPreRun cannot be skipped conditionally based on the subcomand.

@codecov
Copy link
Copy Markdown

codecov bot commented Aug 26, 2021

Codecov Report

Merging #5046 (96a01e6) into master (d9ac0ed) will decrease coverage by 0.47%.
The diff coverage is 92.85%.

@@            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     
Impacted Files Coverage Δ
cli/cmd/root.go 63.75% <92.85%> (+6.39%) ⬆️
cli/cmd/version.go 51.61% <0.00%> (-4.31%) ⬇️
secret-service/pkg/repository/scopes.go
secret-service/pkg/backend/registry.go
secret-service/pkg/backend/secretbackend_k8s.go
secret-service/pkg/handler/secrethandler.go
secret-service/pkg/common/utils.go
secret-service/pkg/handler/common.go

Signed-off-by: Suraj Banakar (vadasambar) <[email protected]>
@vadasambar vadasambar force-pushed the fix/3158/skip-version-check-for-install branch from 8cea6b3 to 1b076ed Compare August 27, 2021 16:53
- `panic`'ing right now

Signed-off-by: Suraj Banakar (vadasambar) <[email protected]>
@johannes-b
Copy link
Copy Markdown
Member

Hello @vadasambar,
thanks for working on this issue. Can you please address the broken unit test: https://github.com/keptn/keptn/pull/5046/checks?check_run_id=3492104219?

Signed-off-by: Suraj Banakar (vadasambar) <[email protected]>
@vadasambar vadasambar force-pushed the fix/3158/skip-version-check-for-install branch from f1da7a1 to e8d29ee Compare September 2, 2021 16:30
@vadasambar
Copy link
Copy Markdown
Member Author

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) {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

metadataStatus int
metadataResponse keptnapimodels.Metadata
cliVersion string
flags []string
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

wantOutput: "* Warning: could not check Keptn server version: received invalid response from Keptn API\n",
},
{
name: "skip version check for 'keptn install'",
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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]>
@vadasambar vadasambar marked this pull request as ready for review September 6, 2021 15:58
@vadasambar vadasambar requested a review from a team as a code owner September 6, 2021 15:58
- 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]>
@vadasambar vadasambar force-pushed the fix/3158/skip-version-check-for-install branch from 8bc5b41 to 96a01e6 Compare September 9, 2021 15:32
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Sep 9, 2021

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

Copy link
Copy Markdown
Member

@bacherfl bacherfl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@bacherfl bacherfl merged commit a5aecd4 into keptn:master Sep 10, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cli: keptn version checking on install

3 participants