Skip to content

Commit

Permalink
Use the correct field to assign the value of a slice flag (#3548)
Browse files Browse the repository at this point in the history
I noticed that in some cases using `Value` field instead of
`Destination` can cause a bug in how `urfave/cli` parses the flags and
arguments.
According to
[documentation](https://cli.urfave.org/v2/examples/flags/#placeholder-values)
`Destination` is the correct field to use.
  • Loading branch information
idodod authored Nov 28, 2023
1 parent ec3b5d6 commit 3bcb139
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions cmd/earthly/subcmd/build_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ import (
func (a *Build) buildFlags() []cli.Flag {
return []cli.Flag{
&cli.StringSliceFlag{
Name: "platform",
EnvVars: []string{"EARTHLY_PLATFORMS"},
Usage: "Specify the target platform to build for or this can be read from ENV VAR",
Value: &a.platformsStr,
Name: "platform",
EnvVars: []string{"EARTHLY_PLATFORMS"},
Usage: "Specify the target platform to build for or this can be read from ENV VAR",
Destination: &a.platformsStr,
},
&cli.StringSliceFlag{
Name: "build-arg",
EnvVars: []string{"EARTHLY_BUILD_ARGS"},
Usage: "A build arg override, specified as <key>=[<value>]",
Value: &a.buildArgs,
Hidden: true, // Deprecated
Name: "build-arg",
EnvVars: []string{"EARTHLY_BUILD_ARGS"},
Usage: "A build arg override, specified as <key>=[<value>]",
Destination: &a.buildArgs,
Hidden: true, // Deprecated
},
&cli.StringSliceFlag{
Name: "secret",
Expand All @@ -35,11 +35,11 @@ func (a *Build) buildFlags() []cli.Flag {
Destination: &a.secretFiles,
},
&cli.StringSliceFlag{
Name: "cache-from",
EnvVars: []string{"EARTHLY_CACHE_FROM"},
Usage: "Remote docker image tags to use as readonly explicit cache (experimental)",
Value: &a.cacheFrom,
Hidden: true, // Experimental
Name: "cache-from",
EnvVars: []string{"EARTHLY_CACHE_FROM"},
Usage: "Remote docker image tags to use as readonly explicit cache (experimental)",
Destination: &a.cacheFrom,
Hidden: true, // Experimental
},
}
}
Expand Down

0 comments on commit 3bcb139

Please sign in to comment.