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

fix(influx): add env vars to cli usage and normalize usage and flag/env var priority #16491

Merged
merged 2 commits into from
Jan 10, 2020

Conversation

jsteenb2
Copy link
Contributor

@jsteenb2 jsteenb2 commented Jan 10, 2020

also rids the pkg of the cobra tutorial init style and encapsulates things into funcs. One step closer to builder pattern for this cmd pkg.

Closes #16246
Closes #16048

@jsteenb2 jsteenb2 force-pushed the 16246/add_env_vars_to_cli_usage branch from 8f48640 to 7a98a48 Compare January 10, 2020 05:24
@jsteenb2 jsteenb2 requested a review from a team January 10, 2020 05:24
@jsteenb2
Copy link
Contributor Author

@sanderson this will make a bunch of changes to the CLI help outputs. The env vars will be exposed so folks will know what they are when they see the -h usage.

@jsteenb2 jsteenb2 force-pushed the 16246/add_env_vars_to_cli_usage branch 2 times, most recently from 078357e to 11cd3c3 Compare January 10, 2020 06:21
}

if userName := authCreateFlags.user; userName != "" {
userSvc, err := newUserService()
if err != nil {
return err
}
user, err := userSvc.FindUser(ctx, platform.UserFilter{
user, err := userSvc.FindUser(context.Background(), platform.UserFilter{
Copy link
Contributor

@kelwang kelwang Jan 10, 2020

Choose a reason for hiding this comment

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

I'd love to see us use some context signaling to cancel on the typical signals. However, this one was always context.Background().

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 wish that were the case, but the context that was removed above waws just context.Background() 🤷‍♂. It just happened to be instantiated well before its use case.

cmd.Flags().StringVarP(&authorizationFindFlags.id, "id", "i", "", "The authorization ID")

return cmd
}

func newAuthorizationService(f Flags) (platform.AuthorizationService, error) {
func newAuthorizationService() (platform.AuthorizationService, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I am never a big fan of anything global. If passing the flags bothers you, you could compose a struct and make this function a method.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

totally agree. I'd like to see all the commands use the builder pattern of sorts so we can dep inject. We'r enot quite there yet. That'll take some time.

return //return here, since cobra already handles the error
}
c.Printf("See '%s -h' for help\n", c.CommandPath())
var flags struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

i don't really like such a global thing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

totally agree. I didn't remedy all the issues in this pkg on this go round. However, I agree, the global constructs in this are a major issue and should be fixed. I didn't do it here b/c it was already bigger body of work than I anticipated 😢

Copy link
Contributor

@kelwang kelwang left a comment

Choose a reason for hiding this comment

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

Have a few comments. The biggest one is the global struct.

@jsteenb2 jsteenb2 force-pushed the 16246/add_env_vars_to_cli_usage branch 4 times, most recently from 10aa46d to a199998 Compare January 10, 2020 23:00
…nv var priority

also rids us of the cobra tutorial code and encapsulates things into funcs
@jsteenb2 jsteenb2 force-pushed the 16246/add_env_vars_to_cli_usage branch from a199998 to ee3198f Compare January 10, 2020 23:04
@jsteenb2 jsteenb2 merged commit 9338a0b into master Jan 10, 2020
@jsteenb2 jsteenb2 deleted the 16246/add_env_vars_to_cli_usage branch January 10, 2020 23:20
@jsteenb2 jsteenb2 mentioned this pull request Feb 7, 2020
4 tasks
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.

cli flags should override environmental variables Add environment variables to the influx --help command
2 participants