-
Notifications
You must be signed in to change notification settings - Fork 54
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
[OSD-21620] Add validation for the backplane config file #420
Conversation
/retest |
1 similar comment
/retest |
The test passed locally, but got timeout in the CI... |
/retest |
7d995ec
to
0ed2136
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #420 +/- ##
==========================================
+ Coverage 44.51% 44.58% +0.07%
==========================================
Files 63 63
Lines 5284 5291 +7
==========================================
+ Hits 2352 2359 +7
Misses 2615 2615
Partials 317 317
|
pkg/cli/config/config.go
Outdated
|
||
// Validate the proxy url | ||
if viper.GetStringSlice("proxy-url") == nil && os.Getenv(info.BackplaneProxyEnvName) == "" && globalOpts.ProxyURL == "" { | ||
return fmt.Errorf("proxy-url must be set explicitly in either config file or via the environment HTTPS_PROXY or the global option --proxy") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have concerns on making proxy mandatory. There are cases where we don't need/want a proxy. Eg, for testing environment or Fedramp environment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree with you that it should not be mandatory, anyway it is Warning for now https://github.com/openshift/backplane-cli/pull/420/files#diff-4e5b97588faff423da8ddd605ee2a4760f4f168d9bdb8ad220d4adc5823ef086R67-R68
The plan is to make the field required, but it seems for some use cases, we will still need the proxy unset.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, ok, I missed the logger.Warn(err)
.
pkg/cli/config/config_test.go
Outdated
@@ -26,6 +26,19 @@ func TestGetBackplaneConfig(t *testing.T) { | |||
} | |||
}) | |||
|
|||
t.Run("It should fail if the proxy-url is not configured", func(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I expect the GetBackplaneConfiguration()
should succeed if the proxy-url is not configured. I am also confused on why this test succeed.....
API KEY in config file if login via PD
The globalFlag |
@bmeng: all tests passed! Full PR test history. Your PR dashboard. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: bmeng, mjlshen The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
validation mandatory value proxy-url in backplane config validate the PD API KEY in config file if login via PD
What type of PR is this?
(/feature/)
What this PR does / Why we need it?
There are two parts for this PR:
The original plan is to make the struct
BackplaneConfiguration
to have the mandatory fields as required, but it turns out the there are multiple ways to setup the proxy-url currently.So it is not possible to change the struct. Adding a small function to make sure the proxy url was set by any of above methods, and exit early if it is not set.
Currently, the PD API Key can be configured in config file only, and the
--pd
will be used in login sub-command only. So, just add a simple condition to check the backplane config when--pd
passed.Which Jira/Github issue(s) does this PR fix?
Resolves #OSD-21620
Special notes for your reviewer
Pre-checks (if applicable)