@@ -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,90 +25,91 @@ 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 },
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
0 commit comments