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

fix(cli): switch automatic version check based on config#5290

Merged
bacherfl merged 1 commit intokeptn:masterfrom
vadasambar:fix/5218/fix-automatic-version-check-flag
Oct 15, 2021
Merged

fix(cli): switch automatic version check based on config#5290
bacherfl merged 1 commit intokeptn:masterfrom
vadasambar:fix/5218/fix-automatic-version-check-flag

Conversation

@vadasambar
Copy link
Copy Markdown
Member

@vadasambar vadasambar commented Sep 17, 2021

This PR

Fixes #5218

How to test

You should not be able to reproduce the issue (check under "To Reproduce") in this comment

@codecov
Copy link
Copy Markdown

codecov bot commented Sep 21, 2021

Codecov Report

Merging #5290 (77c31da) into master (49ca272) will decrease coverage by 0.46%.
The diff coverage is 63.63%.

@@            Coverage Diff             @@
##           master    #5290      +/-   ##
==========================================
- Coverage   53.21%   52.74%   -0.47%     
==========================================
  Files         304      298       -6     
  Lines       17793    17528     -265     
  Branches      813      813              
==========================================
- Hits         9468     9245     -223     
+ Misses       7444     7410      -34     
+ Partials      881      873       -8     
Impacted Files Coverage Δ
cli/cmd/root.go 67.94% <63.63%> (+4.19%) ⬆️
cli/pkg/platform/platform_manager.go 13.04% <0.00%> (-0.29%) ⬇️
cli/cmd/install.go 48.03% <0.00%> (ø)
secret-service/pkg/backend/registry.go
secret-service/pkg/common/utils.go
secret-service/pkg/backend/secretbackend_k8s.go
secret-service/pkg/handler/common.go
secret-service/pkg/repository/scopes.go
secret-service/pkg/handler/secrethandler.go
cli/cmd/upgrade.go 36.74% <0.00%> (+0.72%) ⬆️
... and 2 more

@vadasambar vadasambar force-pushed the fix/5218/fix-automatic-version-check-flag branch 2 times, most recently from 2c0cbc3 to c6a3f74 Compare September 29, 2021 16:05
@vadasambar vadasambar marked this pull request as ready for review September 30, 2021 15:44
@vadasambar vadasambar requested a review from a team as a code owner September 30, 2021 15:44
@vadasambar vadasambar changed the title fix(cli): WIP switch automatic version check based on config fix(cli): switch automatic version check based on config Sep 30, 2021
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.

I have used CLIConfigManager here instead of viper because we already have it in place and it works well.
TODO for the future can be to re-write NewCLIConfigManager with viper.

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 because changing rootCLIConfig directly can have impact on other tests.

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.

Passing rootCLIConfig just makes it easier to test runVersionCheck

- use cfg mgr instead of viper to load config
-- we already use it in `set config`
- pass cliconfig as an argument to runVersionCheck
-- makes it easier to test
- add hook function to shallow copy cli config
-- this is so that cli config can be tweaked for the tests
- remove viper from root cmd (not used anymore)
Signed-off-by: Suraj Banakar (vadasambar) <[email protected]>
@vadasambar vadasambar force-pushed the fix/5218/fix-automatic-version-check-flag branch from c6a3f74 to 77c31da Compare October 4, 2021 16:19
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Oct 4, 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 1 Code Smell

No Coverage information No Coverage information
2.4% 2.4% Duplication

@vadasambar vadasambar mentioned this pull request Oct 4, 2021
14 tasks
}

viper.AutomaticEnv() // read in environment variables that match
logging.PrintLog(fmt.Sprintf("Using config file: %s", cfgMgr.CLIConfigPath), logging.InfoLevel)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think we can remove this log output. Other than that the PR looks good :)

Copy link
Copy Markdown
Member Author

@vadasambar vadasambar Oct 14, 2021

Choose a reason for hiding this comment

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

Printing the above log message is the default behavior. Do you want me to change this? If yes, I would like to know the reason. Thank you!

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The main reason I was thinking of is that it might interfere with pipelines where the keptn CLI is used within scripts - but I just checked that the --quiet flag is applied correctly here, meaning that the message is not shown if this flag is set. So therefore we can leave it in there

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.

keptn set config AutomaticVersionCheck false doesn't work

2 participants