Skip to content

FilePath does not take precedence over EnvVar #1866

@zc-devs

Description

@zc-devs

My urfave/cli version is v2.27.1

Dependency Management

  • I am unsure of what my dependency management setup is.

Describe the bug

FilePath does not take precedence over EnvVar as described in documentation.

To reproduce

  1. Set some flag
&cli.StringFlag{
	EnvVars:  []string{"WOODPECKER_DATABASE_DATASOURCE"},
	Name:     "datasource",
	Usage:    "database driver configuration string",
	Value:    "woodpecker.sqlite",
	FilePath: os.Getenv("WOODPECKER_DATABASE_DATASOURCE_FILE"),
},
  1. Set EnvVar:
export WOODPECKER_DATABASE_DATASOURCE=/var/lib/woodpecker/woodpecker.sqlite
  1. Set FilePath variable:
export WOODPECKER_DATABASE_DATASOURCE_FILE=/run/secrets/woodpecker-datasource.conf
  1. Get /var/lib/woodpecker/woodpecker.sqlite instead /run/secrets/woodpecker-datasource.conf in datasource flag.

Observed behavior

Step 4.

Expected behavior

FilePath should take precedence over EnvVar. So, I should get /run/secrets/woodpecker-datasource.conf in datasource flag.

Additional context

woodpecker-ci/woodpecker#3389

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/v2relates to / is being considered for v2kind/bugdescribes or fixes a bugstatus/triagemaintainers still need to look into this

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions