Skip to content

CLOUDP-56474: Validate orgIDs and projectIDs are valid values #111

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

Merged
merged 2 commits into from
Apr 17, 2020

Conversation

gssbzn
Copy link
Collaborator

@gssbzn gssbzn commented Apr 17, 2020

Proposed changes

Jira ticket: CLOUDP-56474

Checklist

  • I have added tests that prove my fix is effective or that my feature works
  • I have added any necessary documentation (if appropriate)
  • I have run make fmt and formatted my code

Further comments

This is a small change but we had the project validation duplicated everywhere so also centralising this and using now an init function with callbacks we can reuse and extend in a better way

@gssbzn gssbzn requested a review from andreaangiolillo April 17, 2020 15:14

// PreRunE is a function to call before running the command,
// this will validate the project ID and call any additional function pass as a callback
func (opts *globalOpts) PreRunE(cbs ...cmdOpt) error {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is our main change, we now have the validation here, and we can pass callbacks with any additional init function that the command may need

Comment on lines +41 to +42
b, err := hex.DecodeString(s)
if err != nil || len(b) != 12 {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

got this from the go mongodb client

@@ -26,15 +26,16 @@ import (
)

type atlasEventsListOpts struct {
globalOpts
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this command wasn't using any of globalOpts functions so no need to compose it here and I'll just use the properties

Copy link
Collaborator

@colm-quinn colm-quinn left a comment

Choose a reason for hiding this comment

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

Nice job - Having the checks in one place is def worth the effort here. LGTM.

@gssbzn gssbzn merged commit 95223e1 into master Apr 17, 2020
@gssbzn gssbzn deleted the CLOUDP-56474 branch April 17, 2020 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants