mirror of
https://github.com/cloudflare/cloudflared.git
synced 2025-07-28 00:59:58 +00:00
TUN-4116: Ingore credentials-file setting in configuration file during tunnel create and delete opeations.
This change has two parts: 1. Update to newer version of the urfave/cli fork that correctly sets flag value along the context hierarchy while respecting config file overide behavior of the most specific instance of the flag. 2. Redefine --credentials-file flag so that create and delete subcommand don't use value from the config file.
This commit is contained in:
48
vendor/github.com/urfave/cli/v2/altsrc/flag.go
generated
vendored
48
vendor/github.com/urfave/cli/v2/altsrc/flag.go
generated
vendored
@@ -22,10 +22,39 @@ type FlagInputSourceExtension interface {
|
||||
// to an alternate input source.
|
||||
func ApplyInputSourceValues(context *cli.Context, inputSourceContext InputSourceContext, flags []cli.Flag) error {
|
||||
for _, f := range flags {
|
||||
inputSourceExtendedFlag, isType := f.(FlagInputSourceExtension)
|
||||
if isType {
|
||||
err := inputSourceExtendedFlag.ApplyInputSourceValue(context, inputSourceContext)
|
||||
if err != nil {
|
||||
if err := applyFlagValue(f, context, inputSourceContext); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// ApplyInputSource sets flags from `inputSource` across cli.Context hierarchy.
|
||||
// If a flag is defined at multiple levels, this method will try to update only the most specific context
|
||||
// that uses the flag. If the most specific version of the flag doesn't support loading values from an input source
|
||||
// the method will not check definitions from less-specific contexts.
|
||||
func ApplyInputSource(c *cli.Context, inputSource InputSourceContext) error {
|
||||
visited := make(map[string]bool)
|
||||
for _, context := range c.Lineage() {
|
||||
if context.Command == nil {
|
||||
// we've reached the placeholder root context not associated with the app
|
||||
break
|
||||
}
|
||||
flags := context.Command.Flags
|
||||
if context.Command.Name == "" {
|
||||
// commands that define child subcommands are executed as if they were an app
|
||||
flags = context.App.Flags
|
||||
}
|
||||
applyingFlags:
|
||||
for _, f := range flags {
|
||||
for _, name := range f.Names() {
|
||||
if visited[name] {
|
||||
continue applyingFlags
|
||||
}
|
||||
visited[name] = true
|
||||
}
|
||||
if err := applyFlagValue(f, context, inputSource); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@@ -34,6 +63,17 @@ func ApplyInputSourceValues(context *cli.Context, inputSourceContext InputSource
|
||||
return nil
|
||||
}
|
||||
|
||||
func applyFlagValue(flag cli.Flag, context *cli.Context, inputSource InputSourceContext) error {
|
||||
inputSourceExtendedFlag, isType := flag.(FlagInputSourceExtension)
|
||||
if isType {
|
||||
err := inputSourceExtendedFlag.ApplyInputSourceValue(context, inputSource)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// InitInputSource is used to to setup an InputSourceContext on a cli.Command Before method. It will create a new
|
||||
// input source based on the func provided. If there is no error it will then apply the new input source to any flags
|
||||
// that are supported by the input source
|
||||
|
Reference in New Issue
Block a user