Skip to content

Commit 9018ee5

Browse files
committed
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.
1 parent 1244767 commit 9018ee5

File tree

20 files changed

+2498
-180
lines changed

20 files changed

+2498
-180
lines changed

CHANGES.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,25 @@
11
**Experimental**: This is a new format for release notes. The format and availability is subject to change.
22

3+
## UNRELEASED
4+
5+
### Backward Incompatible Changes
6+
7+
- none
8+
9+
### New Features
10+
11+
- none
12+
13+
### Improvements
14+
15+
- none
16+
17+
### Bug Fixes
18+
19+
- Tunnel create and delete commands no longer use path to credentials from the configuration file.
20+
If you need ot place tunnel credentials file at a specific location, you must use `--credentials-file` flag.
21+
22+
323
## 2021.3.2
424

525
### New Features

cmd/cloudflared/cliutil/handler.go

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -32,26 +32,8 @@ func setFlagsFromConfigFile(c *cli.Context) error {
3232
return cli.Exit(err, errorExitCode)
3333
}
3434

35-
if err := applyConfig(c, inputSource); err != nil {
35+
if err := altsrc.ApplyInputSource(c, inputSource); err != nil {
3636
return cli.Exit(err, errorExitCode)
3737
}
3838
return nil
3939
}
40-
41-
func applyConfig(c *cli.Context, inputSource altsrc.InputSourceContext) error {
42-
for _, context := range c.Lineage() {
43-
if context.Command == nil {
44-
// we've reached the placeholder root context not associated with the app
45-
break
46-
}
47-
targetFlags := context.Command.Flags
48-
if context.Command.Name == "" {
49-
// commands that define child subcommands are executed as if they were an app
50-
targetFlags = context.App.Flags
51-
}
52-
if err := altsrc.ApplyInputSourceValues(context, inputSource, targetFlags); err != nil {
53-
return err
54-
}
55-
}
56-
return nil
57-
}

cmd/cloudflared/tunnel/subcommands.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,14 @@ var (
9494
Aliases: []string{"F"},
9595
Usage: "Opt into various features that are still being developed or tested.",
9696
})
97-
credentialsFileFlag = altsrc.NewStringFlag(&cli.StringFlag{
97+
credentialsFileFlagCLIOnly = &cli.StringFlag{
9898
Name: CredFileFlag,
9999
Aliases: []string{CredFileFlagAlias},
100100
Usage: "Filepath at which to read/write the tunnel credentials",
101101
EnvVars: []string{"TUNNEL_CRED_FILE"},
102-
})
103-
forceDeleteFlag = &cli.BoolFlag{
102+
}
103+
credentialsFileFlag = altsrc.NewStringFlag(credentialsFileFlagCLIOnly)
104+
forceDeleteFlag = &cli.BoolFlag{
104105
Name: "force",
105106
Aliases: []string{"f"},
106107
Usage: "Cleans up any stale connections before the tunnel is deleted. cloudflared will not " +
@@ -146,7 +147,7 @@ func buildCreateCommand() *cli.Command {
146147
For example, to create a tunnel named 'my-tunnel' run:
147148
148149
$ cloudflared tunnel create my-tunnel`,
149-
Flags: []cli.Flag{outputFormatFlag, credentialsFileFlag},
150+
Flags: []cli.Flag{outputFormatFlag, credentialsFileFlagCLIOnly},
150151
CustomHelpTemplate: commandHelpTemplate(),
151152
}
152153
}
@@ -501,7 +502,7 @@ func buildDeleteCommand() *cli.Command {
501502
Usage: "Delete existing tunnel by UUID or name",
502503
UsageText: "cloudflared tunnel [tunnel command options] delete [subcommand options] TUNNEL",
503504
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.",
504-
Flags: []cli.Flag{credentialsFileFlag, forceDeleteFlag},
505+
Flags: []cli.Flag{credentialsFileFlagCLIOnly, forceDeleteFlag},
505506
CustomHelpTemplate: commandHelpTemplate(),
506507
}
507508
}

go.mod

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ require (
99
github.com/coredns/coredns v1.7.0
1010
github.com/coreos/go-oidc v0.0.0-20171002155002-a93f71fdfe73
1111
github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf
12+
github.com/cpuguy83/go-md2man/v2 v2.0.0 // indirect
1213
github.com/facebookgo/ensure v0.0.0-20160127193407-b4ab57deab51 // indirect
1314
github.com/facebookgo/freeport v0.0.0-20150612182905-d4adf43b75b9 // indirect
1415
github.com/facebookgo/grace v0.0.0-20180706040059-75cf19382434
@@ -39,6 +40,7 @@ require (
3940
github.com/prometheus/common v0.13.0 // indirect
4041
github.com/rivo/tview v0.0.0-20200712113419-c65badfc3d92
4142
github.com/rs/zerolog v1.20.0
43+
github.com/russross/blackfriday/v2 v2.1.0 // indirect
4244
github.com/stretchr/testify v1.6.0
4345
github.com/urfave/cli/v2 v2.2.0
4446
golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a
@@ -58,4 +60,4 @@ require (
5860
zombiezen.com/go/capnproto2 v2.18.0+incompatible
5961
)
6062

61-
replace github.com/urfave/cli/v2 => github.com/ipostelnik/cli/v2 v2.3.1-0.20210223162147-c8b4f97735e4
63+
replace github.com/urfave/cli/v2 => github.com/ipostelnik/cli/v2 v2.3.1-0.20210324024421-b6ea8234fe3d

go.sum

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,9 @@ github.com/coreos/go-systemd/v22 v22.0.0/go.mod h1:xO0FLkIi5MaZafQlIrOotqXZ90ih+
140140
github.com/coreos/license-bill-of-materials v0.0.0-20190913234955-13baff47494e/go.mod h1:4xMOusJ7xxc84WclVxKT8+lNfGYDwojOUC2OQNCwcj4=
141141
github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
142142
github.com/cpu/goacmedns v0.0.1/go.mod h1:sesf/pNnCYwUevQEQfEwY0Y3DydlQWSGZbaMElOWxok=
143-
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY=
144143
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
144+
github.com/cpuguy83/go-md2man/v2 v2.0.0 h1:EoUDS0afbrsXAZ9YQ9jdu/mZ2sXgT1/2yyNng4PGlyM=
145+
github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
145146
github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY=
146147
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
147148
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
@@ -347,8 +348,8 @@ github.com/imdario/mergo v0.3.9/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJ
347348
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
348349
github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo=
349350
github.com/infobloxopen/go-trees v0.0.0-20190313150506-2af4e13f9062/go.mod h1:PcNJqIlcX/dj3DTG/+QQnRvSgTMG6CLpRMjWcv4+J6w=
350-
github.com/ipostelnik/cli/v2 v2.3.1-0.20210223162147-c8b4f97735e4 h1:U2OxGKZHC5puhKZnGo6wWWjuWusJCM6J/S1eF7Vt+Uk=
351-
github.com/ipostelnik/cli/v2 v2.3.1-0.20210223162147-c8b4f97735e4/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI=
351+
github.com/ipostelnik/cli/v2 v2.3.1-0.20210324024421-b6ea8234fe3d h1:PRDnysJ9dF1vUMmEzBu6aHQeUluSQy4eWH3RsSSy/vI=
352+
github.com/ipostelnik/cli/v2 v2.3.1-0.20210324024421-b6ea8234fe3d/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI=
352353
github.com/jimstudt/http-authentication v0.0.0-20140401203705-3eca13d6893a/go.mod h1:wK6yTYYcgjHE1Z1QtXACPDjcFJyBskHEdagmnq3vsP8=
353354
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
354355
github.com/jmespath/go-jmespath v0.3.0/go.mod h1:9QtRXoHjLGCJ5IBSaohpXITPlowMeeYCZ7fLUTSywik=
@@ -544,14 +545,14 @@ github.com/rs/zerolog v1.20.0 h1:38k9hgtUBdxFwE34yS8rTHmHBa4eN16E4DJlv177LNs=
544545
github.com/rs/zerolog v1.20.0/go.mod h1:IzD0RJ65iWH0w97OQQebJEvTZYvsCUm9WVLWBQrJRjo=
545546
github.com/russross/blackfriday v0.0.0-20170610170232-067529f716f4 h1:S9YlS71UNJIyS61OqGAmLXv3w5zclSidN+qwr80XxKs=
546547
github.com/russross/blackfriday v0.0.0-20170610170232-067529f716f4/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
547-
github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q=
548548
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
549+
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
550+
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
549551
github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
550552
github.com/sacloud/libsacloud v1.26.1/go.mod h1:79ZwATmHLIFZIMd7sxA3LwzVy/B77uj3LDoToVTxDoQ=
551553
github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E=
552554
github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
553555
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
554-
github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo=
555556
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
556557
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
557558
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=

vendor/github.com/russross/blackfriday/v2/README.md

Lines changed: 67 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)