Reduce the number of package level variables
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 816
- Forks
- 230
- Avg merge
- 6h 4m
- Merged PRs (30d)
- 1
Description
Expected Behaviour
It would be nice/better if the CLI flag values were scoped to the methods being run instead of the package, e.g. we shouldn't expose the secretName variable to the deploy command.
Current Behaviour
Many (or all) of the CLI commands have flag values that are parsed by supplying a pointer to a package level variable, e.g.
cmd.Flags().StringVar(&name, "name", "", "Secret name")
Possible Solution
Flag values can be parsed and retrieved via the getter methods, for example
secretValue, err := cmd.Flags().GetString("from-literal")
if err != nil {
return err
}
Context
This idea was discussed during teh review of #580
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the CLI commands that bind flags with package-level variables, such as the StringVar example for the name flag. Review the related discussion in issue #580 and compare the commands' flag definitions and handlers. Done means flag values are scoped to the commands or methods that use them rather than exposed through package-level variables.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- cli
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100