mirror of
https://github.com/cloudflare/cloudflared.git
synced 2025-07-28 14:49:59 +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:
@@ -32,26 +32,8 @@ func setFlagsFromConfigFile(c *cli.Context) error {
|
||||
return cli.Exit(err, errorExitCode)
|
||||
}
|
||||
|
||||
if err := applyConfig(c, inputSource); err != nil {
|
||||
if err := altsrc.ApplyInputSource(c, inputSource); err != nil {
|
||||
return cli.Exit(err, errorExitCode)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func applyConfig(c *cli.Context, inputSource altsrc.InputSourceContext) error {
|
||||
for _, context := range c.Lineage() {
|
||||
if context.Command == nil {
|
||||
// we've reached the placeholder root context not associated with the app
|
||||
break
|
||||
}
|
||||
targetFlags := context.Command.Flags
|
||||
if context.Command.Name == "" {
|
||||
// commands that define child subcommands are executed as if they were an app
|
||||
targetFlags = context.App.Flags
|
||||
}
|
||||
if err := altsrc.ApplyInputSourceValues(context, inputSource, targetFlags); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@@ -94,13 +94,14 @@ var (
|
||||
Aliases: []string{"F"},
|
||||
Usage: "Opt into various features that are still being developed or tested.",
|
||||
})
|
||||
credentialsFileFlag = altsrc.NewStringFlag(&cli.StringFlag{
|
||||
credentialsFileFlagCLIOnly = &cli.StringFlag{
|
||||
Name: CredFileFlag,
|
||||
Aliases: []string{CredFileFlagAlias},
|
||||
Usage: "Filepath at which to read/write the tunnel credentials",
|
||||
EnvVars: []string{"TUNNEL_CRED_FILE"},
|
||||
})
|
||||
forceDeleteFlag = &cli.BoolFlag{
|
||||
}
|
||||
credentialsFileFlag = altsrc.NewStringFlag(credentialsFileFlagCLIOnly)
|
||||
forceDeleteFlag = &cli.BoolFlag{
|
||||
Name: "force",
|
||||
Aliases: []string{"f"},
|
||||
Usage: "Cleans up any stale connections before the tunnel is deleted. cloudflared will not " +
|
||||
@@ -146,7 +147,7 @@ func buildCreateCommand() *cli.Command {
|
||||
For example, to create a tunnel named 'my-tunnel' run:
|
||||
|
||||
$ cloudflared tunnel create my-tunnel`,
|
||||
Flags: []cli.Flag{outputFormatFlag, credentialsFileFlag},
|
||||
Flags: []cli.Flag{outputFormatFlag, credentialsFileFlagCLIOnly},
|
||||
CustomHelpTemplate: commandHelpTemplate(),
|
||||
}
|
||||
}
|
||||
@@ -501,7 +502,7 @@ func buildDeleteCommand() *cli.Command {
|
||||
Usage: "Delete existing tunnel by UUID or name",
|
||||
UsageText: "cloudflared tunnel [tunnel command options] delete [subcommand options] TUNNEL",
|
||||
Description: "cloudflared tunnel delete will delete tunnels with the given tunnel UUIDs or names. A tunnel cannot be deleted if it has active connections. To delete the tunnel unconditionally, use -f flag.",
|
||||
Flags: []cli.Flag{credentialsFileFlag, forceDeleteFlag},
|
||||
Flags: []cli.Flag{credentialsFileFlagCLIOnly, forceDeleteFlag},
|
||||
CustomHelpTemplate: commandHelpTemplate(),
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user