openfaas / openfaas/faas-cli

Reduce the number of package level variables

Open
#583 0 comments 0 reactions 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.