Skip to content

README: GITHUB_TOOLSETS doesn't take precedence over --toolsets (viper gives the flag priority) #3578

Open

Description

@EmanueleCell4

The README says:
"The environment variable GITHUB_TOOLSETS takes precedence over the command line argument if both are provided."

The environment variable `GITHUB_TOOLSETS` takes precedence over the command line argument if both are provided.

--toolsets is bound through viper, and the env is wired with AutomaticEnv:

_ = viper.BindPFlag("toolsets", rootCmd.PersistentFlags().Lookup("toolsets"))

// Initialize Viper configuration
viper.SetEnvPrefix("github")
viper.SetEnvKeyReplacer(strings.NewReplacer("-", "_"))
viper.AutomaticEnv()
}

if viper.IsSet("toolsets") {
if err := viper.UnmarshalKey("toolsets", &enabledToolsets); err != nil {
return fmt.Errorf("failed to unmarshal toolsets: %w", err)
}

Viper's lookup order is Set() > flag (if changed) > env > config > default, so when both are given the flag wins, the opposite of the README. That matters a bit for anyone trying to narrow toolsets via env on top of a launcher that already passes --toolsets. Probably just the README sentence that needs flipping.

Found while testing a docs-vs-code checker I'm building (Elliot), then verified by hand.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions