Skip to content

Commit a340997

Browse files
committed
TUN-4094: Don't read configuration file for access commands
1 parent 8c5498f commit a340997

File tree

12 files changed

+35
-44
lines changed

12 files changed

+35
-44
lines changed

cmd/cloudflared/access/cmd.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,6 @@ func Commands() []*cli.Command {
9191
Once authenticated with your identity provider, the login command will generate a JSON Web Token (JWT)
9292
scoped to your identity, the application you intend to reach, and valid for a session duration set by your
9393
administrator. cloudflared stores the token in local storage.`,
94-
Flags: []cli.Flag{
95-
&cli.StringFlag{
96-
Name: "url",
97-
Hidden: true,
98-
},
99-
},
10094
},
10195
{
10296
Name: "curl",

cmd/cloudflared/cliutil/handler.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ import (
99
)
1010

1111
func Action(actionFunc cli.ActionFunc) cli.ActionFunc {
12+
return WithErrorHandler(actionFunc)
13+
}
14+
15+
func ConfiguredAction(actionFunc cli.ActionFunc) cli.ActionFunc {
1216
return WithErrorHandler(func(c *cli.Context) error {
1317
if err := setFlagsFromConfigFile(c); err != nil {
1418
return err

cmd/cloudflared/linux_service.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func runApp(app *cli.App, graceShutdownC chan struct{}) {
2424
{
2525
Name: "install",
2626
Usage: "Install Argo Tunnel as a system service",
27-
Action: cliutil.Action(installLinuxService),
27+
Action: cliutil.ConfiguredAction(installLinuxService),
2828
Flags: []cli.Flag{
2929
&cli.BoolFlag{
3030
Name: "legacy",
@@ -35,7 +35,7 @@ func runApp(app *cli.App, graceShutdownC chan struct{}) {
3535
{
3636
Name: "uninstall",
3737
Usage: "Uninstall the Argo Tunnel service",
38-
Action: cliutil.Action(uninstallLinuxService),
38+
Action: cliutil.ConfiguredAction(uninstallLinuxService),
3939
},
4040
},
4141
})

cmd/cloudflared/macos_service.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ func runApp(app *cli.App, graceShutdownC chan struct{}) {
2525
{
2626
Name: "install",
2727
Usage: "Install Argo Tunnel as an user launch agent",
28-
Action: cliutil.Action(installLaunchd),
28+
Action: cliutil.ConfiguredAction(installLaunchd),
2929
},
3030
{
3131
Name: "uninstall",
3232
Usage: "Uninstall the Argo Tunnel launch agent",
33-
Action: cliutil.Action(uninstallLaunchd),
33+
Action: cliutil.ConfiguredAction(uninstallLaunchd),
3434
},
3535
},
3636
})

cmd/cloudflared/main.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ import (
88

99
"github.com/cloudflare/cloudflared/cmd/cloudflared/access"
1010
"github.com/cloudflare/cloudflared/cmd/cloudflared/cliutil"
11-
"github.com/cloudflare/cloudflared/config"
1211
"github.com/cloudflare/cloudflared/cmd/cloudflared/proxydns"
1312
"github.com/cloudflare/cloudflared/cmd/cloudflared/tunnel"
1413
"github.com/cloudflare/cloudflared/cmd/cloudflared/updater"
14+
"github.com/cloudflare/cloudflared/config"
1515
"github.com/cloudflare/cloudflared/logger"
1616
"github.com/cloudflare/cloudflared/metrics"
1717
"github.com/cloudflare/cloudflared/overwatch"
@@ -89,7 +89,7 @@ func commands(version func(c *cli.Context)) []*cli.Command {
8989
cmds := []*cli.Command{
9090
{
9191
Name: "update",
92-
Action: cliutil.Action(updater.Update),
92+
Action: cliutil.ConfiguredAction(updater.Update),
9393
Usage: "Update the agent if a new version exists",
9494
Flags: []cli.Flag{
9595
&cli.BoolFlag{
@@ -144,7 +144,7 @@ func isEmptyInvocation(c *cli.Context) bool {
144144
}
145145

146146
func action(graceShutdownC chan struct{}) cli.ActionFunc {
147-
return cliutil.Action(func(c *cli.Context) (err error) {
147+
return cliutil.ConfiguredAction(func(c *cli.Context) (err error) {
148148
if isEmptyInvocation(c) {
149149
return handleServiceMode(c, graceShutdownC)
150150
}

cmd/cloudflared/proxydns/cmd.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ import (
1717
func Command(hidden bool) *cli.Command {
1818
return &cli.Command{
1919
Name: "proxy-dns",
20-
Action: cliutil.Action(Run),
20+
Action: cliutil.ConfiguredAction(Run),
2121

22-
Usage: "Run a DNS over HTTPS proxy server.",
22+
Usage: "Run a DNS over HTTPS proxy server.",
2323
Flags: []cli.Flag{
2424
&cli.StringFlag{
2525
Name: "metrics",
@@ -112,5 +112,3 @@ func Run(c *cli.Context) error {
112112
}
113113
return err
114114
}
115-
116-

cmd/cloudflared/tunnel/cmd.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ func Commands() []*cli.Command {
119119
func buildTunnelCommand(subcommands []*cli.Command) *cli.Command {
120120
return &cli.Command{
121121
Name: "tunnel",
122-
Action: cliutil.Action(TunnelCommand),
122+
Action: cliutil.ConfiguredAction(TunnelCommand),
123123
Category: "Tunnel",
124124
Usage: "Make a locally-running web service accessible over the internet using Argo Tunnel.",
125125
ArgsUsage: " ",

cmd/cloudflared/tunnel/ingress_subcommands.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func buildIngressSubcommand() *cli.Command {
4545
func buildValidateIngressCommand() *cli.Command {
4646
return &cli.Command{
4747
Name: "validate",
48-
Action: cliutil.Action(validateIngressCommand),
48+
Action: cliutil.ConfiguredAction(validateIngressCommand),
4949
Usage: "Validate the ingress configuration ",
5050
UsageText: "cloudflared tunnel [--config FILEPATH] ingress validate",
5151
Description: "Validates the configuration file, ensuring your ingress rules are OK.",
@@ -55,7 +55,7 @@ func buildValidateIngressCommand() *cli.Command {
5555
func buildTestURLCommand() *cli.Command {
5656
return &cli.Command{
5757
Name: "rule",
58-
Action: cliutil.Action(testURLCommand),
58+
Action: cliutil.ConfiguredAction(testURLCommand),
5959
Usage: "Check which ingress rule matches a given request URL",
6060
UsageText: "cloudflared tunnel [--config FILEPATH] ingress rule URL",
6161
ArgsUsage: "URL",

cmd/cloudflared/tunnel/login.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,10 @@ const (
2626
func buildLoginSubcommand(hidden bool) *cli.Command {
2727
return &cli.Command{
2828
Name: "login",
29-
Action: cliutil.Action(login),
29+
Action: cliutil.ConfiguredAction(login),
3030
Usage: "Generate a configuration file with your login details",
3131
ArgsUsage: " ",
32-
Flags: []cli.Flag{
33-
&cli.StringFlag{
34-
Name: "url",
35-
Hidden: true,
36-
},
37-
},
38-
Hidden: hidden,
32+
Hidden: hidden,
3933
}
4034
}
4135

cmd/cloudflared/tunnel/subcommands.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ var (
119119
func buildCreateCommand() *cli.Command {
120120
return &cli.Command{
121121
Name: "create",
122-
Action: cliutil.Action(createCommand),
122+
Action: cliutil.ConfiguredAction(createCommand),
123123
Usage: "Create a new tunnel with given name",
124124
UsageText: "cloudflared tunnel [tunnel command options] create [subcommand options] NAME",
125125
Description: `Creates a tunnel, registers it with Cloudflare edge and generates credential file used to run this tunnel.
@@ -190,7 +190,7 @@ func writeTunnelCredentials(
190190
func buildListCommand() *cli.Command {
191191
return &cli.Command{
192192
Name: "list",
193-
Action: cliutil.Action(listCommand),
193+
Action: cliutil.ConfiguredAction(listCommand),
194194
Usage: "List existing tunnels",
195195
UsageText: "cloudflared tunnel [tunnel command options] list [subcommand options]",
196196
Description: "cloudflared tunnel list will display all active tunnels, their created time and associated connections. Use -d flag to include deleted tunnels. See the list of options to filter the list",
@@ -339,7 +339,7 @@ func fmtConnections(connections []tunnelstore.Connection, showRecentlyDisconnect
339339
func buildDeleteCommand() *cli.Command {
340340
return &cli.Command{
341341
Name: "delete",
342-
Action: cliutil.Action(deleteCommand),
342+
Action: cliutil.ConfiguredAction(deleteCommand),
343343
Usage: "Delete existing tunnel by UUID or name",
344344
UsageText: "cloudflared tunnel [tunnel command options] delete [subcommand options] TUNNEL",
345345
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.",
@@ -392,7 +392,7 @@ func buildRunCommand() *cli.Command {
392392
flags = append(flags, configureProxyFlags(false)...)
393393
return &cli.Command{
394394
Name: "run",
395-
Action: cliutil.Action(runCommand),
395+
Action: cliutil.ConfiguredAction(runCommand),
396396
Usage: "Proxy a local web server by running the given tunnel",
397397
UsageText: "cloudflared tunnel [tunnel command options] run [subcommand options] [TUNNEL]",
398398
Description: `Runs the tunnel identified by name or UUUD, creating highly available connections
@@ -444,7 +444,7 @@ func runNamedTunnel(sc *subcommandContext, tunnelRef string) error {
444444
func buildCleanupCommand() *cli.Command {
445445
return &cli.Command{
446446
Name: "cleanup",
447-
Action: cliutil.Action(cleanupCommand),
447+
Action: cliutil.ConfiguredAction(cleanupCommand),
448448
Usage: "Cleanup tunnel connections",
449449
UsageText: "cloudflared tunnel [tunnel command options] cleanup [subcommand options] TUNNEL",
450450
Description: "Delete connections for tunnels with the given UUIDs or names.",
@@ -473,7 +473,7 @@ func cleanupCommand(c *cli.Context) error {
473473
func buildRouteCommand() *cli.Command {
474474
return &cli.Command{
475475
Name: "route",
476-
Action: cliutil.Action(routeCommand),
476+
Action: cliutil.ConfiguredAction(routeCommand),
477477
Usage: "Define which traffic routed from Cloudflare edge to this tunnel: requests to a DNS hostname, to a Cloudflare Load Balancer, or traffic originating from Cloudflare WARP clients",
478478
UsageText: "cloudflared tunnel [tunnel command options] route [subcommand options] [dns TUNNEL HOSTNAME]|[lb TUNNEL HOSTNAME LB-POOL]|[ip NETWORK TUNNEL]",
479479
Description: `The route command defines how Cloudflare will proxy requests to this tunnel.

0 commit comments

Comments
 (0)