@@ -3,12 +3,13 @@ package main
33import (
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
1415const (
@@ -24,83 +25,84 @@ var (
2425)
2526
2627func 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 & cli.BoolFlag {
106108 Name : "destroy-if-non-empty" ,
@@ -111,10 +113,10 @@ func main() {
111113 },
112114 },
113115 Action : run ,
114- Authors : []* cli. Author {
115- {
116- Name : "Lucas Tesson - PandatiX" ,
117- Email : "lucastesson@protonmail.com" ,
116+ Authors : []any {
117+ mail. Address {
118+ Name : "Lucas Tesson - PandatiX" ,
119+ Address : "lucastesson@protonmail.com" ,
118120 },
119121 },
120122 Version : version ,
@@ -130,33 +132,33 @@ func main() {
130132 ctx , stop := signal .NotifyContext (context .Background (), syscall .SIGINT , syscall .SIGTERM )
131133 defer stop ()
132134
133- if err := app .RunContext (ctx , os .Args ); err != nil {
135+ if err := app .Run (ctx , os .Args ); err != nil {
134136 log .Fatal (err )
135137 }
136138}
137139
138- func run (ctx * cli.Context ) error {
140+ func run (ctx context. Context , cmd * cli.Command ) error {
139141 // Build SDK arguments
140142 args := & victor.VictorArgs {
141- Verbose : ctx .Bool ("verbose" ),
143+ Verbose : cmd .Bool ("verbose" ),
142144 Version : version ,
143- Statefile : ctx .String ("statefile" ),
144- Username : ptrCli (ctx , "username" ),
145- Password : ptrCli (ctx , "password" ),
146- Passphrase : ctx .String ("passphrase" ),
147- Context : ctx .String ("context" ),
148- Server : ptrCli (ctx , "server" ),
149- Resources : ctx .StringSlice ("resources" ),
150- Configuration : ctx .StringSlice ("configuration" ),
151- Outputs : ptrCli (ctx , "outputs" ),
152- DestroyIfNonEmpty : ctx .Bool ("destroy-if-non-empty" ),
145+ Statefile : cmd .String ("statefile" ),
146+ Username : ptrCli (cmd , "username" ),
147+ Password : ptrCli (cmd , "password" ),
148+ Passphrase : cmd .String ("passphrase" ),
149+ Context : cmd .String ("context" ),
150+ Server : ptrCli (cmd , "server" ),
151+ Resources : cmd .StringSlice ("resources" ),
152+ Configuration : cmd .StringSlice ("configuration" ),
153+ Outputs : ptrCli (cmd , "outputs" ),
154+ DestroyIfNonEmpty : cmd .Bool ("destroy-if-non-empty" ),
153155 }
154- return victor .Victor (ctx . Context , args )
156+ return victor .Victor (ctx , args )
155157}
156158
157- func ptrCli (ctx * cli.Context , key string ) * string {
158- v := ctx .String (key )
159- if ctx .IsSet (key ) {
159+ func ptrCli (cmd * cli.Command , key string ) * string {
160+ v := cmd .String (key )
161+ if cmd .IsSet (key ) {
160162 return & v
161163 }
162164 return nil
0 commit comments