Skip to content

Commit f2e2454

Browse files
authored
chore(deps): update urfave/cli/v2 to v3 (#258)
1 parent 2514035 commit f2e2454

File tree

3 files changed

+39
-45
lines changed

3 files changed

+39
-45
lines changed

cmd/victor/main.go

Lines changed: 36 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@ package main
33
import (
44
"context"
55
"log"
6+
"net/mail"
67
"os"
78
"os/signal"
89
"syscall"
910

1011
"github.com/ctfer-io/victor"
11-
"github.com/urfave/cli/v2"
12+
"github.com/urfave/cli/v3"
1213
)
1314

1415
const (
@@ -24,90 +25,91 @@ var (
2425
)
2526

2627
func main() {
27-
app := &cli.App{
28-
Name: "Victor",
29-
Usage: "Continuous Deployment for Pulumi in Drone pileline, with external state management deffered to a webserver.",
28+
app := &cli.Command{
29+
Name: "Victor",
30+
Usage: " Victor is always here to assist you through continuous deployment, and especially when updating" +
31+
"and storing Pulumi stack states in webservers through a GitHub Action workflow or a Drone pipeline.",
3032
Flags: []cli.Flag{
3133
cli.VersionFlag,
3234
cli.HelpFlag,
3335
&cli.BoolFlag{
3436
Name: "verbose",
3537
Usage: "Turn on the verbose mode i.e. writes the Pulumi state outputs to stdout.",
3638
Required: false,
37-
EnvVars: []string{"VERBOSE", "PLUGIN_VERBOSE"},
39+
Sources: cli.EnvVars("VERBOSE", "PLUGIN_VERBOSE"),
3840
},
3941
// Webserver related
4042
&cli.StringFlag{
4143
Name: "statefile",
4244
Category: catWebserver,
4345
Usage: "Where the Pulumi stack state file is supposed to be saved. If it does not currently exist, Victor will create a brand new one.",
4446
Required: true,
45-
EnvVars: []string{"STATEFILE", "PLUGIN_STATEFILE"},
47+
Sources: cli.EnvVars("STATEFILE", "PLUGIN_STATEFILE"),
4648
},
4749
&cli.StringFlag{
4850
Name: "username",
4951
Category: catWebserver,
5052
Usage: "What username to use when getting/pushing the Pulumi stack state file. Don't set for unauthenticated.",
5153
Required: false,
52-
EnvVars: []string{"USERNAME", "PLUGIN_USERNAME"},
54+
Sources: cli.EnvVars("USERNAME", "PLUGIN_USERNAME"),
5355
},
5456
&cli.StringFlag{
5557
Name: "password",
5658
Category: catWebserver,
5759
Usage: "What password to use when getting/pushing the Pulumi stack state file. Don't set for unauthenticated.",
5860
Required: false,
59-
EnvVars: []string{"PASSWORD", "PLUGIN_PASSWORD"},
61+
Sources: cli.EnvVars("PASSWORD", "PLUGIN_PASSWORD"),
6062
},
6163
// Pulumi related
6264
&cli.StringFlag{
6365
Name: "passphrase",
6466
Category: catPulumi,
6567
Usage: "Pulumi stack password, used to decipher and recipher the state.",
6668
Required: false,
67-
EnvVars: []string{"PULUMI_CONFIG_PASSPHRASE", "PLUGIN_PASSPHRASE"},
69+
Sources: cli.EnvVars("PULUMI_CONFIG_PASSPHRASE", "PLUGIN_PASSPHRASE"),
6870
},
6971
&cli.StringFlag{
7072
Name: "context",
7173
Category: catPulumi,
7274
Usage: "Where to deploy i.e. the Pulumi entrypoint (the directory pointing to a `main.go` file containing the `pulumi.Run` call).",
7375
Required: false,
7476
Value: ".",
75-
EnvVars: []string{"CONTEXT", "PLUGIN_CONTEXT"},
77+
Sources: cli.EnvVars("CONTEXT", "PLUGIN_CONTEXT"),
7678
},
7779
&cli.StringFlag{
7880
Name: "server",
7981
Category: catPulumi,
8082
Usage: "Where to download the Pulumi plugin resources. If set, overrides the online default mode of Pulumi.",
8183
Required: false,
82-
EnvVars: []string{"SERVER", "PLUGIN_SERVER"},
84+
Sources: cli.EnvVars("SERVER", "PLUGIN_SERVER"),
8385
},
8486
&cli.StringSliceFlag{
8587
Name: "resources",
8688
Category: catPulumi,
8789
Usage: "List of Pulumi plugin resources (<name> <version>) to install before performing the update.",
8890
Required: false,
89-
EnvVars: []string{"RESOURCES", "PLUGIN_RESOURCES"},
91+
Sources: cli.EnvVars("RESOURCES", "PLUGIN_RESOURCES"),
9092
},
9193
&cli.StringSliceFlag{
9294
Name: "configuration",
9395
Category: catPulumi,
9496
Usage: "List of configurations tuples (<key> <value>) to pass to the Pulumi entrypoint. Does not support secrets yet.",
9597
Required: false,
96-
EnvVars: []string{"CONFIGURATION", "PLUGIN_CONFIGURATION"},
98+
Sources: cli.EnvVars("CONFIGURATION", "PLUGIN_CONFIGURATION"),
9799
},
98100
&cli.StringFlag{
99101
Name: "outputs",
100102
Category: catPulumi,
101103
Usage: "Where to write the Pulumi stack outputs. If set to \"-\" will write to stdout, else to the given filename.",
102104
Required: false,
103-
EnvVars: []string{"OUTPUTS", "PLUGIN_OUTPUTS"},
105+
Sources: cli.EnvVars("OUTPUTS", "PLUGIN_OUTPUTS"),
104106
},
105107
},
106108
Action: run,
107-
Authors: []*cli.Author{
108-
{
109-
Name: "Lucas Tesson - PandatiX",
110-
Email: "lucastesson@protonmail.com",
109+
Authors: []any{
110+
mail.Address{
111+
Name: "Lucas Tesson - PandatiX",
112+
Address: "lucastesson@protonmail.com",
111113
},
112114
},
113115
Version: version,
@@ -123,32 +125,32 @@ func main() {
123125
ctx, stop := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
124126
defer stop()
125127

126-
if err := app.RunContext(ctx, os.Args); err != nil {
128+
if err := app.Run(ctx, os.Args); err != nil {
127129
log.Fatal(err)
128130
}
129131
}
130132

131-
func run(ctx *cli.Context) error {
133+
func run(ctx context.Context, cmd *cli.Command) error {
132134
// Build SDK arguments
133135
args := &victor.VictorArgs{
134-
Verbose: ctx.Bool("verbose"),
136+
Verbose: cmd.Bool("verbose"),
135137
Version: version,
136-
Statefile: ctx.String("statefile"),
137-
Username: ptrCli(ctx, "username"),
138-
Password: ptrCli(ctx, "password"),
139-
Passphrase: ctx.String("passphrase"),
140-
Context: ctx.String("context"),
141-
Server: ptrCli(ctx, "server"),
142-
Resources: ctx.StringSlice("resources"),
143-
Configuration: ctx.StringSlice("configuration"),
144-
Outputs: ptrCli(ctx, "outputs"),
138+
Statefile: cmd.String("statefile"),
139+
Username: ptrCli(cmd, "username"),
140+
Password: ptrCli(cmd, "password"),
141+
Passphrase: cmd.String("passphrase"),
142+
Context: cmd.String("context"),
143+
Server: ptrCli(cmd, "server"),
144+
Resources: cmd.StringSlice("resources"),
145+
Configuration: cmd.StringSlice("configuration"),
146+
Outputs: ptrCli(cmd, "outputs"),
145147
}
146-
return victor.Victor(ctx.Context, args)
148+
return victor.Victor(ctx, args)
147149
}
148150

149-
func ptrCli(ctx *cli.Context, key string) *string {
150-
v := ctx.String(key)
151-
if ctx.IsSet(key) {
151+
func ptrCli(cmd *cli.Command, key string) *string {
152+
v := cmd.String(key)
153+
if cmd.IsSet(key) {
152154
return &v
153155
}
154156
return nil

go.mod

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ go 1.24.1
55
require (
66
github.com/pkg/errors v0.9.1
77
github.com/pulumi/pulumi/sdk/v3 v3.184.0
8-
github.com/urfave/cli/v2 v2.27.7
8+
github.com/urfave/cli/v3 v3.3.8
99
go.uber.org/multierr v1.11.0
1010
go.uber.org/zap v1.27.0
1111
)
@@ -28,7 +28,6 @@ require (
2828
github.com/cheggaaa/pb v1.0.29 // indirect
2929
github.com/cloudflare/circl v1.6.1 // indirect
3030
github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81 // indirect
31-
github.com/cpuguy83/go-md2man/v2 v2.0.7 // indirect
3231
github.com/cyphar/filepath-securejoin v0.3.6 // indirect
3332
github.com/djherbis/times v1.5.0 // indirect
3433
github.com/emirpasic/gods v1.18.1 // indirect
@@ -68,7 +67,6 @@ require (
6867
github.com/pulumi/esc v0.14.3 // indirect
6968
github.com/rivo/uniseg v0.4.4 // indirect
7069
github.com/rogpeppe/go-internal v1.12.0 // indirect
71-
github.com/russross/blackfriday/v2 v2.1.0 // indirect
7270
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06 // indirect
7371
github.com/santhosh-tekuri/jsonschema/v5 v5.0.0 // indirect
7472
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect
@@ -79,7 +77,6 @@ require (
7977
github.com/uber/jaeger-client-go v2.30.0+incompatible // indirect
8078
github.com/uber/jaeger-lib v2.4.1+incompatible // indirect
8179
github.com/xanzy/ssh-agent v0.3.3 // indirect
82-
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect
8380
github.com/zclconf/go-cty v1.13.2 // indirect
8481
go.uber.org/atomic v1.9.0 // indirect
8582
golang.org/x/crypto v0.39.0 // indirect

go.sum

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ github.com/cloudflare/circl v1.6.1/go.mod h1:uddAzsPgqdMAYatqJ0lsjX1oECcQLIlRpzZ
4040
github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81 h1:q2hJAaP1k2wIvVRd/hEHD7lacgqrCPS+k8g1MndzfWY=
4141
github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81/go.mod h1:YynlIjWYF8myEu6sdkwKIvGQq+cOckRm6So2avqoYAk=
4242
github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
43-
github.com/cpuguy83/go-md2man/v2 v2.0.7 h1:zbFlGlXEAKlwXpmvle3d8Oe3YnkKIK4xSRTd3sHPnBo=
44-
github.com/cpuguy83/go-md2man/v2 v2.0.7/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
4543
github.com/cyphar/filepath-securejoin v0.3.6 h1:4d9N5ykBnSp5Xn2JkhocYDkOpURL/18CYMpo6xB9uWM=
4644
github.com/cyphar/filepath-securejoin v0.3.6/go.mod h1:Sdj7gXlvMcPZsbhwhQ33GguGLDGQL7h7bg04C/+u9jI=
4745
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
@@ -165,7 +163,6 @@ github.com/rivo/uniseg v0.4.4 h1:8TfxU8dW6PdqD27gjM8MVNuicgxIjxpm4K7x4jp8sis=
165163
github.com/rivo/uniseg v0.4.4/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
166164
github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8=
167165
github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4=
168-
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
169166
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
170167
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06 h1:OkMGxebDjyw0ULyrTYWeN0UNCCkmCWfjPnIA2W6oviI=
171168
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06/go.mod h1:+ePHsJ1keEjQtpvf9HHw0f4ZeJ0TLRsxhunSI2hYJSs=
@@ -197,12 +194,10 @@ github.com/uber/jaeger-client-go v2.30.0+incompatible h1:D6wyKGCecFaSRUpo8lCVbaO
197194
github.com/uber/jaeger-client-go v2.30.0+incompatible/go.mod h1:WVhlPFC8FDjOFMMWRy2pZqQJSXxYSwNYOkTr/Z6d3Kk=
198195
github.com/uber/jaeger-lib v2.4.1+incompatible h1:td4jdvLcExb4cBISKIpHuGoVXh+dVKhn2Um6rjCsSsg=
199196
github.com/uber/jaeger-lib v2.4.1+incompatible/go.mod h1:ComeNDZlWwrWnDv8aPp0Ba6+uUTzImX/AauajbLI56U=
200-
github.com/urfave/cli/v2 v2.27.7 h1:bH59vdhbjLv3LAvIu6gd0usJHgoTTPhCFib8qqOwXYU=
201-
github.com/urfave/cli/v2 v2.27.7/go.mod h1:CyNAG/xg+iAOg0N4MPGZqVmv2rCoP267496AOXUZjA4=
197+
github.com/urfave/cli/v3 v3.3.8 h1:BzolUExliMdet9NlJ/u4m5vHSotJ3PzEqSAZ1oPMa/E=
198+
github.com/urfave/cli/v3 v3.3.8/go.mod h1:FJSKtM/9AiiTOJL4fJ6TbMUkxBXn7GO9guZqoZtpYpo=
202199
github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM=
203200
github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw=
204-
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 h1:gEOO8jv9F4OT7lGCjxCBTO/36wtF6j2nSip77qHd4x4=
205-
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1/go.mod h1:Ohn+xnUBiLI6FVj/9LpzZWtj1/D6lUovWYBkxHVV3aM=
206201
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
207202
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
208203
github.com/zclconf/go-cty v1.13.2 h1:4GvrUxe/QUDYuJKAav4EYqdM47/kZa672LwmXFmEKT0=

0 commit comments

Comments
 (0)