-
Notifications
You must be signed in to change notification settings - Fork 66
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
updating ospid logic to exit if legacy project id is provided #773
updating ospid logic to exit if legacy project id is provided #773
Conversation
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.
Couple of suggestions..
certification/runtime/config.go
Outdated
// counting the `-` values, if the user provides more than one, we know they inputted a legacy project id | ||
// which can not be used to query pyxis, exiting early to show the help menu | ||
if strings.Count(certificationProjectID, "-") != 1 { | ||
return errors.Errorf("certification prodject id: %s is improperly formatted see help for instructions on obtaining proper value", certificationProjectID) |
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.
return errors.Errorf("certification prodject id: %s is improperly formatted see help for instructions on obtaining proper value", certificationProjectID) | |
return errors.Errorf("certification prodject id: %s is improperly formatted, see instructions to obtain the proper value", certificationProjectID) |
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.
But also... Where are these instructions? A link might help.
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.
We only have that info in our help
output, I believe.
certification/runtime/config.go
Outdated
return &cfg, nil | ||
} | ||
|
||
// storeContainerPolicyConfiguration reads container-policy-specific config | ||
// items in viper, normalizes them, and stores them in Config. | ||
func (c *Config) storeContainerPolicyConfiguration(vcfg viper.Viper) { | ||
func (c *Config) storeContainerPolicyConfiguration(vcfg viper.Viper) error { | ||
c.PyxisAPIToken = vcfg.GetString("pyxis_api_token") | ||
c.Submit = vcfg.GetBool("submit") | ||
c.PyxisHost = pyxisHostLookup(vcfg.GetString("pyxis_env"), vcfg.GetString("pyxis_host")) | ||
|
||
// Strip the ospid- prefix from the project ID if provided. | ||
certificationProjectID := vcfg.GetString("certification_project_id") | ||
if strings.HasPrefix(certificationProjectID, "ospid-") { |
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.
Does it make more sense to do these validations before we get here? Like as a PreRunE
.
I can see it both ways; it won't take much to sway me one way or the other. Consider this non-blocking. Just thinking out loud.
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 don't think that the flags would be loaded into viper if there was a PreRunE
, but I might be wrong.
@bcrochet Thoughts on this?
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.
You can add a PreRunE. It should still run the PersistentPreRun. And I agree with @komish. The validation should happen earlier.
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.
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.
The flags do get loaded before PreRunE
so I have removed the logic from config.go
to check_containter.go
PTAL.
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.
Fix the gofumpt error, but otherwise lgtm
/test 4.8-images |
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
Putting this on hold, there is another use case that we've never covered. ie a user never gives an |
…egacy project id Signed-off-by: Adam D. Cornett <adc@redhat.com>
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
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: acornett21, bcrochet, jomkz, komish 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 |
PreRunE
to validate the project id, and throw an error if it's in an improper format is used.Output from test
Signed-off-by: Adam D. Cornett adc@redhat.com