Skip to content
This repository has been archived by the owner on Apr 24, 2023. It is now read-only.

refactor cli of the smtp-service #10

Merged
merged 7 commits into from
Feb 19, 2020
Merged

refactor cli of the smtp-service #10

merged 7 commits into from
Feb 19, 2020

Conversation

aidenkeating
Copy link
Contributor

refactor the cli of the smtp-service to have a structure more
similar to the default cobra generated file structure.

along with this, other changes have been made:

  • output a secret on the 'refresh' command
  • allow the secret name to be overridden on 'create' and 'refresh'
  • change the default output secret name to 'redhat-rhmi-smtp'
  • change the debug flow to be a single 'debug' boolean flag

verification:

  • for each subcommand: 'create', 'get', 'refresh', 'delete',
    'version', do the following steps
  • run the command, ensure it succeeds
  • run 'create' and 'refresh' with the 'secret-name' flag set to a
    different string and ensure the output secret name is overridden
  • run any command with the 'debug' flag set to 'true' and ensure
    that debug and info logs are shown and they're output to stderr

Aiden Keating added 2 commits February 17, 2020 10:29
refactor the cli of the smtp-service to have a structure more
similar to the default cobra generated file structure.

along with this, other changes have been made:
- output a secret on the 'refresh' command
- allow the secret name to be overridden on 'create' and 'refresh'
- change the default output secret name to 'redhat-rhmi-smtp'
- change the debug flow to be a single 'debug' boolean flag

verification:
- for each subcommand: 'create', 'get', 'refresh', 'delete',
  'version', do the following steps
- run the command, ensure it succeeds
- run 'create' and 'refresh' with the 'secret-name' flag set to a
  different string and ensure the output secret name is overridden
- run any command with the 'debug' flag set to 'true' and ensure
  that debug and info logs are shown and they're output to stderr
from bf3f9ec the 'refresh' subcommand will now return
smtpdetails rather than a string with a new api key.

this change in interface resulted in tests failing. this change
updates the tests to not expect a string to be returned and to
expect a smtpdetails struct instead.

verification:
- run 'make test/unit'
- ensure all tests complete successfully
@aidenkeating
Copy link
Contributor Author

@dimitraz @austinmartinh Mind taking a look? This is a minor refactor of the CLI to give it some more structure and to ensure the secret name can be overridden in create and refresh.

}
}
if foundUser == nil {
return nil, &NotExistError{Message: fmt.Sprintf("uaer with username %s not found in sendgrid subuser list", username)}

Choose a reason for hiding this comment

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

Suggested change
return nil, &NotExistError{Message: fmt.Sprintf("uaer with username %s not found in sendgrid subuser list", username)}
return nil, &NotExistError{Message: fmt.Sprintf("user with username %s not found in sendgrid subuser list", username)}

Comment on lines 35 to 43
// Here you will define your flags and configuration settings.

// Cobra supports Persistent Flags which will work for this command
// and all subcommands, e.g.:
// versionCmd.PersistentFlags().String("foo", "", "A help for foo")

// Cobra supports local flags which will only run when this command
// is called directly, e.g.:
// versionCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")

Choose a reason for hiding this comment

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

Suggested change
// Here you will define your flags and configuration settings.
// Cobra supports Persistent Flags which will work for this command
// and all subcommands, e.g.:
// versionCmd.PersistentFlags().String("foo", "", "A help for foo")
// Cobra supports local flags which will only run when this command
// is called directly, e.g.:
// versionCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")

Should this comment block be removed?

Copy link

@austinmartinh austinmartinh left a comment

Choose a reason for hiding this comment

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

Verified with minor suggestions

Aiden Keating added 3 commits February 19, 2020 09:34
remove comments generated by the cobra cli tool, these include:
- license headers
- flag example comments

license headers can be added to all files if needed in a later
commit.
fix 'user' typo in sendgridapi.go
result of 'make vendor/fix'
@aidenkeating
Copy link
Contributor Author

@austinmartinh I think I hit all those comments, mind taking one more look?

@@ -173,7 +173,7 @@ func (c *BackendAPIClient) ListSubUsers(query map[string]string) ([]*SubUser, er
query = map[string]string{}
}
listReq := c.restClient.BuildRequest(APIRouteSubUsers, rest.Get)
listReq.QueryParams = query
//listReq.QueryParams = query
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll delete this

Aiden Keating added 2 commits February 19, 2020 11:35
remove commented code for query handling in sendgridapi.go that is
no longer used.
bump version to 0.2.0

verification:
- run 'make build/cli'
- run './cli version'
- ensure the output is '0.2.0'
Copy link
Member

@ciaranRoche ciaranRoche left a comment

Choose a reason for hiding this comment

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

lgtm 👍

just reviewed it, happy to give it another verify if you want?

@aidenkeating aidenkeating merged commit d790fe9 into master Feb 19, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants