Skip to content

Commit

Permalink
CLOUDP-67923: Add --deleteAfter to dbusers create (#285)
Browse files Browse the repository at this point in the history
  • Loading branch information
andreaangiolillo committed Jul 27, 2020
1 parent 246e52b commit b57e0ac
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 15 deletions.
1 change: 1 addition & 0 deletions e2e/atlas/dbusers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ func TestDBUsers(t *testing.T) {
dbusersEntity,
"create",
"atlasAdmin",
"--deleteAfter", time.Now().AddDate(0, 0, 1).Format(time.RFC3339),
"--username", username,
"--password=passW0rd")
cmd.Env = os.Environ()
Expand Down
29 changes: 16 additions & 13 deletions internal/cli/atlas/dbusers/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,13 @@ import (

type CreateOpts struct {
cli.GlobalOpts
username string
password string
x509Type string
awsIamType string
roles []string
store store.DatabaseUserCreator
username string
password string
x509Type string
awsIamType string
deleteAfter string
roles []string
store store.DatabaseUserCreator
}

const (
Expand Down Expand Up @@ -87,13 +88,14 @@ func (opts *CreateOpts) newDatabaseUser() *atlas.DatabaseUser {
}

return &atlas.DatabaseUser{
Roles: convert.BuildAtlasRoles(opts.roles),
GroupID: opts.ConfigProjectID(),
Username: opts.username,
Password: opts.password,
X509Type: opts.x509Type,
AWSIAMType: opts.awsIamType,
DatabaseName: authDB,
Roles: convert.BuildAtlasRoles(opts.roles),
GroupID: opts.ConfigProjectID(),
Username: opts.username,
Password: opts.password,
X509Type: opts.x509Type,
AWSIAMType: opts.awsIamType,
DeleteAfterDate: opts.deleteAfter,
DatabaseName: authDB,
}
}

Expand Down Expand Up @@ -177,6 +179,7 @@ func CreateBuilder() *cobra.Command {

cmd.Flags().StringVarP(&opts.username, flag.Username, flag.UsernameShort, "", usage.Username)
cmd.Flags().StringVarP(&opts.password, flag.Password, flag.PasswordShort, "", usage.Password)
cmd.Flags().StringVar(&opts.deleteAfter, flag.DeleteAfter, "", usage.BDUsersDeleteAfter)
cmd.Flags().StringSliceVar(&opts.roles, flag.Role, []string{}, usage.Roles)
cmd.Flags().StringVar(&opts.x509Type, flag.X509Type, AuthTypeNone, usage.X509Type)
cmd.Flags().StringVar(&opts.awsIamType, flag.AWSIAMType, AuthTypeNone, usage.AWSIAMType)
Expand Down
2 changes: 1 addition & 1 deletion internal/cli/atlas/whitelist/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func CreateBuilder() *cobra.Command {

cmd.Flags().StringVar(&opts.entryType, flag.Type, ipAddress, usage.WhitelistType)
cmd.Flags().StringVar(&opts.comment, flag.Comment, "", usage.Comment)
cmd.Flags().StringVar(&opts.deleteAfter, flag.DeleteAfter, "", usage.DeleteAfter)
cmd.Flags().StringVar(&opts.deleteAfter, flag.DeleteAfter, "", usage.WhiteListsDeleteAfter)

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

Expand Down
3 changes: 2 additions & 1 deletion internal/usage/usage.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ const (
DataLakeRegion = "Name of the region to which Data Lake routes client connections for data processing."
DataLakeTestBucket = `Name of an S3 data bucket which Data Lake uses to validate the provided role.`
Comment = "Optional description or comment for the entry."
DeleteAfter = "ISO-8601-formatted UTC date after which Atlas removes the entry from the whitelist."
WhiteListsDeleteAfter = "ISO-8601-formatted UTC date after which Atlas removes the entry from the whitelist."
BDUsersDeleteAfter = "Timestamp in ISO 8601 date and time format in UTC after which Atlas deletes the user."
Force = "Don't ask for confirmation."
Email = "User’s email address."
LogOut = "Optional output filename, if none given will use the log name."
Expand Down

0 comments on commit b57e0ac

Please sign in to comment.