Skip to content
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

CLOUDP-69682: Add global API whitelist support #376

Merged
merged 4 commits into from
Aug 19, 2020
Merged

CLOUDP-69682: Add global API whitelist support #376

merged 4 commits into from
Aug 19, 2020

Conversation

gssbzn
Copy link
Collaborator

@gssbzn gssbzn commented Aug 19, 2020

Proposed changes

Jira ticket: CLOUDP-69682

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

List

$ mongocli iam globalWhitelist ls 
ID                         CIDR BLOCK   CREATED AT
5f3cf81b89034c6b3c0a528e   172.20.0.1   2020-08-19T16:13:08Z
$ mongocli iam globalWhitelist ls -o json
{
  "results": [
    {
      "id": "5f3cf81b89034c6b3c0a528e",
      "cidrBlock": "172.20.0.1",
      "created": "2020-08-19T16:13:13Z",
      "description": "CLI",
      "type": "GLOBAL_ROLE",
      "updated": "2020-08-19T16:13:13Z"
    }
  ],
  "links": [
    {
      "rel": "self",
      "href": "http://mms:8080/api/public/v1.0/admin/whitelist?pageNum=1\u0026itemsPerPage=100"
    }
  ],
  "totalCount": 1
}

Describe

$ mongocli iam globalWhitelist describe 5f3cf81b89034c6b3c0a528e
ID                         CIDR BLOCK   CREATED AT
5f3cf81b89034c6b3c0a528e   172.20.0.1   2020-08-19T16:15:46Z
$ongocli iam globalWhitelist describe 5f3cf81b89034c6b3c0a528e -o json
{
  "id": "5f3cf81b89034c6b3c0a528e",
  "cidrBlock": "172.20.0.1",
  "created": "2020-08-19T16:15:42Z",
  "description": "CLI",
  "type": "GLOBAL_ROLE",
  "updated": "2020-08-19T16:15:42Z"
}

Create

$ mongocli iam globalWhitelist create --cidr 172.20.0.2 --desc test  -P om
Global whitelist entry '5f3d5694fb9aa6294e22e494' created.
$ mongocli iam globalWhitelist create --cidr 172.20.0.3 --desc test  -P om -o json
{
  "id": "5f3d569efb9aa6294e22e49a",
  "cidrBlock": "172.20.0.3",
  "created": "2020-08-19T16:43:10Z",
  "description": "test",
  "type": "GLOBAL_ROLE",
  "updated": "2020-08-19T16:43:10Z"
}

Delete

$ mongocli iam globalWhitelist rm 5f3d5449fb9aa6294e22e2be  -P om
? Are you sure you want to delete: 5f3d5449fb9aa6294e22e2be Yes
Whitelist entry '5f3d5449fb9aa6294e22e2be' deleted

Copy link
Contributor

@robcarlan-mlab robcarlan-mlab left a comment

Choose a reason for hiding this comment

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

Just a couple of nitpicks that are worth addressing, then lgtm

internal/cli/iam/globalwhitelist/delete.go Outdated Show resolved Hide resolved
createWhitelist = "Create an access whitelist for Global API Key."
deleteWhitelist = "Delete a database user from Global API Key."
listWhitelist = "List Atlas whitelist entries for Global API Key."
describeEntry = "Return one Global Whitelist Entry using its unique identifier."
Copy link
Contributor

Choose a reason for hiding this comment

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

[np] given these are in the package, could just be "create/delete/list/describe"?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

they could, I've have issues in other packages of clash so I won't fix this here but feel free to improve on the idea, I even think we should consider getting rid of this file

internal/store/global_api_keys_whitelist.go Outdated Show resolved Hide resolved
DeleteGlobalAPIKeyWhitelist(string) error
}

// GlobalAPIKeyWhitelists encapsulates the logic to manage different cloud providers
Copy link
Contributor

Choose a reason for hiding this comment

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

[np] comments

Copy link
Collaborator

@andreaangiolillo andreaangiolillo left a comment

Choose a reason for hiding this comment

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

One change but it is not a blocker. LGTM! Great work! 🚀

const (
short = "Manage the access whitelist for Global API Key."
createWhitelist = "Create an access whitelist for Global API Key."
deleteWhitelist = "Delete a database user from Global API Key."
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
deleteWhitelist = "Delete a database user from Global API Key."
deleteWhitelist = "Delete an access whitelist for Global API Key."

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

copy/pasta and wrong also in the original, thanks for catching this

@@ -67,7 +67,5 @@ func DeleteBuilder() *cobra.Command {

cmd.Flags().StringVar(&opts.OrgID, flag.OrgID, "", usage.OrgID)

_ = cmd.MarkFlagRequired(flag.Role)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

drive by fix

@@ -16,6 +16,6 @@ package whitelist
const (
short = "Manage the access whitelist for your API Key."
createWhitelist = "Create an access whitelist for your API Key."
deleteWhitelist = "Delete a database user from your API Key."
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

drive by fix

Copy link
Collaborator

@andreaangiolillo andreaangiolillo left a comment

Choose a reason for hiding this comment

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

LGTM

@gssbzn gssbzn merged commit 9379063 into master Aug 19, 2020
@gssbzn gssbzn deleted the CLOUDP-69682 branch August 19, 2020 17:30
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.

3 participants