From df1b616885b18c13d9f7690962f27f0d1655bf42 Mon Sep 17 00:00:00 2001 From: Predrag Janosevic Date: Mon, 12 Jan 2026 14:43:40 +0000 Subject: [PATCH 1/6] Recover 'exo api' command registration removed by mistake in 4fc825d --- cmd/x.go | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 cmd/x.go diff --git a/cmd/x.go b/cmd/x.go new file mode 100644 index 00000000..090982e4 --- /dev/null +++ b/cmd/x.go @@ -0,0 +1,76 @@ +package cmd + +import ( + "fmt" + + "github.com/spf13/cobra" + + egoscale "github.com/exoscale/egoscale/v3" + + "github.com/exoscale/cli/cmd/internal/x" + "github.com/exoscale/cli/pkg/account" + "github.com/exoscale/cli/pkg/globalstate" +) + +var xCmd *cobra.Command + +func init() { + xCmd = x.InitCommand() + xCmd.Use = "x" + xCmd.Aliases = append(xCmd.Aliases, "api") + xCmd.Hidden = true + xCmd.Long = `Low-level Exoscale API calls -- don't use this unless you have to. + +These commands are automatically generated using openapi-cli-generator[1], +input parameters can be supplied either via stdin or using Shorthands[2]. + +[1]: https://github.com/exoscale/openapi-cli-generator +[2]: https://github.com/exoscale/openapi-cli-generator/tree/master/shorthand +` + + // This code being executed very early, at this point some information is not ready + // to be used such as the account's configuration and some global variables, so we + // we use the subcommand pre-run hook to perform last second changes to the + // outgoing requests. + xCmd.PersistentPreRunE = func(cmd *cobra.Command, _ []string) error { + // If no value is provided for flag `--server`, infer the server URL from the current + // CLI profile's default zone (or explicit `--zone` flag if specified) and environment + // (or explicit `--environment` flag if speficied): + if server, _ := cmd.Flags().GetString("server"); server == "" { + zone := account.CurrentAccount.DefaultZone + if z, _ := cmd.Flags().GetString("zone"); z != "" { + zone = z + } + + endpoint, err := globalstate.EgoscaleV3Client.GetZoneAPIEndpoint(GContext, egoscale.ZoneName(zone)) + if err != nil { + return err + } + + if err := cmd.Flags().Set("server", string(endpoint)); err != nil { + return err + } + } + + x.SetClientUserAgent(fmt.Sprintf( + "Exoscale-CLI-X/%s (%s) %s", + globalstate.GitVersion, + globalstate.GitCommit, + egoscale.UserAgent, + )) + + return x.SetClientCredentials(account.CurrentAccount.Key, account.CurrentAccount.Secret) + } + + RootCmd.AddCommand(xCmd) +} + +func buildServerURL(zone, env string) string { + server := "https://api-ch-gva-2.exoscale.com/v2" + + if zone != "" && env != "" { + server = fmt.Sprintf("https://%s-%s.exoscale.com/v2", env, zone) + } + + return server +} From 71ebeb85cb5f0fe556224fab4b3c9a63fa5ba36f Mon Sep 17 00:00:00 2001 From: Predrag Janosevic Date: Mon, 12 Jan 2026 14:50:27 +0000 Subject: [PATCH 2/6] fixup! Recover 'exo api' command registration removed by mistake in 4fc825d --- cmd/x.go | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/cmd/x.go b/cmd/x.go index 090982e4..b5afdea7 100644 --- a/cmd/x.go +++ b/cmd/x.go @@ -64,13 +64,3 @@ input parameters can be supplied either via stdin or using Shorthands[2]. RootCmd.AddCommand(xCmd) } - -func buildServerURL(zone, env string) string { - server := "https://api-ch-gva-2.exoscale.com/v2" - - if zone != "" && env != "" { - server = fmt.Sprintf("https://%s-%s.exoscale.com/v2", env, zone) - } - - return server -} From 4c55a9fa89f2616311d3d965f5c161b94aac1781 Mon Sep 17 00:00:00 2001 From: Predrag Janosevic Date: Mon, 12 Jan 2026 14:59:17 +0000 Subject: [PATCH 3/6] fixup! Recover 'exo api' command registration removed by mistake in 4fc825d --- cmd/x.go | 1 + 1 file changed, 1 insertion(+) diff --git a/cmd/x.go b/cmd/x.go index b5afdea7..e4160aee 100644 --- a/cmd/x.go +++ b/cmd/x.go @@ -56,6 +56,7 @@ input parameters can be supplied either via stdin or using Shorthands[2]. "Exoscale-CLI-X/%s (%s) %s", globalstate.GitVersion, globalstate.GitCommit, + //lint:ignore SA1019 we only read value so it is fine egoscale.UserAgent, )) From 61e28fa811545d8f6d75bd367660b0ea052915ef Mon Sep 17 00:00:00 2001 From: Predrag Janosevic Date: Mon, 12 Jan 2026 15:09:25 +0000 Subject: [PATCH 4/6] fixup! Recover 'exo api' command registration removed by mistake in 4fc825d --- cmd/x.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/x.go b/cmd/x.go index e4160aee..5e20c8fd 100644 --- a/cmd/x.go +++ b/cmd/x.go @@ -57,7 +57,7 @@ input parameters can be supplied either via stdin or using Shorthands[2]. globalstate.GitVersion, globalstate.GitCommit, //lint:ignore SA1019 we only read value so it is fine - egoscale.UserAgent, + egoscale.UserAgent, //nolint:staticcheck )) return x.SetClientCredentials(account.CurrentAccount.Key, account.CurrentAccount.Secret) From ccae1a60af5eb2dde6298089ab4793d87c2bafbc Mon Sep 17 00:00:00 2001 From: Predrag Janosevic Date: Mon, 12 Jan 2026 15:12:52 +0000 Subject: [PATCH 5/6] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5559055c..326810ef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ ### Bug fixes - dedicated-inference: get deployment logs command fixed +- Recover 'exo api' command registration removed by mistake #782 ## 1.89.0 From 10c48f859101bc34c589138a3ade72aeddfb7605 Mon Sep 17 00:00:00 2001 From: Predrag Janosevic Date: Mon, 12 Jan 2026 17:04:00 +0000 Subject: [PATCH 6/6] Update CHANGELOG.md --- CHANGELOG.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 326810ef..718ec6ce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## Unreleased + +### Bug fixes + +- Recover 'exo api' command registration removed by mistake #782 + ## 1.90.0 ### Features @@ -9,7 +15,6 @@ ### Bug fixes - dedicated-inference: get deployment logs command fixed -- Recover 'exo api' command registration removed by mistake #782 ## 1.89.0