diff --git a/cli/app/app.go b/cli/app/app.go index 72ff7da1d..a4f0c5709 100644 --- a/cli/app/app.go +++ b/cli/app/app.go @@ -1,7 +1,7 @@ package app import ( - "github.com/urfave/cli/v2" + "github.com/urfave/cli/v3" ) var AppCommand = cli.Command{ @@ -9,7 +9,7 @@ var AppCommand = cli.Command{ Aliases: []string{"a"}, Usage: "Manage apps", ArgsUsage: "", - Subcommands: []*cli.Command{ + Commands: []*cli.Command{ &appBackupCommand, &appCheckCommand, &appCmdCommand, diff --git a/cli/app/backup.go b/cli/app/backup.go index 879e21bc5..3a22e8ba3 100644 --- a/cli/app/backup.go +++ b/cli/app/backup.go @@ -1,13 +1,14 @@ package app import ( + "context" "fmt" "coopcloud.tech/abra/cli/internal" "coopcloud.tech/abra/pkg/autocomplete" "coopcloud.tech/abra/pkg/client" "coopcloud.tech/abra/pkg/log" - "github.com/urfave/cli/v2" + "github.com/urfave/cli/v3" ) var snapshot string @@ -43,11 +44,12 @@ var appBackupListCommand = cli.Command{ snapshotFlag, includePathFlag, }, - Before: internal.SubCommandBefore, - Usage: "List all backups", - BashComplete: autocomplete.AppNameComplete, - Action: func(c *cli.Context) error { - app := internal.ValidateApp(c) + Before: internal.SubCommandBefore, + Usage: "List all backups", + EnableShellCompletion: true, + ShellComplete: autocomplete.AppNameComplete, + Action: func(ctx context.Context, cmd *cli.Command) error { + app := internal.ValidateApp(cmd) if err := app.Recipe.Ensure(internal.Chaos, internal.Offline); err != nil { log.Fatal(err) @@ -90,11 +92,12 @@ var appBackupDownloadCommand = cli.Command{ snapshotFlag, includePathFlag, }, - Before: internal.SubCommandBefore, - Usage: "Download a backup", - BashComplete: autocomplete.AppNameComplete, - Action: func(c *cli.Context) error { - app := internal.ValidateApp(c) + Before: internal.SubCommandBefore, + Usage: "Download a backup", + EnableShellCompletion: true, + ShellComplete: autocomplete.AppNameComplete, + Action: func(ctx context.Context, cmd *cli.Command) error { + app := internal.ValidateApp(cmd) if err := app.Recipe.EnsureExists(); err != nil { log.Fatal(err) @@ -160,11 +163,12 @@ var appBackupCreateCommand = cli.Command{ internal.OfflineFlag, resticRepoFlag, }, - Before: internal.SubCommandBefore, - Usage: "Create a new backup", - BashComplete: autocomplete.AppNameComplete, - Action: func(c *cli.Context) error { - app := internal.ValidateApp(c) + Before: internal.SubCommandBefore, + Usage: "Create a new backup", + EnableShellCompletion: true, + ShellComplete: autocomplete.AppNameComplete, + Action: func(ctx context.Context, cmd *cli.Command) error { + app := internal.ValidateApp(cmd) if err := app.Recipe.EnsureExists(); err != nil { log.Fatal(err) @@ -218,11 +222,12 @@ var appBackupSnapshotsCommand = cli.Command{ internal.OfflineFlag, snapshotFlag, }, - Before: internal.SubCommandBefore, - Usage: "List backup snapshots", - BashComplete: autocomplete.AppNameComplete, - Action: func(c *cli.Context) error { - app := internal.ValidateApp(c) + Before: internal.SubCommandBefore, + Usage: "List backup snapshots", + EnableShellCompletion: true, + ShellComplete: autocomplete.AppNameComplete, + Action: func(ctx context.Context, cmd *cli.Command) error { + app := internal.ValidateApp(cmd) if err := app.Recipe.EnsureExists(); err != nil { log.Fatal(err) @@ -273,7 +278,7 @@ var appBackupCommand = cli.Command{ Aliases: []string{"b"}, Usage: "Manage app backups", ArgsUsage: "", - Subcommands: []*cli.Command{ + Commands: []*cli.Command{ &appBackupListCommand, &appBackupSnapshotsCommand, &appBackupDownloadCommand, diff --git a/cli/app/check.go b/cli/app/check.go index 008f151ae..6ac73a901 100644 --- a/cli/app/check.go +++ b/cli/app/check.go @@ -1,12 +1,14 @@ package app import ( + "context" + "coopcloud.tech/abra/cli/internal" appPkg "coopcloud.tech/abra/pkg/app" "coopcloud.tech/abra/pkg/autocomplete" "coopcloud.tech/abra/pkg/formatter" "coopcloud.tech/abra/pkg/log" - "github.com/urfave/cli/v2" + "github.com/urfave/cli/v3" ) var appCheckCommand = cli.Command{ @@ -31,10 +33,11 @@ ${FOO:} syntax). "check" does not confirm or deny this for you.`, internal.ChaosFlag, internal.OfflineFlag, }, - Before: internal.SubCommandBefore, - BashComplete: autocomplete.AppNameComplete, - Action: func(c *cli.Context) error { - app := internal.ValidateApp(c) + Before: internal.SubCommandBefore, + EnableShellCompletion: true, + ShellComplete: autocomplete.AppNameComplete, + Action: func(ctx context.Context, cmd *cli.Command) error { + app := internal.ValidateApp(cmd) if err := app.Recipe.Ensure(internal.Chaos, internal.Offline); err != nil { log.Fatal(err) diff --git a/cli/app/cmd.go b/cli/app/cmd.go index 26baea0e6..c2b2753fd 100644 --- a/cli/app/cmd.go +++ b/cli/app/cmd.go @@ -1,6 +1,7 @@ package app import ( + "context" "errors" "fmt" "os" @@ -14,7 +15,8 @@ import ( "coopcloud.tech/abra/pkg/autocomplete" "coopcloud.tech/abra/pkg/client" "coopcloud.tech/abra/pkg/log" - "github.com/urfave/cli/v2" + "coopcloud.tech/abra/pkg/recipe" + "github.com/urfave/cli/v3" ) var appCmdCommand = cli.Command{ @@ -43,32 +45,33 @@ EXAMPLE: internal.ChaosFlag, }, Before: internal.SubCommandBefore, - Subcommands: []*cli.Command{ + Commands: []*cli.Command{ &appCmdListCommand, }, - BashComplete: func(ctx *cli.Context) { - args := ctx.Args() + EnableShellCompletion: true, + ShellComplete: func(ctx context.Context, cmd *cli.Command) { + args := cmd.Args() switch args.Len() { case 0: - autocomplete.AppNameComplete(ctx) + autocomplete.AppNameComplete(ctx, cmd) case 1: autocomplete.ServiceNameComplete(args.Get(0)) case 2: cmdNameComplete(args.Get(0)) } }, - Action: func(c *cli.Context) error { - app := internal.ValidateApp(c) + Action: func(ctx context.Context, cmd *cli.Command) error { + app := internal.ValidateApp(cmd) if err := app.Recipe.Ensure(internal.Chaos, internal.Offline); err != nil { log.Fatal(err) } if internal.LocalCmd && internal.RemoteUser != "" { - internal.ShowSubcommandHelpAndError(c, errors.New("cannot use --local & --user together")) + internal.ShowSubcommandHelpAndError(cmd, errors.New("cannot use --local & --user together")) } - hasCmdArgs, parsedCmdArgs := parseCmdArgs(c.Args().Slice(), internal.LocalCmd) + hasCmdArgs, parsedCmdArgs := parseCmdArgs(cmd.Args().Slice(), internal.LocalCmd) if _, err := os.Stat(app.Recipe.AbraShPath); err != nil { if os.IsNotExist(err) { @@ -78,11 +81,11 @@ EXAMPLE: } if internal.LocalCmd { - if !(c.Args().Len() >= 2) { - internal.ShowSubcommandHelpAndError(c, errors.New("missing arguments")) + if !(cmd.Args().Len() >= 2) { + internal.ShowSubcommandHelpAndError(cmd, errors.New("missing arguments")) } - cmdName := c.Args().Get(1) + cmdName := cmd.Args().Get(1) if err := internal.EnsureCommand(app.Recipe.AbraShPath, app.Recipe.Name, cmdName); err != nil { log.Fatal(err) } @@ -114,13 +117,13 @@ EXAMPLE: log.Fatal(err) } } else { - if !(c.Args().Len() >= 3) { - internal.ShowSubcommandHelpAndError(c, errors.New("missing arguments")) + if !(cmd.Args().Len() >= 3) { + internal.ShowSubcommandHelpAndError(cmd, errors.New("missing arguments")) } - targetServiceName := c.Args().Get(1) + targetServiceName := cmd.Args().Get(1) - cmdName := c.Args().Get(2) + cmdName := cmd.Args().Get(2) if err := internal.EnsureCommand(app.Recipe.AbraShPath, app.Recipe.Name, cmdName); err != nil { log.Fatal(err) } @@ -208,8 +211,9 @@ var appCmdListCommand = cli.Command{ }, BashComplete: autocomplete.AppNameComplete, Before: internal.SubCommandBefore, - Action: func(c *cli.Context) error { - app := internal.ValidateApp(c) + Action: func(ctx context.Context, cmd *cli.Command) error { + app := internal.ValidateApp(cmd) + r := recipe.Get(app.Recipe.Name) if err := app.Recipe.EnsureExists(); err != nil { log.Fatal(err) diff --git a/cli/app/config.go b/cli/app/config.go index 5b583deba..e873b2dad 100644 --- a/cli/app/config.go +++ b/cli/app/config.go @@ -1,6 +1,7 @@ package app import ( + "context" "errors" "os" "os/exec" @@ -10,7 +11,7 @@ import ( "coopcloud.tech/abra/pkg/autocomplete" "coopcloud.tech/abra/pkg/log" "github.com/AlecAivazis/survey/v2" - "github.com/urfave/cli/v2" + "github.com/urfave/cli/v3" ) var appConfigCommand = cli.Command{ @@ -21,13 +22,14 @@ var appConfigCommand = cli.Command{ Flags: []cli.Flag{ internal.DebugFlag, }, - Before: internal.SubCommandBefore, - BashComplete: autocomplete.AppNameComplete, - Action: func(c *cli.Context) error { - appName := c.Args().First() + Before: internal.SubCommandBefore, + EnableShellCompletion: true, + ShellComplete: autocomplete.AppNameComplete, + Action: func(ctx context.Context, cmd *cli.Command) error { + appName := cmd.Args().First() if appName == "" { - internal.ShowSubcommandHelpAndError(c, errors.New("no app provided")) + internal.ShowSubcommandHelpAndError(cmd, errors.New("no app provided")) } files, err := appPkg.LoadAppFiles("") @@ -51,11 +53,11 @@ var appConfigCommand = cli.Command{ } } - cmd := exec.Command(ed, appFile.Path) - cmd.Stdin = os.Stdin - cmd.Stdout = os.Stdout - cmd.Stderr = os.Stderr - if err := cmd.Run(); err != nil { + c := exec.Command(ed, appFile.Path) + c.Stdin = os.Stdin + c.Stdout = os.Stdout + c.Stderr = os.Stderr + if err := c.Run(); err != nil { log.Fatal(err) } diff --git a/cli/app/cp.go b/cli/app/cp.go index 26124b3d3..ee3d7d2d1 100644 --- a/cli/app/cp.go +++ b/cli/app/cp.go @@ -22,7 +22,7 @@ import ( dockerClient "github.com/docker/docker/client" "github.com/docker/docker/errdefs" "github.com/docker/docker/pkg/archive" - "github.com/urfave/cli/v2" + "github.com/urfave/cli/v3" ) var appCpCommand = cli.Command{ @@ -44,18 +44,17 @@ If you want to copy a myfile.txt to the root of the app service: And if you want to copy that file back to your current working directory locally: - abra app cp app:/myfile.txt . -`, - BashComplete: autocomplete.AppNameComplete, - Action: func(c *cli.Context) error { - app := internal.ValidateApp(c) - + abra app cp app:/myfile.txt`, + EnableShellCompletion: true, + ShellComplete: autocomplete.AppNameComplete, + Action: func(ctx context.Context, cmd *cli.Command) error { + app := internal.ValidateApp(cmd) if err := app.Recipe.Ensure(internal.Chaos, internal.Offline); err != nil { log.Fatal(err) } - src := c.Args().Get(1) - dst := c.Args().Get(2) + src := cmd.Args().Get(1) + dst := cmd.Args().Get(2) if src == "" { log.Fatal("missing argument") } diff --git a/cli/app/deploy.go b/cli/app/deploy.go index 75680f84e..aad8d330c 100644 --- a/cli/app/deploy.go +++ b/cli/app/deploy.go @@ -15,7 +15,7 @@ import ( "coopcloud.tech/abra/pkg/lint" "coopcloud.tech/abra/pkg/log" "coopcloud.tech/abra/pkg/upstream/stack" - "github.com/urfave/cli/v2" + "github.com/urfave/cli/v3" ) var appDeployCommand = cli.Command{ @@ -45,15 +45,17 @@ EXAMPLE: abra app deploy foo.example.com abra app deploy foo.example.com 1.2.3+3.2.1 abra app deploy foo.example.com 1e83340e`, - BashComplete: autocomplete.AppNameComplete, - Action: func(c *cli.Context) error { - app := internal.ValidateApp(c) + EnableShellCompletion: true, + ShellComplete: autocomplete.AppNameComplete, + Action: func(ctx context.Context, cmd *cli.Command) error { + app := internal.ValidateApp(cmd) stackName := app.StackName() - specificVersion := c.Args().Get(1) + specificVersion := cmd.Args().Get(1) if specificVersion == "" { specificVersion = app.Recipe.Version } + if specificVersion != "" && internal.Chaos { log.Fatal("cannot use and --chaos together") } diff --git a/cli/app/list.go b/cli/app/list.go index 877da76b9..134b97ada 100644 --- a/cli/app/list.go +++ b/cli/app/list.go @@ -1,6 +1,7 @@ package app import ( + "context" "encoding/json" "fmt" "sort" @@ -12,7 +13,7 @@ import ( "coopcloud.tech/abra/pkg/formatter" "coopcloud.tech/abra/pkg/log" "coopcloud.tech/tagcmp" - "github.com/urfave/cli/v2" + "github.com/urfave/cli/v3" ) var ( @@ -89,7 +90,7 @@ can take some time.`, internal.OfflineFlag, }, Before: internal.SubCommandBefore, - Action: func(c *cli.Context) error { + Action: func(ctx context.Context, cmd *cli.Command) error { appFiles, err := appPkg.LoadAppFiles(listAppServer) if err != nil { log.Fatal(err) diff --git a/cli/app/logs.go b/cli/app/logs.go index ff8bc2ace..acfed5481 100644 --- a/cli/app/logs.go +++ b/cli/app/logs.go @@ -19,7 +19,7 @@ import ( "github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/swarm" dockerClient "github.com/docker/docker/client" - "github.com/urfave/cli/v2" + "github.com/urfave/cli/v3" ) var appLogsCommand = cli.Command{ @@ -32,10 +32,11 @@ var appLogsCommand = cli.Command{ internal.SinceLogsFlag, internal.DebugFlag, }, - Before: internal.SubCommandBefore, - BashComplete: autocomplete.AppNameComplete, - Action: func(c *cli.Context) error { - app := internal.ValidateApp(c) + Before: internal.SubCommandBefore, + EnableShellCompletion: true, + ShellComplete: autocomplete.AppNameComplete, + Action: func(ctx context.Context, cmd *cli.Command) error { + app := internal.ValidateApp(cmd) stackName := app.StackName() if err := app.Recipe.EnsureExists(); err != nil { @@ -56,7 +57,7 @@ var appLogsCommand = cli.Command{ log.Fatalf("%s is not deployed?", app.Name) } - serviceName := c.Args().Get(1) + serviceName := cmd.Args().Get(1) serviceNames := []string{} if serviceName != "" { serviceNames = []string{serviceName} diff --git a/cli/app/new.go b/cli/app/new.go index 450eaf672..735dff254 100644 --- a/cli/app/new.go +++ b/cli/app/new.go @@ -1,6 +1,7 @@ package app import ( + "context" "fmt" "coopcloud.tech/abra/cli/internal" @@ -15,7 +16,7 @@ import ( "coopcloud.tech/abra/pkg/secret" "github.com/AlecAivazis/survey/v2" dockerClient "github.com/docker/docker/client" - "github.com/urfave/cli/v2" + "github.com/urfave/cli/v3" ) var appNewDescription = ` @@ -52,19 +53,20 @@ var appNewCommand = cli.Command{ internal.OfflineFlag, internal.ChaosFlag, }, - Before: internal.SubCommandBefore, - ArgsUsage: "[] []", - BashComplete: func(ctx *cli.Context) { - args := ctx.Args() + Before: internal.SubCommandBefore, + ArgsUsage: "[] []", + EnableShellCompletion: true, + ShellComplete: func(ctx context.Context, cmd *cli.Command) { + args := cmd.Args() switch args.Len() { case 0: - autocomplete.RecipeNameComplete(ctx) + autocomplete.RecipeNameComplete(ctx, cmd) case 1: - autocomplete.RecipeVersionComplete(ctx.Args().Get(0)) + autocomplete.RecipeVersionComplete(cmd.Args().Get(0)) } }, - Action: func(c *cli.Context) error { - recipe := internal.ValidateRecipe(c) + Action: func(ctx context.Context, cmd *cli.Command) error { + recipe := internal.ValidateRecipe(cmd) if !internal.Chaos { if err := recipe.EnsureIsClean(); err != nil { @@ -75,7 +77,7 @@ var appNewCommand = cli.Command{ log.Fatal(err) } } - if c.Args().Get(1) == "" { + if cmd.Args().Get(1) == "" { var version string recipeVersions, err := recipe.GetRecipeVersions() @@ -100,7 +102,7 @@ var appNewCommand = cli.Command{ } } } else { - if _, err := recipe.EnsureVersion(c.Args().Get(1)); err != nil { + if _, err := recipe.EnsureVersion(cmd.Args().Get(1)); err != nil { log.Fatal(err) } } diff --git a/cli/app/ps.go b/cli/app/ps.go index defd850ab..71822527a 100644 --- a/cli/app/ps.go +++ b/cli/app/ps.go @@ -17,7 +17,7 @@ import ( containerTypes "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/filters" dockerClient "github.com/docker/docker/client" - "github.com/urfave/cli/v2" + "github.com/urfave/cli/v3" ) var appPsCommand = cli.Command{ @@ -30,10 +30,11 @@ var appPsCommand = cli.Command{ internal.MachineReadableFlag, internal.DebugFlag, }, - Before: internal.SubCommandBefore, - BashComplete: autocomplete.AppNameComplete, - Action: func(c *cli.Context) error { - app := internal.ValidateApp(c) + Before: internal.SubCommandBefore, + EnableShellCompletion: true, + ShellComplete: autocomplete.AppNameComplete, + Action: func(ctx context.Context, cmd *cli.Command) error { + app := internal.ValidateApp(cmd) if err := app.Recipe.Ensure(false, false); err != nil { log.Fatal(err) } diff --git a/cli/app/remove.go b/cli/app/remove.go index f8dc7a5ec..8cbcd5f39 100644 --- a/cli/app/remove.go +++ b/cli/app/remove.go @@ -12,7 +12,7 @@ import ( stack "coopcloud.tech/abra/pkg/upstream/stack" "github.com/AlecAivazis/survey/v2" "github.com/docker/docker/api/types" - "github.com/urfave/cli/v2" + "github.com/urfave/cli/v3" ) var appRemoveCommand = cli.Command{ @@ -43,10 +43,11 @@ flag.`, internal.NoInputFlag, internal.OfflineFlag, }, - BashComplete: autocomplete.AppNameComplete, - Before: internal.SubCommandBefore, - Action: func(c *cli.Context) error { - app := internal.ValidateApp(c) + EnableShellCompletion: true, + ShellComplete: autocomplete.AppNameComplete, + Before: internal.SubCommandBefore, + Action: func(ctx context.Context, cmd *cli.Command) error { + app := internal.ValidateApp(cmd) if !internal.Force && !internal.NoInput { response := false diff --git a/cli/app/restart.go b/cli/app/restart.go index 3de623c94..193e3ae97 100644 --- a/cli/app/restart.go +++ b/cli/app/restart.go @@ -12,7 +12,7 @@ import ( "coopcloud.tech/abra/pkg/log" upstream "coopcloud.tech/abra/pkg/upstream/service" stack "coopcloud.tech/abra/pkg/upstream/stack" - "github.com/urfave/cli/v2" + "github.com/urfave/cli/v3" ) var appRestartCommand = cli.Command{ @@ -36,17 +36,18 @@ Pass "--all-services/-a" to restart all services. EXAMPLE: abra app restart example.com app`, - BashComplete: autocomplete.AppNameComplete, - Action: func(c *cli.Context) error { - app := internal.ValidateApp(c) + EnableShellCompletion: true, + ShellComplete: autocomplete.AppNameComplete, + Action: func(ctx context.Context, cmd *cli.Command) error { + app := internal.ValidateApp(cmd) if err := app.Recipe.Ensure(false, false); err != nil { log.Fatal(err) } - serviceName := c.Args().Get(1) + serviceName := cmd.Args().Get(1) if serviceName == "" && !internal.AllServices { err := errors.New("missing ") - internal.ShowSubcommandHelpAndError(c, err) + internal.ShowSubcommandHelpAndError(cmd, err) } if serviceName != "" && internal.AllServices { diff --git a/cli/app/restore.go b/cli/app/restore.go index c73a347b0..103bb80f4 100644 --- a/cli/app/restore.go +++ b/cli/app/restore.go @@ -1,13 +1,14 @@ package app import ( + "context" "fmt" "coopcloud.tech/abra/cli/internal" "coopcloud.tech/abra/pkg/autocomplete" "coopcloud.tech/abra/pkg/client" "coopcloud.tech/abra/pkg/log" - "github.com/urfave/cli/v2" + "github.com/urfave/cli/v3" ) var targetPath string @@ -28,10 +29,11 @@ var appRestoreCommand = cli.Command{ internal.OfflineFlag, targetPathFlag, }, - Before: internal.SubCommandBefore, - BashComplete: autocomplete.AppNameComplete, - Action: func(c *cli.Context) error { - app := internal.ValidateApp(c) + Before: internal.SubCommandBefore, + EnableShellCompletion: true, + ShellComplete: autocomplete.AppNameComplete, + Action: func(ctx context.Context, cmd *cli.Command) error { + app := internal.ValidateApp(cmd) if err := app.Recipe.Ensure(internal.Chaos, internal.Offline); err != nil { log.Fatal(err) } diff --git a/cli/app/rollback.go b/cli/app/rollback.go index f3936e8d4..12cd47edb 100644 --- a/cli/app/rollback.go +++ b/cli/app/rollback.go @@ -15,7 +15,7 @@ import ( "coopcloud.tech/abra/pkg/client" "coopcloud.tech/abra/pkg/log" "github.com/AlecAivazis/survey/v2" - "github.com/urfave/cli/v2" + "github.com/urfave/cli/v3" ) var appRollbackCommand = cli.Command{ @@ -45,9 +45,10 @@ EXAMPLE: abra app rollback foo.example.com abra app rollback foo.example.com 1.2.3+3.2.1`, - BashComplete: autocomplete.AppNameComplete, - Action: func(c *cli.Context) error { - app := internal.ValidateApp(c) + EnableShellCompletion: true, + ShellComplete: autocomplete.AppNameComplete, + Action: func(ctx context.Context, cmd *cli.Command) error { + app := internal.ValidateApp(cmd) stackName := app.StackName() if err := app.Recipe.Ensure(internal.Chaos, internal.Offline); err != nil { @@ -85,10 +86,11 @@ EXAMPLE: log.Warnf("failed to determine deployed version of %s", app.Name) } - specificVersion := c.Args().Get(1) + specificVersion := cmd.Args().Get(1) if specificVersion == "" { specificVersion = app.Recipe.Version } + if specificVersion != "" { parsedDeployedVersion, err := tagcmp.Parse(deployMeta.Version) if err != nil { diff --git a/cli/app/run.go b/cli/app/run.go index b71921572..cc6a6b3f2 100644 --- a/cli/app/run.go +++ b/cli/app/run.go @@ -14,7 +14,7 @@ import ( "github.com/docker/cli/cli/command" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/filters" - "github.com/urfave/cli/v2" + "github.com/urfave/cli/v3" ) var user string @@ -40,19 +40,20 @@ var appRunCommand = cli.Command{ noTTYFlag, userFlag, }, - Before: internal.SubCommandBefore, - ArgsUsage: " ...", - Usage: "Run a command in a service container", - BashComplete: autocomplete.AppNameComplete, - Action: func(c *cli.Context) error { - app := internal.ValidateApp(c) + Before: internal.SubCommandBefore, + ArgsUsage: " ...", + Usage: "Run a command in a service container", + EnableShellCompletion: true, + ShellComplete: autocomplete.AppNameComplete, + Action: func(ctx context.Context, cmd *cli.Command) error { + app := internal.ValidateApp(cmd) - if c.Args().Len() < 2 { - internal.ShowSubcommandHelpAndError(c, errors.New("no provided?")) + if cmd.Args().Len() < 2 { + internal.ShowSubcommandHelpAndError(cmd, errors.New("no provided?")) } - if c.Args().Len() < 3 { - internal.ShowSubcommandHelpAndError(c, errors.New("no provided?")) + if cmd.Args().Len() < 3 { + internal.ShowSubcommandHelpAndError(cmd, errors.New("no provided?")) } cl, err := client.New(app.Server) @@ -60,7 +61,7 @@ var appRunCommand = cli.Command{ log.Fatal(err) } - serviceName := c.Args().Get(1) + serviceName := cmd.Args().Get(1) stackAndServiceName := fmt.Sprintf("^%s_%s", app.StackName(), serviceName) filters := filters.NewArgs() filters.Add("name", stackAndServiceName) @@ -70,12 +71,12 @@ var appRunCommand = cli.Command{ log.Fatal(err) } - cmd := c.Args().Slice()[2:] + c := cmd.Args().Slice()[2:] execCreateOpts := types.ExecConfig{ AttachStderr: true, AttachStdin: true, AttachStdout: true, - Cmd: cmd, + Cmd: c, Detach: false, Tty: true, } diff --git a/cli/app/secret.go b/cli/app/secret.go index 78a9e28f4..6025afd26 100644 --- a/cli/app/secret.go +++ b/cli/app/secret.go @@ -17,7 +17,7 @@ import ( "coopcloud.tech/abra/pkg/secret" "github.com/docker/docker/api/types" dockerClient "github.com/docker/docker/client" - "github.com/urfave/cli/v2" + "github.com/urfave/cli/v3" ) var ( @@ -53,22 +53,23 @@ var appSecretGenerateCommand = cli.Command{ internal.OfflineFlag, internal.ChaosFlag, }, - Before: internal.SubCommandBefore, - BashComplete: autocomplete.AppNameComplete, - Action: func(c *cli.Context) error { - app := internal.ValidateApp(c) + Before: internal.SubCommandBefore, + EnableShellCompletion: true, + ShellComplete: autocomplete.AppNameComplete, + Action: func(ctx context.Context, cmd *cli.Command) error { + app := internal.ValidateApp(cmd) if err := app.Recipe.Ensure(internal.Chaos, internal.Offline); err != nil { log.Fatal(err) } - if c.Args().Len() == 1 && !allSecrets { + if cmd.Args().Len() == 1 && !allSecrets { err := errors.New("missing arguments / or '--all'") - internal.ShowSubcommandHelpAndError(c, err) + internal.ShowSubcommandHelpAndError(cmd, err) } - if c.Args().Get(1) != "" && allSecrets { + if cmd.Args().Get(1) != "" && allSecrets { err := errors.New("cannot use ' ' and '--all' together") - internal.ShowSubcommandHelpAndError(c, err) + internal.ShowSubcommandHelpAndError(cmd, err) } composeFiles, err := app.Recipe.GetComposeFiles(app.Env) @@ -82,8 +83,8 @@ var appSecretGenerateCommand = cli.Command{ } if !allSecrets { - secretName := c.Args().Get(1) - secretVersion := c.Args().Get(2) + secretName := cmd.Args().Get(1) + secretVersion := cmd.Args().Get(2) s, ok := secrets[secretName] if !ok { log.Fatalf("%s doesn't exist in the env config?", secretName) @@ -144,9 +145,10 @@ var appSecretInsertCommand = cli.Command{ internal.FileFlag, internal.TrimFlag, }, - Before: internal.SubCommandBefore, - ArgsUsage: " ", - BashComplete: autocomplete.AppNameComplete, + Before: internal.SubCommandBefore, + ArgsUsage: " ", + EnableShellCompletion: true, + ShellComplete: autocomplete.AppNameComplete, Description: ` This command inserts a secret into an app environment. @@ -159,11 +161,11 @@ Example: abra app secret insert myapp db_pass v1 mySecretPassword `, - Action: func(c *cli.Context) error { - app := internal.ValidateApp(c) + Action: func(ctx context.Context, cmd *cli.Command) error { + app := internal.ValidateApp(cmd) - if c.Args().Len() != 4 { - internal.ShowSubcommandHelpAndError(c, errors.New("missing arguments?")) + if cmd.Args().Len() != 4 { + internal.ShowSubcommandHelpAndError(cmd, errors.New("missing arguments?")) } cl, err := client.New(app.Server) @@ -171,9 +173,9 @@ Example: log.Fatal(err) } - name := c.Args().Get(1) - version := c.Args().Get(2) - data := c.Args().Get(3) + name := cmd.Args().Get(1) + version := cmd.Args().Get(2) + data := cmd.Args().Get(3) if internal.File { raw, err := os.ReadFile(data) @@ -235,9 +237,10 @@ var appSecretRmCommand = cli.Command{ internal.OfflineFlag, internal.ChaosFlag, }, - Before: internal.SubCommandBefore, - ArgsUsage: " []", - BashComplete: autocomplete.AppNameComplete, + Before: internal.SubCommandBefore, + ArgsUsage: " []", + EnableShellCompletion: true, + ShellComplete: autocomplete.AppNameComplete, Description: ` This command removes app secrets. @@ -245,8 +248,8 @@ Example: abra app secret remove myapp db_pass `, - Action: func(c *cli.Context) error { - app := internal.ValidateApp(c) + Action: func(ctx context.Context, cmd *cli.Command) error { + app := internal.ValidateApp(cmd) if err := app.Recipe.Ensure(internal.Chaos, internal.Offline); err != nil { log.Fatal(err) } @@ -261,12 +264,12 @@ Example: log.Fatal(err) } - if c.Args().Get(1) != "" && rmAllSecrets { - internal.ShowSubcommandHelpAndError(c, errors.New("cannot use '' and '--all' together")) + if cmd.Args().Get(1) != "" && rmAllSecrets { + internal.ShowSubcommandHelpAndError(cmd, errors.New("cannot use '' and '--all' together")) } - if c.Args().Get(1) == "" && !rmAllSecrets { - internal.ShowSubcommandHelpAndError(c, errors.New("no secret(s) specified?")) + if cmd.Args().Get(1) == "" && !rmAllSecrets { + internal.ShowSubcommandHelpAndError(cmd, errors.New("no secret(s) specified?")) } cl, err := client.New(app.Server) @@ -290,7 +293,7 @@ Example: } match := false - secretToRm := c.Args().Get(1) + secretToRm := cmd.Args().Get(1) for secretName, val := range secrets { secretRemoteName := fmt.Sprintf("%s_%s_%s", app.StackName(), secretName, val.Version) if _, ok := remoteSecretNames[secretRemoteName]; ok { @@ -333,11 +336,12 @@ var appSecretLsCommand = cli.Command{ internal.ChaosFlag, internal.MachineReadableFlag, }, - Before: internal.SubCommandBefore, - Usage: "List all secrets", - BashComplete: autocomplete.AppNameComplete, - Action: func(c *cli.Context) error { - app := internal.ValidateApp(c) + Before: internal.SubCommandBefore, + Usage: "List all secrets", + EnableShellCompletion: true, + ShellComplete: autocomplete.AppNameComplete, + Action: func(ctx context.Context, cmd *cli.Command) error { + app := internal.ValidateApp(cmd) if err := app.Recipe.Ensure(internal.Chaos, internal.Offline); err != nil { log.Fatal(err) } @@ -384,7 +388,7 @@ var appSecretCommand = cli.Command{ Aliases: []string{"s"}, Usage: "Manage app secrets", ArgsUsage: "", - Subcommands: []*cli.Command{ + Commands: []*cli.Command{ &appSecretGenerateCommand, &appSecretInsertCommand, &appSecretRmCommand, diff --git a/cli/app/services.go b/cli/app/services.go index 892375c1d..b406cbf08 100644 --- a/cli/app/services.go +++ b/cli/app/services.go @@ -13,7 +13,7 @@ import ( "coopcloud.tech/abra/pkg/service" stack "coopcloud.tech/abra/pkg/upstream/stack" containerTypes "github.com/docker/docker/api/types/container" - "github.com/urfave/cli/v2" + "github.com/urfave/cli/v3" ) var appServicesCommand = cli.Command{ @@ -24,10 +24,11 @@ var appServicesCommand = cli.Command{ Flags: []cli.Flag{ internal.DebugFlag, }, - Before: internal.SubCommandBefore, - BashComplete: autocomplete.AppNameComplete, - Action: func(c *cli.Context) error { - app := internal.ValidateApp(c) + Before: internal.SubCommandBefore, + EnableShellCompletion: true, + ShellComplete: autocomplete.AppNameComplete, + Action: func(ctx context.Context, cmd *cli.Command) error { + app := internal.ValidateApp(cmd) if err := app.Recipe.Ensure(internal.Chaos, internal.Offline); err != nil { log.Fatal(err) } diff --git a/cli/app/undeploy.go b/cli/app/undeploy.go index 06105a101..62ebb735a 100644 --- a/cli/app/undeploy.go +++ b/cli/app/undeploy.go @@ -13,7 +13,7 @@ import ( stack "coopcloud.tech/abra/pkg/upstream/stack" "github.com/docker/docker/api/types/filters" dockerClient "github.com/docker/docker/client" - "github.com/urfave/cli/v2" + "github.com/urfave/cli/v3" ) var prune bool @@ -70,9 +70,10 @@ var appUndeployCommand = cli.Command{ internal.NoInputFlag, pruneFlag, }, - Before: internal.SubCommandBefore, - Usage: "Undeploy an app", - BashComplete: autocomplete.AppNameComplete, + Before: internal.SubCommandBefore, + Usage: "Undeploy an app", + EnableShellCompletion: true, + ShellComplete: autocomplete.AppNameComplete, Description: ` This does not destroy any of the application data. @@ -80,8 +81,8 @@ However, you should remain vigilant, as your swarm installation will consider any previously attached volumes as eligible for pruning once undeployed. Passing "-p/--prune" does not remove those volumes.`, - Action: func(c *cli.Context) error { - app := internal.ValidateApp(c) + Action: func(ctx context.Context, cmd *cli.Command) error { + app := internal.ValidateApp(cmd) if err := app.Recipe.Ensure(internal.Chaos, internal.Offline); err != nil { log.Fatal(err) } diff --git a/cli/app/upgrade.go b/cli/app/upgrade.go index ee0354f99..f01fa7536 100644 --- a/cli/app/upgrade.go +++ b/cli/app/upgrade.go @@ -14,7 +14,7 @@ import ( stack "coopcloud.tech/abra/pkg/upstream/stack" "coopcloud.tech/tagcmp" "github.com/AlecAivazis/survey/v2" - "github.com/urfave/cli/v2" + "github.com/urfave/cli/v3" ) var appUpgradeCommand = cli.Command{ @@ -45,9 +45,10 @@ EXAMPLE: abra app upgrade foo.example.com abra app upgrade foo.example.com 1.2.3+3.2.1`, - BashComplete: autocomplete.AppNameComplete, - Action: func(c *cli.Context) error { - app := internal.ValidateApp(c) + EnableShellCompletion: true, + ShellComplete: autocomplete.AppNameComplete, + Action: func(ctx context.Context, cmd *cli.Command) error { + app := internal.ValidateApp(cmd) stackName := app.StackName() if err := app.Recipe.Ensure(internal.Chaos, internal.Offline); err != nil { @@ -85,7 +86,7 @@ EXAMPLE: log.Warnf("failed to determine deployed version of %s", app.Name) } - specificVersion := c.Args().Get(1) + specificVersion := cmd.Args().Get(1) if specificVersion != "" { parsedDeployedVersion, err := tagcmp.Parse(deployMeta.Version) if err != nil { diff --git a/cli/app/volume.go b/cli/app/volume.go index 1abefff58..c5b34937c 100644 --- a/cli/app/volume.go +++ b/cli/app/volume.go @@ -10,7 +10,7 @@ import ( "coopcloud.tech/abra/pkg/log" "coopcloud.tech/abra/pkg/upstream/stack" "github.com/AlecAivazis/survey/v2" - "github.com/urfave/cli/v2" + "github.com/urfave/cli/v3" ) var appVolumeListCommand = cli.Command{ @@ -21,11 +21,12 @@ var appVolumeListCommand = cli.Command{ internal.DebugFlag, internal.NoInputFlag, }, - Before: internal.SubCommandBefore, - Usage: "List volumes associated with an app", - BashComplete: autocomplete.AppNameComplete, - Action: func(c *cli.Context) error { - app := internal.ValidateApp(c) + Before: internal.SubCommandBefore, + Usage: "List volumes associated with an app", + EnableShellCompletion: true, + ShellComplete: autocomplete.AppNameComplete, + Action: func(ctx context.Context, cmd *cli.Command) error { + app := internal.ValidateApp(cmd) cl, err := client.New(app.Server) if err != nil { @@ -81,10 +82,11 @@ Passing "--force/-f" will select all volumes for removal. Be careful.`, internal.NoInputFlag, internal.ForceFlag, }, - Before: internal.SubCommandBefore, - BashComplete: autocomplete.AppNameComplete, - Action: func(c *cli.Context) error { - app := internal.ValidateApp(c) + Before: internal.SubCommandBefore, + EnableShellCompletion: true, + ShellComplete: autocomplete.AppNameComplete, + Action: func(ctx context.Context, cmd *cli.Command) error { + app := internal.ValidateApp(cmd) cl, err := client.New(app.Server) if err != nil { @@ -149,7 +151,7 @@ var appVolumeCommand = cli.Command{ Aliases: []string{"vl"}, Usage: "Manage app volumes", ArgsUsage: "", - Subcommands: []*cli.Command{ + Commands: []*cli.Command{ &appVolumeListCommand, &appVolumeRemoveCommand, }, diff --git a/cli/catalogue/catalogue.go b/cli/catalogue/catalogue.go index d3ef81ce7..575150f64 100644 --- a/cli/catalogue/catalogue.go +++ b/cli/catalogue/catalogue.go @@ -1,6 +1,7 @@ package catalogue import ( + "context" "encoding/json" "fmt" "io/ioutil" @@ -15,7 +16,7 @@ import ( "coopcloud.tech/abra/pkg/log" "coopcloud.tech/abra/pkg/recipe" "github.com/go-git/go-git/v5" - "github.com/urfave/cli/v2" + "github.com/urfave/cli/v3" ) var catalogueGenerateCommand = cli.Command{ @@ -45,14 +46,15 @@ If you have a Hub account you can have Abra log you in to avoid this. Pass Push your new release to git.coopcloud.tech with "-p/--publish". This requires that you have permission to git push to these repositories and have your SSH keys configured on your account.`, - ArgsUsage: "[]", - BashComplete: autocomplete.RecipeNameComplete, - Action: func(c *cli.Context) error { - recipeName := c.Args().First() + ArgsUsage: "[]", + EnableShellCompletion: true, + ShellComplete: autocomplete.RecipeNameComplete, + Action: func(ctx context.Context, cmd *cli.Command) error { + recipeName := cmd.Args().First() r := recipe.Get(recipeName) if recipeName != "" { - internal.ValidateRecipe(c) + internal.ValidateRecipe(cmd) } if !internal.Chaos { @@ -209,7 +211,7 @@ var CatalogueCommand = cli.Command{ Usage: "Manage the recipe catalogue", Aliases: []string{"c"}, ArgsUsage: "", - Subcommands: []*cli.Command{ + Commands: []*cli.Command{ &catalogueGenerateCommand, }, } diff --git a/cli/cli.go b/cli/cli.go index ecffaeb62..f2a2f8530 100644 --- a/cli/cli.go +++ b/cli/cli.go @@ -2,6 +2,7 @@ package cli import ( + "context" "errors" "fmt" "os" @@ -18,7 +19,7 @@ import ( "coopcloud.tech/abra/pkg/log" "coopcloud.tech/abra/pkg/web" charmLog "github.com/charmbracelet/log" - "github.com/urfave/cli/v2" + "github.com/urfave/cli/v3" ) // AutoCompleteCommand helps people set up auto-complete in their shells @@ -38,11 +39,11 @@ EXAMPLE: Flags: []cli.Flag{ internal.DebugFlag, }, - Action: func(c *cli.Context) error { - shellType := c.Args().First() + Action: func(ctx context.Context, cmd *cli.Command) error { + shellType := cmd.Args().First() if shellType == "" { - internal.ShowSubcommandHelpAndError(c, errors.New("no shell provided")) + internal.ShowSubcommandHelpAndError(cmd, errors.New("no shell provided")) } supportedShells := map[string]bool{ @@ -125,18 +126,18 @@ EXAMPLE: abra upgrade abra upgrade --rc`, Flags: []cli.Flag{internal.RCFlag}, - Action: func(c *cli.Context) error { + Action: func(ctx context.Context, cmd *cli.Command) error { mainURL := "https://install.abra.coopcloud.tech" - cmd := exec.Command("bash", "-c", fmt.Sprintf("wget -q -O- %s | bash", mainURL)) + c := exec.Command("bash", "-c", fmt.Sprintf("wget -q -O- %s | bash", mainURL)) if internal.RC { releaseCandidateURL := "https://git.coopcloud.tech/coop-cloud/abra/raw/branch/main/scripts/installer/installer" - cmd = exec.Command("bash", "-c", fmt.Sprintf("wget -q -O- %s | bash -s -- --rc", releaseCandidateURL)) + c = exec.Command("bash", "-c", fmt.Sprintf("wget -q -O- %s | bash -s -- --rc", releaseCandidateURL)) } - log.Debugf("attempting to run %s", cmd) + log.Debugf("attempting to run %s", c) - if err := internal.RunCmd(cmd); err != nil { + if err := internal.RunCmd(c); err != nil { log.Fatal(err) } @@ -144,8 +145,8 @@ EXAMPLE: }, } -func newAbraApp(version, commit string) *cli.App { - app := &cli.App{ +func newAbraApp(version, commit string) *cli.Command { + app := &cli.Command{ Name: "abra", Usage: `the Co-op Cloud command-line utility belt 🎩🐇 ____ ____ _ _ @@ -164,12 +165,11 @@ func newAbraApp(version, commit string) *cli.App { &UpgradeCommand, &AutoCompleteCommand, }, - BashComplete: autocomplete.SubcommandComplete, + EnableShellCompletion: true, + ShellComplete: autocomplete.SubcommandComplete, } - app.EnableBashCompletion = true - - app.Before = func(c *cli.Context) error { + app.Before = func(ctx context.Context, cmd *cli.Command) error { paths := []string{ config.ABRA_DIR, config.SERVERS_DIR, @@ -200,7 +200,7 @@ func newAbraApp(version, commit string) *cli.App { func RunApp(version, commit string) { app := newAbraApp(version, commit) - if err := app.Run(os.Args); err != nil { + if err := app.Run(context.Background(), os.Args); err != nil { log.Fatal(err) } } diff --git a/cli/internal/cli.go b/cli/internal/cli.go index ae4c52a73..48b94a025 100644 --- a/cli/internal/cli.go +++ b/cli/internal/cli.go @@ -1,10 +1,11 @@ package internal import ( + "context" "os" "coopcloud.tech/abra/pkg/log" - "github.com/urfave/cli/v2" + "github.com/urfave/cli/v3" ) // Secrets stores the variable from SecretsFlag @@ -319,7 +320,7 @@ var AllServicesFlag = &cli.BoolFlag{ } // SubCommandBefore wires up pre-action machinery (e.g. --debug handling). -func SubCommandBefore(c *cli.Context) error { +func SubCommandBefore(ctx context.Context, cmd *cli.Command) error { if Debug { log.SetLevel(log.DebugLevel) log.SetOutput(os.Stderr) diff --git a/cli/internal/errors.go b/cli/internal/errors.go index 199accd7a..45a197523 100644 --- a/cli/internal/errors.go +++ b/cli/internal/errors.go @@ -4,13 +4,13 @@ import ( "os" "coopcloud.tech/abra/pkg/log" - "github.com/urfave/cli/v2" + "github.com/urfave/cli/v3" ) // ShowSubcommandHelpAndError exits the program on error, logs the error to the // terminal, and shows the help command. -func ShowSubcommandHelpAndError(c *cli.Context, err interface{}) { - if err2 := cli.ShowSubcommandHelp(c); err2 != nil { +func ShowSubcommandHelpAndError(cmd *cli.Command, err interface{}) { + if err2 := cli.ShowSubcommandHelp(cmd); err2 != nil { log.Error(err2) } log.Error(err) diff --git a/cli/internal/validate.go b/cli/internal/validate.go index 42bb66352..29a41b1ef 100644 --- a/cli/internal/validate.go +++ b/cli/internal/validate.go @@ -9,12 +9,12 @@ import ( "coopcloud.tech/abra/pkg/log" "coopcloud.tech/abra/pkg/recipe" "github.com/AlecAivazis/survey/v2" - "github.com/urfave/cli/v2" + "github.com/urfave/cli/v3" ) // ValidateRecipe ensures the recipe arg is valid. -func ValidateRecipe(c *cli.Context) recipe.Recipe { - recipeName := c.Args().First() +func ValidateRecipe(cmd *cli.Command) recipe.Recipe { + recipeName := cmd.Args().First() if recipeName == "" && !NoInput { var recipes []string @@ -54,7 +54,7 @@ func ValidateRecipe(c *cli.Context) recipe.Recipe { } if recipeName == "" { - ShowSubcommandHelpAndError(c, errors.New("no recipe name provided")) + ShowSubcommandHelpAndError(cmd, errors.New("no recipe name provided")) } chosenRecipe := recipe.Get(recipeName) @@ -64,7 +64,7 @@ func ValidateRecipe(c *cli.Context) recipe.Recipe { } _, err = chosenRecipe.GetComposeConfig(nil) if err != nil { - if c.Command.Name == "generate" { + if cmd.Name == "generate" { if strings.Contains(err.Error(), "missing a compose") { log.Fatal(err) } @@ -83,11 +83,11 @@ func ValidateRecipe(c *cli.Context) recipe.Recipe { } // ValidateApp ensures the app name arg is valid. -func ValidateApp(c *cli.Context) app.App { - appName := c.Args().First() +func ValidateApp(cmd *cli.Command) app.App { + appName := cmd.Args().First() if appName == "" { - ShowSubcommandHelpAndError(c, errors.New("no app provided")) + ShowSubcommandHelpAndError(cmd, errors.New("no app provided")) } app, err := app.Get(appName) @@ -101,8 +101,8 @@ func ValidateApp(c *cli.Context) app.App { } // ValidateDomain ensures the domain name arg is valid. -func ValidateDomain(c *cli.Context) string { - domainName := c.Args().First() +func ValidateDomain(cmd *cli.Command) string { + domainName := cmd.Args().First() if domainName == "" && !NoInput { prompt := &survey.Input{ @@ -115,7 +115,7 @@ func ValidateDomain(c *cli.Context) string { } if domainName == "" { - ShowSubcommandHelpAndError(c, errors.New("no domain provided")) + ShowSubcommandHelpAndError(cmd, errors.New("no domain provided")) } log.Debugf("validated %s as domain argument", domainName) @@ -124,10 +124,10 @@ func ValidateDomain(c *cli.Context) string { } // ValidateSubCmdFlags ensures flag order conforms to correct order -func ValidateSubCmdFlags(c *cli.Context) bool { - for argIdx, arg := range c.Args().Slice() { +func ValidateSubCmdFlags(cmd *cli.Command) bool { + for argIdx, arg := range cmd.Args().Slice() { if !strings.HasPrefix(arg, "--") { - for _, flag := range c.Args().Slice()[argIdx:] { + for _, flag := range cmd.Args().Slice()[argIdx:] { if strings.HasPrefix(flag, "--") { return false } @@ -138,8 +138,8 @@ func ValidateSubCmdFlags(c *cli.Context) bool { } // ValidateServer ensures the server name arg is valid. -func ValidateServer(c *cli.Context) string { - serverName := c.Args().First() +func ValidateServer(cmd *cli.Command) string { + serverName := cmd.Args().First() serverNames, err := config.ReadServerNames() if err != nil { @@ -164,11 +164,11 @@ func ValidateServer(c *cli.Context) string { } if serverName == "" { - ShowSubcommandHelpAndError(c, errors.New("no server provided")) + ShowSubcommandHelpAndError(cmd, errors.New("no server provided")) } if !matched { - ShowSubcommandHelpAndError(c, errors.New("server doesn't exist?")) + ShowSubcommandHelpAndError(cmd, errors.New("server doesn't exist?")) } log.Debugf("validated %s as server argument", serverName) diff --git a/cli/recipe/diff.go b/cli/recipe/diff.go index 3eb424825..118714f6a 100644 --- a/cli/recipe/diff.go +++ b/cli/recipe/diff.go @@ -1,11 +1,13 @@ package recipe import ( + "context" + "coopcloud.tech/abra/cli/internal" "coopcloud.tech/abra/pkg/autocomplete" gitPkg "coopcloud.tech/abra/pkg/git" "coopcloud.tech/abra/pkg/log" - "github.com/urfave/cli/v2" + "github.com/urfave/cli/v3" ) var recipeDiffCommand = cli.Command{ @@ -18,10 +20,11 @@ var recipeDiffCommand = cli.Command{ internal.DebugFlag, internal.NoInputFlag, }, - Before: internal.SubCommandBefore, - BashComplete: autocomplete.RecipeNameComplete, - Action: func(c *cli.Context) error { - r := internal.ValidateRecipe(c) + Before: internal.SubCommandBefore, + EnableShellCompletion: true, + ShellComplete: autocomplete.RecipeNameComplete, + Action: func(ctx context.Context, cmd *cli.Command) error { + r := internal.ValidateRecipe(cmd) if err := gitPkg.DiffUnstaged(r.Dir); err != nil { log.Fatal(err) diff --git a/cli/recipe/fetch.go b/cli/recipe/fetch.go index d9da2eedb..a3a67c78e 100644 --- a/cli/recipe/fetch.go +++ b/cli/recipe/fetch.go @@ -1,12 +1,14 @@ package recipe import ( + "context" + "coopcloud.tech/abra/cli/internal" "coopcloud.tech/abra/pkg/autocomplete" "coopcloud.tech/abra/pkg/formatter" "coopcloud.tech/abra/pkg/log" "coopcloud.tech/abra/pkg/recipe" - "github.com/urfave/cli/v2" + "github.com/urfave/cli/v3" ) var recipeFetchCommand = cli.Command{ @@ -20,13 +22,14 @@ var recipeFetchCommand = cli.Command{ internal.NoInputFlag, internal.OfflineFlag, }, - Before: internal.SubCommandBefore, - BashComplete: autocomplete.RecipeNameComplete, - Action: func(c *cli.Context) error { - recipeName := c.Args().First() + Before: internal.SubCommandBefore, + EnableShellCompletion: true, + ShellComplete: autocomplete.RecipeNameComplete, + Action: func(ctx context.Context, cmd *cli.Command) error { + recipeName := cmd.Args().First() r := recipe.Get(recipeName) if recipeName != "" { - internal.ValidateRecipe(c) + internal.ValidateRecipe(cmd) if err := r.Ensure(false, false); err != nil { log.Fatal(err) } diff --git a/cli/recipe/lint.go b/cli/recipe/lint.go index c7f0bb465..418deab74 100644 --- a/cli/recipe/lint.go +++ b/cli/recipe/lint.go @@ -1,6 +1,7 @@ package recipe import ( + "context" "fmt" "coopcloud.tech/abra/cli/internal" @@ -8,7 +9,7 @@ import ( "coopcloud.tech/abra/pkg/formatter" "coopcloud.tech/abra/pkg/lint" "coopcloud.tech/abra/pkg/log" - "github.com/urfave/cli/v2" + "github.com/urfave/cli/v3" ) var recipeLintCommand = cli.Command{ @@ -23,10 +24,11 @@ var recipeLintCommand = cli.Command{ internal.NoInputFlag, internal.ChaosFlag, }, - Before: internal.SubCommandBefore, - BashComplete: autocomplete.RecipeNameComplete, - Action: func(c *cli.Context) error { - recipe := internal.ValidateRecipe(c) + Before: internal.SubCommandBefore, + EnableShellCompletion: true, + ShellComplete: autocomplete.RecipeNameComplete, + Action: func(ctx context.Context, cmd *cli.Command) error { + recipe := internal.ValidateRecipe(cmd) if err := recipe.Ensure(internal.Chaos, internal.Offline); err != nil { log.Fatal(err) diff --git a/cli/recipe/list.go b/cli/recipe/list.go index 60032ae0f..73b0ebe7f 100644 --- a/cli/recipe/list.go +++ b/cli/recipe/list.go @@ -1,6 +1,7 @@ package recipe import ( + "context" "fmt" "sort" "strconv" @@ -10,7 +11,7 @@ import ( "coopcloud.tech/abra/pkg/formatter" "coopcloud.tech/abra/pkg/log" "coopcloud.tech/abra/pkg/recipe" - "github.com/urfave/cli/v2" + "github.com/urfave/cli/v3" ) var pattern string @@ -33,7 +34,7 @@ var recipeListCommand = cli.Command{ internal.OfflineFlag, }, Before: internal.SubCommandBefore, - Action: func(c *cli.Context) error { + Action: func(ctx context.Context, cmd *cli.Command) error { catl, err := recipe.ReadRecipeCatalogue(internal.Offline) if err != nil { log.Fatal(err.Error()) diff --git a/cli/recipe/new.go b/cli/recipe/new.go index 16e8f6f74..4ed01b160 100644 --- a/cli/recipe/new.go +++ b/cli/recipe/new.go @@ -2,6 +2,7 @@ package recipe import ( "bytes" + "context" "errors" "fmt" "os" @@ -13,7 +14,7 @@ import ( "coopcloud.tech/abra/pkg/git" "coopcloud.tech/abra/pkg/log" "coopcloud.tech/abra/pkg/recipe" - "github.com/urfave/cli/v2" + "github.com/urfave/cli/v3" ) // recipeMetadata is the recipe metadata for the README.md @@ -49,12 +50,12 @@ Create a new recipe. Abra uses the built-in example repository which is available here: https://git.coopcloud.tech/coop-cloud/example`, - Action: func(c *cli.Context) error { - recipeName := c.Args().First() + Action: func(ctx context.Context, cmd *cli.Command) error { + recipeName := cmd.Args().First() r := recipe.Get(recipeName) if recipeName == "" { - internal.ShowSubcommandHelpAndError(c, errors.New("no recipe name provided")) + internal.ShowSubcommandHelpAndError(cmd, errors.New("no recipe name provided")) } if _, err := os.Stat(r.Dir); !os.IsNotExist(err) { diff --git a/cli/recipe/recipe.go b/cli/recipe/recipe.go index bed88864c..4ab7b251e 100644 --- a/cli/recipe/recipe.go +++ b/cli/recipe/recipe.go @@ -1,7 +1,7 @@ package recipe import ( - "github.com/urfave/cli/v2" + "github.com/urfave/cli/v3" ) // RecipeCommand defines all recipe related sub-commands. @@ -19,7 +19,7 @@ for you. Anyone who uses a recipe can become a maintainer. Maintainers typically make sure the recipe is in good working order and the config upgraded in a timely manner.`, - Subcommands: []*cli.Command{ + Commands: []*cli.Command{ &recipeFetchCommand, &recipeLintCommand, &recipeListCommand, diff --git a/cli/recipe/release.go b/cli/recipe/release.go index 1fdae64cc..506875f3e 100644 --- a/cli/recipe/release.go +++ b/cli/recipe/release.go @@ -1,6 +1,7 @@ package recipe import ( + "context" "errors" "fmt" "os" @@ -18,7 +19,7 @@ import ( "github.com/AlecAivazis/survey/v2" "github.com/distribution/reference" "github.com/go-git/go-git/v5" - "github.com/urfave/cli/v2" + "github.com/urfave/cli/v3" ) var recipeReleaseCommand = cli.Command{ @@ -55,10 +56,11 @@ your SSH keys configured on your account.`, internal.PublishFlag, internal.OfflineFlag, }, - Before: internal.SubCommandBefore, - BashComplete: autocomplete.RecipeNameComplete, - Action: func(c *cli.Context) error { - recipe := internal.ValidateRecipe(c) + Before: internal.SubCommandBefore, + EnableShellCompletion: true, + ShellComplete: autocomplete.RecipeNameComplete, + Action: func(ctx context.Context, cmd *cli.Command) error { + recipe := internal.ValidateRecipe(cmd) imagesTmp, err := getImageVersions(recipe) if err != nil { @@ -75,7 +77,7 @@ your SSH keys configured on your account.`, log.Fatalf("main app service version for %s is empty?", recipe.Name) } - tagString := c.Args().Get(1) + tagString := cmd.Args().Get(1) if tagString != "" { if _, err := tagcmp.Parse(tagString); err != nil { log.Fatalf("cannot parse %s, invalid tag specified?", tagString) diff --git a/cli/recipe/reset.go b/cli/recipe/reset.go index 158be4a00..be0f8e6b8 100644 --- a/cli/recipe/reset.go +++ b/cli/recipe/reset.go @@ -1,12 +1,14 @@ package recipe import ( + "context" + "coopcloud.tech/abra/cli/internal" "coopcloud.tech/abra/pkg/autocomplete" "coopcloud.tech/abra/pkg/log" "coopcloud.tech/abra/pkg/recipe" "github.com/go-git/go-git/v5" - "github.com/urfave/cli/v2" + "github.com/urfave/cli/v3" ) var recipeResetCommand = cli.Command{ @@ -19,14 +21,15 @@ var recipeResetCommand = cli.Command{ internal.DebugFlag, internal.NoInputFlag, }, - Before: internal.SubCommandBefore, - BashComplete: autocomplete.RecipeNameComplete, - Action: func(c *cli.Context) error { - recipeName := c.Args().First() + Before: internal.SubCommandBefore, + EnableShellCompletion: true, + ShellComplete: autocomplete.RecipeNameComplete, + Action: func(ctx context.Context, cmd *cli.Command) error { + recipeName := cmd.Args().First() r := recipe.Get(recipeName) if recipeName != "" { - internal.ValidateRecipe(c) + internal.ValidateRecipe(cmd) } repo, err := git.PlainOpen(r.Dir) diff --git a/cli/recipe/sync.go b/cli/recipe/sync.go index 06f11b730..c85992b71 100644 --- a/cli/recipe/sync.go +++ b/cli/recipe/sync.go @@ -1,6 +1,7 @@ package recipe import ( + "context" "fmt" "strconv" @@ -12,7 +13,7 @@ import ( "github.com/AlecAivazis/survey/v2" "github.com/go-git/go-git/v5" "github.com/go-git/go-git/v5/plumbing" - "github.com/urfave/cli/v2" + "github.com/urfave/cli/v3" ) var recipeSyncCommand = cli.Command{ @@ -38,9 +39,10 @@ named "app") which corresponds to the following format: Where can be specifed on the command-line or Abra can attempt to auto-generate it for you. The configuration will be updated on the local file system.`, - BashComplete: autocomplete.RecipeNameComplete, - Action: func(c *cli.Context) error { - recipe := internal.ValidateRecipe(c) + EnableShellCompletion: true, + ShellComplete: autocomplete.RecipeNameComplete, + Action: func(ctx context.Context, cmd *cli.Command) error { + recipe := internal.ValidateRecipe(cmd) mainApp, err := internal.GetMainAppImage(recipe) if err != nil { @@ -59,7 +61,7 @@ local file system.`, log.Fatal(err) } - nextTag := c.Args().Get(1) + nextTag := cmd.Args().Get(1) if len(tags) == 0 && nextTag == "" { log.Warnf("no git tags found for %s", recipe.Name) if internal.NoInput { diff --git a/cli/recipe/upgrade.go b/cli/recipe/upgrade.go index 69c089e7f..358bd8ac7 100644 --- a/cli/recipe/upgrade.go +++ b/cli/recipe/upgrade.go @@ -2,6 +2,7 @@ package recipe import ( "bufio" + "context" "encoding/json" "fmt" "os" @@ -19,7 +20,7 @@ import ( "coopcloud.tech/tagcmp" "github.com/AlecAivazis/survey/v2" "github.com/distribution/reference" - "github.com/urfave/cli/v2" + "github.com/urfave/cli/v3" ) type imgPin struct { @@ -68,10 +69,11 @@ EXAMPLE: internal.MachineReadableFlag, internal.AllTagsFlag, }, - Before: internal.SubCommandBefore, - BashComplete: autocomplete.RecipeNameComplete, - Action: func(c *cli.Context) error { - recipe := internal.ValidateRecipe(c) + Before: internal.SubCommandBefore, + EnableShellCompletion: true, + ShellComplete: autocomplete.RecipeNameComplete, + Action: func(ctx context.Context, cmd *cli.Command) error { + recipe := internal.ValidateRecipe(cmd) if err := recipe.Ensure(internal.Chaos, internal.Offline); err != nil { log.Fatal(err) diff --git a/cli/recipe/version.go b/cli/recipe/version.go index 0d3fd0521..9ba346edd 100644 --- a/cli/recipe/version.go +++ b/cli/recipe/version.go @@ -1,6 +1,7 @@ package recipe import ( + "context" "fmt" "sort" @@ -10,7 +11,7 @@ import ( "coopcloud.tech/abra/pkg/log" recipePkg "coopcloud.tech/abra/pkg/recipe" "github.com/olekukonko/tablewriter" - "github.com/urfave/cli/v2" + "github.com/urfave/cli/v3" ) func sortServiceByName(versions [][]string) func(i, j int) bool { @@ -34,10 +35,11 @@ var recipeVersionCommand = cli.Command{ internal.NoInputFlag, internal.MachineReadableFlag, }, - Before: internal.SubCommandBefore, - BashComplete: autocomplete.RecipeNameComplete, - Action: func(c *cli.Context) error { - recipe := internal.ValidateRecipe(c) + Before: internal.SubCommandBefore, + EnableShellCompletion: true, + ShellComplete: autocomplete.RecipeNameComplete, + Action: func(ctx context.Context, cmd *cli.Command) error { + recipe := internal.ValidateRecipe(cmd) catl, err := recipePkg.ReadRecipeCatalogue(internal.Offline) if err != nil { diff --git a/cli/server/add.go b/cli/server/add.go index c19ab42cb..c4a09fbe2 100644 --- a/cli/server/add.go +++ b/cli/server/add.go @@ -1,6 +1,7 @@ package server import ( + "context" "errors" "os" "path/filepath" @@ -13,7 +14,7 @@ import ( "coopcloud.tech/abra/pkg/log" "coopcloud.tech/abra/pkg/server" sshPkg "coopcloud.tech/abra/pkg/ssh" - "github.com/urfave/cli/v2" + "github.com/urfave/cli/v3" ) var local bool @@ -131,17 +132,17 @@ of your ~/.ssh/config. Checks for a valid online domain will be skipped: }, Before: internal.SubCommandBefore, ArgsUsage: "", - Action: func(c *cli.Context) error { - if c.Args().Len() > 0 && local || !internal.ValidateSubCmdFlags(c) { + Action: func(ctx context.Context, cmd *cli.Command) error { + if cmd.Args().Len() > 0 && local || !internal.ValidateSubCmdFlags(cmd) { err := errors.New("cannot use and --local together") - internal.ShowSubcommandHelpAndError(c, err) + internal.ShowSubcommandHelpAndError(cmd, err) } var name string if local { name = "default" } else { - name = internal.ValidateDomain(c) + name = internal.ValidateDomain(cmd) } // NOTE(d1): reasonable 5 second timeout for connections which can't diff --git a/cli/server/list.go b/cli/server/list.go index f93bfe2fc..fa8deddad 100644 --- a/cli/server/list.go +++ b/cli/server/list.go @@ -1,15 +1,16 @@ package server import ( + "context" "strings" "coopcloud.tech/abra/cli/internal" "coopcloud.tech/abra/pkg/config" - "coopcloud.tech/abra/pkg/context" + contextPkg "coopcloud.tech/abra/pkg/context" "coopcloud.tech/abra/pkg/formatter" "coopcloud.tech/abra/pkg/log" "github.com/docker/cli/cli/connhelper/ssh" - "github.com/urfave/cli/v2" + "github.com/urfave/cli/v3" ) var serverListCommand = cli.Command{ @@ -22,8 +23,8 @@ var serverListCommand = cli.Command{ internal.OfflineFlag, }, Before: internal.SubCommandBefore, - Action: func(c *cli.Context) error { - dockerContextStore := context.NewDefaultDockerContextStore() + Action: func(ctx context.Context, cmd *cli.Command) error { + dockerContextStore := contextPkg.NewDefaultDockerContextStore() contexts, err := dockerContextStore.Store.List() if err != nil { log.Fatal(err) @@ -39,14 +40,14 @@ var serverListCommand = cli.Command{ for _, serverName := range serverNames { var row []string - for _, ctx := range contexts { - endpoint, err := context.GetContextEndpoint(ctx) + for _, dockerCtx := range contexts { + endpoint, err := contextPkg.GetContextEndpoint(dockerCtx) if err != nil && strings.Contains(err.Error(), "does not exist") { // No local context found, we can continue safely continue } - if ctx.Name == serverName { + if dockerCtx.Name == serverName { sp, err := ssh.ParseURL(endpoint) if err != nil { log.Fatal(err) diff --git a/cli/server/prune.go b/cli/server/prune.go index b913ee4b3..c773d1084 100644 --- a/cli/server/prune.go +++ b/cli/server/prune.go @@ -9,7 +9,7 @@ import ( "coopcloud.tech/abra/pkg/formatter" "coopcloud.tech/abra/pkg/log" "github.com/docker/docker/api/types/filters" - "github.com/urfave/cli/v2" + "github.com/urfave/cli/v3" ) var allFilter bool @@ -47,10 +47,11 @@ app. This can result in unwanted data loss if not used carefully.`, internal.OfflineFlag, internal.NoInputFlag, }, - Before: internal.SubCommandBefore, - BashComplete: autocomplete.ServerNameComplete, - Action: func(c *cli.Context) error { - serverName := internal.ValidateServer(c) + Before: internal.SubCommandBefore, + EnableShellCompletion: true, + ShellComplete: autocomplete.ServerNameComplete, + Action: func(ctx context.Context, cmd *cli.Command) error { + serverName := internal.ValidateServer(cmd) cl, err := client.New(serverName) if err != nil { @@ -59,7 +60,6 @@ app. This can result in unwanted data loss if not used carefully.`, var args filters.Args - ctx := context.Background() cr, err := cl.ContainersPrune(ctx, args) if err != nil { log.Fatal(err) diff --git a/cli/server/remove.go b/cli/server/remove.go index 5364e12e7..b0b8add99 100644 --- a/cli/server/remove.go +++ b/cli/server/remove.go @@ -1,6 +1,7 @@ package server import ( + "context" "os" "path/filepath" @@ -9,7 +10,7 @@ import ( "coopcloud.tech/abra/pkg/client" "coopcloud.tech/abra/pkg/config" "coopcloud.tech/abra/pkg/log" - "github.com/urfave/cli/v2" + "github.com/urfave/cli/v3" ) var serverRemoveCommand = cli.Command{ @@ -28,10 +29,11 @@ rain.`, internal.NoInputFlag, internal.OfflineFlag, }, - Before: internal.SubCommandBefore, - BashComplete: autocomplete.ServerNameComplete, - Action: func(c *cli.Context) error { - serverName := internal.ValidateServer(c) + Before: internal.SubCommandBefore, + EnableShellCompletion: true, + ShellComplete: autocomplete.ServerNameComplete, + Action: func(ctx context.Context, cmd *cli.Command) error { + serverName := internal.ValidateServer(cmd) if err := client.DeleteContext(serverName); err != nil { log.Fatal(err) diff --git a/cli/server/server.go b/cli/server/server.go index 196702ddb..99c963b85 100644 --- a/cli/server/server.go +++ b/cli/server/server.go @@ -1,7 +1,7 @@ package server import ( - "github.com/urfave/cli/v2" + "github.com/urfave/cli/v3" ) // ServerCommand defines the `abra server` command and its subcommands @@ -9,7 +9,7 @@ var ServerCommand = cli.Command{ Name: "server", Aliases: []string{"s"}, Usage: "Manage servers", - Subcommands: []*cli.Command{ + Commands: []*cli.Command{ &serverAddCommand, &serverListCommand, &serverRemoveCommand, diff --git a/cli/updater/updater.go b/cli/updater/updater.go index 6dc25c44e..3f1f92746 100644 --- a/cli/updater/updater.go +++ b/cli/updater/updater.go @@ -23,7 +23,7 @@ import ( dockerclient "github.com/docker/docker/client" "coopcloud.tech/abra/pkg/log" - "github.com/urfave/cli/v2" + "github.com/urfave/cli/v3" ) const SERVER = "localhost" @@ -62,7 +62,7 @@ catalogue. If a new patch/minor version is available, a notification is printed. Use "--major" to include new major versions.`, - Action: func(c *cli.Context) error { + Action: func(ctx context.Context, cmd *cli.Command) error { cl, err := client.New("default") if err != nil { log.Fatal(err) @@ -118,15 +118,15 @@ available, the app is upgraded. To include major versions use the "--major" flag. You probably don't want that as it will break things. Only apps that are not deployed with "--chaos" are upgraded, to update chaos deployments use the "--chaos" flag. Use it with care.`, - Action: func(c *cli.Context) error { + Action: func(ctx context.Context, cmd *cli.Command) error { cl, err := client.New("default") if err != nil { log.Fatal(err) } if !updateAll { - stackName := c.Args().Get(0) - recipeName := c.Args().Get(1) + stackName := cmd.Args().Get(0) + recipeName := cmd.Args().Get(1) err = tryUpgrade(cl, stackName, recipeName) if err != nil { log.Fatal(err) @@ -470,8 +470,8 @@ func upgrade(cl *dockerclient.Client, stackName, recipeName, upgradeVersion stri return err } -func newAbraApp(version, commit string) *cli.App { - app := &cli.App{ +func newAbraApp(version, commit string) *cli.Command { + app := &cli.Command{ Name: "kadabra", Usage: `The Co-op Cloud auto-updater ____ ____ _ _ @@ -488,7 +488,7 @@ func newAbraApp(version, commit string) *cli.App { }, } - app.Before = func(c *cli.Context) error { + app.Before = func(ctx context.Context, cmd *cli.Command) error { charmLog.SetDefault(log.Logger) log.Debugf("kadabra version %s, commit %s", version, commit) return nil @@ -501,7 +501,7 @@ func newAbraApp(version, commit string) *cli.App { func RunApp(version, commit string) { app := newAbraApp(version, commit) - if err := app.Run(os.Args); err != nil { + if err := app.Run(context.Background(), os.Args); err != nil { log.Fatal(err) } } diff --git a/go.mod b/go.mod index ef8eccc7d..7b85da188 100644 --- a/go.mod +++ b/go.mod @@ -2,6 +2,8 @@ module coopcloud.tech/abra go 1.21 +replace github.com/urfave/cli/v3 => github.com/fiatjaf/cli/v3 v3.0.0-20240704165307-ad0e1925dd42 + require ( coopcloud.tech/tagcmp v0.0.0-20230809071031-eb3e7758d4eb git.coopcloud.tech/coop-cloud/godotenv v1.5.2-0.20231130100509-01bff8284355 @@ -18,7 +20,7 @@ require ( github.com/olekukonko/tablewriter v0.0.5 github.com/pkg/errors v0.9.1 github.com/schollz/progressbar/v3 v3.14.4 - github.com/urfave/cli/v2 v2.27.2 + github.com/urfave/cli/v3 v3.0.0-alpha9 gopkg.in/yaml.v3 v3.0.1 gotest.tools/v3 v3.5.1 ) @@ -37,7 +39,6 @@ require ( github.com/charmbracelet/x/ansi v0.1.2 // indirect github.com/cloudflare/circl v1.3.9 // indirect github.com/containerd/log v0.1.0 // indirect - github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect github.com/cyphar/filepath-securejoin v0.2.5 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/docker/distribution v2.8.3+incompatible // indirect @@ -85,14 +86,12 @@ require ( github.com/prometheus/common v0.55.0 // indirect github.com/prometheus/procfs v0.15.1 // indirect github.com/rivo/uniseg v0.4.7 // indirect - github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/sirupsen/logrus v1.9.3 // indirect github.com/skeema/knownhosts v1.2.2 // indirect github.com/spf13/pflag v1.0.5 // indirect github.com/xanzy/ssh-agent v0.3.3 // indirect github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect github.com/xeipuuv/gojsonschema v1.2.0 // indirect - github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.53.0 // indirect go.opentelemetry.io/otel v1.28.0 // indirect go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.28.0 // indirect diff --git a/go.sum b/go.sum index 02690cf81..a3f7b9297 100644 --- a/go.sum +++ b/go.sum @@ -273,7 +273,6 @@ github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfc github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= -github.com/cpuguy83/go-md2man/v2 v2.0.4 h1:wfIWP927BUkWJb2NmU/kNDYIBTh/ziUX91+lVfRxZq4= github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= @@ -356,6 +355,8 @@ github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM= github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE= github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg= github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= +github.com/fiatjaf/cli/v3 v3.0.0-20240704165307-ad0e1925dd42 h1:yId1d3b2PHJ9vnYCxojs9NslXYVQ1iv7svK/CuDRoU0= +github.com/fiatjaf/cli/v3 v3.0.0-20240704165307-ad0e1925dd42/go.mod h1:Z1ItyMma7t6I7zHG9OpbExhHQOSkFf/96n+mAZ9MtVI= github.com/form3tech-oss/jwt-go v3.2.2+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k= github.com/frankban/quicktest v1.11.3/go.mod h1:wRf/ReqHper53s+kmmSZizM8NamnL3IM0I9ntUbOk+k= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= @@ -802,7 +803,6 @@ github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFR github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/safchain/ethtool v0.0.0-20190326074333-42ed695e3de8/go.mod h1:Z0q5wiBQGYcxhMZ6gUqHn6pYNLypFAvaL3UvgZLR0U4= github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= @@ -886,8 +886,6 @@ github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijb github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= github.com/urfave/cli v1.22.2/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= github.com/urfave/cli v1.22.4/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= -github.com/urfave/cli/v2 v2.27.2 h1:6e0H+AkS+zDckwPCUrZkKX38mRaau4nL2uipkJpbkcI= -github.com/urfave/cli/v2 v2.27.2/go.mod h1:g0+79LmHHATl7DAcHO99smiR/T7uGLw84w8Y42x+4eM= github.com/vbatts/tar-split v0.11.2/go.mod h1:vV3ZuO2yWSVsz+pfFzDG/upWH1JhjOiEaWq6kXyQ3VI= github.com/vishvananda/netlink v0.0.0-20181108222139-023a6dafdcdf/go.mod h1:+SR5DhBJrl6ZM7CoCKvpw5BKroDKQ+PJqOg65H/2ktk= github.com/vishvananda/netlink v1.1.0/go.mod h1:cTgwzPIzzgDAYoQrMm0EdrjRUBkTqKYppBueQtXaqoE= @@ -909,8 +907,6 @@ github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17 github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= -github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913 h1:+qGGcbkzsfDQNPPe9UDgpxAWQrhbbBXOYJFQDq/dtJw= -github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913/go.mod h1:4aEEwZQutDLsQv2Deui4iYQ6DWTxR14g6m8Wv88+Xqk= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= diff --git a/pkg/autocomplete/autocomplete.go b/pkg/autocomplete/autocomplete.go index 93e57d73d..b4cce02a6 100644 --- a/pkg/autocomplete/autocomplete.go +++ b/pkg/autocomplete/autocomplete.go @@ -1,22 +1,23 @@ package autocomplete import ( + "context" "fmt" "coopcloud.tech/abra/pkg/app" "coopcloud.tech/abra/pkg/log" "coopcloud.tech/abra/pkg/recipe" - "github.com/urfave/cli/v2" + "github.com/urfave/cli/v3" ) // AppNameComplete copletes app names. -func AppNameComplete(c *cli.Context) { +func AppNameComplete(ctx context.Context, cmd *cli.Command) { appNames, err := app.GetAppNames() if err != nil { log.Warn(err) } - if c.NArg() > 0 { + if cmd.NArg() > 0 { return } @@ -36,13 +37,13 @@ func ServiceNameComplete(appName string) { } // RecipeNameComplete completes recipe names. -func RecipeNameComplete(c *cli.Context) { +func RecipeNameComplete(ctx context.Context, cmd *cli.Command) { catl, err := recipe.ReadRecipeCatalogue(false) if err != nil { log.Warn(err) } - if c.NArg() > 0 { + if cmd.NArg() > 0 { return } @@ -66,13 +67,13 @@ func RecipeVersionComplete(recipeName string) { } // ServerNameComplete completes server names. -func ServerNameComplete(c *cli.Context) { +func ServerNameComplete(ctx context.Context, cmd *cli.Command) { files, err := app.LoadAppFiles("") if err != nil { log.Fatal(err) } - if c.NArg() > 0 { + if cmd.NArg() > 0 { return } @@ -82,8 +83,8 @@ func ServerNameComplete(c *cli.Context) { } // SubcommandComplete completes sub-commands. -func SubcommandComplete(c *cli.Context) { - if c.NArg() > 0 { +func SubcommandComplete(ctx context.Context, cmd *cli.Command) { + if cmd.NArg() > 0 { return }