From 7107ebcf2b548737508a56aa7f797b3e80ed3e83 Mon Sep 17 00:00:00 2001 From: cgoetz-inovex Date: Fri, 12 Jun 2026 14:08:11 +0200 Subject: [PATCH 01/44] feat(vpn): basic connection commands (#1433) feat(vpn): basic connection commands - implement create, describe, list, delete, status for vpn connection - add helpers for string based enum flags - make JoinStringPtr generic to accept string based enum slices STACKITCLI-384 --- docs/stackit_beta.md | 1 + docs/stackit_beta_vpn.md | 34 ++ docs/stackit_beta_vpn_connection.md | 38 ++ docs/stackit_beta_vpn_connection_create.md | 94 +++++ docs/stackit_beta_vpn_connection_delete.md | 41 ++ docs/stackit_beta_vpn_connection_describe.md | 41 ++ docs/stackit_beta_vpn_connection_list.md | 41 ++ docs/stackit_beta_vpn_connection_status.md | 41 ++ go.mod | 1 + go.sum | 2 + internal/cmd/beta/beta.go | 2 + .../cmd/beta/vpn/connection/connection.go | 34 ++ .../cmd/beta/vpn/connection/create/create.go | 393 ++++++++++++++++++ .../beta/vpn/connection/create/create_test.go | 326 +++++++++++++++ .../cmd/beta/vpn/connection/delete/delete.go | 119 ++++++ .../beta/vpn/connection/delete/delete_test.go | 156 +++++++ .../beta/vpn/connection/describe/describe.go | 170 ++++++++ .../vpn/connection/describe/describe_test.go | 243 +++++++++++ internal/cmd/beta/vpn/connection/list/list.go | 120 ++++++ .../cmd/beta/vpn/connection/list/list_test.go | 207 +++++++++ .../cmd/beta/vpn/connection/status/status.go | 164 ++++++++ .../beta/vpn/connection/status/status_test.go | 219 ++++++++++ internal/cmd/beta/vpn/vpn.go | 25 ++ internal/pkg/config/config.go | 1 + internal/pkg/flags/string_enum.go | 117 ++++++ internal/pkg/flags/string_enum_test.go | 149 +++++++ internal/pkg/flags/string_enumslice.go | 126 ++++++ internal/pkg/flags/string_enumslice_test.go | 161 +++++++ internal/pkg/services/vpn/client/client.go | 14 + internal/pkg/utils/strings.go | 17 +- 30 files changed, 3095 insertions(+), 2 deletions(-) create mode 100644 docs/stackit_beta_vpn.md create mode 100644 docs/stackit_beta_vpn_connection.md create mode 100644 docs/stackit_beta_vpn_connection_create.md create mode 100644 docs/stackit_beta_vpn_connection_delete.md create mode 100644 docs/stackit_beta_vpn_connection_describe.md create mode 100644 docs/stackit_beta_vpn_connection_list.md create mode 100644 docs/stackit_beta_vpn_connection_status.md create mode 100644 internal/cmd/beta/vpn/connection/connection.go create mode 100644 internal/cmd/beta/vpn/connection/create/create.go create mode 100644 internal/cmd/beta/vpn/connection/create/create_test.go create mode 100644 internal/cmd/beta/vpn/connection/delete/delete.go create mode 100644 internal/cmd/beta/vpn/connection/delete/delete_test.go create mode 100644 internal/cmd/beta/vpn/connection/describe/describe.go create mode 100644 internal/cmd/beta/vpn/connection/describe/describe_test.go create mode 100644 internal/cmd/beta/vpn/connection/list/list.go create mode 100644 internal/cmd/beta/vpn/connection/list/list_test.go create mode 100644 internal/cmd/beta/vpn/connection/status/status.go create mode 100644 internal/cmd/beta/vpn/connection/status/status_test.go create mode 100644 internal/cmd/beta/vpn/vpn.go create mode 100644 internal/pkg/flags/string_enum.go create mode 100644 internal/pkg/flags/string_enum_test.go create mode 100644 internal/pkg/flags/string_enumslice.go create mode 100644 internal/pkg/flags/string_enumslice_test.go create mode 100644 internal/pkg/services/vpn/client/client.go diff --git a/docs/stackit_beta.md b/docs/stackit_beta.md index 1f34c1859..d79fd6e9f 100644 --- a/docs/stackit_beta.md +++ b/docs/stackit_beta.md @@ -47,4 +47,5 @@ stackit beta [flags] * [stackit beta intake](./stackit_beta_intake.md) - Provides functionality for intake * [stackit beta sfs](./stackit_beta_sfs.md) - Provides functionality for SFS (STACKIT File Storage) * [stackit beta sqlserverflex](./stackit_beta_sqlserverflex.md) - Provides functionality for SQLServer Flex +* [stackit beta vpn](./stackit_beta_vpn.md) - Provides functionality for VPN diff --git a/docs/stackit_beta_vpn.md b/docs/stackit_beta_vpn.md new file mode 100644 index 000000000..c15583893 --- /dev/null +++ b/docs/stackit_beta_vpn.md @@ -0,0 +1,34 @@ +## stackit beta vpn + +Provides functionality for VPN + +### Synopsis + +Provides functionality for VPN. + +``` +stackit beta vpn [flags] +``` + +### Options + +``` + -h, --help Help for "stackit beta vpn" +``` + +### Options inherited from parent commands + +``` + -y, --assume-yes If set, skips all confirmation prompts + --async If set, runs the command asynchronously + -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -p, --project-id string Project ID + --region string Target region for region-specific requests + --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") +``` + +### SEE ALSO + +* [stackit beta](./stackit_beta.md) - Contains beta STACKIT CLI commands +* [stackit beta vpn connection](./stackit_beta_vpn_connection.md) - Provides functionality for VPN connections + diff --git a/docs/stackit_beta_vpn_connection.md b/docs/stackit_beta_vpn_connection.md new file mode 100644 index 000000000..033fbf7bd --- /dev/null +++ b/docs/stackit_beta_vpn_connection.md @@ -0,0 +1,38 @@ +## stackit beta vpn connection + +Provides functionality for VPN connections + +### Synopsis + +Provides functionality for VPN connections. + +``` +stackit beta vpn connection [flags] +``` + +### Options + +``` + -h, --help Help for "stackit beta vpn connection" +``` + +### Options inherited from parent commands + +``` + -y, --assume-yes If set, skips all confirmation prompts + --async If set, runs the command asynchronously + -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -p, --project-id string Project ID + --region string Target region for region-specific requests + --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") +``` + +### SEE ALSO + +* [stackit beta vpn](./stackit_beta_vpn.md) - Provides functionality for VPN +* [stackit beta vpn connection create](./stackit_beta_vpn_connection_create.md) - Creates a VPN connection +* [stackit beta vpn connection delete](./stackit_beta_vpn_connection_delete.md) - Deletes a VPN connection +* [stackit beta vpn connection describe](./stackit_beta_vpn_connection_describe.md) - Shows details of a VPN connection +* [stackit beta vpn connection list](./stackit_beta_vpn_connection_list.md) - Lists all VPN connections of a gateway +* [stackit beta vpn connection status](./stackit_beta_vpn_connection_status.md) - Shows the status of a VPN connection + diff --git a/docs/stackit_beta_vpn_connection_create.md b/docs/stackit_beta_vpn_connection_create.md new file mode 100644 index 000000000..1525fd345 --- /dev/null +++ b/docs/stackit_beta_vpn_connection_create.md @@ -0,0 +1,94 @@ +## stackit beta vpn connection create + +Creates a VPN connection + +### Synopsis + +Creates a VPN connection. + +``` +stackit beta vpn connection create [flags] +``` + +### Examples + +``` + Create a VPN connection + $ stackit beta vpn connection create --gateway-id xxx --display-name my-connection --tunnel1-remote-address 1.2.3.4 --tunnel2-remote-address 5.6.7.8 +``` + +### Options + +``` + --display-name string Required: A user friendly name for the connection. + --enabled Enable the connection (default true) + --gateway-id string Required: Gateway ID + -h, --help Help for "stackit beta vpn connection create" + --labels stringToString Map of custom labels. Key and values must be a string with max 63 chars, start/end with alphanumeric. The key of a label follows the same rules as the LabelValue except that it cannot be empty. (example: foo=bar) (default []) + --local-subnets strings Defaults to 0.0.0.0/0 for Route-based VPN configurations. Mandatory for Policy-based. + --remote-subnets strings Defaults to 0.0.0.0/0 for Route-based VPN configurations. Mandatory for Policy-based. + --static-routes strings Use this for route-based VPN. + --tunnel1-bgp-remote-asn int Required: Tunnel 1 BGP Remote ASN. + ASN for private use (reserved by IANA), both 16Bit and 32Bit ranges are valid (RFC 6996). + --tunnel1-peering-local-address string Tunnel 1 Peering Local Address. + The peering object defines the point-to-point IP configuration for the Tunnel Interface. These addresses serve as next-hop identifiers and are used for BGP peering sessions and can be used in Static Route-Based connectivity. + --tunnel1-peering-remote-address string Tunnel 1 Peering Remote Address + --tunnel1-phase1-dh-groups strings Tunnel 1 Phase 1 DH Groups. + The Diffie-Hellman Group. Required, except if AEAD algorithms are selected. (possible values: [modp1024, modp2048, ecp256, ecp384, modp2048s256]) (default []) + --tunnel1-phase1-encryption-algorithms strings Required: Tunnel 1 Phase 1 Encryption Algorithms (possible values: [aes256, aes128gcm16, aes256gcm16]) (default []) + --tunnel1-phase1-integrity-algorithms strings Required: Tunnel 1 Phase 1 Integrity Algorithms (possible values: [sha1, sha2_256, sha2_384]) (default []) + --tunnel1-phase1-rekey-time int Tunnel 1 Phase 1 Rekey Time. + Time to schedule a IKE re-keying (in seconds). + --tunnel1-phase2-dh-groups strings Tunnel 1 Phase 2 DH Groups (possible values: [modp1024, modp2048, ecp256, ecp384, modp2048s256]) (default []) + --tunnel1-phase2-dpd-action string Tunnel 1 Phase 2 DPD Action. + Action to perform for this CHILD_SA on DPD timeout. "clear": Closes the CHILD_SA and does not take further action. "restart": immediately tries to re-negotiate the CILD_SA under a fresh IKE_SA. (possible values: [clear, restart]) + --tunnel1-phase2-encryption-algorithms strings Required: Tunnel 1 Phase 2 Encryption Algorithms (possible values: [aes256, aes128gcm16, aes256gcm16]) (default []) + --tunnel1-phase2-integrity-algorithms strings Required: Tunnel 1 Phase 2 Integrity Algorithms (possible values: [sha1, sha2_256, sha2_384]) (default []) + --tunnel1-phase2-rekey-time int Tunnel 1 Phase 2 Rekey Time. + Time to schedule a Child SA re-keying (in seconds). + --tunnel1-phase2-start-action string Tunnel 1 Phase 2 Start Action. + Action to perform after loading the connection configuration. "none": The connection will be loaded but needs to be manually initiated. "start": initiates the connection actively. (possible values: [none, start]) + --tunnel1-pre-shared-key string Required: Tunnel 1 Pre Shared Key. + A Pre-Shared Key for authentication. Required in create-requests, optional in update-requests and omitted in every response. + --tunnel1-remote-address string Tunnel 1 Remote Address + --tunnel2-bgp-remote-asn int Tunnel 2 BGP Remote ASN + --tunnel2-peering-local-address string Tunnel 2 Peering Local Address. + The peering object defines the point-to-point IP configuration for the Tunnel Interface. These addresses serve as next-hop identifiers and are used for BGP peering sessions and can be used in Static Route-Based connectivity. + --tunnel2-peering-remote-address string Tunnel 2 Peering Remote Address + --tunnel2-phase1-dh-groups strings Tunnel 2 Phase 1 DH Groups + The Diffie-Hellman Group. Required, except if AEAD algorithms are selected. (possible values: [modp1024, modp2048, ecp256, ecp384, modp2048s256]) (default []) + --tunnel2-phase1-encryption-algorithms strings Required: Tunnel 2 Phase 1 Encryption Algorithms (possible values: [aes256, aes128gcm16, aes256gcm16]) (default []) + --tunnel2-phase1-integrity-algorithms strings Required: Tunnel 2 Phase 1 Integrity Algorithms (possible values: [sha1, sha2_256, sha2_384]) (default []) + --tunnel2-phase1-rekey-time int Tunnel 2 Phase 1 Rekey Time. + Time to schedule a IKE re-keying (in seconds). + --tunnel2-phase2-dh-groups strings Tunnel 2 Phase 2 DH Groups (possible values: [modp1024, modp2048, ecp256, ecp384, modp2048s256]) (default []) + --tunnel2-phase2-dpd-action string Tunnel 2 Phase 2 DPD Action. + Action to perform for this CHILD_SA on DPD timeout. "clear": Closes the CHILD_SA and does not take further action. "restart": immediately tries to re-negotiate the CILD_SA under a fresh IKE_SA. (possible values: [clear, restart]) + --tunnel2-phase2-encryption-algorithms strings Required: Tunnel 2 Phase 2 Encryption Algorithms (possible values: [aes256, aes128gcm16, aes256gcm16]) (default []) + --tunnel2-phase2-integrity-algorithms strings Required: Tunnel 2 Phase 2 Integrity Algorithms (possible values: [sha1, sha2_256, sha2_384]) (default []) + --tunnel2-phase2-rekey-time int Tunnel 2 Phase 2 Rekey Time. + Time to schedule a Child SA re-keying (in seconds). + --tunnel2-phase2-start-action string Tunnel 2 Phase 2 Start Action. + Default: "start" + Enum: "none" "start" + Action to perform after loading the connection configuration. "none": The connection will be loaded but needs to be manually initiated. "start": initiates the connection actively. (possible values: [none, start]) + --tunnel2-pre-shared-key string Required: Tunnel 2 Pre Shared Key. + A Pre-Shared Key for authentication. Required in create-requests, optional in update-requests and omitted in every response. + --tunnel2-remote-address string Tunnel 2 Remote Address +``` + +### Options inherited from parent commands + +``` + -y, --assume-yes If set, skips all confirmation prompts + --async If set, runs the command asynchronously + -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -p, --project-id string Project ID + --region string Target region for region-specific requests + --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") +``` + +### SEE ALSO + +* [stackit beta vpn connection](./stackit_beta_vpn_connection.md) - Provides functionality for VPN connections + diff --git a/docs/stackit_beta_vpn_connection_delete.md b/docs/stackit_beta_vpn_connection_delete.md new file mode 100644 index 000000000..724c0f42a --- /dev/null +++ b/docs/stackit_beta_vpn_connection_delete.md @@ -0,0 +1,41 @@ +## stackit beta vpn connection delete + +Deletes a VPN connection + +### Synopsis + +Deletes a VPN connection. + +``` +stackit beta vpn connection delete CONNECTION_ID [flags] +``` + +### Examples + +``` + Delete a VPN connection + $ stackit beta vpn connection delete xxx --gateway-id yyy +``` + +### Options + +``` + --gateway-id string Gateway ID + -h, --help Help for "stackit beta vpn connection delete" +``` + +### Options inherited from parent commands + +``` + -y, --assume-yes If set, skips all confirmation prompts + --async If set, runs the command asynchronously + -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -p, --project-id string Project ID + --region string Target region for region-specific requests + --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") +``` + +### SEE ALSO + +* [stackit beta vpn connection](./stackit_beta_vpn_connection.md) - Provides functionality for VPN connections + diff --git a/docs/stackit_beta_vpn_connection_describe.md b/docs/stackit_beta_vpn_connection_describe.md new file mode 100644 index 000000000..ddfb63f1c --- /dev/null +++ b/docs/stackit_beta_vpn_connection_describe.md @@ -0,0 +1,41 @@ +## stackit beta vpn connection describe + +Shows details of a VPN connection + +### Synopsis + +Shows details of a VPN connection. + +``` +stackit beta vpn connection describe CONNECTION_ID [flags] +``` + +### Examples + +``` + Show details of a VPN connection + $ stackit beta vpn connection describe xxx --gateway-id yyy +``` + +### Options + +``` + --gateway-id string Gateway ID + -h, --help Help for "stackit beta vpn connection describe" +``` + +### Options inherited from parent commands + +``` + -y, --assume-yes If set, skips all confirmation prompts + --async If set, runs the command asynchronously + -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -p, --project-id string Project ID + --region string Target region for region-specific requests + --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") +``` + +### SEE ALSO + +* [stackit beta vpn connection](./stackit_beta_vpn_connection.md) - Provides functionality for VPN connections + diff --git a/docs/stackit_beta_vpn_connection_list.md b/docs/stackit_beta_vpn_connection_list.md new file mode 100644 index 000000000..6f5bff9bb --- /dev/null +++ b/docs/stackit_beta_vpn_connection_list.md @@ -0,0 +1,41 @@ +## stackit beta vpn connection list + +Lists all VPN connections of a gateway + +### Synopsis + +Lists all VPN connections of a gateway. + +``` +stackit beta vpn connection list [flags] +``` + +### Examples + +``` + List all VPN connections of a gateway + $ stackit beta vpn connection list --gateway-id xxx +``` + +### Options + +``` + --gateway-id string Gateway ID + -h, --help Help for "stackit beta vpn connection list" +``` + +### Options inherited from parent commands + +``` + -y, --assume-yes If set, skips all confirmation prompts + --async If set, runs the command asynchronously + -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -p, --project-id string Project ID + --region string Target region for region-specific requests + --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") +``` + +### SEE ALSO + +* [stackit beta vpn connection](./stackit_beta_vpn_connection.md) - Provides functionality for VPN connections + diff --git a/docs/stackit_beta_vpn_connection_status.md b/docs/stackit_beta_vpn_connection_status.md new file mode 100644 index 000000000..a3325b019 --- /dev/null +++ b/docs/stackit_beta_vpn_connection_status.md @@ -0,0 +1,41 @@ +## stackit beta vpn connection status + +Shows the status of a VPN connection + +### Synopsis + +Shows the status of a VPN connection. + +``` +stackit beta vpn connection status CONNECTION_ID [flags] +``` + +### Examples + +``` + Show status of a VPN connection + $ stackit beta vpn connection status xxx --gateway-id yyy +``` + +### Options + +``` + --gateway-id string Gateway ID + -h, --help Help for "stackit beta vpn connection status" +``` + +### Options inherited from parent commands + +``` + -y, --assume-yes If set, skips all confirmation prompts + --async If set, runs the command asynchronously + -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -p, --project-id string Project ID + --region string Target region for region-specific requests + --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") +``` + +### SEE ALSO + +* [stackit beta vpn connection](./stackit_beta_vpn_connection.md) - Provides functionality for VPN connections + diff --git a/go.mod b/go.mod index 52f30f8dd..f1a464268 100644 --- a/go.mod +++ b/go.mod @@ -36,6 +36,7 @@ require ( github.com/stackitcloud/stackit-sdk-go/services/serviceaccount v0.12.0 github.com/stackitcloud/stackit-sdk-go/services/serviceenablement v1.2.7 github.com/stackitcloud/stackit-sdk-go/services/ske v1.11.0 + github.com/stackitcloud/stackit-sdk-go/services/vpn v0.14.0 github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex v1.11.0 github.com/zalando/go-keyring v0.2.6 golang.org/x/mod v0.34.0 diff --git a/go.sum b/go.sum index 2f09fd94f..ca418c039 100644 --- a/go.sum +++ b/go.sum @@ -654,6 +654,8 @@ github.com/stackitcloud/stackit-sdk-go/services/sfs v0.9.0 h1:JWAFnskRbNKT8x62pZ github.com/stackitcloud/stackit-sdk-go/services/sfs v0.9.0/go.mod h1:jMlBoXqrPNX5nXbo6oT7exalqilw1jiLPoIp4Cn0CdI= github.com/stackitcloud/stackit-sdk-go/services/ske v1.11.0 h1:QoKyQPe8FqDqJLNgE5uRlZ/y1c1GUxjV1DDLu5QEBD8= github.com/stackitcloud/stackit-sdk-go/services/ske v1.11.0/go.mod h1:KhVYCR58wETqdI7Quwhe3OR3BhB2T/b7DzaMsfDnr8g= +github.com/stackitcloud/stackit-sdk-go/services/vpn v0.14.0 h1:LMgbzhPunuelsIsfyEj/5O/aYfNcg/eGHsnZ7AZOhYg= +github.com/stackitcloud/stackit-sdk-go/services/vpn v0.14.0/go.mod h1:toIjQk1dhxdUFVyCWJJja0w/0nFpDid8MWX0ukQfvfo= github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex v1.11.0 h1:PwjQeupEnXxhu+uWCUzO/hUfL4yqNblOcZbP2jvaQtU= github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex v1.11.0/go.mod h1:AiUoMAqQcOlMgDtkVJlqI7P/VGD5xjN3dYjERGnwN/M= github.com/stbenjam/no-sprintf-host-port v0.3.1 h1:AyX7+dxI4IdLBPtDbsGAyqiTSLpCP9hWRrXQDU4Cm/g= diff --git a/internal/cmd/beta/beta.go b/internal/cmd/beta/beta.go index 1bcb3ae55..f739b0c03 100644 --- a/internal/cmd/beta/beta.go +++ b/internal/cmd/beta/beta.go @@ -11,6 +11,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/cmd/beta/intake" "github.com/stackitcloud/stackit-cli/internal/cmd/beta/sfs" "github.com/stackitcloud/stackit-cli/internal/cmd/beta/sqlserverflex" + "github.com/stackitcloud/stackit-cli/internal/cmd/beta/vpn" "github.com/stackitcloud/stackit-cli/internal/pkg/args" "github.com/stackitcloud/stackit-cli/internal/pkg/examples" "github.com/stackitcloud/stackit-cli/internal/pkg/utils" @@ -47,4 +48,5 @@ func addSubcommands(cmd *cobra.Command, params *types.CmdParams) { cmd.AddCommand(edge.NewCmd(params)) cmd.AddCommand(intake.NewCmd(params)) cmd.AddCommand(cdn.NewCmd(params)) + cmd.AddCommand(vpn.NewCmd(params)) } diff --git a/internal/cmd/beta/vpn/connection/connection.go b/internal/cmd/beta/vpn/connection/connection.go new file mode 100644 index 000000000..2de835d71 --- /dev/null +++ b/internal/cmd/beta/vpn/connection/connection.go @@ -0,0 +1,34 @@ +package connection + +import ( + "github.com/spf13/cobra" + + "github.com/stackitcloud/stackit-cli/internal/cmd/beta/vpn/connection/create" + "github.com/stackitcloud/stackit-cli/internal/cmd/beta/vpn/connection/delete" + "github.com/stackitcloud/stackit-cli/internal/cmd/beta/vpn/connection/describe" + "github.com/stackitcloud/stackit-cli/internal/cmd/beta/vpn/connection/list" + "github.com/stackitcloud/stackit-cli/internal/cmd/beta/vpn/connection/status" + "github.com/stackitcloud/stackit-cli/internal/pkg/args" + "github.com/stackitcloud/stackit-cli/internal/pkg/types" + "github.com/stackitcloud/stackit-cli/internal/pkg/utils" +) + +func NewCmd(p *types.CmdParams) *cobra.Command { + cmd := &cobra.Command{ + Use: "connection", + Short: "Provides functionality for VPN connections", + Long: "Provides functionality for VPN connections.", + Args: args.NoArgs, + Run: utils.CmdHelp, + } + addSubcommands(cmd, p) + return cmd +} + +func addSubcommands(cmd *cobra.Command, p *types.CmdParams) { + cmd.AddCommand(create.NewCmd(p)) + cmd.AddCommand(delete.NewCmd(p)) + cmd.AddCommand(describe.NewCmd(p)) + cmd.AddCommand(list.NewCmd(p)) + cmd.AddCommand(status.NewCmd(p)) +} diff --git a/internal/cmd/beta/vpn/connection/create/create.go b/internal/cmd/beta/vpn/connection/create/create.go new file mode 100644 index 000000000..d9f1b227f --- /dev/null +++ b/internal/cmd/beta/vpn/connection/create/create.go @@ -0,0 +1,393 @@ +package create + +import ( + "context" + "fmt" + + "github.com/spf13/cobra" + vpn "github.com/stackitcloud/stackit-sdk-go/services/vpn/v1api" + + "github.com/stackitcloud/stackit-cli/internal/pkg/args" + cliErr "github.com/stackitcloud/stackit-cli/internal/pkg/errors" + "github.com/stackitcloud/stackit-cli/internal/pkg/examples" + "github.com/stackitcloud/stackit-cli/internal/pkg/flags" + "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" + "github.com/stackitcloud/stackit-cli/internal/pkg/print" + "github.com/stackitcloud/stackit-cli/internal/pkg/projectname" + "github.com/stackitcloud/stackit-cli/internal/pkg/services/vpn/client" + "github.com/stackitcloud/stackit-cli/internal/pkg/types" + "github.com/stackitcloud/stackit-cli/internal/pkg/utils" +) + +const ( + gatewayIdFlag = "gateway-id" + + displayNameFlag = "display-name" + enabledFlag = "enabled" + labelsFlag = "labels" + localSubnetsFlag = "local-subnets" + remoteSubnetsFlag = "remote-subnets" + staticRoutesFlag = "static-routes" + + tunnel1BgpRemoteAsnFlag = "tunnel1-bgp-remote-asn" + tunnel1PeeringLocalAddressFlag = "tunnel1-peering-local-address" + tunnel1PeeringRemoteAddressFlag = "tunnel1-peering-remote-address" + tunnel1Phase1RekeyTimeFlag = "tunnel1-phase1-rekey-time" + tunnel1Phase2RekeyTimeFlag = "tunnel1-phase2-rekey-time" + tunnel1PreSharedKeyFlag = "tunnel1-pre-shared-key" + tunnel1RemoteAddressFlag = "tunnel1-remote-address" + + tunnel2BgpRemoteAsnFlag = "tunnel2-bgp-remote-asn" + tunnel2PeeringLocalAddressFlag = "tunnel2-peering-local-address" + tunnel2PeeringRemoteAddressFlag = "tunnel2-peering-remote-address" + tunnel2Phase1RekeyTimeFlag = "tunnel2-phase1-rekey-time" + tunnel2Phase2RekeyTimeFlag = "tunnel2-phase2-rekey-time" + tunnel2PreSharedKeyFlag = "tunnel2-pre-shared-key" + tunnel2RemoteAddressFlag = "tunnel2-remote-address" +) + +var ( + // tunnel 1 + tunnel1Phase1DhGroupsFlag = flags.StringEnumSliceFlag( + "tunnel1-phase1-dh-groups", + vpn.AllowedPhaseDhGroupsInnerEnumValues, + "Tunnel 1 Phase 1 DH Groups.\nThe Diffie-Hellman Group. Required, except if AEAD algorithms are selected.", + ) + tunnel1Phase1EncryptionAlgorithmsFlag = flags.StringEnumSliceFlag( + "tunnel1-phase1-encryption-algorithms", + vpn.AllowedPhaseEncryptionAlgorithmsInnerEnumValues, + "Required: Tunnel 1 Phase 1 Encryption Algorithms", + ) + tunnel1Phase1IntegrityAlgorithmsFlag = flags.StringEnumSliceFlag( + "tunnel1-phase1-integrity-algorithms", + vpn.AllowedPhaseIntegrityAlgorithmsInnerEnumValues, + "Required: Tunnel 1 Phase 1 Integrity Algorithms", + ) + tunnel1Phase2DhGroupsFlag = flags.StringEnumSliceFlag( + "tunnel1-phase2-dh-groups", + vpn.AllowedPhaseDhGroupsInnerEnumValues, + "Tunnel 1 Phase 2 DH Groups", + ) + tunnel1Phase2EncryptionAlgorithmsFlag = flags.StringEnumSliceFlag( + "tunnel1-phase2-encryption-algorithms", + vpn.AllowedPhaseEncryptionAlgorithmsInnerEnumValues, + "Required: Tunnel 1 Phase 2 Encryption Algorithms", + ) + tunnel1Phase2IntegrityAlgorithmsFlag = flags.StringEnumSliceFlag( + "tunnel1-phase2-integrity-algorithms", + vpn.AllowedPhaseIntegrityAlgorithmsInnerEnumValues, + "Required: Tunnel 1 Phase 2 Integrity Algorithms", + ) + tunnel1Phase2DpdActionFlag = flags.StringEnumFlag( + "tunnel1-phase2-dpd-action", + vpn.AllowedTunnelConfigurationPhase2AllOfDpdActionEnumValues, + "Tunnel 1 Phase 2 DPD Action.\nAction to perform for this CHILD_SA on DPD timeout. \"clear\": Closes the CHILD_SA and does not take further action. \"restart\": immediately tries to re-negotiate the CILD_SA under a fresh IKE_SA.", + ) + tunnel1Phase2StartActionFlag = flags.StringEnumFlag( + "tunnel1-phase2-start-action", + vpn.AllowedTunnelConfigurationPhase2AllOfStartActionEnumValues, + "Tunnel 1 Phase 2 Start Action.\nAction to perform after loading the connection configuration. \"none\": The connection will be loaded but needs to be manually initiated. \"start\": initiates the connection actively.", + ) + // tunnel 2 + tunnel2Phase1DhGroupsFlag = flags.StringEnumSliceFlag( + "tunnel2-phase1-dh-groups", + vpn.AllowedPhaseDhGroupsInnerEnumValues, + "Tunnel 2 Phase 1 DH Groups\nThe Diffie-Hellman Group. Required, except if AEAD algorithms are selected.", + ) + tunnel2Phase1EncryptionAlgorithmsFlag = flags.StringEnumSliceFlag( + "tunnel2-phase1-encryption-algorithms", + vpn.AllowedPhaseEncryptionAlgorithmsInnerEnumValues, + "Required: Tunnel 2 Phase 1 Encryption Algorithms", + ) + tunnel2Phase1IntegrityAlgorithmsFlag = flags.StringEnumSliceFlag( + "tunnel2-phase1-integrity-algorithms", + vpn.AllowedPhaseIntegrityAlgorithmsInnerEnumValues, + "Required: Tunnel 2 Phase 1 Integrity Algorithms", + ) + tunnel2Phase2DhGroupsFlag = flags.StringEnumSliceFlag( + "tunnel2-phase2-dh-groups", + vpn.AllowedPhaseDhGroupsInnerEnumValues, + "Tunnel 2 Phase 2 DH Groups", + ) + tunnel2Phase2EncryptionAlgorithmsFlag = flags.StringEnumSliceFlag( + "tunnel2-phase2-encryption-algorithms", + vpn.AllowedPhaseEncryptionAlgorithmsInnerEnumValues, + "Required: Tunnel 2 Phase 2 Encryption Algorithms", + ) + tunnel2Phase2IntegrityAlgorithmsFlag = flags.StringEnumSliceFlag( + "tunnel2-phase2-integrity-algorithms", + vpn.AllowedPhaseIntegrityAlgorithmsInnerEnumValues, + "Required: Tunnel 2 Phase 2 Integrity Algorithms", + ) + tunnel2Phase2DpdActionFlag = flags.StringEnumFlag( + "tunnel2-phase2-dpd-action", + vpn.AllowedTunnelConfigurationPhase2AllOfDpdActionEnumValues, + "Tunnel 2 Phase 2 DPD Action.\nAction to perform for this CHILD_SA on DPD timeout. \"clear\": Closes the CHILD_SA and does not take further action. \"restart\": immediately tries to re-negotiate the CILD_SA under a fresh IKE_SA.", + ) + tunnel2Phase2StartActionFlag = flags.StringEnumFlag( + "tunnel2-phase2-start-action", + vpn.AllowedTunnelConfigurationPhase2AllOfStartActionEnumValues, + "Tunnel 2 Phase 2 Start Action.\nDefault: \"start\"\nEnum: \"none\" \"start\"\nAction to perform after loading the connection configuration. \"none\": The connection will be loaded but needs to be manually initiated. \"start\": initiates the connection actively.", + ) +) + +type tunnelInputModel struct { + BgpRemoteAsn *int64 + PeeringLocalAddress *string + PeeringRemoteAddress *string + Phase1DhGroups []vpn.PhaseDhGroupsInner + Phase1EncryptionAlgorithms []vpn.PhaseEncryptionAlgorithmsInner + Phase1IntegrityAlgorithms []vpn.PhaseIntegrityAlgorithmsInner + Phase1RekeyTime *int32 + Phase2DhGroups []vpn.PhaseDhGroupsInner + Phase2EncryptionAlgorithms []vpn.PhaseEncryptionAlgorithmsInner + Phase2IntegrityAlgorithms []vpn.PhaseIntegrityAlgorithmsInner + Phase2RekeyTime *int32 + Phase2DpdAction *vpn.TunnelConfigurationPhase2AllOfDpdAction + Phase2StartAction *vpn.TunnelConfigurationPhase2AllOfStartAction + PreSharedKey string + RemoteAddress string +} + +type inputModel struct { + *globalflags.GlobalFlagModel + GatewayId string + + DisplayName string + Enabled *bool + Labels *map[string]string + LocalSubnets []string + RemoteSubnets []string + StaticRoutes []string + + Tunnel1 tunnelInputModel + Tunnel2 tunnelInputModel +} + +func NewCmd(p *types.CmdParams) *cobra.Command { + cmd := &cobra.Command{ + Use: "create", + Short: "Creates a VPN connection", + Long: "Creates a VPN connection.", + Args: args.NoArgs, + Example: examples.Build( + examples.NewExample( + `Create a VPN connection`, + "$ stackit beta vpn connection create --gateway-id xxx --display-name my-connection --tunnel1-remote-address 1.2.3.4 --tunnel2-remote-address 5.6.7.8"), + ), + RunE: func(cmd *cobra.Command, _ []string) error { + ctx := context.Background() + model, err := parseInput(p.Printer, cmd) + if err != nil { + return err + } + + // Configure API client + apiClient, err := client.ConfigureClient(p.Printer, p.CliVersion) + if err != nil { + return err + } + + projectLabel, err := projectname.GetProjectName(ctx, p.Printer, p.CliVersion, cmd) + if err != nil { + p.Printer.Debug(print.ErrorLevel, "get project name: %v", err) + projectLabel = model.ProjectId + } + + prompt := fmt.Sprintf("Are you sure you want to create a VPN connection for gateway %q?", model.GatewayId) + err = p.Printer.PromptForConfirmation(prompt) + if err != nil { + return err + } + + // Call API + req, err := buildRequest(ctx, model, apiClient) + if err != nil { + return err + } + resp, err := req.Execute() + if err != nil { + return fmt.Errorf("create VPN connection: %w", err) + } + + return outputResult(p.Printer, model, projectLabel, resp) + }, + } + configureFlags(cmd) + return cmd +} + +func configureFlags(cmd *cobra.Command) { + cmd.Flags().Var(flags.UUIDFlag(), gatewayIdFlag, "Required: Gateway ID") + cmd.Flags().String(displayNameFlag, "", "Required: A user friendly name for the connection.") + cmd.Flags().Bool(enabledFlag, true, "Enable the connection") + cmd.Flags().StringToString(labelsFlag, nil, "Map of custom labels. Key and values must be a string with max 63 chars, start/end with alphanumeric. The key of a label follows the same rules as the LabelValue except that it cannot be empty. (example: foo=bar)") + cmd.Flags().StringSlice(localSubnetsFlag, nil, "Defaults to 0.0.0.0/0 for Route-based VPN configurations. Mandatory for Policy-based.") + cmd.Flags().StringSlice(remoteSubnetsFlag, nil, "Defaults to 0.0.0.0/0 for Route-based VPN configurations. Mandatory for Policy-based.") + cmd.Flags().StringSlice(staticRoutesFlag, nil, "Use this for route-based VPN.") + + cmd.Flags().Int64(tunnel1BgpRemoteAsnFlag, 0, "Required: Tunnel 1 BGP Remote ASN.\nASN for private use (reserved by IANA), both 16Bit and 32Bit ranges are valid (RFC 6996).") + cmd.Flags().String(tunnel1PeeringLocalAddressFlag, "", "Tunnel 1 Peering Local Address.\nThe peering object defines the point-to-point IP configuration for the Tunnel Interface. These addresses serve as next-hop identifiers and are used for BGP peering sessions and can be used in Static Route-Based connectivity.") + cmd.Flags().String(tunnel1PeeringRemoteAddressFlag, "", "Tunnel 1 Peering Remote Address") + tunnel1Phase1DhGroupsFlag.Register(cmd) + tunnel1Phase1EncryptionAlgorithmsFlag.Register(cmd) + tunnel1Phase1IntegrityAlgorithmsFlag.Register(cmd) + cmd.Flags().Int64(tunnel1Phase1RekeyTimeFlag, 0, "Tunnel 1 Phase 1 Rekey Time.\nTime to schedule a IKE re-keying (in seconds).") + tunnel1Phase2DhGroupsFlag.Register(cmd) + tunnel1Phase2EncryptionAlgorithmsFlag.Register(cmd) + tunnel1Phase2IntegrityAlgorithmsFlag.Register(cmd) + cmd.Flags().Int64(tunnel1Phase2RekeyTimeFlag, 0, "Tunnel 1 Phase 2 Rekey Time.\nTime to schedule a Child SA re-keying (in seconds).") + tunnel1Phase2DpdActionFlag.Register(cmd) + tunnel1Phase2StartActionFlag.Register(cmd) + cmd.Flags().String(tunnel1PreSharedKeyFlag, "", "Required: Tunnel 1 Pre Shared Key.\nA Pre-Shared Key for authentication. Required in create-requests, optional in update-requests and omitted in every response.") + cmd.Flags().String(tunnel1RemoteAddressFlag, "", "Tunnel 1 Remote Address") + + cmd.Flags().Int64(tunnel2BgpRemoteAsnFlag, 0, "Tunnel 2 BGP Remote ASN") + cmd.Flags().String(tunnel2PeeringLocalAddressFlag, "", "Tunnel 2 Peering Local Address.\nThe peering object defines the point-to-point IP configuration for the Tunnel Interface. These addresses serve as next-hop identifiers and are used for BGP peering sessions and can be used in Static Route-Based connectivity.") + cmd.Flags().String(tunnel2PeeringRemoteAddressFlag, "", "Tunnel 2 Peering Remote Address") + tunnel2Phase1DhGroupsFlag.Register(cmd) + tunnel2Phase1EncryptionAlgorithmsFlag.Register(cmd) + tunnel2Phase1IntegrityAlgorithmsFlag.Register(cmd) + cmd.Flags().Int64(tunnel2Phase1RekeyTimeFlag, 0, "Tunnel 2 Phase 1 Rekey Time.\nTime to schedule a IKE re-keying (in seconds).") + tunnel2Phase2DhGroupsFlag.Register(cmd) + tunnel2Phase2EncryptionAlgorithmsFlag.Register(cmd) + tunnel2Phase2IntegrityAlgorithmsFlag.Register(cmd) + cmd.Flags().Int64(tunnel2Phase2RekeyTimeFlag, 0, "Tunnel 2 Phase 2 Rekey Time.\nTime to schedule a Child SA re-keying (in seconds).") + tunnel2Phase2DpdActionFlag.Register(cmd) + tunnel2Phase2StartActionFlag.Register(cmd) + cmd.Flags().String(tunnel2PreSharedKeyFlag, "", "Required: Tunnel 2 Pre Shared Key.\nA Pre-Shared Key for authentication. Required in create-requests, optional in update-requests and omitted in every response.") + cmd.Flags().String(tunnel2RemoteAddressFlag, "", "Tunnel 2 Remote Address") + + err := flags.MarkFlagsRequired( + cmd, + gatewayIdFlag, displayNameFlag, + tunnel1RemoteAddressFlag, + tunnel1PreSharedKeyFlag, + tunnel1Phase1EncryptionAlgorithmsFlag.Name(), tunnel1Phase1IntegrityAlgorithmsFlag.Name(), + tunnel1Phase2EncryptionAlgorithmsFlag.Name(), tunnel1Phase2IntegrityAlgorithmsFlag.Name(), + tunnel2RemoteAddressFlag, + tunnel2PreSharedKeyFlag, + tunnel2Phase1EncryptionAlgorithmsFlag.Name(), tunnel2Phase1IntegrityAlgorithmsFlag.Name(), + tunnel2Phase2EncryptionAlgorithmsFlag.Name(), tunnel2Phase2IntegrityAlgorithmsFlag.Name(), + ) + cobra.CheckErr(err) +} + +func parseInput(p *print.Printer, cmd *cobra.Command) (*inputModel, error) { + globalFlags := globalflags.Parse(p, cmd) + if globalFlags.ProjectId == "" { + return nil, &cliErr.ProjectIdError{} + } + + model := inputModel{ + GlobalFlagModel: globalFlags, + GatewayId: flags.FlagToStringValue(p, cmd, gatewayIdFlag), + + DisplayName: flags.FlagToStringValue(p, cmd, displayNameFlag), + Enabled: flags.FlagToBoolPointer(p, cmd, enabledFlag), + Labels: flags.FlagToStringToStringPointer(p, cmd, labelsFlag), + LocalSubnets: flags.FlagToStringSliceValue(p, cmd, localSubnetsFlag), + RemoteSubnets: flags.FlagToStringSliceValue(p, cmd, remoteSubnetsFlag), + StaticRoutes: flags.FlagToStringSliceValue(p, cmd, staticRoutesFlag), + + Tunnel1: tunnelInputModel{ + BgpRemoteAsn: flags.FlagToInt64Pointer(p, cmd, tunnel1BgpRemoteAsnFlag), + PeeringLocalAddress: flags.FlagToStringPointer(p, cmd, tunnel1PeeringLocalAddressFlag), + PeeringRemoteAddress: flags.FlagToStringPointer(p, cmd, tunnel1PeeringRemoteAddressFlag), + Phase1DhGroups: tunnel1Phase1DhGroupsFlag.Get(), + Phase1EncryptionAlgorithms: tunnel1Phase1EncryptionAlgorithmsFlag.Get(), + Phase1IntegrityAlgorithms: tunnel1Phase1IntegrityAlgorithmsFlag.Get(), + Phase1RekeyTime: flags.FlagToInt32Pointer(p, cmd, tunnel1Phase1RekeyTimeFlag), + Phase2DhGroups: tunnel1Phase2DhGroupsFlag.Get(), + Phase2EncryptionAlgorithms: tunnel1Phase2EncryptionAlgorithmsFlag.Get(), + Phase2IntegrityAlgorithms: tunnel1Phase2IntegrityAlgorithmsFlag.Get(), + Phase2RekeyTime: flags.FlagToInt32Pointer(p, cmd, tunnel1Phase2RekeyTimeFlag), + Phase2DpdAction: tunnel1Phase2DpdActionFlag.Ptr(), + Phase2StartAction: tunnel1Phase2StartActionFlag.Ptr(), + PreSharedKey: flags.FlagToStringValue(p, cmd, tunnel1PreSharedKeyFlag), + RemoteAddress: flags.FlagToStringValue(p, cmd, tunnel1RemoteAddressFlag), + }, + + Tunnel2: tunnelInputModel{ + BgpRemoteAsn: flags.FlagToInt64Pointer(p, cmd, tunnel2BgpRemoteAsnFlag), + PeeringLocalAddress: flags.FlagToStringPointer(p, cmd, tunnel2PeeringLocalAddressFlag), + PeeringRemoteAddress: flags.FlagToStringPointer(p, cmd, tunnel2PeeringRemoteAddressFlag), + Phase1DhGroups: tunnel2Phase1DhGroupsFlag.Get(), + Phase1EncryptionAlgorithms: tunnel2Phase1EncryptionAlgorithmsFlag.Get(), + Phase1IntegrityAlgorithms: tunnel2Phase1IntegrityAlgorithmsFlag.Get(), + Phase1RekeyTime: flags.FlagToInt32Pointer(p, cmd, tunnel2Phase1RekeyTimeFlag), + Phase2DhGroups: tunnel2Phase2DhGroupsFlag.Get(), + Phase2EncryptionAlgorithms: tunnel2Phase2EncryptionAlgorithmsFlag.Get(), + Phase2IntegrityAlgorithms: tunnel2Phase2IntegrityAlgorithmsFlag.Get(), + Phase2RekeyTime: flags.FlagToInt32Pointer(p, cmd, tunnel2Phase2RekeyTimeFlag), + Phase2DpdAction: tunnel2Phase2DpdActionFlag.Ptr(), + Phase2StartAction: tunnel2Phase2StartActionFlag.Ptr(), + PreSharedKey: flags.FlagToStringValue(p, cmd, tunnel2PreSharedKeyFlag), + RemoteAddress: flags.FlagToStringValue(p, cmd, tunnel2RemoteAddressFlag), + }, + } + + p.DebugInputModel(model) + return &model, nil +} + +func buildTunnelConfiguration(model *tunnelInputModel) vpn.TunnelConfiguration { + tunnel := vpn.TunnelConfiguration{ + RemoteAddress: model.RemoteAddress, + } + if model.BgpRemoteAsn != nil { + tunnel.Bgp = &vpn.BGPTunnelConfig{ + RemoteAsn: *model.BgpRemoteAsn, + } + } + if model.PeeringLocalAddress != nil || model.PeeringRemoteAddress != nil { + tunnel.Peering = &vpn.PeeringConfig{ + LocalAddress: model.PeeringLocalAddress, + RemoteAddress: model.PeeringRemoteAddress, + } + } + tunnel.Phase1 = vpn.TunnelConfigurationPhase1{ + DhGroups: model.Phase1DhGroups, + EncryptionAlgorithms: model.Phase1EncryptionAlgorithms, + IntegrityAlgorithms: model.Phase1IntegrityAlgorithms, + RekeyTime: model.Phase1RekeyTime, + } + tunnel.Phase2 = vpn.TunnelConfigurationPhase2{ + DhGroups: model.Phase2DhGroups, + EncryptionAlgorithms: model.Phase2EncryptionAlgorithms, + IntegrityAlgorithms: model.Phase2IntegrityAlgorithms, + RekeyTime: model.Phase2RekeyTime, + DpdAction: model.Phase2DpdAction, + StartAction: model.Phase2StartAction, + } + tunnel.PreSharedKey = &model.PreSharedKey + return tunnel +} + +func buildRequest(ctx context.Context, model *inputModel, apiClient *vpn.APIClient) (vpn.ApiCreateGatewayConnectionRequest, error) { + req := apiClient.DefaultAPI.CreateGatewayConnection(ctx, model.ProjectId, model.Region, model.GatewayId) + + payload := vpn.CreateGatewayConnectionPayload{ + DisplayName: model.DisplayName, + Enabled: model.Enabled, + Labels: model.Labels, + LocalSubnets: model.LocalSubnets, + RemoteSubnets: model.RemoteSubnets, + StaticRoutes: model.StaticRoutes, + } + + payload.Tunnel1 = buildTunnelConfiguration(&model.Tunnel1) + payload.Tunnel2 = buildTunnelConfiguration(&model.Tunnel2) + + return req.CreateGatewayConnectionPayload(payload), nil +} + +func outputResult(p *print.Printer, model *inputModel, projectLabel string, resp *vpn.ConnectionResponse) error { + if resp == nil { + return fmt.Errorf("create response is empty") + } + return p.OutputResult(model.OutputFormat, resp, func() error { + p.Outputf("Created VPN connection %q for gateway %q in project %q.\n", utils.PtrString(resp.Id), model.GatewayId, projectLabel) + return nil + }) +} diff --git a/internal/cmd/beta/vpn/connection/create/create_test.go b/internal/cmd/beta/vpn/connection/create/create_test.go new file mode 100644 index 000000000..64d594ef1 --- /dev/null +++ b/internal/cmd/beta/vpn/connection/create/create_test.go @@ -0,0 +1,326 @@ +package create + +import ( + "context" + "fmt" + "testing" + + "github.com/google/go-cmp/cmp" + "github.com/google/go-cmp/cmp/cmpopts" + "github.com/google/uuid" + vpn "github.com/stackitcloud/stackit-sdk-go/services/vpn/v1api" + + "github.com/spf13/cobra" + sdkConfig "github.com/stackitcloud/stackit-sdk-go/core/config" + + "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" + "github.com/stackitcloud/stackit-cli/internal/pkg/print" + "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" + "github.com/stackitcloud/stackit-cli/internal/pkg/testutils" + "github.com/stackitcloud/stackit-cli/internal/pkg/utils" +) + +type testCtxKey struct{} + +var ( + testCtx = context.WithValue(context.Background(), testCtxKey{}, "test") + testProjectId = uuid.NewString() + testGatewayID = uuid.NewString() + testClient, _ = vpn.NewAPIClient( + sdkConfig.WithoutAuthentication(), + ) +) + +func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string { + flagValues := map[string]string{ + globalflags.ProjectIdFlag: testProjectId, + gatewayIdFlag: testGatewayID, + displayNameFlag: "test-connection", + tunnel1RemoteAddressFlag: "1.2.3.4", + tunnel1PreSharedKeyFlag: "test-psk-1", + tunnel1Phase1EncryptionAlgorithmsFlag.Name(): "aes256", + tunnel1Phase1IntegrityAlgorithmsFlag.Name(): "sha2_256", + tunnel1Phase2EncryptionAlgorithmsFlag.Name(): "aes256", + tunnel1Phase2IntegrityAlgorithmsFlag.Name(): "sha2_256", + tunnel2RemoteAddressFlag: "5.6.7.8", + tunnel2PreSharedKeyFlag: "test-psk-2", + tunnel2Phase1EncryptionAlgorithmsFlag.Name(): "aes256", + tunnel2Phase1IntegrityAlgorithmsFlag.Name(): "sha2_256", + tunnel2Phase2EncryptionAlgorithmsFlag.Name(): "aes256", + tunnel2Phase2IntegrityAlgorithmsFlag.Name(): "sha2_256", + } + for _, m := range mods { + m(flagValues) + } + return flagValues +} + +func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { + model := &inputModel{ + GlobalFlagModel: &globalflags.GlobalFlagModel{ + Verbosity: globalflags.VerbosityDefault, + ProjectId: testProjectId, + }, + GatewayId: testGatewayID, + DisplayName: "test-connection", + Enabled: nil, + Tunnel1: tunnelInputModel{ + RemoteAddress: "1.2.3.4", + PreSharedKey: "test-psk-1", + Phase1EncryptionAlgorithms: []vpn.PhaseEncryptionAlgorithmsInner{"aes256"}, + Phase1IntegrityAlgorithms: []vpn.PhaseIntegrityAlgorithmsInner{"sha2_256"}, + Phase2EncryptionAlgorithms: []vpn.PhaseEncryptionAlgorithmsInner{"aes256"}, + Phase2IntegrityAlgorithms: []vpn.PhaseIntegrityAlgorithmsInner{"sha2_256"}, + }, + Tunnel2: tunnelInputModel{ + RemoteAddress: "5.6.7.8", + PreSharedKey: "test-psk-2", + Phase1EncryptionAlgorithms: []vpn.PhaseEncryptionAlgorithmsInner{"aes256"}, + Phase1IntegrityAlgorithms: []vpn.PhaseIntegrityAlgorithmsInner{"sha2_256"}, + Phase2EncryptionAlgorithms: []vpn.PhaseEncryptionAlgorithmsInner{"aes256"}, + Phase2IntegrityAlgorithms: []vpn.PhaseIntegrityAlgorithmsInner{"sha2_256"}, + }, + } + for _, mod := range mods { + mod(model) + } + return model +} + +func fixtureRequest(mods ...func(request *vpn.ApiCreateGatewayConnectionRequest)) vpn.ApiCreateGatewayConnectionRequest { + request := testClient.DefaultAPI.CreateGatewayConnection(testCtx, testProjectId, "", testGatewayID) + payload := vpn.CreateGatewayConnectionPayload{ + DisplayName: "test-connection", + Enabled: nil, + Tunnel1: vpn.TunnelConfiguration{ + RemoteAddress: "1.2.3.4", + PreSharedKey: utils.Ptr("test-psk-1"), + Phase1: vpn.TunnelConfigurationPhase1{ + EncryptionAlgorithms: []vpn.PhaseEncryptionAlgorithmsInner{"aes256"}, + IntegrityAlgorithms: []vpn.PhaseIntegrityAlgorithmsInner{"sha2_256"}, + }, + Phase2: vpn.TunnelConfigurationPhase2{ + EncryptionAlgorithms: []vpn.PhaseEncryptionAlgorithmsInner{"aes256"}, + IntegrityAlgorithms: []vpn.PhaseIntegrityAlgorithmsInner{"sha2_256"}, + }, + }, + Tunnel2: vpn.TunnelConfiguration{ + RemoteAddress: "5.6.7.8", + PreSharedKey: utils.Ptr("test-psk-2"), + Phase1: vpn.TunnelConfigurationPhase1{ + EncryptionAlgorithms: []vpn.PhaseEncryptionAlgorithmsInner{"aes256"}, + IntegrityAlgorithms: []vpn.PhaseIntegrityAlgorithmsInner{"sha2_256"}, + }, + Phase2: vpn.TunnelConfigurationPhase2{ + EncryptionAlgorithms: []vpn.PhaseEncryptionAlgorithmsInner{"aes256"}, + IntegrityAlgorithms: []vpn.PhaseIntegrityAlgorithmsInner{"sha2_256"}, + }, + }, + } + request = request.CreateGatewayConnectionPayload(payload) + for _, mod := range mods { + mod(&request) + } + return request +} + +func TestParseInput(t *testing.T) { + tests := []struct { + description string + argValues []string + flagValues map[string]string + isValid bool + expectedModel *inputModel + }{ + { + description: "base", + argValues: []string{}, + flagValues: fixtureFlagValues(), + isValid: true, + expectedModel: fixtureInputModel(), + }, + { + description: "no flags", + argValues: []string{}, + flagValues: map[string]string{}, + isValid: false, + }, + { + description: "missing project id", + argValues: []string{}, + flagValues: fixtureFlagValues(func(flagValues map[string]string) { + delete(flagValues, globalflags.ProjectIdFlag) + }), + isValid: false, + }, + { + description: "missing gateway id", + argValues: []string{}, + flagValues: fixtureFlagValues(func(flagValues map[string]string) { + delete(flagValues, gatewayIdFlag) + }), + isValid: false, + }, + { + description: "missing display name", + argValues: []string{}, + flagValues: fixtureFlagValues(func(flagValues map[string]string) { + delete(flagValues, displayNameFlag) + }), + isValid: false, + }, + { + description: "missing tunnel1 remote address", + argValues: []string{}, + flagValues: fixtureFlagValues(func(flagValues map[string]string) { + delete(flagValues, tunnel1RemoteAddressFlag) + }), + isValid: false, + }, + } + + for _, tt := range tests { + t.Run(tt.description, func(t *testing.T) { + testutils.TestParseInput(t, NewCmd, func(printer *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, error) { + return parseInput(printer, cmd) + }, tt.expectedModel, tt.argValues, tt.flagValues, tt.isValid) + }) + } +} + +func TestBuildRequest(t *testing.T) { + tests := []struct { + description string + model *inputModel + expectedResult vpn.ApiCreateGatewayConnectionRequest + }{ + { + description: "base", + model: fixtureInputModel(), + expectedResult: fixtureRequest(), + }, + { + description: "with optional fields", + model: fixtureInputModel(func(model *inputModel) { + model.Labels = &map[string]string{"env": "prod"} + model.LocalSubnets = []string{"10.0.0.0/24"} + model.RemoteSubnets = []string{"192.168.0.0/24"} + model.StaticRoutes = []string{"10.1.0.0/24"} + model.Tunnel1.BgpRemoteAsn = utils.Ptr(int64(65000)) + model.Tunnel1.PeeringLocalAddress = utils.Ptr("169.254.0.1") + model.Tunnel1.PeeringRemoteAddress = utils.Ptr("169.254.0.2") + model.Tunnel1.Phase1DhGroups = []vpn.PhaseDhGroupsInner{"14"} + model.Tunnel1.Phase1RekeyTime = utils.Ptr(int32(3600)) + model.Tunnel1.Phase2DhGroups = []vpn.PhaseDhGroupsInner{"14"} + model.Tunnel1.Phase2RekeyTime = utils.Ptr(int32(3600)) + model.Tunnel1.Phase2DpdAction = utils.Ptr(vpn.TunnelConfigurationPhase2AllOfDpdAction("restart")) + model.Tunnel1.Phase2StartAction = utils.Ptr(vpn.TunnelConfigurationPhase2AllOfStartAction("start")) + }), + expectedResult: fixtureRequest(func(request *vpn.ApiCreateGatewayConnectionRequest) { + payload := vpn.CreateGatewayConnectionPayload{ + DisplayName: "test-connection", + Enabled: nil, + Labels: &map[string]string{"env": "prod"}, + LocalSubnets: []string{"10.0.0.0/24"}, + RemoteSubnets: []string{"192.168.0.0/24"}, + StaticRoutes: []string{"10.1.0.0/24"}, + Tunnel1: vpn.TunnelConfiguration{ + RemoteAddress: "1.2.3.4", + PreSharedKey: utils.Ptr("test-psk-1"), + Bgp: &vpn.BGPTunnelConfig{ + RemoteAsn: 65000, + }, + Peering: &vpn.PeeringConfig{ + LocalAddress: utils.Ptr("169.254.0.1"), + RemoteAddress: utils.Ptr("169.254.0.2"), + }, + Phase1: vpn.TunnelConfigurationPhase1{ + DhGroups: []vpn.PhaseDhGroupsInner{"14"}, + EncryptionAlgorithms: []vpn.PhaseEncryptionAlgorithmsInner{"aes256"}, + IntegrityAlgorithms: []vpn.PhaseIntegrityAlgorithmsInner{"sha2_256"}, + RekeyTime: utils.Ptr(int32(3600)), + }, + Phase2: vpn.TunnelConfigurationPhase2{ + DhGroups: []vpn.PhaseDhGroupsInner{"14"}, + EncryptionAlgorithms: []vpn.PhaseEncryptionAlgorithmsInner{"aes256"}, + IntegrityAlgorithms: []vpn.PhaseIntegrityAlgorithmsInner{"sha2_256"}, + RekeyTime: utils.Ptr(int32(3600)), + DpdAction: utils.Ptr(vpn.TunnelConfigurationPhase2AllOfDpdAction("restart")), + StartAction: utils.Ptr(vpn.TunnelConfigurationPhase2AllOfStartAction("start")), + }, + }, + Tunnel2: vpn.TunnelConfiguration{ + RemoteAddress: "5.6.7.8", + PreSharedKey: utils.Ptr("test-psk-2"), + Phase1: vpn.TunnelConfigurationPhase1{ + EncryptionAlgorithms: []vpn.PhaseEncryptionAlgorithmsInner{"aes256"}, + IntegrityAlgorithms: []vpn.PhaseIntegrityAlgorithmsInner{"sha2_256"}, + }, + Phase2: vpn.TunnelConfigurationPhase2{ + EncryptionAlgorithms: []vpn.PhaseEncryptionAlgorithmsInner{"aes256"}, + IntegrityAlgorithms: []vpn.PhaseIntegrityAlgorithmsInner{"sha2_256"}, + }, + }, + } + *request = request.CreateGatewayConnectionPayload(payload) + }), + }, + } + + for _, tt := range tests { + t.Run(tt.description, func(t *testing.T) { + request, err := buildRequest(testCtx, tt.model, testClient) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + + diff := cmp.Diff(request, tt.expectedResult, + cmp.AllowUnexported(tt.expectedResult), + cmpopts.IgnoreUnexported(vpn.DefaultAPIService{}), + cmpopts.EquateComparable(testCtx), + ) + if diff != "" { + t.Fatalf("data does not match: %s", diff) + } + }) + } +} + +func TestOutputResult(t *testing.T) { + tests := []struct { + description string + model *inputModel + resp *vpn.ConnectionResponse + expected string + wantErr bool + }{ + { + description: "nil response", + model: fixtureInputModel(), + resp: nil, + wantErr: true, + expected: "", + }, + { + description: "success", + model: fixtureInputModel(), + resp: &vpn.ConnectionResponse{ + Id: utils.Ptr("conn-1234"), + }, + expected: fmt.Sprintf("Created VPN connection \"conn-1234\" for gateway %q in project %q.\n", testGatewayID, testProjectId), + }, + } + + for _, tt := range tests { + t.Run(tt.description, func(t *testing.T) { + params := testparams.NewTestParams() + err := outputResult(params.Printer, tt.model, testProjectId, tt.resp) + if (err != nil) != tt.wantErr { + t.Errorf("outputResult() error = %v, wantErr %v", err, tt.wantErr) + } + if !tt.wantErr && params.Out.String() != tt.expected { + t.Errorf("want:\n%s\ngot:\n%s", tt.expected, params.Out.String()) + } + }) + } +} diff --git a/internal/cmd/beta/vpn/connection/delete/delete.go b/internal/cmd/beta/vpn/connection/delete/delete.go new file mode 100644 index 000000000..1e5de918e --- /dev/null +++ b/internal/cmd/beta/vpn/connection/delete/delete.go @@ -0,0 +1,119 @@ +package delete + +import ( + "context" + "fmt" + + "github.com/spf13/cobra" + vpn "github.com/stackitcloud/stackit-sdk-go/services/vpn/v1api" + + "github.com/stackitcloud/stackit-cli/internal/pkg/args" + cliErr "github.com/stackitcloud/stackit-cli/internal/pkg/errors" + "github.com/stackitcloud/stackit-cli/internal/pkg/examples" + "github.com/stackitcloud/stackit-cli/internal/pkg/flags" + "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" + "github.com/stackitcloud/stackit-cli/internal/pkg/print" + "github.com/stackitcloud/stackit-cli/internal/pkg/projectname" + "github.com/stackitcloud/stackit-cli/internal/pkg/services/vpn/client" + "github.com/stackitcloud/stackit-cli/internal/pkg/types" +) + +const ( + connectionIdArg = "CONNECTION_ID" + + gatewayIdFlag = "gateway-id" +) + +type inputModel struct { + *globalflags.GlobalFlagModel + GatewayId *string + ConnectionId string +} + +func NewCmd(p *types.CmdParams) *cobra.Command { + cmd := &cobra.Command{ + Use: fmt.Sprintf("delete %s", connectionIdArg), + Short: "Deletes a VPN connection", + Long: "Deletes a VPN connection.", + Args: args.SingleArg(connectionIdArg, nil), + Example: examples.Build( + examples.NewExample( + `Delete a VPN connection`, + "$ stackit beta vpn connection delete xxx --gateway-id yyy"), + ), + RunE: func(cmd *cobra.Command, args []string) error { + ctx := context.Background() + model, err := parseInput(p.Printer, cmd, args) + if err != nil { + return err + } + + // Configure API client + apiClient, err := client.ConfigureClient(p.Printer, p.CliVersion) + if err != nil { + return err + } + + projectLabel, err := projectname.GetProjectName(ctx, p.Printer, p.CliVersion, cmd) + if err != nil { + p.Printer.Debug(print.ErrorLevel, "get project name: %v", err) + projectLabel = model.ProjectId + } + + prompt := fmt.Sprintf("Are you sure you want to delete VPN connection %q from gateway %q?", model.ConnectionId, *model.GatewayId) + err = p.Printer.PromptForConfirmation(prompt) + if err != nil { + return err + } + + // Call API + req, err := buildRequest(ctx, model, apiClient) + if err != nil { + return err + } + err = req.Execute() + if err != nil { + return fmt.Errorf("delete VPN connection: %w", err) + } + + return outputResult(p.Printer, model, projectLabel) + }, + } + configureFlags(cmd) + return cmd +} + +func configureFlags(cmd *cobra.Command) { + cmd.Flags().Var(flags.UUIDFlag(), gatewayIdFlag, "Gateway ID") + + err := flags.MarkFlagsRequired(cmd, gatewayIdFlag) + cobra.CheckErr(err) +} + +func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inputModel, error) { + connectionId := inputArgs[0] + + globalFlags := globalflags.Parse(p, cmd) + if globalFlags.ProjectId == "" { + return nil, &cliErr.ProjectIdError{} + } + + model := inputModel{ + GlobalFlagModel: globalFlags, + GatewayId: flags.FlagToStringPointer(p, cmd, gatewayIdFlag), + ConnectionId: connectionId, + } + + p.DebugInputModel(model) + return &model, nil +} + +func buildRequest(ctx context.Context, model *inputModel, apiClient *vpn.APIClient) (vpn.ApiDeleteGatewayConnectionRequest, error) { + req := apiClient.DefaultAPI.DeleteGatewayConnection(ctx, model.ProjectId, model.Region, *model.GatewayId, model.ConnectionId) + return req, nil +} + +func outputResult(p *print.Printer, model *inputModel, projectLabel string) error { + p.Outputf("deleted VPN connection %q for gateway %q in project %q.\n", model.ConnectionId, *model.GatewayId, projectLabel) + return nil +} diff --git a/internal/cmd/beta/vpn/connection/delete/delete_test.go b/internal/cmd/beta/vpn/connection/delete/delete_test.go new file mode 100644 index 000000000..1d2eee692 --- /dev/null +++ b/internal/cmd/beta/vpn/connection/delete/delete_test.go @@ -0,0 +1,156 @@ +package delete + +import ( + "context" + "testing" + + "github.com/google/go-cmp/cmp" + "github.com/google/go-cmp/cmp/cmpopts" + "github.com/google/uuid" + vpn "github.com/stackitcloud/stackit-sdk-go/services/vpn/v1api" + + sdkConfig "github.com/stackitcloud/stackit-sdk-go/core/config" + + "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" + "github.com/stackitcloud/stackit-cli/internal/pkg/testutils" +) + +type testCtxKey struct{} + +var ( + testCtx = context.WithValue(context.Background(), testCtxKey{}, "test") + testProjectId = uuid.NewString() + testGatewayID = uuid.NewString() + testConnectionID = uuid.NewString() + testClient, _ = vpn.NewAPIClient( + sdkConfig.WithoutAuthentication(), + ) +) + +func fixtureArgValues(mods ...func(argValues []string)) []string { + argValues := []string{ + testConnectionID, + } + for _, m := range mods { + m(argValues) + } + return argValues +} + +func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string { + flagValues := map[string]string{ + globalflags.ProjectIdFlag: testProjectId, + gatewayIdFlag: testGatewayID, + } + for _, m := range mods { + m(flagValues) + } + return flagValues +} + +func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { + model := &inputModel{ + GlobalFlagModel: &globalflags.GlobalFlagModel{ + Verbosity: globalflags.VerbosityDefault, + ProjectId: testProjectId, + }, + GatewayId: &testGatewayID, + ConnectionId: testConnectionID, + } + for _, mod := range mods { + mod(model) + } + return model +} + +func fixtureRequest(mods ...func(request *vpn.ApiDeleteGatewayConnectionRequest)) vpn.ApiDeleteGatewayConnectionRequest { + request := testClient.DefaultAPI.DeleteGatewayConnection(testCtx, testProjectId, "", testGatewayID, testConnectionID) + for _, mod := range mods { + mod(&request) + } + return request +} + +func TestParseInput(t *testing.T) { + tests := []struct { + description string + argValues []string + flagValues map[string]string + isValid bool + expectedModel *inputModel + }{ + { + description: "base", + argValues: fixtureArgValues(), + flagValues: fixtureFlagValues(), + isValid: true, + expectedModel: fixtureInputModel(), + }, + { + description: "no values", + argValues: []string{}, + flagValues: map[string]string{}, + isValid: false, + }, + { + description: "no arg values", + argValues: []string{}, + flagValues: fixtureFlagValues(), + isValid: false, + }, + { + description: "no gateway id", + argValues: fixtureArgValues(), + flagValues: fixtureFlagValues(func(flagValues map[string]string) { + delete(flagValues, gatewayIdFlag) + }), + isValid: false, + }, + { + description: "no project id", + argValues: fixtureArgValues(), + flagValues: fixtureFlagValues(func(flagValues map[string]string) { + delete(flagValues, globalflags.ProjectIdFlag) + }), + isValid: false, + }, + } + + for _, tt := range tests { + t.Run(tt.description, func(t *testing.T) { + testutils.TestParseInput(t, NewCmd, parseInput, tt.expectedModel, tt.argValues, tt.flagValues, tt.isValid) + }) + } +} + +func TestBuildRequest(t *testing.T) { + tests := []struct { + description string + model *inputModel + expectedResult vpn.ApiDeleteGatewayConnectionRequest + }{ + { + description: "base", + model: fixtureInputModel(), + expectedResult: fixtureRequest(), + }, + } + + for _, tt := range tests { + t.Run(tt.description, func(t *testing.T) { + request, err := buildRequest(testCtx, tt.model, testClient) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + + diff := cmp.Diff(request, tt.expectedResult, + cmp.AllowUnexported(tt.expectedResult), + cmpopts.IgnoreUnexported(vpn.DefaultAPIService{}), + cmpopts.EquateComparable(testCtx), + ) + if diff != "" { + t.Fatalf("data does not match: %s", diff) + } + }) + } +} diff --git a/internal/cmd/beta/vpn/connection/describe/describe.go b/internal/cmd/beta/vpn/connection/describe/describe.go new file mode 100644 index 000000000..16f581821 --- /dev/null +++ b/internal/cmd/beta/vpn/connection/describe/describe.go @@ -0,0 +1,170 @@ +package describe + +import ( + "context" + "fmt" + "strings" + + "github.com/spf13/cobra" + vpn "github.com/stackitcloud/stackit-sdk-go/services/vpn/v1api" + + "github.com/stackitcloud/stackit-cli/internal/pkg/args" + cliErr "github.com/stackitcloud/stackit-cli/internal/pkg/errors" + "github.com/stackitcloud/stackit-cli/internal/pkg/examples" + "github.com/stackitcloud/stackit-cli/internal/pkg/flags" + "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" + "github.com/stackitcloud/stackit-cli/internal/pkg/print" + "github.com/stackitcloud/stackit-cli/internal/pkg/services/vpn/client" + "github.com/stackitcloud/stackit-cli/internal/pkg/tables" + "github.com/stackitcloud/stackit-cli/internal/pkg/types" + "github.com/stackitcloud/stackit-cli/internal/pkg/utils" +) + +const ( + connectionIdArg = "CONNECTION_ID" + + gatewayIdFlag = "gateway-id" +) + +type inputModel struct { + *globalflags.GlobalFlagModel + GatewayId *string + ConnectionId string +} + +func NewCmd(p *types.CmdParams) *cobra.Command { + cmd := &cobra.Command{ + Use: fmt.Sprintf("describe %s", connectionIdArg), + Short: "Shows details of a VPN connection", + Long: "Shows details of a VPN connection.", + Args: args.SingleArg(connectionIdArg, nil), + Example: examples.Build( + examples.NewExample( + `Show details of a VPN connection`, + "$ stackit beta vpn connection describe xxx --gateway-id yyy"), + ), + RunE: func(cmd *cobra.Command, args []string) error { + ctx := context.Background() + model, err := parseInput(p.Printer, cmd, args) + if err != nil { + return err + } + + // Configure API client + apiClient, err := client.ConfigureClient(p.Printer, p.CliVersion) + if err != nil { + return err + } + + // Call API + req, err := buildRequest(ctx, model, apiClient) + if err != nil { + return err + } + resp, err := req.Execute() + if err != nil { + return fmt.Errorf("describe VPN connection: %w", err) + } + + return outputResult(p.Printer, model, resp) + }, + } + configureFlags(cmd) + return cmd +} + +func configureFlags(cmd *cobra.Command) { + cmd.Flags().Var(flags.UUIDFlag(), gatewayIdFlag, "Gateway ID") + + err := flags.MarkFlagsRequired(cmd, gatewayIdFlag) + cobra.CheckErr(err) +} + +func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inputModel, error) { + connectionId := inputArgs[0] + + globalFlags := globalflags.Parse(p, cmd) + if globalFlags.ProjectId == "" { + return nil, &cliErr.ProjectIdError{} + } + + model := inputModel{ + GlobalFlagModel: globalFlags, + GatewayId: flags.FlagToStringPointer(p, cmd, gatewayIdFlag), + ConnectionId: connectionId, + } + + p.DebugInputModel(model) + return &model, nil +} + +func buildRequest(ctx context.Context, model *inputModel, apiClient *vpn.APIClient) (vpn.ApiGetGatewayConnectionRequest, error) { + req := apiClient.DefaultAPI.GetGatewayConnection(ctx, model.ProjectId, model.Region, *model.GatewayId, model.ConnectionId) + return req, nil +} + +func outputResult(p *print.Printer, model *inputModel, resp *vpn.ConnectionResponse) error { + if resp == nil { + return fmt.Errorf("describe response is empty") + } + + return p.OutputResult(model.OutputFormat, resp, func() error { + mainTable := tables.NewTable() + mainTable.AddRow("ID", utils.PtrString(resp.Id)) + mainTable.AddRow("Name", resp.DisplayName) + mainTable.AddRow("Enabled", utils.PtrString(resp.Enabled)) + var labels string + if resp.Labels != nil { + labels = utils.JoinStringMap(*resp.Labels, "=", ", ") + } + mainTable.AddRow("Labels", labels) + mainTable.AddRow("Local Subnets", strings.Join(resp.LocalSubnets, ", ")) + mainTable.AddRow("Remote Subnets", strings.Join(resp.RemoteSubnets, ", ")) + mainTable.AddRow("Static Routes", strings.Join(resp.StaticRoutes, ", ")) + + ts := []tables.Table{ + mainTable, + } + ts = append(ts, tunnelTables(&resp.Tunnel1, "Tunnel 1")...) + ts = append(ts, tunnelTables(&resp.Tunnel2, "Tunnel 2")...) + return tables.DisplayTables(p, ts) + }) +} + +func tunnelTables(tunnel *vpn.TunnelConfiguration, title string) []tables.Table { + table := tables.NewTable() + table.SetTitle(title) + table.AddRow("IP Address", tunnel.RemoteAddress) + var bgp string + if tunnel.Bgp != nil { + bgp = fmt.Sprintf("%d", tunnel.Bgp.RemoteAsn) + } + table.AddRow("BGP ASN", bgp) + var peering string + if tunnel.Peering != nil { + peering = fmt.Sprintf("%s/%s", utils.PtrString(tunnel.Peering.LocalAddress), utils.PtrString(tunnel.Peering.RemoteAddress)) + } + table.AddRow("Peering (local/remote)", peering) + + phase1Table := tables.NewTable() + phase1Table.SetTitle(fmt.Sprintf("%s Phase 1", title)) + phase1Table.AddRow("DH Groups", utils.JoinStringPtr(&tunnel.Phase1.DhGroups, ", ")) + phase1Table.AddRow("Encryption Algos", utils.JoinStringPtr(&tunnel.Phase1.EncryptionAlgorithms, ", ")) + phase1Table.AddRow("Integrity Algos", utils.JoinStringPtr(&tunnel.Phase1.IntegrityAlgorithms, ", ")) + phase1Table.AddRow("Rekey Time", utils.PtrString(tunnel.Phase1.RekeyTime)) + + phase2Table := tables.NewTable() + phase2Table.SetTitle(fmt.Sprintf("%s Phase 2", title)) + phase2Table.AddRow("DH Groups", utils.JoinStringPtr(&tunnel.Phase2.DhGroups, ", ")) + phase2Table.AddRow("Encryption Algos", utils.JoinStringPtr(&tunnel.Phase2.EncryptionAlgorithms, ", ")) + phase2Table.AddRow("Integrity Algos", utils.JoinStringPtr(&tunnel.Phase2.IntegrityAlgorithms, ", ")) + phase2Table.AddRow("Rekey Time", utils.PtrString(tunnel.Phase1.RekeyTime)) + phase2Table.AddRow("Dpd Action", utils.PtrString(tunnel.Phase2.DpdAction)) + phase2Table.AddRow("Start Action", utils.PtrString(tunnel.Phase2.StartAction)) + + return []tables.Table{ + table, + phase1Table, + phase2Table, + } +} diff --git a/internal/cmd/beta/vpn/connection/describe/describe_test.go b/internal/cmd/beta/vpn/connection/describe/describe_test.go new file mode 100644 index 000000000..c9f42ef62 --- /dev/null +++ b/internal/cmd/beta/vpn/connection/describe/describe_test.go @@ -0,0 +1,243 @@ +package describe + +import ( + "context" + "testing" + + "github.com/google/go-cmp/cmp" + "github.com/google/go-cmp/cmp/cmpopts" + "github.com/google/uuid" + vpn "github.com/stackitcloud/stackit-sdk-go/services/vpn/v1api" + + sdkConfig "github.com/stackitcloud/stackit-sdk-go/core/config" + + "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" + "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" + "github.com/stackitcloud/stackit-cli/internal/pkg/testutils" + "github.com/stackitcloud/stackit-cli/internal/pkg/utils" +) + +type testCtxKey struct{} + +var ( + testCtx = context.WithValue(context.Background(), testCtxKey{}, "test") + testProjectId = uuid.NewString() + testGatewayID = uuid.NewString() + testConnectionID = uuid.NewString() + testClient, _ = vpn.NewAPIClient( + sdkConfig.WithoutAuthentication(), + ) +) + +func fixtureArgValues(mods ...func(argValues []string)) []string { + argValues := []string{ + testConnectionID, + } + for _, m := range mods { + m(argValues) + } + return argValues +} + +func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string { + flagValues := map[string]string{ + globalflags.ProjectIdFlag: testProjectId, + gatewayIdFlag: testGatewayID, + } + for _, m := range mods { + m(flagValues) + } + return flagValues +} + +func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { + model := &inputModel{ + GlobalFlagModel: &globalflags.GlobalFlagModel{ + Verbosity: globalflags.VerbosityDefault, + ProjectId: testProjectId, + }, + GatewayId: utils.Ptr(testGatewayID), + ConnectionId: testConnectionID, + } + for _, mod := range mods { + mod(model) + } + return model +} + +func fixtureRequest(mods ...func(request *vpn.ApiGetGatewayConnectionRequest)) vpn.ApiGetGatewayConnectionRequest { + request := testClient.DefaultAPI.GetGatewayConnection(testCtx, testProjectId, "", testGatewayID, testConnectionID) + for _, mod := range mods { + mod(&request) + } + return request +} + +func fixtureResponse(mods ...func(resp *vpn.ConnectionResponse)) *vpn.ConnectionResponse { + resp := &vpn.ConnectionResponse{ + Id: utils.Ptr(testConnectionID), + DisplayName: "test-connection", + Enabled: utils.Ptr(true), + Labels: &map[string]string{ + "env": "prod", + }, + LocalSubnets: []string{"10.0.0.0/24"}, + RemoteSubnets: []string{"192.168.0.0/24"}, + StaticRoutes: []string{"10.1.0.0/24"}, + Tunnel1: vpn.TunnelConfiguration{ + RemoteAddress: "1.2.3.4", + Bgp: &vpn.BGPTunnelConfig{ + RemoteAsn: 65000, + }, + Peering: &vpn.PeeringConfig{ + LocalAddress: utils.Ptr("169.254.0.1"), + RemoteAddress: utils.Ptr("169.254.0.2"), + }, + Phase1: vpn.TunnelConfigurationPhase1{ + DhGroups: []vpn.PhaseDhGroupsInner{"14"}, + EncryptionAlgorithms: []vpn.PhaseEncryptionAlgorithmsInner{"aes256"}, + IntegrityAlgorithms: []vpn.PhaseIntegrityAlgorithmsInner{"sha2_256"}, + RekeyTime: utils.Ptr(int32(3600)), + }, + Phase2: vpn.TunnelConfigurationPhase2{ + DhGroups: []vpn.PhaseDhGroupsInner{"14"}, + EncryptionAlgorithms: []vpn.PhaseEncryptionAlgorithmsInner{"aes256"}, + IntegrityAlgorithms: []vpn.PhaseIntegrityAlgorithmsInner{"sha2_256"}, + RekeyTime: utils.Ptr(int32(3600)), + DpdAction: utils.Ptr(vpn.TunnelConfigurationPhase2AllOfDpdAction("restart")), + StartAction: utils.Ptr(vpn.TunnelConfigurationPhase2AllOfStartAction("start")), + }, + }, + Tunnel2: vpn.TunnelConfiguration{ + RemoteAddress: "5.6.7.8", + Phase1: vpn.TunnelConfigurationPhase1{ + DhGroups: []vpn.PhaseDhGroupsInner{"14"}, + EncryptionAlgorithms: []vpn.PhaseEncryptionAlgorithmsInner{"aes256"}, + IntegrityAlgorithms: []vpn.PhaseIntegrityAlgorithmsInner{"sha2_256"}, + RekeyTime: utils.Ptr(int32(3600)), + }, + Phase2: vpn.TunnelConfigurationPhase2{ + DhGroups: []vpn.PhaseDhGroupsInner{"14"}, + EncryptionAlgorithms: []vpn.PhaseEncryptionAlgorithmsInner{"aes256"}, + IntegrityAlgorithms: []vpn.PhaseIntegrityAlgorithmsInner{"sha2_256"}, + RekeyTime: utils.Ptr(int32(3600)), + DpdAction: utils.Ptr(vpn.TunnelConfigurationPhase2AllOfDpdAction("restart")), + StartAction: utils.Ptr(vpn.TunnelConfigurationPhase2AllOfStartAction("start")), + }, + }, + } + + for _, mod := range mods { + mod(resp) + } + return resp +} + +func TestParseInput(t *testing.T) { + tests := []struct { + description string + argValues []string + flagValues map[string]string + isValid bool + expectedModel *inputModel + }{ + { + description: "base", + argValues: fixtureArgValues(), + flagValues: fixtureFlagValues(), + isValid: true, + expectedModel: fixtureInputModel(), + }, + { + description: "no args", + argValues: []string{}, + flagValues: fixtureFlagValues(), + isValid: false, + }, + { + description: "no gateway id", + argValues: fixtureArgValues(), + flagValues: fixtureFlagValues(func(flagValues map[string]string) { + delete(flagValues, gatewayIdFlag) + }), + isValid: false, + }, + { + description: "no project id", + argValues: fixtureArgValues(), + flagValues: fixtureFlagValues(func(flagValues map[string]string) { + delete(flagValues, globalflags.ProjectIdFlag) + }), + isValid: false, + }, + } + + for _, tt := range tests { + t.Run(tt.description, func(t *testing.T) { + testutils.TestParseInput(t, NewCmd, parseInput, tt.expectedModel, tt.argValues, tt.flagValues, tt.isValid) + }) + } +} + +func TestBuildRequest(t *testing.T) { + tests := []struct { + description string + model *inputModel + expectedResult vpn.ApiGetGatewayConnectionRequest + }{ + { + description: "base", + model: fixtureInputModel(), + expectedResult: fixtureRequest(), + }, + } + + for _, tt := range tests { + t.Run(tt.description, func(t *testing.T) { + request, err := buildRequest(testCtx, tt.model, testClient) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + + diff := cmp.Diff(request, tt.expectedResult, + cmp.AllowUnexported(tt.expectedResult), + cmpopts.IgnoreUnexported(vpn.DefaultAPIService{}), + cmpopts.EquateComparable(testCtx), + ) + if diff != "" { + t.Fatalf("data does not match: %s", diff) + } + }) + } +} + +func TestOutputResult(t *testing.T) { + tests := []struct { + description string + model *inputModel + resp *vpn.ConnectionResponse + wantErr bool + }{ + { + description: "nil response", + model: fixtureInputModel(), + resp: nil, + wantErr: true, + }, + { + description: "full response", + model: fixtureInputModel(), + resp: fixtureResponse(), + }, + } + + for _, tt := range tests { + t.Run(tt.description, func(t *testing.T) { + params := testparams.NewTestParams() + err := outputResult(params.Printer, tt.model, tt.resp) + if (err != nil) != tt.wantErr { + t.Errorf("outputResult() error = %v, wantErr %v", err, tt.wantErr) + } + }) + } +} diff --git a/internal/cmd/beta/vpn/connection/list/list.go b/internal/cmd/beta/vpn/connection/list/list.go new file mode 100644 index 000000000..02bb5356d --- /dev/null +++ b/internal/cmd/beta/vpn/connection/list/list.go @@ -0,0 +1,120 @@ +package list + +import ( + "context" + "fmt" + + "github.com/spf13/cobra" + vpn "github.com/stackitcloud/stackit-sdk-go/services/vpn/v1api" + + "github.com/stackitcloud/stackit-cli/internal/pkg/args" + cliErr "github.com/stackitcloud/stackit-cli/internal/pkg/errors" + "github.com/stackitcloud/stackit-cli/internal/pkg/examples" + "github.com/stackitcloud/stackit-cli/internal/pkg/flags" + "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" + "github.com/stackitcloud/stackit-cli/internal/pkg/print" + "github.com/stackitcloud/stackit-cli/internal/pkg/services/vpn/client" + "github.com/stackitcloud/stackit-cli/internal/pkg/tables" + "github.com/stackitcloud/stackit-cli/internal/pkg/types" + "github.com/stackitcloud/stackit-cli/internal/pkg/utils" +) + +const ( + gatewayIdFlag = "gateway-id" +) + +type inputModel struct { + *globalflags.GlobalFlagModel + GatewayId *string +} + +func NewCmd(p *types.CmdParams) *cobra.Command { + cmd := &cobra.Command{ + Use: "list", + Short: "Lists all VPN connections of a gateway", + Long: "Lists all VPN connections of a gateway.", + Args: args.NoArgs, + Example: examples.Build( + examples.NewExample( + `List all VPN connections of a gateway`, + "$ stackit beta vpn connection list --gateway-id xxx"), + ), + RunE: func(cmd *cobra.Command, _ []string) error { + ctx := context.Background() + model, err := parseInput(p.Printer, cmd) + if err != nil { + return err + } + + // Configure API client + apiClient, err := client.ConfigureClient(p.Printer, p.CliVersion) + if err != nil { + return err + } + + // Call API + req, err := buildRequest(ctx, model, apiClient) + if err != nil { + return err + } + resp, err := req.Execute() + if err != nil { + return fmt.Errorf("list VPN connections: %w", err) + } + + return outputResult(p.Printer, model, resp) + }, + } + configureFlags(cmd) + return cmd +} + +func configureFlags(cmd *cobra.Command) { + cmd.Flags().Var(flags.UUIDFlag(), gatewayIdFlag, "Gateway ID") + + err := flags.MarkFlagsRequired(cmd, gatewayIdFlag) + cobra.CheckErr(err) +} + +func parseInput(p *print.Printer, cmd *cobra.Command) (*inputModel, error) { + globalFlags := globalflags.Parse(p, cmd) + if globalFlags.ProjectId == "" { + return nil, &cliErr.ProjectIdError{} + } + + model := inputModel{ + GlobalFlagModel: globalFlags, + GatewayId: flags.FlagToStringPointer(p, cmd, gatewayIdFlag), + } + + p.DebugInputModel(model) + return &model, nil +} + +func buildRequest(ctx context.Context, model *inputModel, apiClient *vpn.APIClient) (vpn.ApiListGatewayConnectionsRequest, error) { + req := apiClient.DefaultAPI.ListGatewayConnections(ctx, model.ProjectId, model.Region, *model.GatewayId) + return req, nil +} + +func outputResult(p *print.Printer, model *inputModel, resp *vpn.ConnectionList) error { + if resp == nil || resp.Connections == nil { + return fmt.Errorf("list connections response is empty") + } + + return p.OutputResult(model.OutputFormat, resp.Connections, func() error { + table := tables.NewTable() + table.SetHeader("ID", "NAME", "ENABLED", "LABELS") + for _, c := range resp.Connections { + id := utils.PtrString(c.Id) + name := c.DisplayName + enabled := utils.PtrString(c.Enabled) + var labels string + if c.Labels != nil { + labels = utils.JoinStringMap(*c.Labels, "=", ", ") + } + table.AddRow(id, name, enabled, labels) + } + p.Outputln(table.Render()) + return nil + }) +} diff --git a/internal/cmd/beta/vpn/connection/list/list_test.go b/internal/cmd/beta/vpn/connection/list/list_test.go new file mode 100644 index 000000000..4ddf3db73 --- /dev/null +++ b/internal/cmd/beta/vpn/connection/list/list_test.go @@ -0,0 +1,207 @@ +package list + +import ( + "context" + "testing" + + "github.com/google/go-cmp/cmp" + "github.com/google/go-cmp/cmp/cmpopts" + "github.com/google/uuid" + vpn "github.com/stackitcloud/stackit-sdk-go/services/vpn/v1api" + + "github.com/spf13/cobra" + sdkConfig "github.com/stackitcloud/stackit-sdk-go/core/config" + + "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" + "github.com/stackitcloud/stackit-cli/internal/pkg/print" + "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" + "github.com/stackitcloud/stackit-cli/internal/pkg/testutils" + "github.com/stackitcloud/stackit-cli/internal/pkg/utils" +) + +type testCtxKey struct{} + +var ( + testCtx = context.WithValue(context.Background(), testCtxKey{}, "test") + testProjectId = uuid.NewString() + testGatewayID = uuid.NewString() + testClient, _ = vpn.NewAPIClient( + sdkConfig.WithoutAuthentication(), + ) +) + +func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string { + flagValues := map[string]string{ + globalflags.ProjectIdFlag: testProjectId, + gatewayIdFlag: testGatewayID, + } + for _, m := range mods { + m(flagValues) + } + return flagValues +} + +func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { + model := &inputModel{ + GlobalFlagModel: &globalflags.GlobalFlagModel{ + Verbosity: globalflags.VerbosityDefault, + ProjectId: testProjectId, + }, + GatewayId: utils.Ptr(testGatewayID), + } + for _, mod := range mods { + mod(model) + } + return model +} + +func fixtureRequest(mods ...func(request *vpn.ApiListGatewayConnectionsRequest)) vpn.ApiListGatewayConnectionsRequest { + request := testClient.DefaultAPI.ListGatewayConnections(testCtx, testProjectId, "", testGatewayID) + for _, mod := range mods { + mod(&request) + } + return request +} + +func TestParseInput(t *testing.T) { + tests := []struct { + description string + argValues []string + flagValues map[string]string + isValid bool + expectedModel *inputModel + }{ + { + description: "base", + argValues: []string{}, + flagValues: fixtureFlagValues(), + isValid: true, + expectedModel: fixtureInputModel(), + }, + { + description: "no flags", + argValues: []string{}, + flagValues: map[string]string{}, + isValid: false, + }, + { + description: "no project id", + argValues: []string{}, + flagValues: fixtureFlagValues(func(flagValues map[string]string) { + delete(flagValues, globalflags.ProjectIdFlag) + }), + isValid: false, + }, + { + description: "no gateway id", + argValues: []string{}, + flagValues: fixtureFlagValues(func(flagValues map[string]string) { + delete(flagValues, gatewayIdFlag) + }), + isValid: false, + }, + } + + for _, tt := range tests { + t.Run(tt.description, func(t *testing.T) { + testutils.TestParseInput(t, NewCmd, func(printer *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, error) { + return parseInput(printer, cmd) + }, tt.expectedModel, tt.argValues, tt.flagValues, tt.isValid) + }) + } +} + +func TestBuildRequest(t *testing.T) { + tests := []struct { + description string + model *inputModel + expectedResult vpn.ApiListGatewayConnectionsRequest + }{ + { + description: "base", + model: fixtureInputModel(), + expectedResult: fixtureRequest(), + }, + } + + for _, tt := range tests { + t.Run(tt.description, func(t *testing.T) { + request, err := buildRequest(testCtx, tt.model, testClient) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + + diff := cmp.Diff(request, tt.expectedResult, + cmp.AllowUnexported(tt.expectedResult), + cmpopts.IgnoreUnexported(vpn.DefaultAPIService{}), + cmpopts.EquateComparable(testCtx), + ) + if diff != "" { + t.Fatalf("data does not match: %s", diff) + } + }) + } +} + +func TestOutputResult(t *testing.T) { + tests := []struct { + description string + model *inputModel + resp *vpn.ConnectionList + wantErr bool + }{ + { + description: "empty list", + model: fixtureInputModel(), + resp: &vpn.ConnectionList{ + Connections: []vpn.ConnectionResponse{}, + }, + }, + { + description: "nil response", + model: fixtureInputModel(), + resp: nil, + wantErr: true, + }, + { + description: "nil connections", + model: fixtureInputModel(), + resp: &vpn.ConnectionList{ + Connections: nil, + }, + wantErr: true, + }, + { + description: "with entries", + model: fixtureInputModel(), + resp: &vpn.ConnectionList{ + Connections: []vpn.ConnectionResponse{ + { + Id: utils.Ptr("conn-1"), + DisplayName: "test-conn-1", + Enabled: utils.Ptr(true), + Labels: &map[string]string{ + "env": "prod", + }, + }, + { + Id: utils.Ptr("conn-2"), + DisplayName: "test-conn-2", + Enabled: utils.Ptr(false), + Labels: nil, + }, + }, + }, + }, + } + + for _, tt := range tests { + t.Run(tt.description, func(t *testing.T) { + params := testparams.NewTestParams() + err := outputResult(params.Printer, tt.model, tt.resp) + if (err != nil) != tt.wantErr { + t.Errorf("outputResult() error = %v, wantErr %v", err, tt.wantErr) + } + }) + } +} diff --git a/internal/cmd/beta/vpn/connection/status/status.go b/internal/cmd/beta/vpn/connection/status/status.go new file mode 100644 index 000000000..6f3f91c46 --- /dev/null +++ b/internal/cmd/beta/vpn/connection/status/status.go @@ -0,0 +1,164 @@ +package status + +import ( + "context" + "fmt" + + "github.com/spf13/cobra" + vpn "github.com/stackitcloud/stackit-sdk-go/services/vpn/v1api" + + "github.com/stackitcloud/stackit-cli/internal/pkg/args" + "github.com/stackitcloud/stackit-cli/internal/pkg/errors" + "github.com/stackitcloud/stackit-cli/internal/pkg/examples" + "github.com/stackitcloud/stackit-cli/internal/pkg/flags" + "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" + "github.com/stackitcloud/stackit-cli/internal/pkg/print" + "github.com/stackitcloud/stackit-cli/internal/pkg/services/vpn/client" + "github.com/stackitcloud/stackit-cli/internal/pkg/tables" + "github.com/stackitcloud/stackit-cli/internal/pkg/types" + "github.com/stackitcloud/stackit-cli/internal/pkg/utils" +) + +const ( + connectionIdArg = "CONNECTION_ID" + + gatewayIdFlag = "gateway-id" +) + +type inputModel struct { + *globalflags.GlobalFlagModel + GatewayId *string + ConnectionId string +} + +func NewCmd(p *types.CmdParams) *cobra.Command { + cmd := &cobra.Command{ + Use: fmt.Sprintf("status %s", connectionIdArg), + Short: "Shows the status of a VPN connection", + Long: "Shows the status of a VPN connection.", + Args: args.SingleArg(connectionIdArg, nil), + Example: examples.Build( + examples.NewExample( + `Show status of a VPN connection`, + "$ stackit beta vpn connection status xxx --gateway-id yyy"), + ), + RunE: func(cmd *cobra.Command, args []string) error { + ctx := context.Background() + model, err := parseInput(p.Printer, cmd, args) + if err != nil { + return err + } + + // Configure API client + apiClient, err := client.ConfigureClient(p.Printer, p.CliVersion) + if err != nil { + return err + } + + // Call API + req, err := buildRequest(ctx, model, apiClient) + if err != nil { + return err + } + resp, err := req.Execute() + if err != nil { + return fmt.Errorf("get VPN connection status: %w", err) + } + + return outputResult(p.Printer, model, resp) + }, + } + configureFlags(cmd) + return cmd +} + +func configureFlags(cmd *cobra.Command) { + cmd.Flags().Var(flags.UUIDFlag(), gatewayIdFlag, "Gateway ID") + + err := flags.MarkFlagsRequired(cmd, gatewayIdFlag) + cobra.CheckErr(err) +} + +func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inputModel, error) { + connectionId := inputArgs[0] + + globalFlags := globalflags.Parse(p, cmd) + if globalFlags.ProjectId == "" { + return nil, &errors.ProjectIdError{} + } + + model := inputModel{ + GlobalFlagModel: globalFlags, + GatewayId: flags.FlagToStringPointer(p, cmd, gatewayIdFlag), + ConnectionId: connectionId, + } + + p.DebugInputModel(model) + return &model, nil +} + +func buildRequest(ctx context.Context, model *inputModel, apiClient *vpn.APIClient) (vpn.ApiGetGatewayConnectionStatusRequest, error) { + req := apiClient.DefaultAPI.GetGatewayConnectionStatus(ctx, model.ProjectId, model.Region, *model.GatewayId, model.ConnectionId) + return req, nil +} + +func outputResult(p *print.Printer, model *inputModel, resp *vpn.ConnectionStatusResponse) error { + if resp == nil { + return fmt.Errorf("status response is empty") + } + + return p.OutputResult(model.OutputFormat, resp, func() error { + mainTable := tables.NewTable() + mainTable.AddRow("ID", utils.PtrString(resp.Id)) + mainTable.AddRow("Name", utils.PtrString(resp.DisplayName)) + mainTable.AddRow("Enabled", utils.PtrString(resp.Enabled)) + + ts := []tables.Table{ + mainTable, + } + for _, tunnel := range resp.Tunnels { + ts = append(ts, tunnelTables(&tunnel)...) + } + + return tables.DisplayTables(p, ts) + }) +} + +func tunnelTables(tunnel *vpn.TunnelStatus) []tables.Table { + title := "Tunnel" + if tunnel.Name != nil { + title = string(*tunnel.Name) + } + + table := tables.NewTable() + table.SetTitle(title) + table.AddRow("Established", utils.PtrString(tunnel.Established)) + + res := []tables.Table{table} + + if tunnel.Phase1 != nil { + phase1Table := tables.NewTable() + phase1Table.SetTitle(fmt.Sprintf("%s Phase 1", title)) + phase1Table.AddRow("State", utils.PtrString(tunnel.Phase1.State)) + phase1Table.AddRow("DH Group", utils.PtrString(tunnel.Phase1.DhGroup)) + phase1Table.AddRow("Encryption Algo", utils.PtrString(tunnel.Phase1.EncryptionAlgorithm)) + phase1Table.AddRow("Integrity Algo", utils.PtrString(tunnel.Phase1.IntegrityAlgorithm)) + res = append(res, phase1Table) + } + + if tunnel.Phase2 != nil { + phase2Table := tables.NewTable() + phase2Table.SetTitle(fmt.Sprintf("%s Phase 2", title)) + phase2Table.AddRow("State", utils.PtrString(tunnel.Phase2.State)) + phase2Table.AddRow("Protocol", utils.PtrString(tunnel.Phase2.Protocol)) + phase2Table.AddRow("DH Group", utils.PtrString(tunnel.Phase2.DhGroup)) + phase2Table.AddRow("Encryption Algo", utils.PtrString(tunnel.Phase2.EncryptionAlgorithm)) + phase2Table.AddRow("Integrity Algo", utils.PtrString(tunnel.Phase2.IntegrityAlgorithm)) + phase2Table.AddRow("Encap", utils.PtrString(tunnel.Phase2.Encap)) + phase2Table.AddRow("Bytes In/Out", fmt.Sprintf("%s / %s", utils.PtrString(tunnel.Phase2.BytesIn), utils.PtrString(tunnel.Phase2.BytesOut))) + phase2Table.AddRow("Packets In/Out", fmt.Sprintf("%s / %s", utils.PtrString(tunnel.Phase2.PacketsIn), utils.PtrString(tunnel.Phase2.PacketsOut))) + res = append(res, phase2Table) + } + + return res +} diff --git a/internal/cmd/beta/vpn/connection/status/status_test.go b/internal/cmd/beta/vpn/connection/status/status_test.go new file mode 100644 index 000000000..b43ab13a6 --- /dev/null +++ b/internal/cmd/beta/vpn/connection/status/status_test.go @@ -0,0 +1,219 @@ +package status + +import ( + "context" + "testing" + + "github.com/google/go-cmp/cmp" + "github.com/google/go-cmp/cmp/cmpopts" + "github.com/google/uuid" + vpn "github.com/stackitcloud/stackit-sdk-go/services/vpn/v1api" + + sdkConfig "github.com/stackitcloud/stackit-sdk-go/core/config" + + "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" + "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" + "github.com/stackitcloud/stackit-cli/internal/pkg/testutils" + "github.com/stackitcloud/stackit-cli/internal/pkg/utils" +) + +type testCtxKey struct{} + +var ( + testCtx = context.WithValue(context.Background(), testCtxKey{}, "test") + testProjectId = uuid.NewString() + testGatewayID = uuid.NewString() + testConnectionID = uuid.NewString() + testClient, _ = vpn.NewAPIClient( + sdkConfig.WithoutAuthentication(), + ) +) + +func fixtureArgValues(mods ...func(argValues []string)) []string { + argValues := []string{ + testConnectionID, + } + for _, m := range mods { + m(argValues) + } + return argValues +} + +func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string { + flagValues := map[string]string{ + globalflags.ProjectIdFlag: testProjectId, + gatewayIdFlag: testGatewayID, + } + for _, m := range mods { + m(flagValues) + } + return flagValues +} + +func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { + model := &inputModel{ + GlobalFlagModel: &globalflags.GlobalFlagModel{ + Verbosity: globalflags.VerbosityDefault, + ProjectId: testProjectId, + }, + GatewayId: utils.Ptr(testGatewayID), + ConnectionId: testConnectionID, + } + for _, mod := range mods { + mod(model) + } + return model +} + +func fixtureRequest(mods ...func(request *vpn.ApiGetGatewayConnectionStatusRequest)) vpn.ApiGetGatewayConnectionStatusRequest { + request := testClient.DefaultAPI.GetGatewayConnectionStatus(testCtx, testProjectId, "", testGatewayID, testConnectionID) + for _, mod := range mods { + mod(&request) + } + return request +} + +func fixtureResponse(mods ...func(resp *vpn.ConnectionStatusResponse)) *vpn.ConnectionStatusResponse { + resp := &vpn.ConnectionStatusResponse{ + Id: utils.Ptr(testConnectionID), + DisplayName: utils.Ptr("test-connection"), + Enabled: utils.Ptr(true), + Tunnels: []vpn.TunnelStatus{ + { + Name: utils.Ptr(vpn.TunnelStatusName("tunnel1")), + Established: utils.Ptr(true), + Phase1: &vpn.Phase1Status{ + DhGroup: utils.Ptr("MODP2048"), + EncryptionAlgorithm: utils.Ptr("AES_GCM_16"), + IntegrityAlgorithm: utils.Ptr("SHA_256"), + State: utils.Ptr("INSTALLED"), + }, + Phase2: &vpn.Phase2Status{ + BytesIn: utils.Ptr("453533"), + BytesOut: utils.Ptr("46459064"), + DhGroup: utils.Ptr("MODP2048"), + Encap: utils.Ptr("yes"), + EncryptionAlgorithm: utils.Ptr("AES_GCM_16"), + IntegrityAlgorithm: utils.Ptr("SHA_256"), + PacketsIn: utils.Ptr("1534134"), + PacketsOut: utils.Ptr("65847343"), + Protocol: utils.Ptr("ESP"), + State: utils.Ptr("ESTABLISHED"), + }, + }, + }, + } + for _, mod := range mods { + mod(resp) + } + return resp +} + +func TestParseInput(t *testing.T) { + tests := []struct { + description string + argValues []string + flagValues map[string]string + isValid bool + expectedModel *inputModel + }{ + { + description: "base", + argValues: fixtureArgValues(), + flagValues: fixtureFlagValues(), + isValid: true, + expectedModel: fixtureInputModel(), + }, + { + description: "no args", + argValues: []string{}, + flagValues: fixtureFlagValues(), + isValid: false, + }, + { + description: "no gateway id", + argValues: fixtureArgValues(), + flagValues: fixtureFlagValues(func(flagValues map[string]string) { + delete(flagValues, gatewayIdFlag) + }), + isValid: false, + }, + { + description: "no project id", + argValues: fixtureArgValues(), + flagValues: fixtureFlagValues(func(flagValues map[string]string) { + delete(flagValues, globalflags.ProjectIdFlag) + }), + isValid: false, + }, + } + + for _, tt := range tests { + t.Run(tt.description, func(t *testing.T) { + testutils.TestParseInput(t, NewCmd, parseInput, tt.expectedModel, tt.argValues, tt.flagValues, tt.isValid) + }) + } +} + +func TestBuildRequest(t *testing.T) { + tests := []struct { + name string + model *inputModel + expected vpn.ApiGetGatewayConnectionStatusRequest + }{ + { + name: "base", + model: fixtureInputModel(), + expected: fixtureRequest(), + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + request, err := buildRequest(testCtx, tt.model, testClient) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + + diff := cmp.Diff(request, tt.expected, + cmp.AllowUnexported(tt.expected), + cmpopts.IgnoreUnexported(vpn.DefaultAPIService{}), + cmpopts.EquateComparable(testCtx), + ) + if diff != "" { + t.Fatalf("data does not match: %s", diff) + } + }) + } +} + +func TestOutputResult(t *testing.T) { + tests := []struct { + description string + model *inputModel + resp *vpn.ConnectionStatusResponse + wantErr bool + }{ + { + description: "nil response", + model: fixtureInputModel(), + resp: nil, + wantErr: true, + }, + { + description: "full response", + model: fixtureInputModel(), + resp: fixtureResponse(), + }, + } + + for _, tt := range tests { + t.Run(tt.description, func(t *testing.T) { + params := testparams.NewTestParams() + err := outputResult(params.Printer, tt.model, tt.resp) + if (err != nil) != tt.wantErr { + t.Errorf("outputResult() error = %v, wantErr %v", err, tt.wantErr) + } + }) + } +} diff --git a/internal/cmd/beta/vpn/vpn.go b/internal/cmd/beta/vpn/vpn.go new file mode 100644 index 000000000..8ee353974 --- /dev/null +++ b/internal/cmd/beta/vpn/vpn.go @@ -0,0 +1,25 @@ +package vpn + +import ( + "github.com/spf13/cobra" + + "github.com/stackitcloud/stackit-cli/internal/cmd/beta/vpn/connection" + "github.com/stackitcloud/stackit-cli/internal/pkg/types" + "github.com/stackitcloud/stackit-cli/internal/pkg/utils" +) + +func NewCmd(params *types.CmdParams) *cobra.Command { + cmd := &cobra.Command{ + Use: "vpn", + Short: "Provides functionality for VPN", + Long: "Provides functionality for VPN.", + Args: cobra.NoArgs, + Run: utils.CmdHelp, + } + addSubcommands(cmd, params) + return cmd +} + +func addSubcommands(cmd *cobra.Command, params *types.CmdParams) { + cmd.AddCommand(connection.NewCmd(params)) +} diff --git a/internal/pkg/config/config.go b/internal/pkg/config/config.go index a2852b59f..9e1084dac 100644 --- a/internal/pkg/config/config.go +++ b/internal/pkg/config/config.go @@ -54,6 +54,7 @@ const ( CDNCustomEndpointKey = "cdn_custom_endpoint" IntakeCustomEndpointKey = "intake_custom_endpoint" LogsCustomEndpointKey = "logs_custom_endpoint" + VPNCustomEndpointKey = "vpn_custom_endpoint" ProjectNameKey = "project_name" DefaultProfileName = "default" diff --git a/internal/pkg/flags/string_enum.go b/internal/pkg/flags/string_enum.go new file mode 100644 index 000000000..760c5f6d8 --- /dev/null +++ b/internal/pkg/flags/string_enum.go @@ -0,0 +1,117 @@ +package flags + +import ( + "fmt" + "strings" + + "github.com/spf13/cobra" + "github.com/spf13/pflag" +) + +type stringEnumFlag[T ~string] struct { + ignoreCase bool + options []T + value T + valueSet bool + docs string + name string +} + +type StringEnumFlagOption[T ~string] func(*stringEnumFlag[T]) + +func StringEnumIgnoreCase[T ~string]() StringEnumFlagOption[T] { + return func(f *stringEnumFlag[T]) { + f.ignoreCase = true + } +} + +func StringEnumDefaultValue[T ~string](value T) StringEnumFlagOption[T] { + return func(f *stringEnumFlag[T]) { + f.value = value + f.valueSet = true + } +} + +func StringEnumFlag[T ~string](name string, possibleValues []T, docs string, opts ...StringEnumFlagOption[T]) *stringEnumFlag[T] { + f := &stringEnumFlag[T]{ + name: name, + docs: docs, + } + for _, v := range possibleValues { + if string(v) != "unknown_default_open_api" { + f.options = append(f.options, v) + } + } + for _, opt := range opts { + opt(f) + } + return f +} + +var _ pflag.Value = &stringEnumFlag[string]{} + +func (s *stringEnumFlag[T]) Register(cmd *cobra.Command) { + cmd.Flags().Var(s, s.name, s.Usage()) +} + +func (s *stringEnumFlag[T]) Usage() string { + return s.docs + fmt.Sprintf(" (possible values: %s)", s.fmtValues(s.options)) +} + +func (s *stringEnumFlag[T]) Get() T { + return s.value +} + +func (s *stringEnumFlag[T]) Ptr() *T { + if s.valueSet { + return &s.value + } + return nil +} + +func (s *stringEnumFlag[T]) Name() string { + return s.name +} + +func (s *stringEnumFlag[T]) String() string { + return string(s.value) +} + +func (s *stringEnumFlag[T]) fmtValues(xs []T) string { + var sb strings.Builder + sb.WriteString("[") + for i, v := range xs { + sb.WriteString(string(v)) + if i != len(xs)-1 { + sb.WriteString(", ") + } + } + sb.WriteString("]") + return sb.String() +} + +func (s *stringEnumFlag[T]) Set(value string) error { + v := strings.TrimSpace(value) + + if v == "" { + return fmt.Errorf("value cannot be empty") + } + + for _, o := range s.options { + if !s.ignoreCase && v == string(o) { + s.value = T(v) + s.valueSet = true + return nil + } else if s.ignoreCase && strings.EqualFold(v, string(o)) { + s.value = T(strings.ToLower(v)) + s.valueSet = true + return nil + } + } + + return fmt.Errorf("found value %q, expected one of %q", v, s.options) +} + +func (s *stringEnumFlag[T]) Type() string { + return "string" +} diff --git a/internal/pkg/flags/string_enum_test.go b/internal/pkg/flags/string_enum_test.go new file mode 100644 index 000000000..a59f9b4ae --- /dev/null +++ b/internal/pkg/flags/string_enum_test.go @@ -0,0 +1,149 @@ +package flags + +import ( + "testing" + + "github.com/spf13/cobra" +) + +func TestStringEnumFlag_Set(t *testing.T) { + tests := []struct { + name string + options []string + ignoreCase bool + setValue string + want string + wantErr bool + }{ + { + name: "valid value", + options: []string{"a", "b", "c"}, + setValue: "a", + want: "a", + }, + { + name: "invalid value", + options: []string{"a", "b", "c"}, + setValue: "d", + wantErr: true, + }, + { + name: "empty value", + options: []string{"a", "b", "c"}, + setValue: "", + wantErr: true, + }, + { + name: "case sensitive mismatch", + options: []string{"A", "B"}, + setValue: "a", + ignoreCase: false, + wantErr: true, + }, + { + name: "case insensitive match", + options: []string{"A", "B"}, + setValue: "a", + ignoreCase: true, + want: "a", + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + opts := []StringEnumFlagOption[string]{} + if tt.ignoreCase { + opts = append(opts, StringEnumIgnoreCase[string]()) + } + f := StringEnumFlag("test", tt.options, "docs", opts...) + + err := f.Set(tt.setValue) + if (err != nil) != tt.wantErr { + t.Errorf("Set() error = %v, wantErr %v", err, tt.wantErr) + return + } + if !tt.wantErr { + got := f.Get() + if got != tt.want { + t.Errorf("Set() got = %v, want %v", got, tt.want) + } + } + }) + } +} + +func TestStringEnumFlag_DefaultValue(t *testing.T) { + f := StringEnumFlag("test", []string{"a", "b"}, "docs", StringEnumDefaultValue("a")) + + got := f.Get() + if got != "a" { + t.Errorf("Expected default value a, got %v", got) + } + + // Setting a value should override the default + err := f.Set("b") + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + got = f.Get() + if got != "b" { + t.Errorf("Expected value b after Set, got %v", got) + } +} + +func TestStringEnumFlag_Usage(t *testing.T) { + f := StringEnumFlag("test", []string{"a", "b"}, "docs") + usage := f.Usage() + if usage != "docs (possible values: [a, b])" { + t.Errorf("Expected usage 'docs (possible values: [a, b])', got %q", usage) + } +} + +func TestStringEnumFlag_UnknownDefaultOpenAPI(t *testing.T) { + f := StringEnumFlag("test", []string{"a", "unknown_default_open_api", "b"}, "docs") + usage := f.Usage() + if usage != "docs (possible values: [a, b])" { + t.Errorf("Expected unknown_default_open_api to be filtered out, got %q", usage) + } +} + +func TestStringEnumFlag_Register(t *testing.T) { + cmd := &cobra.Command{Use: "test"} + f := StringEnumFlag("my-flag", []string{"a", "b"}, "docs") + f.Register(cmd) + + flag := cmd.Flags().Lookup("my-flag") + if flag == nil { + t.Fatalf("Expected flag 'my-flag' to be registered") + } + if flag.Usage != "docs (possible values: [a, b])" { + t.Errorf("Expected flag usage to be set correctly") + } +} + +func TestStringEnumFlag_Ptr(t *testing.T) { + f := StringEnumFlag("test", []string{"a", "b"}, "docs") + if f.Ptr() != nil { + t.Errorf("Expected Ptr() to be nil initially, got %v", *f.Ptr()) + } + + err := f.Set("a") + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + + ptr := f.Ptr() + if ptr == nil { + t.Errorf("Expected Ptr() to not be nil after Set") + } else if *ptr != "a" { + t.Errorf("Expected Ptr() to point to 'a', got %v", *ptr) + } + + fWithDefault := StringEnumFlag("test_default", []string{"a", "b"}, "docs", StringEnumDefaultValue("b")) + ptrDefault := fWithDefault.Ptr() + if ptrDefault == nil { + t.Errorf("Expected Ptr() to not be nil with default value") + } else if *ptrDefault != "b" { + t.Errorf("Expected Ptr() to point to 'b' with default value, got %v", *ptrDefault) + } +} diff --git a/internal/pkg/flags/string_enumslice.go b/internal/pkg/flags/string_enumslice.go new file mode 100644 index 000000000..2feb3705f --- /dev/null +++ b/internal/pkg/flags/string_enumslice.go @@ -0,0 +1,126 @@ +package flags + +import ( + "fmt" + "strings" + + "github.com/spf13/cobra" + "github.com/spf13/pflag" +) + +type stringEnumSliceFlag[T ~string] struct { + ignoreCase bool + options []T + value []T + valueSet bool + docs string + name string +} + +type StringEnumSliceFlagOption[T ~string] func(*stringEnumSliceFlag[T]) + +func IgnoreCase[T ~string]() StringEnumSliceFlagOption[T] { + return func(f *stringEnumSliceFlag[T]) { + f.ignoreCase = true + } +} + +func DefaultValues[T ~string](values ...T) StringEnumSliceFlagOption[T] { + return func(f *stringEnumSliceFlag[T]) { + f.value = append(f.value, values...) + } +} + +func StringEnumSliceFlag[T ~string](name string, possibleValues []T, docs string, opts ...StringEnumSliceFlagOption[T]) *stringEnumSliceFlag[T] { + f := &stringEnumSliceFlag[T]{ + name: name, + docs: docs, + } + for _, v := range possibleValues { + if string(v) != "unknown_default_open_api" { + f.options = append(f.options, v) + } + } + for _, opt := range opts { + opt(f) + } + return f +} + +var _ pflag.Value = &stringEnumSliceFlag[string]{} + +func (s *stringEnumSliceFlag[T]) Register(cmd *cobra.Command) { + cmd.Flags().Var(s, s.name, s.Usage()) +} + +func (s *stringEnumSliceFlag[T]) Usage() string { + return s.docs + fmt.Sprintf(" (possible values: %s)", s.fmtValues(s.options)) +} + +func (s *stringEnumSliceFlag[T]) Get() []T { + return s.value +} + +func (s *stringEnumSliceFlag[T]) Name() string { + return s.name +} + +func (s *stringEnumSliceFlag[T]) String() string { + return s.fmtValues(s.value) +} + +func (s *stringEnumSliceFlag[T]) fmtValues(xs []T) string { + var sb strings.Builder + sb.WriteString("[") + for i, v := range xs { + sb.WriteString(string(v)) + if i != len(xs)-1 { + sb.WriteString(", ") + } + } + sb.WriteString("]") + return sb.String() +} + +func (s *stringEnumSliceFlag[T]) Set(value string) error { + // If the default value is still set, remove it + // (Since we're going to append the incoming values to f.value) + if !s.valueSet { + s.value = []T{} + s.valueSet = true + } + + if value == "" { + return fmt.Errorf("value cannot be empty") + } + values := strings.Split(value, ",") + return s.appendToValue(values) +} + +func (s *stringEnumSliceFlag[T]) Type() string { + return "stringSlice" +} + +func (s *stringEnumSliceFlag[T]) appendToValue(values []string) error { + for _, v := range values { + v = strings.TrimSpace(v) + + foundValid := false + for _, o := range s.options { + if !s.ignoreCase && v == string(o) { + s.value = append(s.value, T(v)) + foundValid = true + break + } else if s.ignoreCase && strings.EqualFold(v, string(o)) { + s.value = append(s.value, T(strings.ToLower(v))) + foundValid = true + break + } + } + + if !foundValid { + return fmt.Errorf("found value %q, expected one of %q", v, s.options) + } + } + return nil +} diff --git a/internal/pkg/flags/string_enumslice_test.go b/internal/pkg/flags/string_enumslice_test.go new file mode 100644 index 000000000..ff0be55c9 --- /dev/null +++ b/internal/pkg/flags/string_enumslice_test.go @@ -0,0 +1,161 @@ +package flags + +import ( + "testing" + + "github.com/spf13/cobra" +) + +func TestStringEnumSliceFlag_Set(t *testing.T) { + tests := []struct { + name string + options []string + ignoreCase bool + setValue string + want []string + wantErr bool + }{ + { + name: "valid value", + options: []string{"a", "b", "c"}, + setValue: "a", + want: []string{"a"}, + wantErr: false, + }, + { + name: "multiple valid values", + options: []string{"a", "b", "c"}, + setValue: "a,b", + want: []string{"a", "b"}, + wantErr: false, + }, + { + name: "multiple valid values with spaces", + options: []string{"a", "b", "c"}, + setValue: "a, b ,c", + want: []string{"a", "b", "c"}, + wantErr: false, + }, + { + name: "invalid value", + options: []string{"a", "b", "c"}, + setValue: "d", + wantErr: true, + }, + { + name: "partially invalid value", + options: []string{"a", "b", "c"}, + setValue: "a,d", + wantErr: true, + }, + { + name: "empty value", + options: []string{"a", "b", "c"}, + setValue: "", + wantErr: true, + }, + { + name: "case sensitive mismatch", + options: []string{"A", "B"}, + setValue: "a", + ignoreCase: false, + wantErr: true, + }, + { + name: "case insensitive match", + options: []string{"A", "B"}, + setValue: "a", + ignoreCase: true, + want: []string{"a"}, + wantErr: false, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + opts := []StringEnumSliceFlagOption[string]{} + if tt.ignoreCase { + opts = append(opts, IgnoreCase[string]()) + } + f := StringEnumSliceFlag("test", tt.options, "docs", opts...) + + err := f.Set(tt.setValue) + if (err != nil) != tt.wantErr { + t.Errorf("Set() error = %v, wantErr %v", err, tt.wantErr) + return + } + if !tt.wantErr { + got := f.Get() + if len(got) != len(tt.want) { + t.Errorf("Set() got = %v, want %v", got, tt.want) + return + } + for i := range got { + if got[i] != tt.want[i] { + t.Errorf("Set() got = %v, want %v", got, tt.want) + break + } + } + } + }) + } +} + +func TestStringEnumSliceFlag_DefaultValues(t *testing.T) { + f := StringEnumSliceFlag("test", []string{"a", "b"}, "docs", DefaultValues("a")) + + got := f.Get() + if len(got) != 1 || got[0] != "a" { + t.Errorf("Expected default value [a], got %v", got) + } + + // Setting a value should override the default + err := f.Set("b") + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + got = f.Get() + if len(got) != 1 || got[0] != "b" { + t.Errorf("Expected value [b] after Set, got %v", got) + } + + // Setting another value should append + err = f.Set("a") + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + got = f.Get() + if len(got) != 2 || got[0] != "b" || got[1] != "a" { + t.Errorf("Expected value [b, a] after second Set, got %v", got) + } +} + +func TestStringEnumSliceFlag_Usage(t *testing.T) { + f := StringEnumSliceFlag("test", []string{"a", "b"}, "docs") + usage := f.Usage() + if usage != "docs (possible values: [a, b])" { + t.Errorf("Expected usage 'docs (possible values: [a, b])', got %q", usage) + } +} + +func TestStringEnumSliceFlag_UnknownDefaultOpenAPI(t *testing.T) { + f := StringEnumSliceFlag("test", []string{"a", "unknown_default_open_api", "b"}, "docs") + usage := f.Usage() + if usage != "docs (possible values: [a, b])" { + t.Errorf("Expected unknown_default_open_api to be filtered out, got %q", usage) + } +} + +func TestStringEnumSliceFlag_Register(t *testing.T) { + cmd := &cobra.Command{Use: "test"} + f := StringEnumSliceFlag("my-flag", []string{"a", "b"}, "docs") + f.Register(cmd) + + flag := cmd.Flags().Lookup("my-flag") + if flag == nil { + t.Fatalf("Expected flag 'my-flag' to be registered") + } + if flag.Usage != "docs (possible values: [a, b])" { + t.Errorf("Expected flag usage to be set correctly") + } +} diff --git a/internal/pkg/services/vpn/client/client.go b/internal/pkg/services/vpn/client/client.go new file mode 100644 index 000000000..9eee90830 --- /dev/null +++ b/internal/pkg/services/vpn/client/client.go @@ -0,0 +1,14 @@ +package client + +import ( + "github.com/spf13/viper" + vpn "github.com/stackitcloud/stackit-sdk-go/services/vpn/v1api" + + "github.com/stackitcloud/stackit-cli/internal/pkg/config" + genericclient "github.com/stackitcloud/stackit-cli/internal/pkg/generic-client" + "github.com/stackitcloud/stackit-cli/internal/pkg/print" +) + +func ConfigureClient(p *print.Printer, cliVersion string) (*vpn.APIClient, error) { + return genericclient.ConfigureClientGeneric(p, cliVersion, viper.GetString(config.VPNCustomEndpointKey), false, vpn.NewAPIClient) +} diff --git a/internal/pkg/utils/strings.go b/internal/pkg/utils/strings.go index 64817f4ee..8772e38af 100644 --- a/internal/pkg/utils/strings.go +++ b/internal/pkg/utils/strings.go @@ -47,11 +47,24 @@ func JoinStringMap(m map[string]string, keyValueSeparator, separator string) str // JoinStringPtr concatenates the strings of a string slice pointer, each separatore by the // [sep] string. -func JoinStringPtr(vals *[]string, sep string) string { +func JoinStringPtr[T ~string](vals *[]T, sep string) string { if vals == nil || len(*vals) == 0 { return "" } - return strings.Join(*vals, sep) + deref := *vals + switch len(deref) { + case 0: + return "" + case 1: + return string(deref[0]) + } + var b strings.Builder + b.WriteString(string(deref[0])) + for _, s := range deref[1:] { + b.WriteString(sep) + b.WriteString(string(s)) + } + return b.String() } // Truncate trims the passed string (if it is not nil). If the input string is From 23b629299c5f2cb27db089aa727ae60482372352 Mon Sep 17 00:00:00 2001 From: Jan Obernberger <52105660+j1n-o9r@users.noreply.github.com> Date: Mon, 15 Jun 2026 09:51:18 +0200 Subject: [PATCH 02/44] chore(load-balancer): sdk migration (#1432) relates to STACKITCLI-365 --- docs/stackit_load-balancer_create.md | 2 +- .../stackit_load-balancer_generate-payload.md | 2 +- docs/stackit_load-balancer_update.md | 2 +- go.mod | 2 +- go.sum | 4 +- internal/cmd/load-balancer/create/create.go | 10 +- .../cmd/load-balancer/create/create_test.go | 36 ++--- internal/cmd/load-balancer/delete/delete.go | 8 +- .../cmd/load-balancer/delete/delete_test.go | 8 +- .../cmd/load-balancer/describe/describe.go | 22 +-- .../load-balancer/describe/describe_test.go | 8 +- .../generate-payload/generate_payload.go | 32 ++-- .../generate-payload/generate_payload_test.go | 30 ++-- internal/cmd/load-balancer/list/list.go | 10 +- internal/cmd/load-balancer/list/list_test.go | 8 +- .../observability-credentials/add/add.go | 4 +- .../observability-credentials/add/add_test.go | 10 +- .../cleanup/cleanup.go | 10 +- .../cleanup/cleanup_test.go | 12 +- .../delete/delete.go | 6 +- .../delete/delete_test.go | 8 +- .../describe/describe.go | 4 +- .../describe/describe_test.go | 8 +- .../observability-credentials/list/list.go | 8 +- .../list/list_test.go | 8 +- .../update/update.go | 12 +- .../update/update_test.go | 37 ++--- internal/cmd/load-balancer/quota/quota.go | 6 +- .../cmd/load-balancer/quota/quota_test.go | 8 +- .../target-pool/add-target/add_target.go | 6 +- .../target-pool/add-target/add_target_test.go | 85 +++++------ .../target-pool/describe/describe.go | 14 +- .../target-pool/describe/describe_test.go | 8 +- .../remove-target/remove_target.go | 8 +- .../remove-target/remove_target_test.go | 72 +++++---- internal/cmd/load-balancer/update/update.go | 6 +- .../cmd/load-balancer/update/update_test.go | 38 ++--- .../services/load-balancer/client/client.go | 4 +- .../pkg/services/load-balancer/utils/utils.go | 48 +++--- .../load-balancer/utils/utils_test.go | 140 +++++++++--------- 40 files changed, 368 insertions(+), 386 deletions(-) diff --git a/docs/stackit_load-balancer_create.md b/docs/stackit_load-balancer_create.md index 4172ccb4d..2f1e303ce 100644 --- a/docs/stackit_load-balancer_create.md +++ b/docs/stackit_load-balancer_create.md @@ -6,7 +6,7 @@ Creates a Load Balancer Creates a Load Balancer. The payload can be provided as a JSON string or a file path prefixed with "@". -See https://docs.api.stackit.cloud/documentation/load-balancer/version/v1#tag/Load-Balancer/operation/APIService_CreateLoadBalancer for information regarding the payload structure. +See https://docs.api.stackit.cloud/documentation/load-balancer/version/v2#tag/Load-Balancer/operation/APIService_CreateLoadBalancer for information regarding the payload structure. ``` stackit load-balancer create [flags] diff --git a/docs/stackit_load-balancer_generate-payload.md b/docs/stackit_load-balancer_generate-payload.md index 2cf2b15c7..0dbc9b457 100644 --- a/docs/stackit_load-balancer_generate-payload.md +++ b/docs/stackit_load-balancer_generate-payload.md @@ -5,7 +5,7 @@ Generates a payload to create/update a Load Balancer ### Synopsis Generates a JSON payload with values to be used as --payload input for load balancer creation or update. -See https://docs.api.stackit.cloud/documentation/load-balancer/version/v1#tag/Load-Balancer/operation/APIService_CreateLoadBalancer for information regarding the payload structure. +See https://docs.api.stackit.cloud/documentation/load-balancer/version/v2#tag/Load-Balancer/operation/APIService_CreateLoadBalancer for information regarding the payload structure. ``` stackit load-balancer generate-payload [flags] diff --git a/docs/stackit_load-balancer_update.md b/docs/stackit_load-balancer_update.md index fc577b35b..c80707cca 100644 --- a/docs/stackit_load-balancer_update.md +++ b/docs/stackit_load-balancer_update.md @@ -6,7 +6,7 @@ Updates a Load Balancer Updates a load balancer. The payload can be provided as a JSON string or a file path prefixed with "@". -See https://docs.api.stackit.cloud/documentation/load-balancer/version/v1#tag/Load-Balancer/operation/APIService_UpdateLoadBalancer for information regarding the payload structure. +See https://docs.api.stackit.cloud/documentation/load-balancer/version/v2#tag/Load-Balancer/operation/APIService_UpdateLoadBalancer for information regarding the payload structure. ``` stackit load-balancer update LOAD_BALANCER_NAME [flags] diff --git a/go.mod b/go.mod index f1a464268..80338dc54 100644 --- a/go.mod +++ b/go.mod @@ -266,7 +266,7 @@ require ( github.com/spf13/afero v1.15.0 // indirect github.com/spf13/cast v1.10.0 // indirect github.com/stackitcloud/stackit-sdk-go/services/kms v1.3.2 - github.com/stackitcloud/stackit-sdk-go/services/loadbalancer v1.8.0 + github.com/stackitcloud/stackit-sdk-go/services/loadbalancer v1.14.0 github.com/stackitcloud/stackit-sdk-go/services/logme v0.25.6 github.com/stackitcloud/stackit-sdk-go/services/mariadb v0.25.6 github.com/stackitcloud/stackit-sdk-go/services/objectstorage v1.7.0 diff --git a/go.sum b/go.sum index ca418c039..f9f2fe20e 100644 --- a/go.sum +++ b/go.sum @@ -614,8 +614,8 @@ github.com/stackitcloud/stackit-sdk-go/services/intake v0.7.1 h1:7ZSrwps/zI41rl+ github.com/stackitcloud/stackit-sdk-go/services/intake v0.7.1/go.mod h1:ZIvwBZwEMFO+YfJLCNXqabslI0Fp9zxV7ZBwlZjk7uE= github.com/stackitcloud/stackit-sdk-go/services/kms v1.3.2 h1:2ulSL2IkIAKND59eAjbEhVkOoBMyvm48ojwz1a3t0U0= github.com/stackitcloud/stackit-sdk-go/services/kms v1.3.2/go.mod h1:cuIaMMiHeHQsbvy7BOFMutoV3QtN+ZBx7Tg3GmYUw7s= -github.com/stackitcloud/stackit-sdk-go/services/loadbalancer v1.8.0 h1:DxrN85V738CRLynu6MULQHO+OXyYnkhVPgoZKULfFIs= -github.com/stackitcloud/stackit-sdk-go/services/loadbalancer v1.8.0/go.mod h1:ClPE4TOM1FeaJiwTXvApq4gWaSgTLq6nU3PPHAIQDN4= +github.com/stackitcloud/stackit-sdk-go/services/loadbalancer v1.14.0 h1:1dvL7tX91ziklayQmOupniE3jM4D5Nbtc0auNcx2p18= +github.com/stackitcloud/stackit-sdk-go/services/loadbalancer v1.14.0/go.mod h1:+Ld3dn648I+YKcBV3fEkYpDSr3fel421+LurJGywSBs= github.com/stackitcloud/stackit-sdk-go/services/logme v0.25.6 h1:4x30lC+YBmo7XpsAzTn0W+C/oP5flnLVgIh5u3O/P0o= github.com/stackitcloud/stackit-sdk-go/services/logme v0.25.6/go.mod h1:ewaYUiZcBTSS6urE5zEJBPCqxu70w2IjnBHCvnKdFKE= github.com/stackitcloud/stackit-sdk-go/services/logs v0.5.2 h1:vr4atxFRT+EL+DqONMT5R44f7AzEMbePa9U7PEE0THU= diff --git a/internal/cmd/load-balancer/create/create.go b/internal/cmd/load-balancer/create/create.go index 47d479c8a..bf44700e7 100644 --- a/internal/cmd/load-balancer/create/create.go +++ b/internal/cmd/load-balancer/create/create.go @@ -9,8 +9,8 @@ import ( "github.com/google/uuid" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/loadbalancer" - "github.com/stackitcloud/stackit-sdk-go/services/loadbalancer/wait" + loadbalancer "github.com/stackitcloud/stackit-sdk-go/services/loadbalancer/v2api" + "github.com/stackitcloud/stackit-sdk-go/services/loadbalancer/v2api/wait" "github.com/stackitcloud/stackit-cli/internal/pkg/args" "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -44,7 +44,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { Long: fmt.Sprintf("%s\n%s\n%s", "Creates a Load Balancer.", "The payload can be provided as a JSON string or a file path prefixed with \"@\".", - "See https://docs.api.stackit.cloud/documentation/load-balancer/version/v1#tag/Load-Balancer/operation/APIService_CreateLoadBalancer for information regarding the payload structure.", + "See https://docs.api.stackit.cloud/documentation/load-balancer/version/v2#tag/Load-Balancer/operation/APIService_CreateLoadBalancer for information regarding the payload structure.", ), Args: args.NoArgs, Example: examples.Build( @@ -95,7 +95,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { // Wait for async operation, if async mode not enabled if !model.Async { err := spinner.Run(params.Printer, "Creating load balancer", func() error { - _, err = wait.CreateLoadBalancerWaitHandler(ctx, apiClient, model.ProjectId, model.Region, *model.Payload.Name).WaitWithContext(ctx) + _, err = wait.CreateLoadBalancerWaitHandler(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, *model.Payload.Name).WaitWithContext(ctx) return err }) if err != nil { @@ -148,7 +148,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, } func buildRequest(ctx context.Context, model *inputModel, apiClient *loadbalancer.APIClient) loadbalancer.ApiCreateLoadBalancerRequest { - req := apiClient.CreateLoadBalancer(ctx, model.ProjectId, model.Region) + req := apiClient.DefaultAPI.CreateLoadBalancer(ctx, model.ProjectId, model.Region) req = req.CreateLoadBalancerPayload(*model.Payload) req = req.XRequestID(xRequestId) return req diff --git a/internal/cmd/load-balancer/create/create_test.go b/internal/cmd/load-balancer/create/create_test.go index ac22f6c6d..ed54198d1 100644 --- a/internal/cmd/load-balancer/create/create_test.go +++ b/internal/cmd/load-balancer/create/create_test.go @@ -4,7 +4,7 @@ import ( "context" "testing" - "github.com/stackitcloud/stackit-sdk-go/services/loadbalancer" + loadbalancer "github.com/stackitcloud/stackit-sdk-go/services/loadbalancer/v2api" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/testutils" @@ -23,7 +23,7 @@ type testCtxKey struct{} var ( testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") - testClient = &loadbalancer.APIClient{} + testClient = &loadbalancer.APIClient{DefaultAPI: &loadbalancer.DefaultAPIService{}} testProjectId = uuid.NewString() testRequestId = xRequestId ) @@ -31,12 +31,12 @@ var ( var testPayload = &loadbalancer.CreateLoadBalancerPayload{ ExternalAddress: utils.Ptr(""), - Listeners: &[]loadbalancer.Listener{ + Listeners: []loadbalancer.Listener{ { DisplayName: utils.Ptr(""), - Port: utils.Ptr(int64(0)), - Protocol: loadbalancer.ListenerProtocol("").Ptr(), - ServerNameIndicators: &[]loadbalancer.ServerNameIndicator{ + Port: utils.Ptr(int32(0)), + Protocol: loadbalancer.ListenerProtocol("unknown_default_open_api").Ptr(), + ServerNameIndicators: []loadbalancer.ServerNameIndicator{ { Name: utils.Ptr(""), }, @@ -51,15 +51,15 @@ var testPayload = &loadbalancer.CreateLoadBalancerPayload{ }, }, Name: utils.Ptr(""), - Networks: &[]loadbalancer.Network{ + Networks: []loadbalancer.Network{ { NetworkId: utils.Ptr(""), - Role: loadbalancer.NetworkRole("").Ptr(), + Role: loadbalancer.NetworkRole("unknown_default_open_api").Ptr(), }, }, Options: &loadbalancer.LoadBalancerOptions{ AccessControl: &loadbalancer.LoadbalancerOptionAccessControl{ - AllowedSourceRanges: &[]string{ + AllowedSourceRanges: []string{ "", }, }, @@ -76,21 +76,21 @@ var testPayload = &loadbalancer.CreateLoadBalancerPayload{ }, PrivateNetworkOnly: utils.Ptr(false), }, - TargetPools: &[]loadbalancer.TargetPool{ + TargetPools: []loadbalancer.TargetPool{ { ActiveHealthCheck: &loadbalancer.ActiveHealthCheck{ - HealthyThreshold: utils.Ptr(int64(0)), + HealthyThreshold: utils.Ptr(int32(0)), Interval: utils.Ptr(""), IntervalJitter: utils.Ptr(""), Timeout: utils.Ptr(""), - UnhealthyThreshold: utils.Ptr(int64(0)), + UnhealthyThreshold: utils.Ptr(int32(0)), }, Name: utils.Ptr(""), SessionPersistence: &loadbalancer.SessionPersistence{ UseSourceIpAddress: utils.Ptr(false), }, - TargetPort: utils.Ptr(int64(0)), - Targets: &[]loadbalancer.Target{ + TargetPort: utils.Ptr(int32(0)), + Targets: []loadbalancer.Target{ { DisplayName: utils.Ptr(""), Ip: utils.Ptr(""), @@ -197,7 +197,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *loadbalancer.ApiCreateLoadBalancerRequest)) loadbalancer.ApiCreateLoadBalancerRequest { - request := testClient.CreateLoadBalancer(testCtx, testProjectId, testRegion) + request := testClient.DefaultAPI.CreateLoadBalancer(testCtx, testProjectId, testRegion) request = request.CreateLoadBalancerPayload(*testPayload) request = request.XRequestID(testRequestId) for _, mod := range mods { @@ -277,7 +277,9 @@ func TestParseInput(t *testing.T) { for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { - testutils.TestParseInput(t, NewCmd, parseInput, tt.expectedModel, tt.argValues, tt.flagValues, tt.isValid) + testutils.TestParseInputWithOptions(t, NewCmd, parseInput, tt.expectedModel, tt.argValues, tt.flagValues, nil, tt.isValid, []testutils.TestingOption{ + testutils.WithCmpOptions(cmpopts.EquateEmpty()), + }) }) } } @@ -302,7 +304,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, loadbalancer.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/load-balancer/delete/delete.go b/internal/cmd/load-balancer/delete/delete.go index c60100607..efc79b0fd 100644 --- a/internal/cmd/load-balancer/delete/delete.go +++ b/internal/cmd/load-balancer/delete/delete.go @@ -15,8 +15,8 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/spinner" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/loadbalancer" - "github.com/stackitcloud/stackit-sdk-go/services/loadbalancer/wait" + loadbalancer "github.com/stackitcloud/stackit-sdk-go/services/loadbalancer/v2api" + "github.com/stackitcloud/stackit-sdk-go/services/loadbalancer/v2api/wait" ) const ( @@ -67,7 +67,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { // Wait for async operation, if async mode not enabled if !model.Async { err := spinner.Run(params.Printer, "Deleting load balancer", func() error { - _, err = wait.DeleteLoadBalancerWaitHandler(ctx, apiClient, model.ProjectId, model.Region, model.LoadBalancerName).WaitWithContext(ctx) + _, err = wait.DeleteLoadBalancerWaitHandler(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, model.LoadBalancerName).WaitWithContext(ctx) return err }) if err != nil { @@ -104,6 +104,6 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *loadbalancer.APIClient) loadbalancer.ApiDeleteLoadBalancerRequest { - req := apiClient.DeleteLoadBalancer(ctx, model.ProjectId, model.Region, model.LoadBalancerName) + req := apiClient.DefaultAPI.DeleteLoadBalancer(ctx, model.ProjectId, model.Region, model.LoadBalancerName) return req } diff --git a/internal/cmd/load-balancer/delete/delete_test.go b/internal/cmd/load-balancer/delete/delete_test.go index 61e9a941b..8842ca890 100644 --- a/internal/cmd/load-balancer/delete/delete_test.go +++ b/internal/cmd/load-balancer/delete/delete_test.go @@ -10,7 +10,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/loadbalancer" + loadbalancer "github.com/stackitcloud/stackit-sdk-go/services/loadbalancer/v2api" ) const ( @@ -20,7 +20,7 @@ const ( type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &loadbalancer.APIClient{} +var testClient = &loadbalancer.APIClient{DefaultAPI: &loadbalancer.DefaultAPIService{}} var testProjectId = uuid.NewString() var testLoadBalancerName = "loadBalancer" @@ -61,7 +61,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *loadbalancer.ApiDeleteLoadBalancerRequest)) loadbalancer.ApiDeleteLoadBalancerRequest { - request := testClient.DeleteLoadBalancer(testCtx, testProjectId, testRegion, testLoadBalancerName) + request := testClient.DefaultAPI.DeleteLoadBalancer(testCtx, testProjectId, testRegion, testLoadBalancerName) for _, mod := range mods { mod(&request) } @@ -155,7 +155,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, loadbalancer.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/load-balancer/describe/describe.go b/internal/cmd/load-balancer/describe/describe.go index 5cdffce6a..a4fb843cc 100644 --- a/internal/cmd/load-balancer/describe/describe.go +++ b/internal/cmd/load-balancer/describe/describe.go @@ -17,7 +17,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/loadbalancer" + loadbalancer "github.com/stackitcloud/stackit-sdk-go/services/loadbalancer/v2api" ) const ( @@ -86,7 +86,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *loadbalancer.APIClient) loadbalancer.ApiGetLoadBalancerRequest { - req := apiClient.GetLoadBalancer(ctx, model.ProjectId, model.Region, model.LoadBalancerName) + req := apiClient.DefaultAPI.GetLoadBalancer(ctx, model.ProjectId, model.Region, model.LoadBalancerName) return req } @@ -100,10 +100,10 @@ func outputResult(p *print.Printer, outputFormat string, loadBalancer *loadbalan content = append(content, buildLoadBalancerTable(loadBalancer)) if loadBalancer.Listeners != nil { - content = append(content, buildListenersTable(*loadBalancer.Listeners)) + content = append(content, buildListenersTable(loadBalancer.Listeners)) } if loadBalancer.TargetPools != nil { - content = append(content, buildTargetPoolsTable(*loadBalancer.TargetPools)) + content = append(content, buildTargetPoolsTable(loadBalancer.TargetPools)) } err := tables.DisplayTables(p, content) @@ -120,7 +120,7 @@ func buildLoadBalancerTable(loadBalancer *loadbalancer.LoadBalancer) tables.Tabl privateAccessOnly := false if loadBalancer.Options != nil { if loadBalancer.Options.AccessControl != nil && loadBalancer.Options.AccessControl.AllowedSourceRanges != nil { - acl = *loadBalancer.Options.AccessControl.AllowedSourceRanges + acl = loadBalancer.Options.AccessControl.AllowedSourceRanges } if loadBalancer.Options.PrivateNetworkOnly != nil { @@ -129,16 +129,16 @@ func buildLoadBalancerTable(loadBalancer *loadbalancer.LoadBalancer) tables.Tabl } networkId := "-" - if loadBalancer.Networks != nil && len(*loadBalancer.Networks) > 0 { - networks := *loadBalancer.Networks + if len(loadBalancer.Networks) > 0 { + networks := loadBalancer.Networks networkId = *networks[0].NetworkId } externalAddress := utils.PtrStringDefault(loadBalancer.ExternalAddress, "-") - errorDescriptions := []string{} - if loadBalancer.Errors != nil && len((*loadBalancer.Errors)) > 0 { - for _, err := range *loadBalancer.Errors { + var errorDescriptions []string + if len(loadBalancer.Errors) > 0 { + for _, err := range loadBalancer.Errors { errorDescriptions = append(errorDescriptions, *err.Description) } } @@ -184,7 +184,7 @@ func buildTargetPoolsTable(targetPools []loadbalancer.TargetPool) tables.Table { table.SetTitle("Target Pools") table.SetHeader("NAME", "PORT", "TARGETS") for _, targetPool := range targetPools { - table.AddRow(utils.PtrString(targetPool.Name), utils.PtrString(targetPool.TargetPort), len(*targetPool.Targets)) + table.AddRow(utils.PtrString(targetPool.Name), utils.PtrString(targetPool.TargetPort), len(targetPool.Targets)) } return table } diff --git a/internal/cmd/load-balancer/describe/describe_test.go b/internal/cmd/load-balancer/describe/describe_test.go index 7fee82f98..9547ed15e 100644 --- a/internal/cmd/load-balancer/describe/describe_test.go +++ b/internal/cmd/load-balancer/describe/describe_test.go @@ -7,7 +7,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/loadbalancer" + loadbalancer "github.com/stackitcloud/stackit-sdk-go/services/loadbalancer/v2api" "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" @@ -23,7 +23,7 @@ const ( type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &loadbalancer.APIClient{} +var testClient = &loadbalancer.APIClient{DefaultAPI: &loadbalancer.DefaultAPIService{}} var testProjectId = uuid.NewString() func fixtureArgValues(mods ...func(argValues []string)) []string { @@ -63,7 +63,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *loadbalancer.ApiGetLoadBalancerRequest)) loadbalancer.ApiGetLoadBalancerRequest { - request := testClient.GetLoadBalancer(testCtx, testProjectId, testRegion, testloadBalancerName) + request := testClient.DefaultAPI.GetLoadBalancer(testCtx, testProjectId, testRegion, testloadBalancerName) for _, mod := range mods { mod(&request) } @@ -157,7 +157,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, loadbalancer.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/load-balancer/generate-payload/generate_payload.go b/internal/cmd/load-balancer/generate-payload/generate_payload.go index 0170fcbe9..5fe97b3c5 100644 --- a/internal/cmd/load-balancer/generate-payload/generate_payload.go +++ b/internal/cmd/load-balancer/generate-payload/generate_payload.go @@ -7,7 +7,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/types" - "github.com/stackitcloud/stackit-sdk-go/services/loadbalancer" + loadbalancer "github.com/stackitcloud/stackit-sdk-go/services/loadbalancer/v2api" "github.com/stackitcloud/stackit-cli/internal/pkg/args" "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -36,9 +36,9 @@ type inputModel struct { var ( defaultPayloadListener = &loadbalancer.Listener{ DisplayName: utils.Ptr(""), - Port: utils.Ptr(int64(0)), + Port: utils.Ptr(int32(0)), Protocol: loadbalancer.ListenerProtocol("").Ptr(), - ServerNameIndicators: &[]loadbalancer.ServerNameIndicator{ + ServerNameIndicators: []loadbalancer.ServerNameIndicator{ { Name: utils.Ptr(""), }, @@ -59,18 +59,18 @@ var ( defaultPayloadTargetPool = &loadbalancer.TargetPool{ ActiveHealthCheck: &loadbalancer.ActiveHealthCheck{ - HealthyThreshold: utils.Ptr(int64(0)), + HealthyThreshold: utils.Ptr(int32(0)), Interval: utils.Ptr(""), IntervalJitter: utils.Ptr(""), Timeout: utils.Ptr(""), - UnhealthyThreshold: utils.Ptr(int64(0)), + UnhealthyThreshold: utils.Ptr(int32(0)), }, Name: utils.Ptr(""), SessionPersistence: &loadbalancer.SessionPersistence{ UseSourceIpAddress: utils.Ptr(false), }, - TargetPort: utils.Ptr(int64(0)), - Targets: &[]loadbalancer.Target{ + TargetPort: utils.Ptr(int32(0)), + Targets: []loadbalancer.Target{ { DisplayName: utils.Ptr(""), Ip: utils.Ptr(""), @@ -80,16 +80,16 @@ var ( DefaultCreateLoadBalancerPayload = loadbalancer.CreateLoadBalancerPayload{ ExternalAddress: utils.Ptr(""), - Listeners: &[]loadbalancer.Listener{ + Listeners: []loadbalancer.Listener{ *defaultPayloadListener, }, Name: utils.Ptr(""), - Networks: &[]loadbalancer.Network{ + Networks: []loadbalancer.Network{ *defaultPayloadNetwork, }, Options: &loadbalancer.LoadBalancerOptions{ AccessControl: &loadbalancer.LoadbalancerOptionAccessControl{ - AllowedSourceRanges: &[]string{ + AllowedSourceRanges: []string{ "", }, }, @@ -106,7 +106,7 @@ var ( }, PrivateNetworkOnly: utils.Ptr(false), }, - TargetPools: &[]loadbalancer.TargetPool{ + TargetPools: []loadbalancer.TargetPool{ *defaultPayloadTargetPool, }, } @@ -118,7 +118,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { Short: "Generates a payload to create/update a Load Balancer", Long: fmt.Sprintf("%s\n%s", "Generates a JSON payload with values to be used as --payload input for load balancer creation or update.", - "See https://docs.api.stackit.cloud/documentation/load-balancer/version/v1#tag/Load-Balancer/operation/APIService_CreateLoadBalancer for information regarding the payload structure.", + "See https://docs.api.stackit.cloud/documentation/load-balancer/version/v2#tag/Load-Balancer/operation/APIService_CreateLoadBalancer for information regarding the payload structure.", ), Args: args.NoArgs, Example: examples.Build( @@ -203,7 +203,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, } func buildRequest(ctx context.Context, model *inputModel, apiClient *loadbalancer.APIClient) loadbalancer.ApiGetLoadBalancerRequest { - req := apiClient.GetLoadBalancer(ctx, model.ProjectId, model.Region, *model.LoadBalancerName) + req := apiClient.DefaultAPI.GetLoadBalancer(ctx, model.ProjectId, model.Region, *model.LoadBalancerName) return req } @@ -249,12 +249,12 @@ func outputUpdateResult(p *print.Printer, filePath *string, payload *loadbalance return nil } -func modifyListener(resp *loadbalancer.LoadBalancer) *[]loadbalancer.Listener { - listeners := *resp.Listeners +func modifyListener(resp *loadbalancer.LoadBalancer) []loadbalancer.Listener { + listeners := resp.Listeners for i := range listeners { listeners[i].Name = nil } - return &listeners + return listeners } diff --git a/internal/cmd/load-balancer/generate-payload/generate_payload_test.go b/internal/cmd/load-balancer/generate-payload/generate_payload_test.go index 8728b5686..8e72d149f 100644 --- a/internal/cmd/load-balancer/generate-payload/generate_payload_test.go +++ b/internal/cmd/load-balancer/generate-payload/generate_payload_test.go @@ -9,7 +9,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/loadbalancer" + loadbalancer "github.com/stackitcloud/stackit-sdk-go/services/loadbalancer/v2api" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/testutils" @@ -23,7 +23,7 @@ const ( type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &loadbalancer.APIClient{} +var testClient = &loadbalancer.APIClient{DefaultAPI: &loadbalancer.DefaultAPIService{}} var testProjectId = uuid.NewString() const ( @@ -61,7 +61,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *loadbalancer.ApiGetLoadBalancerRequest)) loadbalancer.ApiGetLoadBalancerRequest { - request := testClient.GetLoadBalancer(testCtx, testProjectId, testRegion, testLoadBalancerName) + request := testClient.DefaultAPI.GetLoadBalancer(testCtx, testProjectId, testRegion, testLoadBalancerName) for _, mod := range mods { mod(&request) } @@ -160,7 +160,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, loadbalancer.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) @@ -173,18 +173,18 @@ func TestModifyListeners(t *testing.T) { tests := []struct { description string response *loadbalancer.LoadBalancer - expected *[]loadbalancer.Listener + expected []loadbalancer.Listener }{ { description: "base", response: &loadbalancer.LoadBalancer{ - Listeners: &[]loadbalancer.Listener{ + Listeners: []loadbalancer.Listener{ { DisplayName: utils.Ptr(""), - Port: utils.Ptr(int64(0)), + Port: utils.Ptr(int32(0)), Protocol: loadbalancer.ListenerProtocol("").Ptr(), Name: utils.Ptr(""), - ServerNameIndicators: &[]loadbalancer.ServerNameIndicator{ + ServerNameIndicators: []loadbalancer.ServerNameIndicator{ { Name: utils.Ptr(""), }, @@ -199,10 +199,10 @@ func TestModifyListeners(t *testing.T) { }, { DisplayName: utils.Ptr(""), - Port: utils.Ptr(int64(0)), + Port: utils.Ptr(int32(0)), Protocol: loadbalancer.ListenerProtocol("").Ptr(), Name: utils.Ptr(""), - ServerNameIndicators: &[]loadbalancer.ServerNameIndicator{ + ServerNameIndicators: []loadbalancer.ServerNameIndicator{ { Name: utils.Ptr(""), }, @@ -217,13 +217,13 @@ func TestModifyListeners(t *testing.T) { }, }, }, - expected: &[]loadbalancer.Listener{ + expected: []loadbalancer.Listener{ { DisplayName: utils.Ptr(""), - Port: utils.Ptr(int64(0)), + Port: utils.Ptr(int32(0)), Protocol: loadbalancer.ListenerProtocol("").Ptr(), Name: nil, - ServerNameIndicators: &[]loadbalancer.ServerNameIndicator{ + ServerNameIndicators: []loadbalancer.ServerNameIndicator{ { Name: utils.Ptr(""), }, @@ -238,10 +238,10 @@ func TestModifyListeners(t *testing.T) { }, { DisplayName: utils.Ptr(""), - Port: utils.Ptr(int64(0)), + Port: utils.Ptr(int32(0)), Protocol: loadbalancer.ListenerProtocol("").Ptr(), Name: nil, - ServerNameIndicators: &[]loadbalancer.ServerNameIndicator{ + ServerNameIndicators: []loadbalancer.ServerNameIndicator{ { Name: utils.Ptr(""), }, diff --git a/internal/cmd/load-balancer/list/list.go b/internal/cmd/load-balancer/list/list.go index 73a091579..4ff11e958 100644 --- a/internal/cmd/load-balancer/list/list.go +++ b/internal/cmd/load-balancer/list/list.go @@ -18,7 +18,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/loadbalancer" + loadbalancer "github.com/stackitcloud/stackit-sdk-go/services/loadbalancer/v2api" ) const ( @@ -67,7 +67,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return fmt.Errorf("get load balancers: %w", err) } - loadBalancers := utils.GetSliceFromPointer(resp.LoadBalancers) + loadBalancers := resp.LoadBalancers projectLabel, err := projectname.GetProjectName(ctx, params.Printer, params.CliVersion, cmd) if err != nil { @@ -116,7 +116,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, } func buildRequest(ctx context.Context, model *inputModel, apiClient *loadbalancer.APIClient) loadbalancer.ApiListLoadBalancersRequest { - req := apiClient.ListLoadBalancers(ctx, model.ProjectId, model.Region) + req := apiClient.DefaultAPI.ListLoadBalancers(ctx, model.ProjectId, model.Region) return req } @@ -132,10 +132,10 @@ func outputResult(p *print.Printer, outputFormat, projectLabel string, loadBalan l := loadBalancers[i] var numListeners, numTargetPools int if l.Listeners != nil { - numListeners = len(*l.Listeners) + numListeners = len(l.Listeners) } if l.TargetPools != nil { - numTargetPools = len(*l.TargetPools) + numTargetPools = len(l.TargetPools) } externalAddress := utils.PtrStringDefault(l.ExternalAddress, "-") diff --git a/internal/cmd/load-balancer/list/list_test.go b/internal/cmd/load-balancer/list/list_test.go index 77b7caeed..024f6d551 100644 --- a/internal/cmd/load-balancer/list/list_test.go +++ b/internal/cmd/load-balancer/list/list_test.go @@ -7,7 +7,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/loadbalancer" + loadbalancer "github.com/stackitcloud/stackit-sdk-go/services/loadbalancer/v2api" "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" @@ -23,7 +23,7 @@ const ( type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &loadbalancer.APIClient{} +var testClient = &loadbalancer.APIClient{DefaultAPI: &loadbalancer.DefaultAPIService{}} var testProjectId = uuid.NewString() func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string { @@ -54,7 +54,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *loadbalancer.ApiListLoadBalancersRequest)) loadbalancer.ApiListLoadBalancersRequest { - request := testClient.ListLoadBalancers(testCtx, testProjectId, testRegion) + request := testClient.DefaultAPI.ListLoadBalancers(testCtx, testProjectId, testRegion) for _, mod := range mods { mod(&request) } @@ -143,7 +143,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, loadbalancer.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/load-balancer/observability-credentials/add/add.go b/internal/cmd/load-balancer/observability-credentials/add/add.go index f37491852..3a02d1d28 100644 --- a/internal/cmd/load-balancer/observability-credentials/add/add.go +++ b/internal/cmd/load-balancer/observability-credentials/add/add.go @@ -19,7 +19,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/loadbalancer" + loadbalancer "github.com/stackitcloud/stackit-sdk-go/services/loadbalancer/v2api" ) const ( @@ -116,7 +116,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, } func buildRequest(ctx context.Context, model *inputModel, apiClient *loadbalancer.APIClient) loadbalancer.ApiCreateCredentialsRequest { - req := apiClient.CreateCredentials(ctx, model.ProjectId, model.Region) + req := apiClient.DefaultAPI.CreateCredentials(ctx, model.ProjectId, model.Region) req = req.XRequestID(uuid.NewString()) req = req.CreateCredentialsPayload(loadbalancer.CreateCredentialsPayload{ diff --git a/internal/cmd/load-balancer/observability-credentials/add/add_test.go b/internal/cmd/load-balancer/observability-credentials/add/add_test.go index cac2ff1d4..8cd8007c5 100644 --- a/internal/cmd/load-balancer/observability-credentials/add/add_test.go +++ b/internal/cmd/load-balancer/observability-credentials/add/add_test.go @@ -7,7 +7,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/loadbalancer" + loadbalancer "github.com/stackitcloud/stackit-sdk-go/services/loadbalancer/v2api" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" @@ -22,7 +22,7 @@ const ( type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &loadbalancer.APIClient{} +var testClient = &loadbalancer.APIClient{DefaultAPI: &loadbalancer.DefaultAPIService{}} var testProjectId = uuid.NewString() func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string { @@ -57,7 +57,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *loadbalancer.ApiCreateCredentialsRequest)) loadbalancer.ApiCreateCredentialsRequest { - request := testClient.CreateCredentials(testCtx, testProjectId, testRegion) + request := testClient.DefaultAPI.CreateCredentials(testCtx, testProjectId, testRegion) request = request.CreateCredentialsPayload(loadbalancer.CreateCredentialsPayload{ DisplayName: utils.Ptr("name"), Username: utils.Ptr("username"), @@ -151,8 +151,8 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), - cmpopts.IgnoreFields(loadbalancer.CreateCredentialsRequest{}, "xRequestID"), + cmpopts.EquateComparable(testCtx, loadbalancer.DefaultAPIService{}), + cmpopts.IgnoreFields(loadbalancer.ApiCreateCredentialsRequest{}, "xRequestID"), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/load-balancer/observability-credentials/cleanup/cleanup.go b/internal/cmd/load-balancer/observability-credentials/cleanup/cleanup.go index 35e123ee3..756163db6 100644 --- a/internal/cmd/load-balancer/observability-credentials/cleanup/cleanup.go +++ b/internal/cmd/load-balancer/observability-credentials/cleanup/cleanup.go @@ -16,7 +16,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/services/load-balancer/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/loadbalancer" + loadbalancer "github.com/stackitcloud/stackit-sdk-go/services/loadbalancer/v2api" ) type inputModel struct { @@ -60,8 +60,8 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } var credentials []loadbalancer.CredentialsResponse - if resp.Credentials != nil && len(*resp.Credentials) > 0 { - credentials, err = utils.FilterCredentials(ctx, apiClient, *resp.Credentials, model.ProjectId, model.Region, utils.OP_FILTER_UNUSED) + if len(resp.Credentials) > 0 { + credentials, err = utils.FilterCredentials(ctx, apiClient.DefaultAPI, resp.Credentials, model.ProjectId, model.Region, utils.OP_FILTER_UNUSED) if err != nil { return fmt.Errorf("filter Load Balancer observability credentials: %w", err) } @@ -122,11 +122,11 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, } func buildDeleteCredentialRequest(ctx context.Context, model *inputModel, apiClient *loadbalancer.APIClient, credentialsRef string) loadbalancer.ApiDeleteCredentialsRequest { - req := apiClient.DeleteCredentials(ctx, model.ProjectId, model.Region, credentialsRef) + req := apiClient.DefaultAPI.DeleteCredentials(ctx, model.ProjectId, model.Region, credentialsRef) return req } func buildListCredentialsRequest(ctx context.Context, model *inputModel, apiClient *loadbalancer.APIClient) loadbalancer.ApiListCredentialsRequest { - req := apiClient.ListCredentials(ctx, model.ProjectId, model.Region) + req := apiClient.DefaultAPI.ListCredentials(ctx, model.ProjectId, model.Region) return req } diff --git a/internal/cmd/load-balancer/observability-credentials/cleanup/cleanup_test.go b/internal/cmd/load-balancer/observability-credentials/cleanup/cleanup_test.go index a081af49c..321312e4c 100644 --- a/internal/cmd/load-balancer/observability-credentials/cleanup/cleanup_test.go +++ b/internal/cmd/load-balancer/observability-credentials/cleanup/cleanup_test.go @@ -4,7 +4,7 @@ import ( "context" "testing" - "github.com/stackitcloud/stackit-sdk-go/services/loadbalancer" + loadbalancer "github.com/stackitcloud/stackit-sdk-go/services/loadbalancer/v2api" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/testutils" @@ -22,7 +22,7 @@ const ( type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &loadbalancer.APIClient{} +var testClient = &loadbalancer.APIClient{DefaultAPI: &loadbalancer.DefaultAPIService{}} var testProjectId = uuid.NewString() func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string { @@ -51,7 +51,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureDeleteCredentialRequest(mods ...func(request *loadbalancer.ApiDeleteCredentialsRequest)) loadbalancer.ApiDeleteCredentialsRequest { - request := testClient.DeleteCredentials(testCtx, testProjectId, testRegion, testCredentialsRef) + request := testClient.DefaultAPI.DeleteCredentials(testCtx, testProjectId, testRegion, testCredentialsRef) for _, mod := range mods { mod(&request) } @@ -59,7 +59,7 @@ func fixtureDeleteCredentialRequest(mods ...func(request *loadbalancer.ApiDelete } func fixtureListCredentialsRequest(mods ...func(request *loadbalancer.ApiListCredentialsRequest)) loadbalancer.ApiListCredentialsRequest { - request := testClient.ListCredentials(testCtx, testProjectId, testRegion) + request := testClient.DefaultAPI.ListCredentials(testCtx, testProjectId, testRegion) for _, mod := range mods { mod(&request) } @@ -140,7 +140,7 @@ func TestBuildDeleteCredentialRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, loadbalancer.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) @@ -168,7 +168,7 @@ func TestListCredentialsRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, loadbalancer.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/load-balancer/observability-credentials/delete/delete.go b/internal/cmd/load-balancer/observability-credentials/delete/delete.go index 4139f56db..0f50ade43 100644 --- a/internal/cmd/load-balancer/observability-credentials/delete/delete.go +++ b/internal/cmd/load-balancer/observability-credentials/delete/delete.go @@ -16,7 +16,7 @@ import ( loadbalancerUtils "github.com/stackitcloud/stackit-cli/internal/pkg/services/load-balancer/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/loadbalancer" + loadbalancer "github.com/stackitcloud/stackit-sdk-go/services/loadbalancer/v2api" ) const ( @@ -58,7 +58,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { projectLabel = model.ProjectId } - credentialsLabel, err := loadbalancerUtils.GetCredentialsDisplayName(ctx, apiClient, model.ProjectId, model.Region, model.CredentialsRef) + credentialsLabel, err := loadbalancerUtils.GetCredentialsDisplayName(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, model.CredentialsRef) if err != nil { params.Printer.Debug(print.ErrorLevel, "get observability credentials display name: %v", err) credentialsLabel = model.CredentialsRef @@ -102,6 +102,6 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *loadbalancer.APIClient) loadbalancer.ApiDeleteCredentialsRequest { - req := apiClient.DeleteCredentials(ctx, model.ProjectId, model.Region, model.CredentialsRef) + req := apiClient.DefaultAPI.DeleteCredentials(ctx, model.ProjectId, model.Region, model.CredentialsRef) return req } diff --git a/internal/cmd/load-balancer/observability-credentials/delete/delete_test.go b/internal/cmd/load-balancer/observability-credentials/delete/delete_test.go index 3a8675d10..80e359e2c 100644 --- a/internal/cmd/load-balancer/observability-credentials/delete/delete_test.go +++ b/internal/cmd/load-balancer/observability-credentials/delete/delete_test.go @@ -4,7 +4,7 @@ import ( "context" "testing" - "github.com/stackitcloud/stackit-sdk-go/services/loadbalancer" + loadbalancer "github.com/stackitcloud/stackit-sdk-go/services/loadbalancer/v2api" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/testutils" @@ -22,7 +22,7 @@ const ( type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &loadbalancer.APIClient{} +var testClient = &loadbalancer.APIClient{DefaultAPI: &loadbalancer.DefaultAPIService{}} var testProjectId = uuid.NewString() func fixtureArgValues(mods ...func(argValues []string)) []string { @@ -62,7 +62,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *loadbalancer.ApiDeleteCredentialsRequest)) loadbalancer.ApiDeleteCredentialsRequest { - request := testClient.DeleteCredentials(testCtx, testProjectId, testRegion, testCredentialsRef) + request := testClient.DefaultAPI.DeleteCredentials(testCtx, testProjectId, testRegion, testCredentialsRef) for _, mod := range mods { mod(&request) } @@ -160,7 +160,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, loadbalancer.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/load-balancer/observability-credentials/describe/describe.go b/internal/cmd/load-balancer/observability-credentials/describe/describe.go index 68a4af99c..244e1e1a0 100644 --- a/internal/cmd/load-balancer/observability-credentials/describe/describe.go +++ b/internal/cmd/load-balancer/observability-credentials/describe/describe.go @@ -16,7 +16,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/loadbalancer" + loadbalancer "github.com/stackitcloud/stackit-sdk-go/services/loadbalancer/v2api" ) const ( @@ -83,7 +83,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *loadbalancer.APIClient) loadbalancer.ApiGetCredentialsRequest { - req := apiClient.GetCredentials(ctx, model.ProjectId, model.Region, model.CredentialsRef) + req := apiClient.DefaultAPI.GetCredentials(ctx, model.ProjectId, model.Region, model.CredentialsRef) return req } diff --git a/internal/cmd/load-balancer/observability-credentials/describe/describe_test.go b/internal/cmd/load-balancer/observability-credentials/describe/describe_test.go index 39ac8a55d..9c1658c89 100644 --- a/internal/cmd/load-balancer/observability-credentials/describe/describe_test.go +++ b/internal/cmd/load-balancer/observability-credentials/describe/describe_test.go @@ -7,7 +7,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/loadbalancer" + loadbalancer "github.com/stackitcloud/stackit-sdk-go/services/loadbalancer/v2api" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" @@ -22,7 +22,7 @@ const ( type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &loadbalancer.APIClient{} +var testClient = &loadbalancer.APIClient{DefaultAPI: &loadbalancer.DefaultAPIService{}} var testProjectId = uuid.NewString() func fixtureArgValues(mods ...func(argValues []string)) []string { @@ -62,7 +62,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *loadbalancer.ApiGetCredentialsRequest)) loadbalancer.ApiGetCredentialsRequest { - request := testClient.GetCredentials(testCtx, testProjectId, testRegion, testCredentialsRef) + request := testClient.DefaultAPI.GetCredentials(testCtx, testProjectId, testRegion, testCredentialsRef) for _, mod := range mods { mod(&request) } @@ -160,7 +160,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, loadbalancer.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/load-balancer/observability-credentials/list/list.go b/internal/cmd/load-balancer/observability-credentials/list/list.go index dcc624339..db3a7394c 100644 --- a/internal/cmd/load-balancer/observability-credentials/list/list.go +++ b/internal/cmd/load-balancer/observability-credentials/list/list.go @@ -7,7 +7,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/types" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/loadbalancer" + loadbalancer "github.com/stackitcloud/stackit-sdk-go/services/loadbalancer/v2api" "github.com/stackitcloud/stackit-cli/internal/pkg/args" "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -85,14 +85,14 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return fmt.Errorf("list Load Balancer observability credentials: %w", err) } - credentials := utils.GetSliceFromPointer(resp.Credentials) + credentials := resp.Credentials filterOp, err := getFilterOp(model.Used, model.Unused) if err != nil { return err } - filteredCredentials, err := lbUtils.FilterCredentials(ctx, apiClient, credentials, model.ProjectId, model.Region, filterOp) + filteredCredentials, err := lbUtils.FilterCredentials(ctx, apiClient.DefaultAPI, credentials, model.ProjectId, model.Region, filterOp) if err != nil { return fmt.Errorf("filter credentials: %w", err) } @@ -153,7 +153,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, } func buildRequest(ctx context.Context, model *inputModel, apiClient *loadbalancer.APIClient) loadbalancer.ApiListCredentialsRequest { - req := apiClient.ListCredentials(ctx, model.ProjectId, model.Region) + req := apiClient.DefaultAPI.ListCredentials(ctx, model.ProjectId, model.Region) return req } diff --git a/internal/cmd/load-balancer/observability-credentials/list/list_test.go b/internal/cmd/load-balancer/observability-credentials/list/list_test.go index ef2d01c7c..a7fcd6abf 100644 --- a/internal/cmd/load-balancer/observability-credentials/list/list_test.go +++ b/internal/cmd/load-balancer/observability-credentials/list/list_test.go @@ -7,7 +7,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/loadbalancer" + loadbalancer "github.com/stackitcloud/stackit-sdk-go/services/loadbalancer/v2api" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" lbUtils "github.com/stackitcloud/stackit-cli/internal/pkg/services/load-balancer/utils" @@ -23,7 +23,7 @@ const ( type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &loadbalancer.APIClient{} +var testClient = &loadbalancer.APIClient{DefaultAPI: &loadbalancer.DefaultAPIService{}} var testProjectId = uuid.NewString() func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string { @@ -54,7 +54,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *loadbalancer.ApiListCredentialsRequest)) loadbalancer.ApiListCredentialsRequest { - request := testClient.ListCredentials(testCtx, testProjectId, testRegion) + request := testClient.DefaultAPI.ListCredentials(testCtx, testProjectId, testRegion) for _, mod := range mods { mod(&request) } @@ -171,7 +171,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, loadbalancer.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/load-balancer/observability-credentials/update/update.go b/internal/cmd/load-balancer/observability-credentials/update/update.go index 5b7e6d95e..77e63bd2f 100644 --- a/internal/cmd/load-balancer/observability-credentials/update/update.go +++ b/internal/cmd/load-balancer/observability-credentials/update/update.go @@ -7,7 +7,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/types" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/loadbalancer" + loadbalancer "github.com/stackitcloud/stackit-sdk-go/services/loadbalancer/v2api" "github.com/stackitcloud/stackit-cli/internal/pkg/args" "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -30,12 +30,12 @@ const ( // enforce implementation of interfaces var ( - _ loadBalancerClient = &loadbalancer.APIClient{} + _ loadBalancerClient = loadbalancer.APIClient{}.DefaultAPI ) type loadBalancerClient interface { UpdateCredentials(ctx context.Context, projectId, region, credentialsRef string) loadbalancer.ApiUpdateCredentialsRequest - GetCredentialsExecute(ctx context.Context, projectId, region, credentialsRef string) (*loadbalancer.GetCredentialsResponse, error) + GetCredentials(ctx context.Context, projectId string, region string, credentialsRef string) loadbalancer.ApiGetCredentialsRequest } type inputModel struct { @@ -79,7 +79,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { projectLabel = model.ProjectId } - credentialsLabel, err := loadBalancerUtils.GetCredentialsDisplayName(ctx, apiClient, model.ProjectId, model.Region, model.CredentialsRef) + credentialsLabel, err := loadBalancerUtils.GetCredentialsDisplayName(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, model.CredentialsRef) if err != nil { params.Printer.Debug(print.ErrorLevel, "get credentials display name: %v", err) credentialsLabel = model.CredentialsRef @@ -92,7 +92,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } // Call API - req, err := buildRequest(ctx, model, apiClient) + req, err := buildRequest(ctx, model, apiClient.DefaultAPI) if err != nil { return err } @@ -141,7 +141,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu func buildRequest(ctx context.Context, model *inputModel, apiClient loadBalancerClient) (loadbalancer.ApiUpdateCredentialsRequest, error) { req := apiClient.UpdateCredentials(ctx, model.ProjectId, model.Region, model.CredentialsRef) - currentCredentials, err := apiClient.GetCredentialsExecute(ctx, model.ProjectId, model.Region, model.CredentialsRef) + currentCredentials, err := apiClient.GetCredentials(ctx, model.ProjectId, model.Region, model.CredentialsRef).Execute() if err != nil { return req, fmt.Errorf("get Load Balancer observability credentials: %w", err) } diff --git a/internal/cmd/load-balancer/observability-credentials/update/update_test.go b/internal/cmd/load-balancer/observability-credentials/update/update_test.go index 563b489d6..3e7187bcd 100644 --- a/internal/cmd/load-balancer/observability-credentials/update/update_test.go +++ b/internal/cmd/load-balancer/observability-credentials/update/update_test.go @@ -5,14 +5,14 @@ import ( "fmt" "testing" - "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" - "github.com/stackitcloud/stackit-cli/internal/pkg/testutils" - "github.com/stackitcloud/stackit-cli/internal/pkg/utils" - "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/loadbalancer" + loadbalancer "github.com/stackitcloud/stackit-sdk-go/services/loadbalancer/v2api" + + "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" + "github.com/stackitcloud/stackit-cli/internal/pkg/testutils" + "github.com/stackitcloud/stackit-cli/internal/pkg/utils" ) const ( @@ -24,24 +24,24 @@ type testCtxKey struct{} var ( testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") - testClient = &loadbalancer.APIClient{} + testClient = &loadbalancer.APIClient{DefaultAPI: &loadbalancer.DefaultAPIService{}} testProjectId = uuid.NewString() ) -type loadBalancerClientMocked struct { +type mockSettings struct { getCredentialsError bool getCredentialsResponse *loadbalancer.GetCredentialsResponse } -func (c *loadBalancerClientMocked) UpdateCredentials(ctx context.Context, projectId, region, credentialsRef string) loadbalancer.ApiUpdateCredentialsRequest { - return testClient.UpdateCredentials(ctx, projectId, region, credentialsRef) -} - -func (c *loadBalancerClientMocked) GetCredentialsExecute(_ context.Context, _, _, _ string) (*loadbalancer.GetCredentialsResponse, error) { - if c.getCredentialsError { - return nil, fmt.Errorf("get credentials failed") +func newAPIMock(s mockSettings) loadbalancer.DefaultAPI { + return &loadbalancer.DefaultAPIServiceMock{ + GetCredentialsExecuteMock: utils.Ptr(func(_ loadbalancer.ApiGetCredentialsRequest) (*loadbalancer.GetCredentialsResponse, error) { + if s.getCredentialsError { + return nil, fmt.Errorf("get credentials failed") + } + return s.getCredentialsResponse, nil + }), } - return c.getCredentialsResponse, nil } func fixtureArgValues(mods ...func(argValues []string)) []string { @@ -87,7 +87,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *loadbalancer.ApiUpdateCredentialsRequest)) loadbalancer.ApiUpdateCredentialsRequest { - request := testClient.UpdateCredentials(testCtx, testProjectId, testRegion, testCredentialsRef) + request := testClient.DefaultAPI.UpdateCredentials(testCtx, testProjectId, testRegion, testCredentialsRef) request = request.UpdateCredentialsPayload(loadbalancer.UpdateCredentialsPayload{ DisplayName: utils.Ptr("name"), Username: utils.Ptr("username"), @@ -232,11 +232,11 @@ func TestBuildRequest(t *testing.T) { for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { - client := &loadBalancerClientMocked{ + client := mockSettings{ getCredentialsError: tt.getCredentialsFails, getCredentialsResponse: tt.getCredentialsResponse, } - request, err := buildRequest(testCtx, tt.model, client) + request, err := buildRequest(testCtx, tt.model, newAPIMock(client)) if err != nil { if !tt.isValid { @@ -252,6 +252,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), cmpopts.EquateComparable(testCtx), + cmpopts.IgnoreFields(loadbalancer.ApiUpdateCredentialsRequest{}, "ApiService"), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/load-balancer/quota/quota.go b/internal/cmd/load-balancer/quota/quota.go index 9539612f9..a6220c83a 100644 --- a/internal/cmd/load-balancer/quota/quota.go +++ b/internal/cmd/load-balancer/quota/quota.go @@ -15,7 +15,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/services/load-balancer/client" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/loadbalancer" + loadbalancer "github.com/stackitcloud/stackit-sdk-go/services/loadbalancer/v2api" ) type inputModel struct { @@ -73,7 +73,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, } func buildRequest(ctx context.Context, model *inputModel, apiClient *loadbalancer.APIClient) loadbalancer.ApiGetQuotaRequest { - req := apiClient.GetQuota(ctx, model.ProjectId, model.Region) + req := apiClient.DefaultAPI.GetQuota(ctx, model.ProjectId, model.Region) return req } @@ -85,7 +85,7 @@ func outputResult(p *print.Printer, outputFormat string, quota *loadbalancer.Get return p.OutputResult(outputFormat, quota, func() error { maxLoadBalancers := "Unlimited" if quota.MaxLoadBalancers != nil && *quota.MaxLoadBalancers != -1 { - maxLoadBalancers = strconv.FormatInt(*quota.MaxLoadBalancers, 10) + maxLoadBalancers = strconv.FormatInt(int64(*quota.MaxLoadBalancers), 10) } p.Outputf("Maximum number of load balancers allowed: %s\n", maxLoadBalancers) diff --git a/internal/cmd/load-balancer/quota/quota_test.go b/internal/cmd/load-balancer/quota/quota_test.go index eb688ef8b..349041153 100644 --- a/internal/cmd/load-balancer/quota/quota_test.go +++ b/internal/cmd/load-balancer/quota/quota_test.go @@ -7,7 +7,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/loadbalancer" + loadbalancer "github.com/stackitcloud/stackit-sdk-go/services/loadbalancer/v2api" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/print" @@ -22,7 +22,7 @@ const ( type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &loadbalancer.APIClient{} +var testClient = &loadbalancer.APIClient{DefaultAPI: &loadbalancer.DefaultAPIService{}} var testProjectId = uuid.NewString() func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string { @@ -51,7 +51,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *loadbalancer.ApiGetQuotaRequest)) loadbalancer.ApiGetQuotaRequest { - request := testClient.GetQuota(testCtx, testProjectId, testRegion) + request := testClient.DefaultAPI.GetQuota(testCtx, testProjectId, testRegion) for _, mod := range mods { mod(&request) } @@ -123,7 +123,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, loadbalancer.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/load-balancer/target-pool/add-target/add_target.go b/internal/cmd/load-balancer/target-pool/add-target/add_target.go index 716c273a3..029c12a3e 100644 --- a/internal/cmd/load-balancer/target-pool/add-target/add_target.go +++ b/internal/cmd/load-balancer/target-pool/add-target/add_target.go @@ -6,7 +6,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/types" - "github.com/stackitcloud/stackit-sdk-go/services/loadbalancer" + loadbalancer "github.com/stackitcloud/stackit-sdk-go/services/loadbalancer/v2api" "github.com/stackitcloud/stackit-cli/internal/pkg/args" "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -70,7 +70,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } // Call API - req, err := buildRequest(ctx, model, apiClient) + req, err := buildRequest(ctx, model, apiClient.DefaultAPI) if err != nil { return fmt.Errorf("build request: %w", err) } @@ -116,7 +116,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu return &model, nil } -func buildRequest(ctx context.Context, model *inputModel, apiClient utils.LoadBalancerClient) (loadbalancer.ApiUpdateTargetPoolRequest, error) { +func buildRequest(ctx context.Context, model *inputModel, apiClient loadbalancer.DefaultAPI) (loadbalancer.ApiUpdateTargetPoolRequest, error) { req := apiClient.UpdateTargetPool(ctx, model.ProjectId, model.Region, model.LBName, model.TargetPoolName) targetPool, err := utils.GetLoadBalancerTargetPool(ctx, apiClient, model.ProjectId, model.Region, model.LBName, model.TargetPoolName) diff --git a/internal/cmd/load-balancer/target-pool/add-target/add_target_test.go b/internal/cmd/load-balancer/target-pool/add-target/add_target_test.go index 476f99e23..12d7c9b4e 100644 --- a/internal/cmd/load-balancer/target-pool/add-target/add_target_test.go +++ b/internal/cmd/load-balancer/target-pool/add-target/add_target_test.go @@ -5,7 +5,7 @@ import ( "fmt" "testing" - "github.com/stackitcloud/stackit-sdk-go/services/loadbalancer" + loadbalancer "github.com/stackitcloud/stackit-sdk-go/services/loadbalancer/v2api" "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" @@ -21,7 +21,7 @@ type testCtxKey struct{} var ( testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") - testClient = &loadbalancer.APIClient{} + testClient = &loadbalancer.APIClient{DefaultAPI: &loadbalancer.DefaultAPIService{}} testProjectId = uuid.NewString() ) @@ -33,33 +33,29 @@ const ( testIP = "1.1.1.1" ) -type loadBalancerClientMocked struct { +type mockSettings struct { getCredentialsFails bool getCredentialsResp *loadbalancer.GetCredentialsResponse getLoadBalancerFails bool getLoadBalancerResp *loadbalancer.LoadBalancer } -func (m *loadBalancerClientMocked) GetCredentialsExecute(_ context.Context, _, _, _ string) (*loadbalancer.GetCredentialsResponse, error) { - if m.getCredentialsFails { - return nil, fmt.Errorf("could not get credentials") - } - return m.getCredentialsResp, nil -} - -func (m *loadBalancerClientMocked) GetLoadBalancerExecute(_ context.Context, _, _, _ string) (*loadbalancer.LoadBalancer, error) { - if m.getLoadBalancerFails { - return nil, fmt.Errorf("could not get load balancer") +func newAPIMock(settings mockSettings) loadbalancer.DefaultAPI { + return &loadbalancer.DefaultAPIServiceMock{ + GetCredentialsExecuteMock: utils.Ptr( + func(_ loadbalancer.ApiGetCredentialsRequest) (*loadbalancer.GetCredentialsResponse, error) { + if settings.getCredentialsFails { + return nil, fmt.Errorf("could not get credentials") + } + return settings.getCredentialsResp, nil + }), + GetLoadBalancerExecuteMock: utils.Ptr(func(_ loadbalancer.ApiGetLoadBalancerRequest) (*loadbalancer.LoadBalancer, error) { + if settings.getLoadBalancerFails { + return nil, fmt.Errorf("could not get load balancer") + } + return settings.getLoadBalancerResp, nil + }), } - return m.getLoadBalancerResp, nil -} - -func (m *loadBalancerClientMocked) UpdateTargetPool(ctx context.Context, projectId, region, loadBalancerName, targetPoolName string) loadbalancer.ApiUpdateTargetPoolRequest { - return testClient.UpdateTargetPool(ctx, projectId, region, loadBalancerName, targetPoolName) -} - -func (m *loadBalancerClientMocked) ListLoadBalancersExecute(_ context.Context, _, _ string) (*loadbalancer.ListLoadBalancersResponse, error) { - return nil, nil } func fixtureArgValues(mods ...func(argValues []string)) []string { @@ -104,8 +100,8 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { return model } -func fixtureTargets() *[]loadbalancer.Target { - return &[]loadbalancer.Target{ +func fixtureTargets() []loadbalancer.Target { + return []loadbalancer.Target{ { DisplayName: utils.Ptr("target-1"), Ip: utils.Ptr("1.2.3.4"), @@ -120,21 +116,21 @@ func fixtureTargets() *[]loadbalancer.Target { func fixtureLoadBalancer(mods ...func(*loadbalancer.LoadBalancer)) *loadbalancer.LoadBalancer { lb := loadbalancer.LoadBalancer{ Name: utils.Ptr(testLBName), - TargetPools: &[]loadbalancer.TargetPool{ + TargetPools: []loadbalancer.TargetPool{ { Name: utils.Ptr(testTargetPoolName), Targets: fixtureTargets(), ActiveHealthCheck: &loadbalancer.ActiveHealthCheck{ - UnhealthyThreshold: utils.Ptr(int64(3)), + UnhealthyThreshold: utils.Ptr(int32(3)), }, SessionPersistence: &loadbalancer.SessionPersistence{ UseSourceIpAddress: utils.Ptr(true), }, - TargetPort: utils.Ptr(int64(80)), + TargetPort: utils.Ptr(int32(80)), }, { Name: utils.Ptr("target-pool-2"), - Targets: &[]loadbalancer.Target{ + Targets: []loadbalancer.Target{ { DisplayName: utils.Ptr("target-1"), Ip: utils.Ptr("6.7.8.9"), @@ -158,12 +154,12 @@ func fixturePayload(mods ...func(payload *loadbalancer.UpdateTargetPoolPayload)) payload := &loadbalancer.UpdateTargetPoolPayload{ Name: utils.Ptr("target-pool-1"), ActiveHealthCheck: &loadbalancer.ActiveHealthCheck{ - UnhealthyThreshold: utils.Ptr(int64(3)), + UnhealthyThreshold: utils.Ptr(int32(3)), }, SessionPersistence: &loadbalancer.SessionPersistence{ UseSourceIpAddress: utils.Ptr(true), }, - TargetPort: utils.Ptr(int64(80)), + TargetPort: utils.Ptr(int32(80)), Targets: fixtureTargets(), } @@ -174,7 +170,7 @@ func fixturePayload(mods ...func(payload *loadbalancer.UpdateTargetPoolPayload)) } func fixtureRequest(mods ...func(request *loadbalancer.ApiUpdateTargetPoolRequest)) loadbalancer.ApiUpdateTargetPoolRequest { - request := testClient.UpdateTargetPool(testCtx, testProjectId, testRegion, testLBName, testTargetPoolName) + request := testClient.DefaultAPI.UpdateTargetPool(testCtx, testProjectId, testRegion, testLBName, testTargetPoolName) request = request.UpdateTargetPoolPayload(*fixturePayload()) for _, mod := range mods { mod(&request) @@ -330,54 +326,54 @@ func TestBuildRequest(t *testing.T) { isValid: true, expectedRequest: fixtureRequest(func(request *loadbalancer.ApiUpdateTargetPoolRequest) { payload := fixturePayload(func(payload *loadbalancer.UpdateTargetPoolPayload) { - payload.Targets = &[]loadbalancer.Target{ - (*fixtureTargets())[0], - (*fixtureTargets())[1], + payload.Targets = []loadbalancer.Target{ + (fixtureTargets())[0], + (fixtureTargets())[1], { DisplayName: utils.Ptr(testTargetName), Ip: utils.Ptr(testIP), }, } }) - *request = (*request).UpdateTargetPoolPayload(*payload) + *request = request.UpdateTargetPoolPayload(*payload) }), }, { description: "empty targets", model: fixtureInputModel(), getLoadBalancerResp: fixtureLoadBalancer(func(lb *loadbalancer.LoadBalancer) { - (*lb.TargetPools)[0].Targets = &[]loadbalancer.Target{} + (lb.TargetPools)[0].Targets = []loadbalancer.Target{} }), isValid: true, expectedRequest: fixtureRequest(func(request *loadbalancer.ApiUpdateTargetPoolRequest) { payload := fixturePayload(func(payload *loadbalancer.UpdateTargetPoolPayload) { - payload.Targets = &[]loadbalancer.Target{ + payload.Targets = []loadbalancer.Target{ { DisplayName: utils.Ptr(testTargetName), Ip: utils.Ptr(testIP), }, } }) - *request = (*request).UpdateTargetPoolPayload(*payload) + *request = request.UpdateTargetPoolPayload(*payload) }), }, { description: "nil targets", model: fixtureInputModel(), getLoadBalancerResp: fixtureLoadBalancer(func(lb *loadbalancer.LoadBalancer) { - (*lb.TargetPools)[0].Targets = nil + (lb.TargetPools)[0].Targets = nil }), isValid: true, expectedRequest: fixtureRequest(func(request *loadbalancer.ApiUpdateTargetPoolRequest) { payload := fixturePayload(func(payload *loadbalancer.UpdateTargetPoolPayload) { - payload.Targets = &[]loadbalancer.Target{ + payload.Targets = []loadbalancer.Target{ { DisplayName: utils.Ptr(testTargetName), Ip: utils.Ptr(testIP), }, } }) - *request = (*request).UpdateTargetPoolPayload(*payload) + *request = request.UpdateTargetPoolPayload(*payload) }), }, { @@ -399,7 +395,7 @@ func TestBuildRequest(t *testing.T) { description: "nil target pool", model: fixtureInputModel(), getLoadBalancerResp: fixtureLoadBalancer(func(lb *loadbalancer.LoadBalancer) { - *lb.TargetPools = nil + lb.TargetPools = nil }), isValid: false, }, @@ -407,11 +403,11 @@ func TestBuildRequest(t *testing.T) { for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { - client := &loadBalancerClientMocked{ + client := mockSettings{ getLoadBalancerFails: tt.getLoadBalancerFails, getLoadBalancerResp: tt.getLoadBalancerResp, } - request, err := buildRequest(testCtx, tt.model, client) + request, err := buildRequest(testCtx, tt.model, newAPIMock(client)) if err != nil { if !tt.isValid { return @@ -422,6 +418,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), cmpopts.EquateComparable(testCtx), + cmpopts.IgnoreFields(loadbalancer.ApiUpdateTargetPoolRequest{}, "ApiService"), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/load-balancer/target-pool/describe/describe.go b/internal/cmd/load-balancer/target-pool/describe/describe.go index 99b267962..2e4dd4018 100644 --- a/internal/cmd/load-balancer/target-pool/describe/describe.go +++ b/internal/cmd/load-balancer/target-pool/describe/describe.go @@ -9,7 +9,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/types" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/loadbalancer" + loadbalancer "github.com/stackitcloud/stackit-sdk-go/services/loadbalancer/v2api" "github.com/stackitcloud/stackit-cli/internal/pkg/args" "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -68,12 +68,12 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return fmt.Errorf("read load balancer: %w", err) } - targetPool := lbUtils.FindLoadBalancerTargetPoolByName(*resp.TargetPools, model.TargetPoolName) + targetPool := lbUtils.FindLoadBalancerTargetPoolByName(resp.TargetPools, model.TargetPoolName) if targetPool == nil { return fmt.Errorf("target pool not found") } - listener := lbUtils.FindLoadBalancerListenerByTargetPool(*resp.Listeners, *targetPool.Name) + listener := lbUtils.FindLoadBalancerListenerByTargetPool(resp.Listeners, *targetPool.Name) return outputResult(params.Printer, model.OutputFormat, *targetPool, listener) }, @@ -108,7 +108,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *loadbalancer.APIClient) loadbalancer.ApiGetLoadBalancerRequest { - req := apiClient.GetLoadBalancer(ctx, model.ProjectId, model.Region, model.LBName) + req := apiClient.DefaultAPI.GetLoadBalancer(ctx, model.ProjectId, model.Region, model.LBName) return req } @@ -138,17 +138,17 @@ func outputResult(p *print.Printer, outputFormat string, targetPool loadbalancer healthCheckInterval = *targetPool.ActiveHealthCheck.Interval } if targetPool.ActiveHealthCheck.UnhealthyThreshold != nil { - healthCheckUnhealthyThreshold = strconv.FormatInt(*targetPool.ActiveHealthCheck.UnhealthyThreshold, 10) + healthCheckUnhealthyThreshold = strconv.FormatInt(int64(*targetPool.ActiveHealthCheck.UnhealthyThreshold), 10) } if targetPool.ActiveHealthCheck.HealthyThreshold != nil { - healthCheckHealthyThreshold = strconv.FormatInt(*targetPool.ActiveHealthCheck.HealthyThreshold, 10) + healthCheckHealthyThreshold = strconv.FormatInt(int64(*targetPool.ActiveHealthCheck.HealthyThreshold), 10) } } targets := "-" if targetPool.Targets != nil { var targetsSlice []string - for _, target := range *targetPool.Targets { + for _, target := range targetPool.Targets { targetStr := fmt.Sprintf("%s (%s)", *target.DisplayName, *target.Ip) targetsSlice = append(targetsSlice, targetStr) } diff --git a/internal/cmd/load-balancer/target-pool/describe/describe_test.go b/internal/cmd/load-balancer/target-pool/describe/describe_test.go index 9a779d966..8e70da65d 100644 --- a/internal/cmd/load-balancer/target-pool/describe/describe_test.go +++ b/internal/cmd/load-balancer/target-pool/describe/describe_test.go @@ -7,7 +7,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/loadbalancer" + loadbalancer "github.com/stackitcloud/stackit-sdk-go/services/loadbalancer/v2api" "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" @@ -18,7 +18,7 @@ type testCtxKey struct{} var ( testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") - testClient = &loadbalancer.APIClient{} + testClient = &loadbalancer.APIClient{DefaultAPI: &loadbalancer.DefaultAPIService{}} testProjectId = uuid.NewString() ) @@ -67,7 +67,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *loadbalancer.ApiGetLoadBalancerRequest)) loadbalancer.ApiGetLoadBalancerRequest { - request := testClient.GetLoadBalancer(testCtx, testProjectId, testRegion, testLoadBalancerName) + request := testClient.DefaultAPI.GetLoadBalancer(testCtx, testProjectId, testRegion, testLoadBalancerName) for _, mod := range mods { mod(&request) } @@ -211,7 +211,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, loadbalancer.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/load-balancer/target-pool/remove-target/remove_target.go b/internal/cmd/load-balancer/target-pool/remove-target/remove_target.go index 129ca8773..320eacffa 100644 --- a/internal/cmd/load-balancer/target-pool/remove-target/remove_target.go +++ b/internal/cmd/load-balancer/target-pool/remove-target/remove_target.go @@ -6,7 +6,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/types" - "github.com/stackitcloud/stackit-sdk-go/services/loadbalancer" + loadbalancer "github.com/stackitcloud/stackit-sdk-go/services/loadbalancer/v2api" "github.com/stackitcloud/stackit-cli/internal/pkg/args" "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -59,7 +59,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return err } - targetLabel, err := utils.GetTargetName(ctx, apiClient, model.ProjectId, model.Region, model.LBName, model.TargetPoolName, model.IP) + targetLabel, err := utils.GetTargetName(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, model.LBName, model.TargetPoolName, model.IP) if err != nil { params.Printer.Debug(print.ErrorLevel, "get target name: %v", err) targetLabel = model.IP @@ -72,7 +72,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } // Call API - req, err := buildRequest(ctx, model, apiClient) + req, err := buildRequest(ctx, model, apiClient.DefaultAPI) if err != nil { return fmt.Errorf("build request: %w", err) } @@ -116,7 +116,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu return &model, nil } -func buildRequest(ctx context.Context, model *inputModel, apiClient utils.LoadBalancerClient) (loadbalancer.ApiUpdateTargetPoolRequest, error) { +func buildRequest(ctx context.Context, model *inputModel, apiClient loadbalancer.DefaultAPI) (loadbalancer.ApiUpdateTargetPoolRequest, error) { req := apiClient.UpdateTargetPool(ctx, model.ProjectId, model.Region, model.LBName, model.TargetPoolName) targetPool, err := utils.GetLoadBalancerTargetPool(ctx, apiClient, model.ProjectId, model.Region, model.LBName, model.TargetPoolName) diff --git a/internal/cmd/load-balancer/target-pool/remove-target/remove_target_test.go b/internal/cmd/load-balancer/target-pool/remove-target/remove_target_test.go index e6c8ac822..6559c3848 100644 --- a/internal/cmd/load-balancer/target-pool/remove-target/remove_target_test.go +++ b/internal/cmd/load-balancer/target-pool/remove-target/remove_target_test.go @@ -5,7 +5,7 @@ import ( "fmt" "testing" - "github.com/stackitcloud/stackit-sdk-go/services/loadbalancer" + loadbalancer "github.com/stackitcloud/stackit-sdk-go/services/loadbalancer/v2api" "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" @@ -21,7 +21,7 @@ type testCtxKey struct{} var ( testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") - testClient = &loadbalancer.APIClient{} + testClient = &loadbalancer.APIClient{DefaultAPI: &loadbalancer.DefaultAPIService{}} testProjectId = uuid.NewString() ) @@ -32,33 +32,28 @@ const ( testIP = "1.2.3.4" ) -type loadBalancerClientMocked struct { +type mockSettings struct { getCredentialsFails bool getCredentialsResp *loadbalancer.GetCredentialsResponse getLoadBalancerFails bool getLoadBalancerResp *loadbalancer.LoadBalancer } -func (m *loadBalancerClientMocked) GetCredentialsExecute(_ context.Context, _, _, _ string) (*loadbalancer.GetCredentialsResponse, error) { - if m.getCredentialsFails { - return nil, fmt.Errorf("could not get credentials") - } - return m.getCredentialsResp, nil -} - -func (m *loadBalancerClientMocked) GetLoadBalancerExecute(_ context.Context, _, _, _ string) (*loadbalancer.LoadBalancer, error) { - if m.getLoadBalancerFails { - return nil, fmt.Errorf("could not get load balancer") +func newAPIMock(s mockSettings) loadbalancer.DefaultAPI { + return loadbalancer.DefaultAPIServiceMock{ + GetCredentialsExecuteMock: utils.Ptr(func(_ loadbalancer.ApiGetCredentialsRequest) (*loadbalancer.GetCredentialsResponse, error) { + if s.getCredentialsFails { + return nil, fmt.Errorf("could not get credentials") + } + return s.getCredentialsResp, nil + }), + GetLoadBalancerExecuteMock: utils.Ptr(func(_ loadbalancer.ApiGetLoadBalancerRequest) (*loadbalancer.LoadBalancer, error) { + if s.getLoadBalancerFails { + return nil, fmt.Errorf("could not get load balancer") + } + return s.getLoadBalancerResp, nil + }), } - return m.getLoadBalancerResp, nil -} - -func (m *loadBalancerClientMocked) UpdateTargetPool(ctx context.Context, projectId, region, loadBalancerName, targetPoolName string) loadbalancer.ApiUpdateTargetPoolRequest { - return testClient.UpdateTargetPool(ctx, projectId, region, loadBalancerName, targetPoolName) -} - -func (m *loadBalancerClientMocked) ListLoadBalancersExecute(_ context.Context, _, _ string) (*loadbalancer.ListLoadBalancersResponse, error) { - return nil, nil } func fixtureArgValues(mods ...func(argValues []string)) []string { @@ -101,8 +96,8 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { return model } -func fixtureTargets() *[]loadbalancer.Target { - return &[]loadbalancer.Target{ +func fixtureTargets() []loadbalancer.Target { + return []loadbalancer.Target{ { DisplayName: utils.Ptr("target-1"), Ip: utils.Ptr("1.2.3.4"), @@ -117,21 +112,21 @@ func fixtureTargets() *[]loadbalancer.Target { func fixtureLoadBalancer(mods ...func(*loadbalancer.LoadBalancer)) *loadbalancer.LoadBalancer { lb := loadbalancer.LoadBalancer{ Name: utils.Ptr(testLBName), - TargetPools: &[]loadbalancer.TargetPool{ + TargetPools: []loadbalancer.TargetPool{ { Name: utils.Ptr(testTargetPoolName), Targets: fixtureTargets(), ActiveHealthCheck: &loadbalancer.ActiveHealthCheck{ - UnhealthyThreshold: utils.Ptr(int64(3)), + UnhealthyThreshold: utils.Ptr(int32(3)), }, SessionPersistence: &loadbalancer.SessionPersistence{ UseSourceIpAddress: utils.Ptr(true), }, - TargetPort: utils.Ptr(int64(80)), + TargetPort: utils.Ptr(int32(80)), }, { Name: utils.Ptr("target-pool-2"), - Targets: &[]loadbalancer.Target{ + Targets: []loadbalancer.Target{ { DisplayName: utils.Ptr("target-1"), Ip: utils.Ptr("6.7.8.9"), @@ -155,12 +150,12 @@ func fixturePayload(mods ...func(payload *loadbalancer.UpdateTargetPoolPayload)) payload := &loadbalancer.UpdateTargetPoolPayload{ Name: utils.Ptr("target-pool-1"), ActiveHealthCheck: &loadbalancer.ActiveHealthCheck{ - UnhealthyThreshold: utils.Ptr(int64(3)), + UnhealthyThreshold: utils.Ptr(int32(3)), }, SessionPersistence: &loadbalancer.SessionPersistence{ UseSourceIpAddress: utils.Ptr(true), }, - TargetPort: utils.Ptr(int64(80)), + TargetPort: utils.Ptr(int32(80)), Targets: fixtureTargets(), } @@ -171,7 +166,7 @@ func fixturePayload(mods ...func(payload *loadbalancer.UpdateTargetPoolPayload)) } func fixtureRequest(mods ...func(request *loadbalancer.ApiUpdateTargetPoolRequest)) loadbalancer.ApiUpdateTargetPoolRequest { - request := testClient.UpdateTargetPool(testCtx, testProjectId, testRegion, testLBName, testTargetPoolName) + request := testClient.DefaultAPI.UpdateTargetPool(testCtx, testProjectId, testRegion, testLBName, testTargetPoolName) request = request.UpdateTargetPoolPayload(*fixturePayload()) for _, mod := range mods { mod(&request) @@ -319,16 +314,16 @@ func TestBuildRequest(t *testing.T) { isValid: true, expectedRequest: fixtureRequest(func(request *loadbalancer.ApiUpdateTargetPoolRequest) { payload := fixturePayload(func(payload *loadbalancer.UpdateTargetPoolPayload) { - payload.Targets = utils.Ptr((*payload.Targets)[1:]) + payload.Targets = (payload.Targets)[1:] }) - *request = (*request).UpdateTargetPoolPayload(*payload) + *request = request.UpdateTargetPoolPayload(*payload) }), }, { description: "empty targets", model: fixtureInputModel(), getLoadBalancerResp: fixtureLoadBalancer(func(lb *loadbalancer.LoadBalancer) { - (*lb.TargetPools)[0].Targets = &[]loadbalancer.Target{} + (lb.TargetPools)[0].Targets = []loadbalancer.Target{} }), isValid: false, }, @@ -345,7 +340,7 @@ func TestBuildRequest(t *testing.T) { description: "nil targets", model: fixtureInputModel(), getLoadBalancerResp: fixtureLoadBalancer(func(lb *loadbalancer.LoadBalancer) { - (*lb.TargetPools)[0].Targets = nil + (lb.TargetPools)[0].Targets = nil }), isValid: false, }, @@ -368,7 +363,7 @@ func TestBuildRequest(t *testing.T) { description: "nil target pool", model: fixtureInputModel(), getLoadBalancerResp: fixtureLoadBalancer(func(lb *loadbalancer.LoadBalancer) { - *lb.TargetPools = nil + lb.TargetPools = nil }), isValid: false, }, @@ -376,11 +371,11 @@ func TestBuildRequest(t *testing.T) { for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { - client := &loadBalancerClientMocked{ + client := mockSettings{ getLoadBalancerFails: tt.getLoadBalancerFails, getLoadBalancerResp: tt.getLoadBalancerResp, } - request, err := buildRequest(testCtx, tt.model, client) + request, err := buildRequest(testCtx, tt.model, newAPIMock(client)) if err != nil { if !tt.isValid { return @@ -391,6 +386,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), cmpopts.EquateComparable(testCtx), + cmpopts.IgnoreFields(loadbalancer.ApiUpdateTargetPoolRequest{}, "ApiService"), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/load-balancer/update/update.go b/internal/cmd/load-balancer/update/update.go index 5e55a414b..ed625c41f 100644 --- a/internal/cmd/load-balancer/update/update.go +++ b/internal/cmd/load-balancer/update/update.go @@ -16,7 +16,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/services/load-balancer/client" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/loadbalancer" + loadbalancer "github.com/stackitcloud/stackit-sdk-go/services/loadbalancer/v2api" ) const ( @@ -37,7 +37,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { Long: fmt.Sprintf("%s\n%s\n%s", "Updates a load balancer.", "The payload can be provided as a JSON string or a file path prefixed with \"@\".", - "See https://docs.api.stackit.cloud/documentation/load-balancer/version/v1#tag/Load-Balancer/operation/APIService_UpdateLoadBalancer for information regarding the payload structure.", + "See https://docs.api.stackit.cloud/documentation/load-balancer/version/v2#tag/Load-Balancer/operation/APIService_UpdateLoadBalancer for information regarding the payload structure.", ), Args: args.SingleArg(loadBalancerNameArg, nil), Example: examples.Build( @@ -121,7 +121,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *loadbalancer.APIClient) loadbalancer.ApiUpdateLoadBalancerRequest { - req := apiClient.UpdateLoadBalancer(ctx, model.ProjectId, model.Region, model.LoadBalancerName) + req := apiClient.DefaultAPI.UpdateLoadBalancer(ctx, model.ProjectId, model.Region, model.LoadBalancerName) req = req.UpdateLoadBalancerPayload(model.Payload) return req diff --git a/internal/cmd/load-balancer/update/update_test.go b/internal/cmd/load-balancer/update/update_test.go index 23504dcfd..d2828ffd5 100644 --- a/internal/cmd/load-balancer/update/update_test.go +++ b/internal/cmd/load-balancer/update/update_test.go @@ -11,7 +11,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/loadbalancer" + loadbalancer "github.com/stackitcloud/stackit-sdk-go/services/loadbalancer/v2api" ) const ( @@ -22,18 +22,18 @@ const ( type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &loadbalancer.APIClient{} +var testClient = &loadbalancer.APIClient{DefaultAPI: &loadbalancer.DefaultAPIService{}} var testProjectId = uuid.NewString() var testPayload = loadbalancer.UpdateLoadBalancerPayload{ ExternalAddress: utils.Ptr(""), - Listeners: &[]loadbalancer.Listener{ + Listeners: []loadbalancer.Listener{ { DisplayName: utils.Ptr(""), - Port: utils.Ptr(int64(0)), - Protocol: loadbalancer.ListenerProtocol("").Ptr(), - ServerNameIndicators: &[]loadbalancer.ServerNameIndicator{ + Port: utils.Ptr(int32(0)), + Protocol: loadbalancer.ListenerProtocol("unknown_default_open_api").Ptr(), + ServerNameIndicators: []loadbalancer.ServerNameIndicator{ { Name: utils.Ptr(""), }, @@ -48,15 +48,15 @@ var testPayload = loadbalancer.UpdateLoadBalancerPayload{ }, }, Name: utils.Ptr(""), - Networks: &[]loadbalancer.Network{ + Networks: []loadbalancer.Network{ { NetworkId: utils.Ptr(""), - Role: loadbalancer.NetworkRole("").Ptr(), + Role: loadbalancer.NetworkRole("unknown_default_open_api").Ptr(), }, }, Options: &loadbalancer.LoadBalancerOptions{ AccessControl: &loadbalancer.LoadbalancerOptionAccessControl{ - AllowedSourceRanges: &[]string{ + AllowedSourceRanges: []string{ "", }, }, @@ -73,21 +73,21 @@ var testPayload = loadbalancer.UpdateLoadBalancerPayload{ }, PrivateNetworkOnly: utils.Ptr(false), }, - TargetPools: &[]loadbalancer.TargetPool{ + TargetPools: []loadbalancer.TargetPool{ { ActiveHealthCheck: &loadbalancer.ActiveHealthCheck{ - HealthyThreshold: utils.Ptr(int64(0)), + HealthyThreshold: utils.Ptr(int32(0)), Interval: utils.Ptr(""), IntervalJitter: utils.Ptr(""), Timeout: utils.Ptr(""), - UnhealthyThreshold: utils.Ptr(int64(0)), + UnhealthyThreshold: utils.Ptr(int32(0)), }, Name: utils.Ptr(""), SessionPersistence: &loadbalancer.SessionPersistence{ UseSourceIpAddress: utils.Ptr(false), }, - TargetPort: utils.Ptr(int64(0)), - Targets: &[]loadbalancer.Target{ + TargetPort: utils.Ptr(int32(0)), + Targets: []loadbalancer.Target{ { DisplayName: utils.Ptr(""), Ip: utils.Ptr(""), @@ -209,7 +209,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *loadbalancer.ApiUpdateLoadBalancerRequest)) loadbalancer.ApiUpdateLoadBalancerRequest { - request := testClient.UpdateLoadBalancer(testCtx, testProjectId, testRegion, testLoadBalancerName) + request := testClient.DefaultAPI.UpdateLoadBalancer(testCtx, testProjectId, testRegion, testLoadBalancerName) request = request.UpdateLoadBalancerPayload(testPayload) for _, mod := range mods { mod(&request) @@ -299,7 +299,9 @@ func TestParseInput(t *testing.T) { for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { - testutils.TestParseInput(t, NewCmd, parseInput, tt.expectedModel, tt.argValues, tt.flagValues, tt.isValid) + testutils.TestParseInputWithOptions(t, NewCmd, parseInput, tt.expectedModel, tt.argValues, tt.flagValues, nil, tt.isValid, []testutils.TestingOption{ + testutils.WithCmpOptions(cmpopts.EquateEmpty()), + }) }) } } @@ -321,10 +323,10 @@ func TestBuildRequest(t *testing.T) { for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { request := buildRequest(testCtx, tt.model, testClient) - diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, loadbalancer.DefaultAPIService{}), + cmpopts.EquateEmpty(), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/pkg/services/load-balancer/client/client.go b/internal/pkg/services/load-balancer/client/client.go index 7234c4f88..273bea02d 100644 --- a/internal/pkg/services/load-balancer/client/client.go +++ b/internal/pkg/services/load-balancer/client/client.go @@ -6,9 +6,9 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/print" "github.com/spf13/viper" - "github.com/stackitcloud/stackit-sdk-go/services/loadbalancer" + loadbalancer "github.com/stackitcloud/stackit-sdk-go/services/loadbalancer/v2api" ) func ConfigureClient(p *print.Printer, cliVersion string) (*loadbalancer.APIClient, error) { - return genericclient.ConfigureClientGeneric(p, cliVersion, viper.GetString(config.LoadBalancerCustomEndpointKey), false, genericclient.CreateApiClient[*loadbalancer.APIClient](loadbalancer.NewAPIClient)) + return genericclient.ConfigureClientGeneric(p, cliVersion, viper.GetString(config.LoadBalancerCustomEndpointKey), false, loadbalancer.NewAPIClient) } diff --git a/internal/pkg/services/load-balancer/utils/utils.go b/internal/pkg/services/load-balancer/utils/utils.go index 1a5ba6076..68fd2fd2f 100644 --- a/internal/pkg/services/load-balancer/utils/utils.go +++ b/internal/pkg/services/load-balancer/utils/utils.go @@ -6,7 +6,7 @@ import ( "slices" "sort" - "github.com/stackitcloud/stackit-sdk-go/services/loadbalancer" + loadbalancer "github.com/stackitcloud/stackit-sdk-go/services/loadbalancer/v2api" ) const ( @@ -15,28 +15,16 @@ const ( OP_FILTER_UNUSED ) -// enforce implementation of interfaces -var ( - _ LoadBalancerClient = &loadbalancer.APIClient{} -) - -type LoadBalancerClient interface { - GetCredentialsExecute(ctx context.Context, projectId, region, credentialsRef string) (*loadbalancer.GetCredentialsResponse, error) - GetLoadBalancerExecute(ctx context.Context, projectId, region, name string) (*loadbalancer.LoadBalancer, error) - UpdateTargetPool(ctx context.Context, projectId, region, loadBalancerName, targetPoolName string) loadbalancer.ApiUpdateTargetPoolRequest - ListLoadBalancersExecute(ctx context.Context, projectId, region string) (*loadbalancer.ListLoadBalancersResponse, error) -} - -func GetCredentialsDisplayName(ctx context.Context, apiClient LoadBalancerClient, projectId, region, credentialsRef string) (string, error) { - resp, err := apiClient.GetCredentialsExecute(ctx, projectId, region, credentialsRef) +func GetCredentialsDisplayName(ctx context.Context, apiClient loadbalancer.DefaultAPI, projectId, region, credentialsRef string) (string, error) { + resp, err := apiClient.GetCredentials(ctx, projectId, region, credentialsRef).Execute() if err != nil { return "", fmt.Errorf("get Load Balancer credentials: %w", err) } return *resp.Credential.DisplayName, nil } -func GetLoadBalancerTargetPool(ctx context.Context, apiClient LoadBalancerClient, projectId, region, loadBalancerName, targetPoolName string) (*loadbalancer.TargetPool, error) { - resp, err := apiClient.GetLoadBalancerExecute(ctx, projectId, region, loadBalancerName) +func GetLoadBalancerTargetPool(ctx context.Context, apiClient loadbalancer.DefaultAPI, projectId, region, loadBalancerName, targetPoolName string) (*loadbalancer.TargetPool, error) { + resp, err := apiClient.GetLoadBalancer(ctx, projectId, region, loadBalancerName).Execute() if err != nil { return nil, fmt.Errorf("get load balancer: %w", err) } @@ -48,7 +36,7 @@ func GetLoadBalancerTargetPool(ctx context.Context, apiClient LoadBalancerClient return nil, fmt.Errorf("no target pools found") } - targetPool := FindLoadBalancerTargetPoolByName(*resp.TargetPools, targetPoolName) + targetPool := FindLoadBalancerTargetPoolByName(resp.TargetPools, targetPoolName) if targetPool == nil { return nil, fmt.Errorf("target pool not found") } @@ -87,10 +75,10 @@ func AddTargetToTargetPool(targetPool *loadbalancer.TargetPool, target *loadbala return fmt.Errorf("target is nil") } if targetPool.Targets == nil { - targetPool.Targets = &[]loadbalancer.Target{*target} + targetPool.Targets = []loadbalancer.Target{*target} return nil } - *targetPool.Targets = append(*targetPool.Targets, *target) + targetPool.Targets = append(targetPool.Targets, *target) return nil } @@ -101,12 +89,12 @@ func RemoveTargetFromTargetPool(targetPool *loadbalancer.TargetPool, ip string) if targetPool.Targets == nil { return fmt.Errorf("no targets found") } - targets := *targetPool.Targets + targets := targetPool.Targets for i, target := range targets { if target.Ip != nil && *target.Ip == ip { newTargets := targets[:i] newTargets = append(newTargets, targets[i+1:]...) - *targetPool.Targets = newTargets + targetPool.Targets = newTargets return nil } } @@ -126,7 +114,7 @@ func ToPayloadTargetPool(targetPool *loadbalancer.TargetPool) *loadbalancer.Upda } } -func GetTargetName(ctx context.Context, apiClient LoadBalancerClient, projectId, region, loadBalancerName, targetPoolName, targetIp string) (string, error) { +func GetTargetName(ctx context.Context, apiClient loadbalancer.DefaultAPI, projectId, region, loadBalancerName, targetPoolName, targetIp string) (string, error) { targetPool, err := GetLoadBalancerTargetPool(ctx, apiClient, projectId, region, loadBalancerName, targetPoolName) if err != nil { return "", fmt.Errorf("get target pool: %w", err) @@ -134,7 +122,7 @@ func GetTargetName(ctx context.Context, apiClient LoadBalancerClient, projectId, if targetPool.Targets == nil { return "", fmt.Errorf("no targets found") } - for _, target := range *targetPool.Targets { + for _, target := range targetPool.Targets { if target.Ip != nil && *target.Ip == targetIp { if target.DisplayName == nil { return "", fmt.Errorf("nil target display name") @@ -147,10 +135,9 @@ func GetTargetName(ctx context.Context, apiClient LoadBalancerClient, projectId, // GetUsedObsCredentials returns a list of credentials that are used by load balancers for observability metrics or logs. // It goes through all load balancers and checks what observability credentials are being used, then returns a list of those credentials. -func GetUsedObsCredentials(ctx context.Context, apiClient LoadBalancerClient, allCredentials []loadbalancer.CredentialsResponse, projectId, region string) ([]loadbalancer.CredentialsResponse, error) { +func GetUsedObsCredentials(ctx context.Context, apiClient loadbalancer.DefaultAPI, allCredentials []loadbalancer.CredentialsResponse, projectId, region string) ([]loadbalancer.CredentialsResponse, error) { var usedCredentialsSlice []loadbalancer.CredentialsResponse - - loadBalancers, err := apiClient.ListLoadBalancersExecute(ctx, projectId, region) + loadBalancers, err := apiClient.ListLoadBalancers(ctx, projectId, region).Execute() if err != nil { return nil, fmt.Errorf("list load balancers: %w", err) } @@ -159,8 +146,8 @@ func GetUsedObsCredentials(ctx context.Context, apiClient LoadBalancerClient, al } var usedCredentialsRefs []string - for i := range *loadBalancers.LoadBalancers { - loadBalancer := &(*loadBalancers.LoadBalancers)[i] + for i := range loadBalancers.LoadBalancers { + loadBalancer := &(loadBalancers.LoadBalancers)[i] if loadBalancer.Options == nil || loadBalancer.Options.Observability == nil { continue @@ -225,7 +212,7 @@ func GetUnusedObsCredentials(usedCredentials, allCredentials []loadbalancer.Cred // If unused is true, it returns only the credentials that are not used by any load balancer for observability metrics or logs. // If both used and unused are true, it returns an error. // If both used and unused are false, it returns the original list of credentials. -func FilterCredentials(ctx context.Context, client LoadBalancerClient, allCredentials []loadbalancer.CredentialsResponse, projectId, region string, filterOp int) ([]loadbalancer.CredentialsResponse, error) { +func FilterCredentials(ctx context.Context, client loadbalancer.DefaultAPI, allCredentials []loadbalancer.CredentialsResponse, projectId, region string, filterOp int) ([]loadbalancer.CredentialsResponse, error) { // check that filter OP is valid if filterOp != OP_FILTER_USED && filterOp != OP_FILTER_UNUSED && filterOp != OP_FILTER_NOP { return nil, fmt.Errorf("invalid filter operation") @@ -234,7 +221,6 @@ func FilterCredentials(ctx context.Context, client LoadBalancerClient, allCreden if filterOp == OP_FILTER_NOP { return allCredentials, nil } - usedCredentials, err := GetUsedObsCredentials(ctx, client, allCredentials, projectId, region) if err != nil { return nil, fmt.Errorf("get used observability credentials: %w", err) diff --git a/internal/pkg/services/load-balancer/utils/utils_test.go b/internal/pkg/services/load-balancer/utils/utils_test.go index 5941b2c93..942c886bf 100644 --- a/internal/pkg/services/load-balancer/utils/utils_test.go +++ b/internal/pkg/services/load-balancer/utils/utils_test.go @@ -7,7 +7,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/utils" - "github.com/stackitcloud/stackit-sdk-go/services/loadbalancer" + loadbalancer "github.com/stackitcloud/stackit-sdk-go/services/loadbalancer/v2api" "github.com/google/go-cmp/cmp" "github.com/google/uuid" @@ -25,7 +25,7 @@ const ( testLoadBalancerName = "my-load-balancer" ) -type loadBalancerClientMocked struct { +type mockSettings struct { getCredentialsFails bool getCredentialsResp *loadbalancer.GetCredentialsResponse getLoadBalancerFails bool @@ -34,38 +34,36 @@ type loadBalancerClientMocked struct { listLoadBalancersResp *loadbalancer.ListLoadBalancersResponse } -func (m *loadBalancerClientMocked) GetCredentialsExecute(_ context.Context, _, _, _ string) (*loadbalancer.GetCredentialsResponse, error) { - if m.getCredentialsFails { - return nil, fmt.Errorf("could not get credentials") - } - return m.getCredentialsResp, nil -} - -func (m *loadBalancerClientMocked) GetLoadBalancerExecute(_ context.Context, _, _, _ string) (*loadbalancer.LoadBalancer, error) { - if m.getLoadBalancerFails { - return nil, fmt.Errorf("could not get load balancer") - } - return m.getLoadBalancerResp, nil -} - -func (m *loadBalancerClientMocked) ListLoadBalancersExecute(_ context.Context, _, _ string) (*loadbalancer.ListLoadBalancersResponse, error) { - if m.listLoadBalancersFails { - return nil, fmt.Errorf("could not list load balancers") +func newAPIMock(s mockSettings) loadbalancer.DefaultAPI { + return &loadbalancer.DefaultAPIServiceMock{ + GetCredentialsExecuteMock: utils.Ptr(func(_ loadbalancer.ApiGetCredentialsRequest) (*loadbalancer.GetCredentialsResponse, error) { + if s.getCredentialsFails { + return nil, fmt.Errorf("could not get credentials") + } + return s.getCredentialsResp, nil + }), + GetLoadBalancerExecuteMock: utils.Ptr(func(_ loadbalancer.ApiGetLoadBalancerRequest) (*loadbalancer.LoadBalancer, error) { + if s.getLoadBalancerFails { + return nil, fmt.Errorf("could not get load balancer") + } + return s.getLoadBalancerResp, nil + }), + ListLoadBalancersExecuteMock: utils.Ptr(func(_ loadbalancer.ApiListLoadBalancersRequest) (*loadbalancer.ListLoadBalancersResponse, error) { + if s.listLoadBalancersFails { + return nil, fmt.Errorf("could not list load balancers") + } + return s.listLoadBalancersResp, nil + }), } - return m.listLoadBalancersResp, nil -} - -func (m *loadBalancerClientMocked) UpdateTargetPool(_ context.Context, _, _, _, _ string) loadbalancer.ApiUpdateTargetPoolRequest { - return loadbalancer.UpdateTargetPoolRequest{} } func fixtureLoadBalancer(mods ...func(*loadbalancer.LoadBalancer)) *loadbalancer.LoadBalancer { lb := loadbalancer.LoadBalancer{ Name: utils.Ptr(testLoadBalancerName), - TargetPools: &[]loadbalancer.TargetPool{ + TargetPools: []loadbalancer.TargetPool{ { Name: utils.Ptr("target-pool-1"), - Targets: &[]loadbalancer.Target{ + Targets: []loadbalancer.Target{ { DisplayName: utils.Ptr("target-1"), Ip: utils.Ptr("1.2.3.4"), @@ -78,7 +76,7 @@ func fixtureLoadBalancer(mods ...func(*loadbalancer.LoadBalancer)) *loadbalancer }, { Name: utils.Ptr("target-pool-2"), - Targets: &[]loadbalancer.Target{ + Targets: []loadbalancer.Target{ { DisplayName: utils.Ptr("target-1"), Ip: utils.Ptr("6.7.8.9"), @@ -136,8 +134,8 @@ func fixtureCredentials(mod ...func([]loadbalancer.CredentialsResponse)) []loadb return credentials } -func fixtureTargets(mod ...func(*[]loadbalancer.Target)) *[]loadbalancer.Target { - targets := &[]loadbalancer.Target{ +func fixtureTargets(mod ...func([]loadbalancer.Target)) []loadbalancer.Target { + targets := []loadbalancer.Target{ { DisplayName: utils.Ptr("target-1"), Ip: utils.Ptr("1.2.3.4"), @@ -186,12 +184,12 @@ func TestGetCredentialsDisplayName(t *testing.T) { for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { - client := &loadBalancerClientMocked{ + client := mockSettings{ getCredentialsFails: tt.getCredentialsFails, getCredentialsResp: tt.getCredentialsResp, } - output, err := GetCredentialsDisplayName(context.Background(), client, testProjectId, testRegion, testCredentialsRef) + output, err := GetCredentialsDisplayName(context.Background(), newAPIMock(client), testProjectId, testRegion, testCredentialsRef) if tt.isValid && err != nil { t.Errorf("failed on valid input") @@ -225,7 +223,7 @@ func TestGetLoadBalancerTargetPool(t *testing.T) { isValid: true, expectedOutput: &loadbalancer.TargetPool{ Name: utils.Ptr("target-pool-1"), - Targets: &[]loadbalancer.Target{ + Targets: []loadbalancer.Target{ { DisplayName: utils.Ptr("target-1"), Ip: utils.Ptr("1.2.3.4"), @@ -246,7 +244,7 @@ func TestGetLoadBalancerTargetPool(t *testing.T) { { description: "no target pools", getLoadBalancerResp: fixtureLoadBalancer(func(lb *loadbalancer.LoadBalancer) { - lb.TargetPools = &[]loadbalancer.TargetPool{} + lb.TargetPools = []loadbalancer.TargetPool{} }), isValid: false, }, @@ -266,12 +264,12 @@ func TestGetLoadBalancerTargetPool(t *testing.T) { for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { - client := &loadBalancerClientMocked{ + client := mockSettings{ getLoadBalancerFails: tt.getLoadBalancerFails, getLoadBalancerResp: tt.getLoadBalancerResp, } - output, err := GetLoadBalancerTargetPool(context.Background(), client, testProjectId, testRegion, testLoadBalancerName, tt.targetPoolName) + output, err := GetLoadBalancerTargetPool(context.Background(), newAPIMock(client), testProjectId, testRegion, testLoadBalancerName, tt.targetPoolName) if tt.isValid && err != nil { t.Errorf("failed on valid input") @@ -424,7 +422,7 @@ func TestAddTargetToTargetPool(t *testing.T) { description: "base", targetPool: &loadbalancer.TargetPool{ Name: utils.Ptr("target-pool-1"), - Targets: &[]loadbalancer.Target{ + Targets: []loadbalancer.Target{ { DisplayName: utils.Ptr("target-1"), Ip: utils.Ptr("1.2.3.4"), @@ -438,7 +436,7 @@ func TestAddTargetToTargetPool(t *testing.T) { isValid: true, expectedTargetPool: &loadbalancer.TargetPool{ Name: utils.Ptr("target-pool-1"), - Targets: &[]loadbalancer.Target{ + Targets: []loadbalancer.Target{ { DisplayName: utils.Ptr("target-1"), Ip: utils.Ptr("1.2.3.4"), @@ -454,7 +452,7 @@ func TestAddTargetToTargetPool(t *testing.T) { description: "no target pool targets", targetPool: &loadbalancer.TargetPool{ Name: utils.Ptr("target-pool-1"), - Targets: &[]loadbalancer.Target{}, + Targets: []loadbalancer.Target{}, }, target: &loadbalancer.Target{ DisplayName: utils.Ptr("target-3"), @@ -463,7 +461,7 @@ func TestAddTargetToTargetPool(t *testing.T) { isValid: true, expectedTargetPool: &loadbalancer.TargetPool{ Name: utils.Ptr("target-pool-1"), - Targets: &[]loadbalancer.Target{ + Targets: []loadbalancer.Target{ { DisplayName: utils.Ptr("target-3"), Ip: utils.Ptr("2.2.2.2"), @@ -484,7 +482,7 @@ func TestAddTargetToTargetPool(t *testing.T) { isValid: true, expectedTargetPool: &loadbalancer.TargetPool{ Name: utils.Ptr("target-pool-1"), - Targets: &[]loadbalancer.Target{ + Targets: []loadbalancer.Target{ { DisplayName: utils.Ptr("target-3"), Ip: utils.Ptr("2.2.2.2"), @@ -505,7 +503,7 @@ func TestAddTargetToTargetPool(t *testing.T) { description: "nil new target", targetPool: &loadbalancer.TargetPool{ Name: utils.Ptr("target-pool-1"), - Targets: &[]loadbalancer.Target{ + Targets: []loadbalancer.Target{ { DisplayName: utils.Ptr("target-1"), Ip: utils.Ptr("1.2.3.4"), @@ -556,7 +554,7 @@ func TestRemoveTargetFromTargetPool(t *testing.T) { isValid: true, expectedTargetPool: &loadbalancer.TargetPool{ Name: utils.Ptr("target-pool-1"), - Targets: &[]loadbalancer.Target{ + Targets: []loadbalancer.Target{ { DisplayName: utils.Ptr("target-2"), Ip: utils.Ptr("2.2.2.2"), @@ -578,7 +576,7 @@ func TestRemoveTargetFromTargetPool(t *testing.T) { isValid: true, expectedTargetPool: &loadbalancer.TargetPool{ Name: utils.Ptr("target-pool-1"), - Targets: &[]loadbalancer.Target{ + Targets: []loadbalancer.Target{ { DisplayName: utils.Ptr("target-1"), Ip: utils.Ptr("1.2.3.4"), @@ -600,7 +598,7 @@ func TestRemoveTargetFromTargetPool(t *testing.T) { isValid: true, expectedTargetPool: &loadbalancer.TargetPool{ Name: utils.Ptr("target-pool-1"), - Targets: &[]loadbalancer.Target{ + Targets: []loadbalancer.Target{ { DisplayName: utils.Ptr("target-1"), Ip: utils.Ptr("1.2.3.4"), @@ -616,7 +614,7 @@ func TestRemoveTargetFromTargetPool(t *testing.T) { description: "remove only target", targetPool: &loadbalancer.TargetPool{ Name: utils.Ptr("target-pool-1"), - Targets: &[]loadbalancer.Target{ + Targets: []loadbalancer.Target{ { DisplayName: utils.Ptr("target-1"), Ip: utils.Ptr("1.2.3.4"), @@ -627,14 +625,14 @@ func TestRemoveTargetFromTargetPool(t *testing.T) { isValid: true, expectedTargetPool: &loadbalancer.TargetPool{ Name: utils.Ptr("target-pool-1"), - Targets: &[]loadbalancer.Target{}, + Targets: []loadbalancer.Target{}, }, }, { description: "no target pool targets", targetPool: &loadbalancer.TargetPool{ Name: utils.Ptr("target-pool-1"), - Targets: &[]loadbalancer.Target{}, + Targets: []loadbalancer.Target{}, }, targetIp: "2.2.2.2", isValid: false, @@ -688,13 +686,13 @@ func TestToPayloadTargetPool(t *testing.T) { input: &loadbalancer.TargetPool{ Name: utils.Ptr("target-pool-1"), ActiveHealthCheck: &loadbalancer.ActiveHealthCheck{ - UnhealthyThreshold: utils.Ptr(int64(3)), + UnhealthyThreshold: utils.Ptr(int32(3)), }, SessionPersistence: &loadbalancer.SessionPersistence{ UseSourceIpAddress: utils.Ptr(true), }, - TargetPort: utils.Ptr(int64(80)), - Targets: &[]loadbalancer.Target{ + TargetPort: utils.Ptr(int32(80)), + Targets: []loadbalancer.Target{ { DisplayName: utils.Ptr("target-1"), Ip: utils.Ptr("1.2.3.4"), @@ -704,13 +702,13 @@ func TestToPayloadTargetPool(t *testing.T) { expected: &loadbalancer.UpdateTargetPoolPayload{ Name: utils.Ptr("target-pool-1"), ActiveHealthCheck: &loadbalancer.ActiveHealthCheck{ - UnhealthyThreshold: utils.Ptr(int64(3)), + UnhealthyThreshold: utils.Ptr(int32(3)), }, SessionPersistence: &loadbalancer.SessionPersistence{ UseSourceIpAddress: utils.Ptr(true), }, - TargetPort: utils.Ptr(int64(80)), - Targets: &[]loadbalancer.Target{ + TargetPort: utils.Ptr(int32(80)), + Targets: []loadbalancer.Target{ { DisplayName: utils.Ptr("target-1"), Ip: utils.Ptr("1.2.3.4"), @@ -767,10 +765,10 @@ func TestGetTargetName(t *testing.T) { targetPoolName: "target-pool-1", targetIp: "1.2.3.4", getLoadBalancerResp: fixtureLoadBalancer(func(lb *loadbalancer.LoadBalancer) { - lb.TargetPools = &[]loadbalancer.TargetPool{ + lb.TargetPools = []loadbalancer.TargetPool{ { Name: utils.Ptr("target-pool-1"), - Targets: &[]loadbalancer.Target{}, + Targets: []loadbalancer.Target{}, }, } }), @@ -781,7 +779,7 @@ func TestGetTargetName(t *testing.T) { targetPoolName: "target-pool-1", targetIp: "1.2.3.4", getLoadBalancerResp: fixtureLoadBalancer(func(lb *loadbalancer.LoadBalancer) { - lb.TargetPools = &[]loadbalancer.TargetPool{ + lb.TargetPools = []loadbalancer.TargetPool{ { Name: utils.Ptr("target-pool-1"), Targets: nil, @@ -796,10 +794,10 @@ func TestGetTargetName(t *testing.T) { targetIp: "1.2.3.4", getLoadBalancerResp: fixtureLoadBalancer( func(lb *loadbalancer.LoadBalancer) { - lb.TargetPools = &[]loadbalancer.TargetPool{ + lb.TargetPools = []loadbalancer.TargetPool{ { Name: utils.Ptr("target-pool-1"), - Targets: &[]loadbalancer.Target{ + Targets: []loadbalancer.Target{ { DisplayName: nil, Ip: utils.Ptr("1.2.3.4"), @@ -821,11 +819,11 @@ func TestGetTargetName(t *testing.T) { for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { - client := &loadBalancerClientMocked{ + client := mockSettings{ getLoadBalancerResp: tt.getLoadBalancerResp, } - output, err := GetTargetName(context.Background(), client, testProjectId, testRegion, testLoadBalancerName, tt.targetPoolName, tt.targetIp) + output, err := GetTargetName(context.Background(), newAPIMock(client), testProjectId, testRegion, testLoadBalancerName, tt.targetPoolName, tt.targetIp) if tt.isValid && err != nil { t.Errorf("failed on valid input") @@ -856,7 +854,7 @@ func TestGetUsedObsCredentials(t *testing.T) { description: "base", allCredentials: fixtureCredentials(), listLoadBalancersResp: &loadbalancer.ListLoadBalancersResponse{ - LoadBalancers: &[]loadbalancer.LoadBalancer{ + LoadBalancers: []loadbalancer.LoadBalancer{ *fixtureLoadBalancer(), }, }, @@ -878,7 +876,7 @@ func TestGetUsedObsCredentials(t *testing.T) { description: "repeated credentials in different load balancers", allCredentials: fixtureCredentials(), listLoadBalancersResp: &loadbalancer.ListLoadBalancersResponse{ - LoadBalancers: &[]loadbalancer.LoadBalancer{ + LoadBalancers: []loadbalancer.LoadBalancer{ *fixtureLoadBalancer(), *fixtureLoadBalancer(), }, @@ -901,7 +899,7 @@ func TestGetUsedObsCredentials(t *testing.T) { description: "no repeated credentials in different load balancers", allCredentials: fixtureCredentials(), listLoadBalancersResp: &loadbalancer.ListLoadBalancersResponse{ - LoadBalancers: &[]loadbalancer.LoadBalancer{ + LoadBalancers: []loadbalancer.LoadBalancer{ *fixtureLoadBalancer(), *fixtureLoadBalancer(func(lb *loadbalancer.LoadBalancer) { lb.Options.Observability.Logs.CredentialsRef = utils.Ptr("credentials-ref-3") @@ -929,7 +927,7 @@ func TestGetUsedObsCredentials(t *testing.T) { description: "no credentials", allCredentials: []loadbalancer.CredentialsResponse{}, listLoadBalancersResp: &loadbalancer.ListLoadBalancersResponse{ - LoadBalancers: &[]loadbalancer.LoadBalancer{ + LoadBalancers: []loadbalancer.LoadBalancer{ *fixtureLoadBalancer(), }, }, @@ -945,7 +943,7 @@ func TestGetUsedObsCredentials(t *testing.T) { description: "no observability options", allCredentials: fixtureCredentials(), listLoadBalancersResp: &loadbalancer.ListLoadBalancersResponse{ - LoadBalancers: &[]loadbalancer.LoadBalancer{ + LoadBalancers: []loadbalancer.LoadBalancer{ *fixtureLoadBalancer(func(lb *loadbalancer.LoadBalancer) { lb.Options = nil }), @@ -958,12 +956,12 @@ func TestGetUsedObsCredentials(t *testing.T) { for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { - client := &loadBalancerClientMocked{ + client := mockSettings{ listLoadBalancersFails: tt.listLoadBalancersFails, listLoadBalancersResp: tt.listLoadBalancersResp, } - output, err := GetUsedObsCredentials(testCtx, client, tt.allCredentials, testProjectId, testRegion) + output, err := GetUsedObsCredentials(testCtx, newAPIMock(client), tt.allCredentials, testProjectId, testRegion) if tt.isValid && err != nil { t.Errorf("failed on valid input") @@ -1077,7 +1075,7 @@ func TestFilterCredentials(t *testing.T) { filterOp: OP_FILTER_USED, allCredentials: fixtureCredentials(), listLoadBalancersResp: &loadbalancer.ListLoadBalancersResponse{ - LoadBalancers: &[]loadbalancer.LoadBalancer{ + LoadBalancers: []loadbalancer.LoadBalancer{ *fixtureLoadBalancer(), }, }, @@ -1100,7 +1098,7 @@ func TestFilterCredentials(t *testing.T) { filterOp: OP_FILTER_UNUSED, allCredentials: fixtureCredentials(), listLoadBalancersResp: &loadbalancer.ListLoadBalancersResponse{ - LoadBalancers: &[]loadbalancer.LoadBalancer{ + LoadBalancers: []loadbalancer.LoadBalancer{ *fixtureLoadBalancer(), }, }, @@ -1136,11 +1134,11 @@ func TestFilterCredentials(t *testing.T) { for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { - client := &loadBalancerClientMocked{ + client := mockSettings{ listLoadBalancersResp: tt.listLoadBalancersResp, listLoadBalancersFails: tt.listLoadBalancersFails, } - filteredCredentials, err := FilterCredentials(testCtx, client, tt.allCredentials, testProjectId, testRegion, tt.filterOp) + filteredCredentials, err := FilterCredentials(testCtx, newAPIMock(client), tt.allCredentials, testProjectId, testRegion, tt.filterOp) if err != nil { if !tt.isValid { return From 6fd51b30f5ad3399f35fda151db4788aae90d0de Mon Sep 17 00:00:00 2001 From: cgoetz-inovex Date: Tue, 16 Jun 2026 15:22:10 +0200 Subject: [PATCH 03/44] chore(kms): migrate kms to new multi version sdk (#1437) STACKITCLI-364 --- docs/stackit_kms_key_create.md | 6 +- docs/stackit_kms_wrapping-key_create.md | 6 +- go.mod | 4 +- go.sum | 8 +- internal/cmd/kms/key/create/create.go | 75 +++++++++--------- internal/cmd/kms/key/create/create_test.go | 50 ++++++------ internal/cmd/kms/key/delete/delete.go | 10 +-- internal/cmd/kms/key/delete/delete_test.go | 8 +- internal/cmd/kms/key/describe/describe.go | 24 +++--- .../cmd/kms/key/describe/describe_test.go | 28 +++---- internal/cmd/kms/key/importKey/importKey.go | 20 ++--- .../cmd/kms/key/importKey/importKey_test.go | 18 ++--- internal/cmd/kms/key/list/list.go | 16 ++-- internal/cmd/kms/key/list/list_test.go | 14 ++-- internal/cmd/kms/key/restore/restore.go | 10 +-- internal/cmd/kms/key/restore/restore_test.go | 8 +- internal/cmd/kms/key/rotate/rotate.go | 8 +- internal/cmd/kms/key/rotate/rotate_test.go | 8 +- internal/cmd/kms/keyring/create/create.go | 17 ++--- .../cmd/kms/keyring/create/create_test.go | 12 +-- internal/cmd/kms/keyring/delete/delete.go | 6 +- .../cmd/kms/keyring/delete/delete_test.go | 8 +- internal/cmd/kms/keyring/describe/describe.go | 12 +-- .../cmd/kms/keyring/describe/describe_test.go | 16 ++-- internal/cmd/kms/keyring/list/list.go | 13 ++-- internal/cmd/kms/keyring/list/list_test.go | 14 ++-- internal/cmd/kms/version/destroy/destroy.go | 9 +-- .../cmd/kms/version/destroy/destroy_test.go | 8 +- internal/cmd/kms/version/disable/disable.go | 13 ++-- .../cmd/kms/version/disable/disable_test.go | 8 +- internal/cmd/kms/version/enable/enable.go | 13 ++-- .../cmd/kms/version/enable/enable_test.go | 8 +- internal/cmd/kms/version/list/list.go | 14 ++-- internal/cmd/kms/version/list/list_test.go | 14 ++-- internal/cmd/kms/version/restore/restore.go | 9 +-- .../cmd/kms/version/restore/restore_test.go | 8 +- internal/cmd/kms/wrappingkey/create/create.go | 76 +++++++++---------- .../cmd/kms/wrappingkey/create/create_test.go | 50 ++++++------ internal/cmd/kms/wrappingkey/delete/delete.go | 6 +- .../cmd/kms/wrappingkey/delete/delete_test.go | 8 +- .../cmd/kms/wrappingkey/describe/describe.go | 24 +++--- .../kms/wrappingkey/describe/describe_test.go | 28 +++---- internal/cmd/kms/wrappingkey/list/list.go | 19 +++-- .../cmd/kms/wrappingkey/list/list_test.go | 14 ++-- internal/pkg/services/kms/client/client.go | 4 +- internal/pkg/services/kms/utils/utils.go | 36 ++++----- internal/pkg/services/kms/utils/utils_test.go | 57 +++++++------- 47 files changed, 414 insertions(+), 431 deletions(-) diff --git a/docs/stackit_kms_key_create.md b/docs/stackit_kms_key_create.md index dcf9716f3..4948416f5 100644 --- a/docs/stackit_kms_key_create.md +++ b/docs/stackit_kms_key_create.md @@ -35,14 +35,14 @@ stackit kms key create [flags] ### Options ``` - --algorithm string En-/Decryption / signing algorithm. Possible values: ["aes_256_gcm" "rsa_2048_oaep_sha256" "rsa_3072_oaep_sha256" "rsa_4096_oaep_sha256" "rsa_4096_oaep_sha512" "hmac_sha256" "hmac_sha384" "hmac_sha512" "ecdsa_p256_sha256" "ecdsa_p384_sha384" "ecdsa_p521_sha512"] + --algorithm string En-/Decryption / signing algorithm. (possible values: [aes_256_gcm, rsa_2048_oaep_sha256, rsa_3072_oaep_sha256, rsa_4096_oaep_sha256, rsa_4096_oaep_sha512, hmac_sha256, hmac_sha384, hmac_sha512, ecdsa_p256_sha256, ecdsa_p384_sha384, ecdsa_p521_sha512]) --description string Optional description of the key -h, --help Help for "stackit kms key create" --import-only States whether versions can be created or only imported --keyring-id string ID of the KMS key ring --name string The display name to distinguish multiple keys - --protection string The underlying system that is responsible for protecting the key material. Possible values: ["symmetric_encrypt_decrypt" "asymmetric_encrypt_decrypt" "message_authentication_code" "asymmetric_sign_verify"] - --purpose string Purpose of the key. Possible values: ["symmetric_encrypt_decrypt" "asymmetric_encrypt_decrypt" "message_authentication_code" "asymmetric_sign_verify"] + --protection string The underlying system that is responsible for protecting the key material. (possible values: [software]) + --purpose string Purpose of the key. (possible values: [symmetric_encrypt_decrypt, asymmetric_encrypt_decrypt, message_authentication_code, asymmetric_sign_verify]) ``` ### Options inherited from parent commands diff --git a/docs/stackit_kms_wrapping-key_create.md b/docs/stackit_kms_wrapping-key_create.md index 616f60ac7..1ba75e7c8 100644 --- a/docs/stackit_kms_wrapping-key_create.md +++ b/docs/stackit_kms_wrapping-key_create.md @@ -23,13 +23,13 @@ stackit kms wrapping-key create [flags] ### Options ``` - --algorithm string En-/Decryption / signing algorithm. Possible values: ["rsa_2048_oaep_sha256" "rsa_3072_oaep_sha256" "rsa_4096_oaep_sha256" "rsa_4096_oaep_sha512" "rsa_2048_oaep_sha256_aes_256_key_wrap" "rsa_3072_oaep_sha256_aes_256_key_wrap" "rsa_4096_oaep_sha256_aes_256_key_wrap" "rsa_4096_oaep_sha512_aes_256_key_wrap"] + --algorithm string En-/Decryption / signing algorithm. (possible values: [rsa_2048_oaep_sha256, rsa_3072_oaep_sha256, rsa_4096_oaep_sha256, rsa_4096_oaep_sha512, rsa_2048_oaep_sha256_aes_256_key_wrap, rsa_3072_oaep_sha256_aes_256_key_wrap, rsa_4096_oaep_sha256_aes_256_key_wrap, rsa_4096_oaep_sha512_aes_256_key_wrap]) --description string Optional description of the wrapping key -h, --help Help for "stackit kms wrapping-key create" --keyring-id string ID of the KMS key ring --name string The display name to distinguish multiple wrapping keys - --protection string The underlying system that is responsible for protecting the wrapping key material. Possible values: ["wrap_symmetric_key" "wrap_asymmetric_key"] - --purpose string Purpose of the wrapping key. Possible values: ["wrap_symmetric_key" "wrap_asymmetric_key"] + --protection string The underlying system that is responsible for protecting the key material. (possible values: [software]) + --purpose string Purpose of the key. (possible values: [wrap_symmetric_key, wrap_asymmetric_key]) ``` ### Options inherited from parent commands diff --git a/go.mod b/go.mod index 80338dc54..1ba8fc21a 100644 --- a/go.mod +++ b/go.mod @@ -36,8 +36,8 @@ require ( github.com/stackitcloud/stackit-sdk-go/services/serviceaccount v0.12.0 github.com/stackitcloud/stackit-sdk-go/services/serviceenablement v1.2.7 github.com/stackitcloud/stackit-sdk-go/services/ske v1.11.0 - github.com/stackitcloud/stackit-sdk-go/services/vpn v0.14.0 github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex v1.11.0 + github.com/stackitcloud/stackit-sdk-go/services/vpn v0.14.0 github.com/zalando/go-keyring v0.2.6 golang.org/x/mod v0.34.0 golang.org/x/oauth2 v0.35.0 @@ -265,7 +265,7 @@ require ( github.com/sourcegraph/conc v0.3.1-0.20240121214520-5f936abd7ae8 // indirect github.com/spf13/afero v1.15.0 // indirect github.com/spf13/cast v1.10.0 // indirect - github.com/stackitcloud/stackit-sdk-go/services/kms v1.3.2 + github.com/stackitcloud/stackit-sdk-go/services/kms v1.11.0 github.com/stackitcloud/stackit-sdk-go/services/loadbalancer v1.14.0 github.com/stackitcloud/stackit-sdk-go/services/logme v0.25.6 github.com/stackitcloud/stackit-sdk-go/services/mariadb v0.25.6 diff --git a/go.sum b/go.sum index f9f2fe20e..e08536c68 100644 --- a/go.sum +++ b/go.sum @@ -612,8 +612,8 @@ github.com/stackitcloud/stackit-sdk-go/services/iaas v1.12.0 h1:H4V3H8qSKOaOalIr github.com/stackitcloud/stackit-sdk-go/services/iaas v1.12.0/go.mod h1:Ts06id0KejUlQWbpR+/rm+tKng6QkTuFV1VQTPJ4dA4= github.com/stackitcloud/stackit-sdk-go/services/intake v0.7.1 h1:7ZSrwps/zI41rl+xYkG4osld8cyAwssyl/UZ/Iu/F2g= github.com/stackitcloud/stackit-sdk-go/services/intake v0.7.1/go.mod h1:ZIvwBZwEMFO+YfJLCNXqabslI0Fp9zxV7ZBwlZjk7uE= -github.com/stackitcloud/stackit-sdk-go/services/kms v1.3.2 h1:2ulSL2IkIAKND59eAjbEhVkOoBMyvm48ojwz1a3t0U0= -github.com/stackitcloud/stackit-sdk-go/services/kms v1.3.2/go.mod h1:cuIaMMiHeHQsbvy7BOFMutoV3QtN+ZBx7Tg3GmYUw7s= +github.com/stackitcloud/stackit-sdk-go/services/kms v1.11.0 h1:OrUaDypQNr1nOXZfVQXCwUpN4YhR5y0vtvYi9/Ogoi4= +github.com/stackitcloud/stackit-sdk-go/services/kms v1.11.0/go.mod h1:pVaCmb1ZHAPGVRlSlBlVOjThp9Tb2sX9+nRX0M+d1KU= github.com/stackitcloud/stackit-sdk-go/services/loadbalancer v1.14.0 h1:1dvL7tX91ziklayQmOupniE3jM4D5Nbtc0auNcx2p18= github.com/stackitcloud/stackit-sdk-go/services/loadbalancer v1.14.0/go.mod h1:+Ld3dn648I+YKcBV3fEkYpDSr3fel421+LurJGywSBs= github.com/stackitcloud/stackit-sdk-go/services/logme v0.25.6 h1:4x30lC+YBmo7XpsAzTn0W+C/oP5flnLVgIh5u3O/P0o= @@ -654,10 +654,10 @@ github.com/stackitcloud/stackit-sdk-go/services/sfs v0.9.0 h1:JWAFnskRbNKT8x62pZ github.com/stackitcloud/stackit-sdk-go/services/sfs v0.9.0/go.mod h1:jMlBoXqrPNX5nXbo6oT7exalqilw1jiLPoIp4Cn0CdI= github.com/stackitcloud/stackit-sdk-go/services/ske v1.11.0 h1:QoKyQPe8FqDqJLNgE5uRlZ/y1c1GUxjV1DDLu5QEBD8= github.com/stackitcloud/stackit-sdk-go/services/ske v1.11.0/go.mod h1:KhVYCR58wETqdI7Quwhe3OR3BhB2T/b7DzaMsfDnr8g= -github.com/stackitcloud/stackit-sdk-go/services/vpn v0.14.0 h1:LMgbzhPunuelsIsfyEj/5O/aYfNcg/eGHsnZ7AZOhYg= -github.com/stackitcloud/stackit-sdk-go/services/vpn v0.14.0/go.mod h1:toIjQk1dhxdUFVyCWJJja0w/0nFpDid8MWX0ukQfvfo= github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex v1.11.0 h1:PwjQeupEnXxhu+uWCUzO/hUfL4yqNblOcZbP2jvaQtU= github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex v1.11.0/go.mod h1:AiUoMAqQcOlMgDtkVJlqI7P/VGD5xjN3dYjERGnwN/M= +github.com/stackitcloud/stackit-sdk-go/services/vpn v0.14.0 h1:LMgbzhPunuelsIsfyEj/5O/aYfNcg/eGHsnZ7AZOhYg= +github.com/stackitcloud/stackit-sdk-go/services/vpn v0.14.0/go.mod h1:toIjQk1dhxdUFVyCWJJja0w/0nFpDid8MWX0ukQfvfo= github.com/stbenjam/no-sprintf-host-port v0.3.1 h1:AyX7+dxI4IdLBPtDbsGAyqiTSLpCP9hWRrXQDU4Cm/g= github.com/stbenjam/no-sprintf-host-port v0.3.1/go.mod h1:ODbZesTCHMVKthBHskvUUexdcNHAQRXk9NpSsL8p/HQ= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= diff --git a/internal/cmd/kms/key/create/create.go b/internal/cmd/kms/key/create/create.go index 740deffa9..0b78618e0 100644 --- a/internal/cmd/kms/key/create/create.go +++ b/internal/cmd/kms/key/create/create.go @@ -13,8 +13,8 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/services/kms/client" "github.com/stackitcloud/stackit-cli/internal/pkg/spinner" - "github.com/stackitcloud/stackit-sdk-go/services/kms" - "github.com/stackitcloud/stackit-sdk-go/services/kms/wait" + kms "github.com/stackitcloud/stackit-sdk-go/services/kms/v1api" + "github.com/stackitcloud/stackit-sdk-go/services/kms/v1api/wait" "github.com/stackitcloud/stackit-cli/internal/pkg/examples" "github.com/stackitcloud/stackit-cli/internal/pkg/flags" @@ -26,24 +26,38 @@ import ( const ( keyRingIdFlag = "keyring-id" - algorithmFlag = "algorithm" descriptionFlag = "description" displayNameFlag = "name" importOnlyFlag = "import-only" - purposeFlag = "purpose" - protectionFlag = "protection" +) + +var ( + algorithmFlag = flags.StringEnumFlag( + "algorithm", + kms.AllowedAlgorithmEnumValues, + "En-/Decryption / signing algorithm.", + ) + purposeFlag = flags.StringEnumFlag( + "purpose", + kms.AllowedPurposeEnumValues, + "Purpose of the key.", + ) + protectionFlag = flags.StringEnumFlag( + "protection", + kms.AllowedProtectionEnumValues, + "The underlying system that is responsible for protecting the key material.") ) type inputModel struct { *globalflags.GlobalFlagModel KeyRingId string - Algorithm *string + Algorithm kms.Algorithm Description *string Name *string ImportOnly bool // Default false - Purpose *string - Protection *string + Purpose kms.Purpose + Protection kms.Protection } func NewCmd(params *types.CmdParams) *cobra.Command { @@ -91,7 +105,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } // Call API - req, _ := buildRequest(ctx, model, apiClient) + req, _ := buildRequest(ctx, model, apiClient.DefaultAPI) resp, err := req.Execute() if err != nil { return fmt.Errorf("create KMS key: %w", err) @@ -100,7 +114,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { // Wait for async operation, if async mode not enabled if !model.Async { err := spinner.Run(params.Printer, "Creating key", func() error { - _, err = wait.CreateOrUpdateKeyWaitHandler(ctx, apiClient, model.ProjectId, model.Region, model.KeyRingId, *resp.Id).WaitWithContext(ctx) + _, err = wait.CreateOrUpdateKeyWaitHandler(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, model.KeyRingId, resp.Id).WaitWithContext(ctx) return err }) if err != nil { @@ -124,12 +138,12 @@ func parseInput(p *print.Printer, cmd *cobra.Command) (*inputModel, error) { model := inputModel{ GlobalFlagModel: globalFlags, KeyRingId: flags.FlagToStringValue(p, cmd, keyRingIdFlag), - Algorithm: flags.FlagToStringPointer(p, cmd, algorithmFlag), + Algorithm: algorithmFlag.Get(), Name: flags.FlagToStringPointer(p, cmd, displayNameFlag), Description: flags.FlagToStringPointer(p, cmd, descriptionFlag), ImportOnly: flags.FlagToBoolValue(p, cmd, importOnlyFlag), - Purpose: flags.FlagToStringPointer(p, cmd, purposeFlag), - Protection: flags.FlagToStringPointer(p, cmd, protectionFlag), + Purpose: purposeFlag.Get(), + Protection: protectionFlag.Get(), } p.DebugInputModel(model) @@ -144,12 +158,12 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient kmsKeyClient req := apiClient.CreateKey(ctx, model.ProjectId, model.Region, model.KeyRingId) req = req.CreateKeyPayload(kms.CreateKeyPayload{ - DisplayName: model.Name, + DisplayName: utils.PtrString(model.Name), Description: model.Description, - Algorithm: kms.CreateKeyPayloadGetAlgorithmAttributeType(model.Algorithm), - Purpose: kms.CreateKeyPayloadGetPurposeAttributeType(model.Purpose), + Algorithm: model.Algorithm, + Purpose: model.Purpose, ImportOnly: &model.ImportOnly, - Protection: kms.CreateKeyPayloadGetProtectionAttributeType(model.Protection), + Protection: model.Protection, }) return req, nil } @@ -164,32 +178,15 @@ func outputResult(p *print.Printer, model *inputModel, resp *kms.Key) error { if model.Async { operationState = "Triggered creation of" } - p.Outputf("%s the KMS key %q. Key ID: %s\n", operationState, utils.PtrString(resp.DisplayName), utils.PtrString(resp.Id)) + p.Outputf("%s the KMS key %q. Key ID: %s\n", operationState, resp.DisplayName, resp.Id) return nil }) } func configureFlags(cmd *cobra.Command) { - // Algorithm - var algorithmFlagOptions []string - for _, val := range kms.AllowedAlgorithmEnumValues { - algorithmFlagOptions = append(algorithmFlagOptions, string(val)) - } - cmd.Flags().Var(flags.EnumFlag(false, "", algorithmFlagOptions...), algorithmFlag, fmt.Sprintf("En-/Decryption / signing algorithm. Possible values: %q", algorithmFlagOptions)) - - // Purpose - var purposeFlagOptions []string - for _, val := range kms.AllowedPurposeEnumValues { - purposeFlagOptions = append(purposeFlagOptions, string(val)) - } - cmd.Flags().Var(flags.EnumFlag(false, "", purposeFlagOptions...), purposeFlag, fmt.Sprintf("Purpose of the key. Possible values: %q", purposeFlagOptions)) - - // Protection - var protectionFlagOptions []string - for _, val := range kms.AllowedProtectionEnumValues { - protectionFlagOptions = append(protectionFlagOptions, string(val)) - } - cmd.Flags().Var(flags.EnumFlag(false, "", protectionFlagOptions...), protectionFlag, fmt.Sprintf("The underlying system that is responsible for protecting the key material. Possible values: %q", purposeFlagOptions)) + algorithmFlag.Register(cmd) + purposeFlag.Register(cmd) + protectionFlag.Register(cmd) // All further non Enum Flags cmd.Flags().Var(flags.UUIDFlag(), keyRingIdFlag, "ID of the KMS key ring") @@ -197,6 +194,6 @@ func configureFlags(cmd *cobra.Command) { cmd.Flags().String(descriptionFlag, "", "Optional description of the key") cmd.Flags().Bool(importOnlyFlag, false, "States whether versions can be created or only imported") - err := flags.MarkFlagsRequired(cmd, keyRingIdFlag, algorithmFlag, purposeFlag, displayNameFlag, protectionFlag) + err := flags.MarkFlagsRequired(cmd, keyRingIdFlag, algorithmFlag.Name(), purposeFlag.Name(), displayNameFlag, protectionFlag.Name()) cobra.CheckErr(err) } diff --git a/internal/cmd/kms/key/create/create_test.go b/internal/cmd/kms/key/create/create_test.go index 6b070db73..94978102f 100644 --- a/internal/cmd/kms/key/create/create_test.go +++ b/internal/cmd/kms/key/create/create_test.go @@ -8,7 +8,7 @@ import ( "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/kms" + kms "github.com/stackitcloud/stackit-sdk-go/services/kms/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/print" @@ -18,19 +18,19 @@ import ( const ( testRegion = "eu01" - testAlgorithm = "rsa_2048_oaep_sha256" + testAlgorithm = kms.ALGORITHM_RSA_2048_OAEP_SHA256 testDisplayName = "my-key" - testPurpose = "asymmetric_encrypt_decrypt" + testPurpose = kms.PURPOSE_ASYMMETRIC_ENCRYPT_DECRYPT testDescription = "my key description" testImportOnly = "true" - testProtection = "software" + testProtection = kms.PROTECTION_SOFTWARE ) type testCtxKey struct{} var ( testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") - testClient = &kms.APIClient{} + testClient = &kms.APIClient{DefaultAPI: &kms.DefaultAPIService{}} testProjectId = uuid.NewString() testKeyRingId = uuid.NewString() ) @@ -41,12 +41,12 @@ func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]st globalflags.ProjectIdFlag: testProjectId, globalflags.RegionFlag: testRegion, keyRingIdFlag: testKeyRingId, - algorithmFlag: testAlgorithm, + algorithmFlag.Name(): string(testAlgorithm), displayNameFlag: testDisplayName, - purposeFlag: testPurpose, + purposeFlag.Name(): string(testPurpose), descriptionFlag: testDescription, importOnlyFlag: testImportOnly, - protectionFlag: testProtection, + protectionFlag.Name(): string(testProtection), } for _, mod := range mods { mod(flagValues) @@ -63,12 +63,12 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { Verbosity: globalflags.VerbosityDefault, }, KeyRingId: testKeyRingId, - Algorithm: utils.Ptr(testAlgorithm), + Algorithm: testAlgorithm, Name: utils.Ptr(testDisplayName), - Purpose: utils.Ptr(testPurpose), + Purpose: testPurpose, Description: utils.Ptr(testDescription), ImportOnly: true, // Watch out: ImportOnly is not testImportOnly! - Protection: utils.Ptr(testProtection), + Protection: testProtection, } for _, mod := range mods { mod(model) @@ -78,14 +78,14 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { // Request func fixtureRequest(mods ...func(request *kms.ApiCreateKeyRequest)) kms.ApiCreateKeyRequest { - request := testClient.CreateKey(testCtx, testProjectId, testRegion, testKeyRingId) + request := testClient.DefaultAPI.CreateKey(testCtx, testProjectId, testRegion, testKeyRingId) request = request.CreateKeyPayload(kms.CreateKeyPayload{ - Algorithm: kms.CreateKeyPayloadGetAlgorithmAttributeType(utils.Ptr(testAlgorithm)), - DisplayName: utils.Ptr(testDisplayName), - Purpose: kms.CreateKeyPayloadGetPurposeAttributeType(utils.Ptr(testPurpose)), + Algorithm: testAlgorithm, + DisplayName: testDisplayName, + Purpose: testPurpose, Description: utils.Ptr(testDescription), ImportOnly: utils.Ptr(true), - Protection: kms.CreateKeyPayloadGetProtectionAttributeType(utils.Ptr(testProtection)), + Protection: testProtection, }) for _, mod := range mods { @@ -162,14 +162,14 @@ func TestParseInput(t *testing.T) { { description: "algorithm missing (required)", flagValues: fixtureFlagValues(func(flagValues map[string]string) { - delete(flagValues, algorithmFlag) + delete(flagValues, algorithmFlag.Name()) }), isValid: false, }, { description: "protection missing (required)", flagValues: fixtureFlagValues(func(flagValues map[string]string) { - delete(flagValues, protectionFlag) + delete(flagValues, protectionFlag.Name()) }), isValid: false, }, @@ -183,7 +183,7 @@ func TestParseInput(t *testing.T) { { description: "purpose missing (required)", flagValues: fixtureFlagValues(func(flagValues map[string]string) { - delete(flagValues, purposeFlag) + delete(flagValues, purposeFlag.Name()) }), isValid: false, }, @@ -255,26 +255,26 @@ func TestBuildRequest(t *testing.T) { model.ImportOnly = false }), expectedRequest: fixtureRequest().CreateKeyPayload(kms.CreateKeyPayload{ - Algorithm: kms.CreateKeyPayloadGetAlgorithmAttributeType(utils.Ptr(testAlgorithm)), - DisplayName: utils.Ptr(testDisplayName), - Purpose: kms.CreateKeyPayloadGetPurposeAttributeType(utils.Ptr(testPurpose)), + Algorithm: testAlgorithm, + DisplayName: testDisplayName, + Purpose: testPurpose, Description: nil, ImportOnly: utils.Ptr(false), - Protection: kms.CreateKeyPayloadGetProtectionAttributeType(utils.Ptr(testProtection)), + Protection: testProtection, }), }, } for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { - request, err := buildRequest(testCtx, tt.model, testClient) + request, err := buildRequest(testCtx, tt.model, testClient.DefaultAPI) if err != nil { t.Fatalf("error building request: %v", err) } diff := cmp.Diff(tt.expectedRequest, request, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, kms.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/kms/key/delete/delete.go b/internal/cmd/kms/key/delete/delete.go index 63bc78763..cfef2759f 100644 --- a/internal/cmd/kms/key/delete/delete.go +++ b/internal/cmd/kms/key/delete/delete.go @@ -17,7 +17,7 @@ import ( kmsUtils "github.com/stackitcloud/stackit-cli/internal/pkg/services/kms/utils" "github.com/stackitcloud/stackit-cli/internal/pkg/utils" - "github.com/stackitcloud/stackit-sdk-go/services/kms" + kms "github.com/stackitcloud/stackit-sdk-go/services/kms/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/services/kms/client" ) @@ -58,7 +58,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return err } - keyName, err := kmsUtils.GetKeyName(ctx, apiClient, model.ProjectId, model.Region, model.KeyRingId, model.KeyId) + keyName, err := kmsUtils.GetKeyName(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, model.KeyRingId, model.KeyId) if err != nil { params.Printer.Debug(print.ErrorLevel, "get key name: %v", err) keyName = model.KeyId @@ -79,7 +79,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { // Don't wait for a month until the deletion was performed. // Just print the deletion date. - resp, err := apiClient.GetKeyExecute(ctx, model.ProjectId, model.Region, model.KeyRingId, model.KeyId) + resp, err := apiClient.DefaultAPI.GetKey(ctx, model.ProjectId, model.Region, model.KeyRingId, model.KeyId).Execute() if err != nil { params.Printer.Debug(print.ErrorLevel, "get key: %v", err) } @@ -111,7 +111,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *kms.APIClient) kms.ApiDeleteKeyRequest { - req := apiClient.DeleteKey(ctx, model.ProjectId, model.Region, model.KeyRingId, model.KeyId) + req := apiClient.DefaultAPI.DeleteKey(ctx, model.ProjectId, model.Region, model.KeyRingId, model.KeyId) return req } @@ -128,7 +128,7 @@ func outputResult(p *print.Printer, outputFormat string, resp *kms.Key) error { } return p.OutputResult(outputFormat, resp, func() error { - p.Outputf("Deletion of KMS key %s scheduled successfully for the deletion date: %s\n", utils.PtrString(resp.DisplayName), utils.PtrString(resp.DeletionDate)) + p.Outputf("Deletion of KMS key %s scheduled successfully for the deletion date: %s\n", resp.DisplayName, utils.PtrString(resp.DeletionDate)) return nil }) } diff --git a/internal/cmd/kms/key/delete/delete_test.go b/internal/cmd/kms/key/delete/delete_test.go index 74af865d7..c98e56814 100644 --- a/internal/cmd/kms/key/delete/delete_test.go +++ b/internal/cmd/kms/key/delete/delete_test.go @@ -7,7 +7,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/kms" + kms "github.com/stackitcloud/stackit-sdk-go/services/kms/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" @@ -23,7 +23,7 @@ type testCtxKey struct{} var ( testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") - testClient = &kms.APIClient{} + testClient = &kms.APIClient{DefaultAPI: &kms.DefaultAPIService{}} testProjectId = uuid.NewString() testKeyRingId = uuid.NewString() testKeyId = uuid.NewString() @@ -72,7 +72,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { // Request func fixtureRequest(mods ...func(request *kms.ApiDeleteKeyRequest)) kms.ApiDeleteKeyRequest { - request := testClient.DeleteKey(testCtx, testProjectId, testRegion, testKeyRingId, testKeyId) + request := testClient.DefaultAPI.DeleteKey(testCtx, testProjectId, testRegion, testKeyRingId, testKeyId) for _, mod := range mods { mod(&request) } @@ -241,7 +241,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, kms.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/kms/key/describe/describe.go b/internal/cmd/kms/key/describe/describe.go index 1ddec4c7a..05c1e63db 100644 --- a/internal/cmd/kms/key/describe/describe.go +++ b/internal/cmd/kms/key/describe/describe.go @@ -7,7 +7,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/types" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/kms" + kms "github.com/stackitcloud/stackit-sdk-go/services/kms/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/args" "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -91,7 +91,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *kms.APIClient) kms.ApiGetKeyRequest { - return apiClient.GetKey(ctx, model.ProjectId, model.Region, model.KeyRingID, model.KeyID) + return apiClient.DefaultAPI.GetKey(ctx, model.ProjectId, model.Region, model.KeyRingID, model.KeyID) } func outputResult(p *print.Printer, outputFormat string, key *kms.Key) error { @@ -100,29 +100,29 @@ func outputResult(p *print.Printer, outputFormat string, key *kms.Key) error { } return p.OutputResult(outputFormat, key, func() error { table := tables.NewTable() - table.AddRow("ID", utils.PtrString(key.Id)) + table.AddRow("ID", key.Id) table.AddSeparator() - table.AddRow("DISPLAY NAME", utils.PtrString(key.DisplayName)) + table.AddRow("DISPLAY NAME", key.DisplayName) table.AddSeparator() - table.AddRow("CREATED AT", utils.PtrString(key.CreatedAt)) + table.AddRow("CREATED AT", key.CreatedAt) table.AddSeparator() - table.AddRow("STATE", utils.PtrString(key.State)) + table.AddRow("STATE", key.State) table.AddSeparator() table.AddRow("DESCRIPTION", utils.PtrString(key.Description)) table.AddSeparator() - table.AddRow("ACCESS SCOPE", utils.PtrString(key.AccessScope)) + table.AddRow("ACCESS SCOPE", key.AccessScope) table.AddSeparator() - table.AddRow("ALGORITHM", utils.PtrString(key.Algorithm)) + table.AddRow("ALGORITHM", key.Algorithm) table.AddSeparator() table.AddRow("DELETION DATE", utils.PtrString(key.DeletionDate)) table.AddSeparator() - table.AddRow("IMPORT ONLY", utils.PtrString(key.ImportOnly)) + table.AddRow("IMPORT ONLY", key.ImportOnly) table.AddSeparator() - table.AddRow("KEYRING ID", utils.PtrString(key.KeyRingId)) + table.AddRow("KEYRING ID", key.KeyRingId) table.AddSeparator() - table.AddRow("PROTECTION", utils.PtrString(key.Protection)) + table.AddRow("PROTECTION", key.Protection) table.AddSeparator() - table.AddRow("PURPOSE", utils.PtrString(key.Purpose)) + table.AddRow("PURPOSE", key.Purpose) err := table.Display(p) if err != nil { diff --git a/internal/cmd/kms/key/describe/describe_test.go b/internal/cmd/kms/key/describe/describe_test.go index a34f54f65..0e863f2d2 100644 --- a/internal/cmd/kms/key/describe/describe_test.go +++ b/internal/cmd/kms/key/describe/describe_test.go @@ -9,7 +9,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/kms" + kms "github.com/stackitcloud/stackit-sdk-go/services/kms/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" @@ -20,7 +20,7 @@ import ( type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &kms.APIClient{} +var testClient = &kms.APIClient{DefaultAPI: &kms.DefaultAPIService{}} var testProjectId = uuid.NewString() var testKeyRingID = uuid.NewString() var testKeyID = uuid.NewString() @@ -131,10 +131,10 @@ func TestParseInput(t *testing.T) { func TestBuildRequest(t *testing.T) { got := buildRequest(testCtx, fixtureInputModel(), testClient) - want := testClient.GetKey(testCtx, testProjectId, testRegion, testKeyRingID, testKeyID) + want := testClient.DefaultAPI.GetKey(testCtx, testProjectId, testRegion, testKeyRingID, testKeyID) diff := cmp.Diff(got, want, cmp.AllowUnexported(want), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, kms.DefaultAPIService{}), ) if diff != "" { t.Fatalf("buildRequest() mismatch (-want +got):\n%s", diff) @@ -158,18 +158,18 @@ func TestOutputResult(t *testing.T) { description: "table format", outputFmt: "table", keyRing: &kms.Key{ - AccessScope: utils.Ptr(kms.ACCESSSCOPE_PUBLIC), - Algorithm: utils.Ptr(kms.ALGORITHM_AES_256_GCM), - CreatedAt: utils.Ptr(testTime), + AccessScope: kms.ACCESSSCOPE_PUBLIC, + Algorithm: kms.ALGORITHM_AES_256_GCM, + CreatedAt: testTime, DeletionDate: nil, Description: utils.Ptr("very secure and secret key"), - DisplayName: utils.Ptr("Test Key"), - Id: utils.Ptr(testKeyID), - ImportOnly: utils.Ptr(true), - KeyRingId: utils.Ptr(testKeyRingID), - Protection: utils.Ptr(kms.PROTECTION_SOFTWARE), - Purpose: utils.Ptr(kms.PURPOSE_SYMMETRIC_ENCRYPT_DECRYPT), - State: utils.Ptr(kms.KEYSTATE_ACTIVE), + DisplayName: "Test Key", + Id: testKeyID, + ImportOnly: true, + KeyRingId: testKeyRingID, + Protection: kms.PROTECTION_SOFTWARE, + Purpose: kms.PURPOSE_SYMMETRIC_ENCRYPT_DECRYPT, + State: kms.KEYSTATE_ACTIVE, }, expected: fmt.Sprintf(` ID │ %-37s diff --git a/internal/cmd/kms/key/importKey/importKey.go b/internal/cmd/kms/key/importKey/importKey.go index 8e83b9681..0c3c0012e 100644 --- a/internal/cmd/kms/key/importKey/importKey.go +++ b/internal/cmd/kms/key/importKey/importKey.go @@ -15,7 +15,7 @@ import ( kmsUtils "github.com/stackitcloud/stackit-cli/internal/pkg/services/kms/utils" "github.com/stackitcloud/stackit-cli/internal/pkg/utils" - "github.com/stackitcloud/stackit-sdk-go/services/kms" + kms "github.com/stackitcloud/stackit-sdk-go/services/kms/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/examples" "github.com/stackitcloud/stackit-cli/internal/pkg/flags" @@ -35,8 +35,8 @@ type inputModel struct { *globalflags.GlobalFlagModel KeyRingId string KeyId string - WrappedKey *string - WrappingKeyId *string + WrappedKey string + WrappingKeyId string } func NewCmd(params *types.CmdParams) *cobra.Command { @@ -68,12 +68,12 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return err } - keyName, err := kmsUtils.GetKeyName(ctx, apiClient, model.ProjectId, model.Region, model.KeyRingId, model.KeyId) + keyName, err := kmsUtils.GetKeyName(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, model.KeyRingId, model.KeyId) if err != nil { params.Printer.Debug(print.ErrorLevel, "get key name: %v", err) keyName = model.KeyId } - keyRingName, err := kmsUtils.GetKeyRingName(ctx, apiClient, model.ProjectId, model.KeyRingId, model.Region) + keyRingName, err := kmsUtils.GetKeyRingName(ctx, apiClient.DefaultAPI, model.ProjectId, model.KeyRingId, model.Region) if err != nil { params.Printer.Debug(print.ErrorLevel, "get key ring name: %v", err) keyRingName = model.KeyRingId @@ -86,7 +86,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } // Call API - req, _ := buildRequest(ctx, model, apiClient) + req, _ := buildRequest(ctx, model, apiClient.DefaultAPI) resp, err := req.Execute() if err != nil { return fmt.Errorf("import KMS key: %w", err) @@ -108,9 +108,9 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } // WrappedKey needs to be base64 encoded - var wrappedKey = flags.FlagToStringPointer(p, cmd, wrappedKeyFlag) - _, err := base64.StdEncoding.DecodeString(*wrappedKey) - if err != nil || *wrappedKey == "" { + var wrappedKey = flags.FlagToStringValue(p, cmd, wrappedKeyFlag) + _, err := base64.StdEncoding.DecodeString(wrappedKey) + if err != nil || wrappedKey == "" { return nil, &cliErr.FlagValidationError{ Flag: wrappedKeyFlag, Details: "The 'wrappedKey' argument is required and needs to be base64 encoded (whether provided inline or via file).", @@ -122,7 +122,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu KeyId: keyId, KeyRingId: flags.FlagToStringValue(p, cmd, keyRingIdFlag), WrappedKey: wrappedKey, - WrappingKeyId: flags.FlagToStringPointer(p, cmd, wrappingKeyIdFlag), + WrappingKeyId: flags.FlagToStringValue(p, cmd, wrappingKeyIdFlag), } p.DebugInputModel(model) diff --git a/internal/cmd/kms/key/importKey/importKey_test.go b/internal/cmd/kms/key/importKey/importKey_test.go index 453d0d522..1c7d519e6 100644 --- a/internal/cmd/kms/key/importKey/importKey_test.go +++ b/internal/cmd/kms/key/importKey/importKey_test.go @@ -7,7 +7,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/kms" + kms "github.com/stackitcloud/stackit-sdk-go/services/kms/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" @@ -23,7 +23,7 @@ type testCtxKey struct{} var ( testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") - testClient = &kms.APIClient{} + testClient = &kms.APIClient{DefaultAPI: &kms.DefaultAPIService{}} testProjectId = uuid.NewString() testKeyRingId = uuid.NewString() testKeyId = uuid.NewString() @@ -67,8 +67,8 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { }, KeyRingId: testKeyRingId, KeyId: testKeyId, - WrappedKey: &testWrappedKey, - WrappingKeyId: &testWrappingKeyId, + WrappedKey: testWrappedKey, + WrappingKeyId: testWrappingKeyId, } for _, mod := range mods { mod(model) @@ -78,10 +78,10 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { // Request func fixtureRequest(mods ...func(request *kms.ApiImportKeyRequest)) kms.ApiImportKeyRequest { - request := testClient.ImportKey(testCtx, testProjectId, testRegion, testKeyRingId, testKeyId) + request := testClient.DefaultAPI.ImportKey(testCtx, testProjectId, testRegion, testKeyRingId, testKeyId) request = request.ImportKeyPayload(kms.ImportKeyPayload{ - WrappedKey: &testWrappedKey, - WrappingKeyId: &testWrappingKeyId, + WrappedKey: testWrappedKey, + WrappingKeyId: testWrappingKeyId, }) for _, mod := range mods { @@ -296,14 +296,14 @@ func TestBuildRequest(t *testing.T) { for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { - request, err := buildRequest(testCtx, tt.model, testClient) + request, err := buildRequest(testCtx, tt.model, testClient.DefaultAPI) if err != nil { t.Fatalf("error building request: %v", err) } diff := cmp.Diff(tt.expectedRequest, request, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, kms.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/kms/key/list/list.go b/internal/cmd/kms/key/list/list.go index 244fb40a0..4c57f24a3 100644 --- a/internal/cmd/kms/key/list/list.go +++ b/internal/cmd/kms/key/list/list.go @@ -7,7 +7,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/types" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/kms" + kms "github.com/stackitcloud/stackit-sdk-go/services/kms/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/args" "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -87,7 +87,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command) (*inputModel, error) { } func buildRequest(ctx context.Context, model *inputModel, apiClient *kms.APIClient) kms.ApiListKeysRequest { - req := apiClient.ListKeys(ctx, model.ProjectId, model.Region, model.KeyRingId) + req := apiClient.DefaultAPI.ListKeys(ctx, model.ProjectId, model.Region, model.KeyRingId) return req } @@ -103,7 +103,7 @@ func outputResult(p *print.Printer, outputFormat, projectId, keyRingId string, r return fmt.Errorf("response was nil / empty") } - keys := *resp.Keys + keys := resp.Keys return p.OutputResult(outputFormat, keys, func() error { if len(keys) == 0 { @@ -115,12 +115,12 @@ func outputResult(p *print.Printer, outputFormat, projectId, keyRingId string, r for _, key := range keys { table.AddRow( - utils.PtrString(key.Id), - utils.PtrString(key.DisplayName), - utils.PtrString(key.Purpose), - utils.PtrString(key.Algorithm), + key.Id, + key.DisplayName, + key.Purpose, + key.Algorithm, utils.PtrString(key.DeletionDate), - utils.PtrString(key.State), + key.State, ) } diff --git a/internal/cmd/kms/key/list/list_test.go b/internal/cmd/kms/key/list/list_test.go index e3a12b748..089baad1c 100644 --- a/internal/cmd/kms/key/list/list_test.go +++ b/internal/cmd/kms/key/list/list_test.go @@ -8,7 +8,7 @@ import ( "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/kms" + kms "github.com/stackitcloud/stackit-sdk-go/services/kms/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/print" @@ -23,7 +23,7 @@ type testCtxKey struct{} var ( testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") - testClient = &kms.APIClient{} + testClient = &kms.APIClient{DefaultAPI: &kms.DefaultAPIService{}} testProjectId = uuid.NewString() testKeyRingId = uuid.NewString() ) @@ -59,7 +59,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { // Request func fixtureRequest(mods ...func(request *kms.ApiListKeysRequest)) kms.ApiListKeysRequest { - request := testClient.ListKeys(testCtx, testProjectId, testRegion, testKeyRingId) + request := testClient.DefaultAPI.ListKeys(testCtx, testProjectId, testRegion, testKeyRingId) for _, mod := range mods { mod(&request) } @@ -189,7 +189,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(tt.expectedRequest, request, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, kms.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) @@ -223,14 +223,14 @@ func TestOutputResult(t *testing.T) { }, { description: "default output", - resp: &kms.KeyList{Keys: &[]kms.Key{}}, + resp: &kms.KeyList{Keys: []kms.Key{}}, projectId: uuid.NewString(), keyRingId: uuid.NewString(), wantErr: false, }, { description: "json output", - resp: &kms.KeyList{Keys: &[]kms.Key{}}, + resp: &kms.KeyList{Keys: []kms.Key{}}, projectId: uuid.NewString(), keyRingId: uuid.NewString(), outputFormat: print.JSONOutputFormat, @@ -238,7 +238,7 @@ func TestOutputResult(t *testing.T) { }, { description: "yaml output", - resp: &kms.KeyList{Keys: &[]kms.Key{}}, + resp: &kms.KeyList{Keys: []kms.Key{}}, projectId: uuid.NewString(), keyRingId: uuid.NewString(), outputFormat: print.YAMLOutputFormat, diff --git a/internal/cmd/kms/key/restore/restore.go b/internal/cmd/kms/key/restore/restore.go index e6825cb92..5849ec00c 100644 --- a/internal/cmd/kms/key/restore/restore.go +++ b/internal/cmd/kms/key/restore/restore.go @@ -17,7 +17,7 @@ import ( kmsUtils "github.com/stackitcloud/stackit-cli/internal/pkg/services/kms/utils" "github.com/stackitcloud/stackit-cli/internal/pkg/utils" - "github.com/stackitcloud/stackit-sdk-go/services/kms" + kms "github.com/stackitcloud/stackit-sdk-go/services/kms/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/services/kms/client" ) @@ -58,7 +58,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return err } - keyName, err := kmsUtils.GetKeyName(ctx, apiClient, model.ProjectId, model.Region, model.KeyRingId, model.KeyId) + keyName, err := kmsUtils.GetKeyName(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, model.KeyRingId, model.KeyId) if err != nil { params.Printer.Debug(print.ErrorLevel, "get key name: %v", err) keyName = model.KeyId @@ -78,7 +78,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } // Grab the key after the restore was applied to display the new state to the user. - resp, err := apiClient.GetKeyExecute(ctx, model.ProjectId, model.Region, model.KeyRingId, model.KeyId) + resp, err := apiClient.DefaultAPI.GetKey(ctx, model.ProjectId, model.Region, model.KeyRingId, model.KeyId).Execute() if err != nil { params.Printer.Debug(print.ErrorLevel, "get key: %v", err) } @@ -110,7 +110,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *kms.APIClient) kms.ApiRestoreKeyRequest { - req := apiClient.RestoreKey(ctx, model.ProjectId, model.Region, model.KeyRingId, model.KeyId) + req := apiClient.DefaultAPI.RestoreKey(ctx, model.ProjectId, model.Region, model.KeyRingId, model.KeyId) return req } @@ -127,7 +127,7 @@ func outputResult(p *print.Printer, outputFormat string, resp *kms.Key) error { } return p.OutputResult(outputFormat, resp, func() error { - p.Outputf("Successfully restored KMS key %q\n", utils.PtrString(resp.DisplayName)) + p.Outputf("Successfully restored KMS key %q\n", resp.DisplayName) return nil }) } diff --git a/internal/cmd/kms/key/restore/restore_test.go b/internal/cmd/kms/key/restore/restore_test.go index 0308a4b6a..2478b9ce6 100644 --- a/internal/cmd/kms/key/restore/restore_test.go +++ b/internal/cmd/kms/key/restore/restore_test.go @@ -7,7 +7,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/kms" + kms "github.com/stackitcloud/stackit-sdk-go/services/kms/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" @@ -23,7 +23,7 @@ type testCtxKey struct{} var ( testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") - testClient = &kms.APIClient{} + testClient = &kms.APIClient{DefaultAPI: &kms.DefaultAPIService{}} testProjectId = uuid.NewString() testKeyRingId = uuid.NewString() testKeyId = uuid.NewString() @@ -72,7 +72,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { // Request func fixtureRequest(mods ...func(request *kms.ApiRestoreKeyRequest)) kms.ApiRestoreKeyRequest { - request := testClient.RestoreKey(testCtx, testProjectId, testRegion, testKeyRingId, testKeyId) + request := testClient.DefaultAPI.RestoreKey(testCtx, testProjectId, testRegion, testKeyRingId, testKeyId) for _, mod := range mods { mod(&request) } @@ -241,7 +241,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, kms.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/kms/key/rotate/rotate.go b/internal/cmd/kms/key/rotate/rotate.go index 1f2332572..8d265912f 100644 --- a/internal/cmd/kms/key/rotate/rotate.go +++ b/internal/cmd/kms/key/rotate/rotate.go @@ -16,7 +16,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/print" kmsUtils "github.com/stackitcloud/stackit-cli/internal/pkg/services/kms/utils" - "github.com/stackitcloud/stackit-sdk-go/services/kms" + kms "github.com/stackitcloud/stackit-sdk-go/services/kms/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/services/kms/client" "github.com/stackitcloud/stackit-cli/internal/pkg/utils" @@ -58,7 +58,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return err } - keyName, err := kmsUtils.GetKeyName(ctx, apiClient, model.ProjectId, model.Region, model.KeyRingId, model.KeyId) + keyName, err := kmsUtils.GetKeyName(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, model.KeyRingId, model.KeyId) if err != nil { params.Printer.Debug(print.ErrorLevel, "get key name: %v", err) keyName = model.KeyId @@ -104,7 +104,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *kms.APIClient) kms.ApiRotateKeyRequest { - req := apiClient.RotateKey(ctx, model.ProjectId, model.Region, model.KeyRingId, model.KeyId) + req := apiClient.DefaultAPI.RotateKey(ctx, model.ProjectId, model.Region, model.KeyRingId, model.KeyId) return req } @@ -121,7 +121,7 @@ func outputResult(p *print.Printer, outputFormat string, resp *kms.Version) erro } return p.OutputResult(outputFormat, resp, func() error { - p.Outputf("Rotated key %s\n", utils.PtrString(resp.KeyId)) + p.Outputf("Rotated key %s\n", resp.KeyId) return nil }) } diff --git a/internal/cmd/kms/key/rotate/rotate_test.go b/internal/cmd/kms/key/rotate/rotate_test.go index 73829c9e0..7b922a81e 100644 --- a/internal/cmd/kms/key/rotate/rotate_test.go +++ b/internal/cmd/kms/key/rotate/rotate_test.go @@ -7,7 +7,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/kms" + kms "github.com/stackitcloud/stackit-sdk-go/services/kms/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" @@ -23,7 +23,7 @@ type testCtxKey struct{} var ( testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") - testClient = &kms.APIClient{} + testClient = &kms.APIClient{DefaultAPI: &kms.DefaultAPIService{}} testProjectId = uuid.NewString() testKeyRingId = uuid.NewString() testKeyId = uuid.NewString() @@ -72,7 +72,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { // Request func fixtureRequest(mods ...func(request *kms.ApiRotateKeyRequest)) kms.ApiRotateKeyRequest { - request := testClient.RotateKey(testCtx, testProjectId, testRegion, testKeyRingId, testKeyId) + request := testClient.DefaultAPI.RotateKey(testCtx, testProjectId, testRegion, testKeyRingId, testKeyId) for _, mod := range mods { mod(&request) } @@ -241,7 +241,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, kms.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/kms/keyring/create/create.go b/internal/cmd/kms/keyring/create/create.go index 2d031e85e..d9b3b76d6 100644 --- a/internal/cmd/kms/keyring/create/create.go +++ b/internal/cmd/kms/keyring/create/create.go @@ -13,14 +13,13 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/services/kms/client" "github.com/stackitcloud/stackit-cli/internal/pkg/spinner" - "github.com/stackitcloud/stackit-sdk-go/services/kms" - "github.com/stackitcloud/stackit-sdk-go/services/kms/wait" + kms "github.com/stackitcloud/stackit-sdk-go/services/kms/v1api" + "github.com/stackitcloud/stackit-sdk-go/services/kms/v1api/wait" "github.com/stackitcloud/stackit-cli/internal/pkg/examples" "github.com/stackitcloud/stackit-cli/internal/pkg/flags" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/print" - "github.com/stackitcloud/stackit-cli/internal/pkg/utils" ) const ( @@ -70,7 +69,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } // Call API - req, _ := buildRequest(ctx, model, apiClient) + req, _ := buildRequest(ctx, model, apiClient.DefaultAPI) keyRing, err := req.Execute() if err != nil { @@ -78,16 +77,16 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } // Prevent potential nil pointer dereference - if keyRing == nil || keyRing.Id == nil { + if keyRing == nil { return fmt.Errorf("API call succeeded but returned an invalid response (missing key ring ID)") } - keyRingId := *keyRing.Id + keyRingId := keyRing.Id // Wait for async operation, if async mode not enabled if !model.Async { err := spinner.Run(params.Printer, "Creating key ring", func() error { - _, err = wait.CreateKeyRingWaitHandler(ctx, apiClient, model.ProjectId, model.Region, keyRingId).WaitWithContext(ctx) + _, err = wait.CreateKeyRingWaitHandler(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, keyRingId).WaitWithContext(ctx) return err }) if err != nil { @@ -134,7 +133,7 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient kmsKeyringCl req := apiClient.CreateKeyRing(ctx, model.ProjectId, model.Region) req = req.CreateKeyRingPayload(kms.CreateKeyRingPayload{ - DisplayName: &model.KeyringName, + DisplayName: model.KeyringName, // Description should be empty by default and only be overwritten with the descriptionFlag if it was passed. Description: &model.Description, @@ -152,7 +151,7 @@ func outputResult(p *print.Printer, model *inputModel, resp *kms.KeyRing) error if model.Async { operationState = "Triggered creation of" } - p.Outputf("%s key ring. KMS key ring ID: %s\n", operationState, utils.PtrString(resp.Id)) + p.Outputf("%s key ring. KMS key ring ID: %s\n", operationState, resp.Id) return nil }) } diff --git a/internal/cmd/kms/keyring/create/create_test.go b/internal/cmd/kms/keyring/create/create_test.go index 18db7fcb3..c74c35753 100644 --- a/internal/cmd/kms/keyring/create/create_test.go +++ b/internal/cmd/kms/keyring/create/create_test.go @@ -8,7 +8,7 @@ import ( "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/kms" + kms "github.com/stackitcloud/stackit-sdk-go/services/kms/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/print" @@ -26,7 +26,7 @@ type testCtxKey struct{} var ( testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") - testClient = &kms.APIClient{} + testClient = &kms.APIClient{DefaultAPI: &kms.DefaultAPIService{}} testProjectId = uuid.NewString() ) @@ -63,9 +63,9 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { // Request func fixtureRequest(mods ...func(request *kms.ApiCreateKeyRingRequest)) kms.ApiCreateKeyRingRequest { - request := testClient.CreateKeyRing(testCtx, testProjectId, testRegion) + request := testClient.DefaultAPI.CreateKeyRing(testCtx, testProjectId, testRegion) request = request.CreateKeyRingPayload(kms.CreateKeyRingPayload{ - DisplayName: utils.Ptr(testKeyRingName), + DisplayName: testKeyRingName, Description: utils.Ptr(testDescription), }) @@ -189,14 +189,14 @@ func TestBuildRequest(t *testing.T) { for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { - request, err := buildRequest(testCtx, tt.model, testClient) + request, err := buildRequest(testCtx, tt.model, testClient.DefaultAPI) if err != nil { t.Fatalf("error building request: %v", err) } diff := cmp.Diff(tt.expectedRequest, request, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, kms.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/kms/keyring/delete/delete.go b/internal/cmd/kms/keyring/delete/delete.go index 03393c270..cb70e54de 100644 --- a/internal/cmd/kms/keyring/delete/delete.go +++ b/internal/cmd/kms/keyring/delete/delete.go @@ -15,7 +15,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/print" kmsUtils "github.com/stackitcloud/stackit-cli/internal/pkg/services/kms/utils" - "github.com/stackitcloud/stackit-sdk-go/services/kms" + kms "github.com/stackitcloud/stackit-sdk-go/services/kms/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/services/kms/client" "github.com/stackitcloud/stackit-cli/internal/pkg/utils" @@ -54,7 +54,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return err } - keyRingLabel, err := kmsUtils.GetKeyRingName(ctx, apiClient, model.ProjectId, model.KeyRingId, model.Region) + keyRingLabel, err := kmsUtils.GetKeyRingName(ctx, apiClient.DefaultAPI, model.ProjectId, model.KeyRingId, model.Region) if err != nil { params.Printer.Debug(print.ErrorLevel, "get key ring name: %v", err) keyRingLabel = model.KeyRingId @@ -101,6 +101,6 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *kms.APIClient) kms.ApiDeleteKeyRingRequest { - req := apiClient.DeleteKeyRing(ctx, model.ProjectId, model.Region, model.KeyRingId) + req := apiClient.DefaultAPI.DeleteKeyRing(ctx, model.ProjectId, model.Region, model.KeyRingId) return req } diff --git a/internal/cmd/kms/keyring/delete/delete_test.go b/internal/cmd/kms/keyring/delete/delete_test.go index e98ca8e02..638f02f90 100644 --- a/internal/cmd/kms/keyring/delete/delete_test.go +++ b/internal/cmd/kms/keyring/delete/delete_test.go @@ -7,7 +7,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/kms" + kms "github.com/stackitcloud/stackit-sdk-go/services/kms/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" @@ -22,7 +22,7 @@ type testCtxKey struct{} var ( testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") - testClient = &kms.APIClient{} + testClient = &kms.APIClient{DefaultAPI: &kms.DefaultAPIService{}} testProjectId = uuid.NewString() testKeyRingId = uuid.NewString() ) @@ -68,7 +68,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { // Request func fixtureRequest(mods ...func(request *kms.ApiDeleteKeyRingRequest)) kms.ApiDeleteKeyRingRequest { - request := testClient.DeleteKeyRing(testCtx, testProjectId, testRegion, testKeyRingId) + request := testClient.DefaultAPI.DeleteKeyRing(testCtx, testProjectId, testRegion, testKeyRingId) for _, mod := range mods { mod(&request) } @@ -203,7 +203,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(tt.expectedRequest, request, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, kms.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/kms/keyring/describe/describe.go b/internal/cmd/kms/keyring/describe/describe.go index c5c54cc7d..73f7db3d6 100644 --- a/internal/cmd/kms/keyring/describe/describe.go +++ b/internal/cmd/kms/keyring/describe/describe.go @@ -7,7 +7,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/types" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/kms" + kms "github.com/stackitcloud/stackit-sdk-go/services/kms/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/args" "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -80,7 +80,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *kms.APIClient) kms.ApiGetKeyRingRequest { - return apiClient.GetKeyRing(ctx, model.ProjectId, model.Region, model.KeyRingID) + return apiClient.DefaultAPI.GetKeyRing(ctx, model.ProjectId, model.Region, model.KeyRingID) } func outputResult(p *print.Printer, outputFormat string, keyRing *kms.KeyRing) error { @@ -89,13 +89,13 @@ func outputResult(p *print.Printer, outputFormat string, keyRing *kms.KeyRing) e } return p.OutputResult(outputFormat, keyRing, func() error { table := tables.NewTable() - table.AddRow("ID", utils.PtrString(keyRing.Id)) + table.AddRow("ID", keyRing.Id) table.AddSeparator() - table.AddRow("DISPLAY NAME", utils.PtrString(keyRing.DisplayName)) + table.AddRow("DISPLAY NAME", keyRing.DisplayName) table.AddSeparator() - table.AddRow("CREATED AT", utils.PtrString(keyRing.CreatedAt)) + table.AddRow("CREATED AT", keyRing.CreatedAt) table.AddSeparator() - table.AddRow("STATE", utils.PtrString(keyRing.State)) + table.AddRow("STATE", keyRing.State) table.AddSeparator() table.AddRow("DESCRIPTION", utils.PtrString(keyRing.Description)) diff --git a/internal/cmd/kms/keyring/describe/describe_test.go b/internal/cmd/kms/keyring/describe/describe_test.go index 47c5ba86e..ff2317b30 100644 --- a/internal/cmd/kms/keyring/describe/describe_test.go +++ b/internal/cmd/kms/keyring/describe/describe_test.go @@ -9,7 +9,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/kms" + kms "github.com/stackitcloud/stackit-sdk-go/services/kms/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" @@ -20,7 +20,7 @@ import ( type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &kms.APIClient{} +var testClient = &kms.APIClient{DefaultAPI: &kms.DefaultAPIService{}} var testProjectId = uuid.NewString() var testKeyRingID = uuid.NewString() var testTime = time.Time{} @@ -114,10 +114,10 @@ func TestParseInput(t *testing.T) { func TestBuildRequest(t *testing.T) { got := buildRequest(testCtx, fixtureInputModel(), testClient) - want := testClient.GetKeyRing(testCtx, testProjectId, testRegion, testKeyRingID) + want := testClient.DefaultAPI.GetKeyRing(testCtx, testProjectId, testRegion, testKeyRingID) diff := cmp.Diff(got, want, cmp.AllowUnexported(want), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, kms.DefaultAPIService{}), ) if diff != "" { t.Fatalf("buildRequest() mismatch (-want +got):\n%s", diff) @@ -141,11 +141,11 @@ func TestOutputResult(t *testing.T) { description: "table format", outputFmt: "table", keyRing: &kms.KeyRing{ - Id: utils.Ptr(testKeyRingID), - DisplayName: utils.Ptr("Test Key Ring"), - CreatedAt: utils.Ptr(testTime), + Id: testKeyRingID, + DisplayName: "Test Key Ring", + CreatedAt: testTime, Description: utils.Ptr("This is a test key ring."), - State: utils.Ptr(kms.KEYRINGSTATE_ACTIVE), + State: kms.KEYRINGSTATE_ACTIVE, }, expected: fmt.Sprintf(` ID │ %-37s diff --git a/internal/cmd/kms/keyring/list/list.go b/internal/cmd/kms/keyring/list/list.go index 4b3b09d67..c7273cca9 100644 --- a/internal/cmd/kms/keyring/list/list.go +++ b/internal/cmd/kms/keyring/list/list.go @@ -7,7 +7,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/types" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/kms" + kms "github.com/stackitcloud/stackit-sdk-go/services/kms/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/args" "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -16,7 +16,6 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/print" "github.com/stackitcloud/stackit-cli/internal/pkg/services/kms/client" "github.com/stackitcloud/stackit-cli/internal/pkg/tables" - "github.com/stackitcloud/stackit-cli/internal/pkg/utils" ) type inputModel struct { @@ -79,7 +78,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command) (*inputModel, error) { } func buildRequest(ctx context.Context, model *inputModel, apiClient *kms.APIClient) kms.ApiListKeyRingsRequest { - req := apiClient.ListKeyRings(ctx, model.ProjectId, model.Region) + req := apiClient.DefaultAPI.ListKeyRings(ctx, model.ProjectId, model.Region) return req } @@ -88,7 +87,7 @@ func outputResult(p *print.Printer, outputFormat, projectId string, resp *kms.Ke return fmt.Errorf("response was nil / empty") } - keyRings := *resp.KeyRings + keyRings := resp.KeyRings return p.OutputResult(outputFormat, keyRings, func() error { if len(keyRings) == 0 { @@ -102,9 +101,9 @@ func outputResult(p *print.Printer, outputFormat, projectId string, resp *kms.Ke for i := range keyRings { keyRing := keyRings[i] table.AddRow( - utils.PtrString(keyRing.Id), - utils.PtrString(keyRing.DisplayName), - utils.PtrString(keyRing.State), + keyRing.Id, + keyRing.DisplayName, + keyRing.State, ) } diff --git a/internal/cmd/kms/keyring/list/list_test.go b/internal/cmd/kms/keyring/list/list_test.go index aecab3178..2a850b1d8 100644 --- a/internal/cmd/kms/keyring/list/list_test.go +++ b/internal/cmd/kms/keyring/list/list_test.go @@ -8,7 +8,7 @@ import ( "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/kms" + kms "github.com/stackitcloud/stackit-sdk-go/services/kms/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/print" @@ -23,7 +23,7 @@ type testCtxKey struct{} var ( testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") - testClient = &kms.APIClient{} + testClient = &kms.APIClient{DefaultAPI: &kms.DefaultAPIService{}} testProjectId = uuid.NewString() ) @@ -56,7 +56,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { // Request func fixtureRequest(mods ...func(request *kms.ApiListKeyRingsRequest)) kms.ApiListKeyRingsRequest { - request := testClient.ListKeyRings(testCtx, testProjectId, testRegion) + request := testClient.DefaultAPI.ListKeyRings(testCtx, testProjectId, testRegion) for _, mod := range mods { mod(&request) } @@ -162,7 +162,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(tt.expectedRequest, request, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, kms.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) @@ -197,21 +197,21 @@ func TestOutputResult(t *testing.T) { { description: "default output", projectId: uuid.NewString(), - resp: &kms.KeyRingList{KeyRings: &[]kms.KeyRing{}}, + resp: &kms.KeyRingList{KeyRings: []kms.KeyRing{}}, projectLabel: "my-project", wantErr: false, }, { description: "json output", projectId: uuid.NewString(), - resp: &kms.KeyRingList{KeyRings: &[]kms.KeyRing{}}, + resp: &kms.KeyRingList{KeyRings: []kms.KeyRing{}}, outputFormat: print.JSONOutputFormat, wantErr: false, }, { description: "yaml output", projectId: uuid.NewString(), - resp: &kms.KeyRingList{KeyRings: &[]kms.KeyRing{}}, + resp: &kms.KeyRingList{KeyRings: []kms.KeyRing{}}, outputFormat: print.YAMLOutputFormat, wantErr: false, }, diff --git a/internal/cmd/kms/version/destroy/destroy.go b/internal/cmd/kms/version/destroy/destroy.go index bc56351c0..04a418c61 100644 --- a/internal/cmd/kms/version/destroy/destroy.go +++ b/internal/cmd/kms/version/destroy/destroy.go @@ -8,7 +8,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/types" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/kms" + kms "github.com/stackitcloud/stackit-sdk-go/services/kms/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/args" "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -17,7 +17,6 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/print" "github.com/stackitcloud/stackit-cli/internal/pkg/services/kms/client" - "github.com/stackitcloud/stackit-cli/internal/pkg/utils" ) const ( @@ -68,7 +67,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } // Get the key version in its state afterwards - resp, err := apiClient.GetVersionExecute(ctx, model.ProjectId, model.Region, model.KeyRingId, model.KeyId, model.VersionNumber) + resp, err := apiClient.DefaultAPI.GetVersion(ctx, model.ProjectId, model.Region, model.KeyRingId, model.KeyId, model.VersionNumber).Execute() if err != nil { params.Printer.Debug(print.ErrorLevel, "get key version: %v", err) } @@ -108,7 +107,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *kms.APIClient) kms.ApiDestroyVersionRequest { - return apiClient.DestroyVersion(ctx, model.ProjectId, model.Region, model.KeyRingId, model.KeyId, model.VersionNumber) + return apiClient.DefaultAPI.DestroyVersion(ctx, model.ProjectId, model.Region, model.KeyRingId, model.KeyId, model.VersionNumber) } func configureFlags(cmd *cobra.Command) { @@ -125,7 +124,7 @@ func outputResult(p *print.Printer, outputFormat string, resp *kms.Version) erro } return p.OutputResult(outputFormat, resp, func() error { - p.Outputf("Destroyed version %d of the key %q\n", utils.PtrValue(resp.Number), utils.PtrValue(resp.KeyId)) + p.Outputf("Destroyed version %d of the key %q\n", resp.Number, resp.KeyId) return nil }) } diff --git a/internal/cmd/kms/version/destroy/destroy_test.go b/internal/cmd/kms/version/destroy/destroy_test.go index edf4dd9db..2c4b5e5f9 100644 --- a/internal/cmd/kms/version/destroy/destroy_test.go +++ b/internal/cmd/kms/version/destroy/destroy_test.go @@ -7,7 +7,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/kms" + kms "github.com/stackitcloud/stackit-sdk-go/services/kms/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" @@ -25,7 +25,7 @@ type testCtxKey struct{} var ( testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") - testClient = &kms.APIClient{} + testClient = &kms.APIClient{DefaultAPI: &kms.DefaultAPIService{}} testProjectId = uuid.NewString() testKeyRingId = uuid.NewString() testKeyId = uuid.NewString() @@ -76,7 +76,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { // Request func fixtureRequest(mods ...func(request *kms.ApiDestroyVersionRequest)) kms.ApiDestroyVersionRequest { - request := testClient.DestroyVersion(testCtx, testProjectId, testRegion, testKeyRingId, testKeyId, testVersionNumber) + request := testClient.DefaultAPI.DestroyVersion(testCtx, testProjectId, testRegion, testKeyRingId, testKeyId, testVersionNumber) for _, mod := range mods { mod(&request) } @@ -269,7 +269,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, kms.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/kms/version/disable/disable.go b/internal/cmd/kms/version/disable/disable.go index 00d92b3f9..85f2ee293 100644 --- a/internal/cmd/kms/version/disable/disable.go +++ b/internal/cmd/kms/version/disable/disable.go @@ -8,8 +8,8 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/types" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/kms" - "github.com/stackitcloud/stackit-sdk-go/services/kms/wait" + kms "github.com/stackitcloud/stackit-sdk-go/services/kms/v1api" + "github.com/stackitcloud/stackit-sdk-go/services/kms/v1api/wait" "github.com/stackitcloud/stackit-cli/internal/pkg/args" "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -19,7 +19,6 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/print" "github.com/stackitcloud/stackit-cli/internal/pkg/services/kms/client" "github.com/stackitcloud/stackit-cli/internal/pkg/spinner" - "github.com/stackitcloud/stackit-cli/internal/pkg/utils" ) const ( @@ -72,7 +71,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { // Wait for async operation, if async mode not enabled if !model.Async { err := spinner.Run(params.Printer, "Disabling key version", func() error { - _, err = wait.DisableKeyVersionWaitHandler(ctx, apiClient, model.ProjectId, model.Region, model.KeyRingId, model.KeyId, model.VersionNumber).WaitWithContext(ctx) + _, err = wait.DisableKeyVersionWaitHandler(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, model.KeyRingId, model.KeyId, model.VersionNumber).WaitWithContext(ctx) return err }) if err != nil { @@ -81,7 +80,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } // Get the key version in its state afterwards - resp, err := apiClient.GetVersionExecute(ctx, model.ProjectId, model.Region, model.KeyRingId, model.KeyId, model.VersionNumber) + resp, err := apiClient.DefaultAPI.GetVersion(ctx, model.ProjectId, model.Region, model.KeyRingId, model.KeyId, model.VersionNumber).Execute() if err != nil { params.Printer.Debug(print.ErrorLevel, "get key version: %v", err) } @@ -121,7 +120,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *kms.APIClient) kms.ApiDisableVersionRequest { - return apiClient.DisableVersion(ctx, model.ProjectId, model.Region, model.KeyRingId, model.KeyId, model.VersionNumber) + return apiClient.DefaultAPI.DisableVersion(ctx, model.ProjectId, model.Region, model.KeyRingId, model.KeyId, model.VersionNumber) } func configureFlags(cmd *cobra.Command) { @@ -142,7 +141,7 @@ func outputResult(p *print.Printer, outputFormat string, async bool, resp *kms.V if async { operationState = "Triggered disable of" } - p.Outputf("%s version %d of the key %q\n", operationState, utils.PtrValue(resp.Number), utils.PtrValue(resp.KeyId)) + p.Outputf("%s version %d of the key %q\n", operationState, resp.Number, resp.KeyId) return nil }) } diff --git a/internal/cmd/kms/version/disable/disable_test.go b/internal/cmd/kms/version/disable/disable_test.go index ede2893ab..86903bfc5 100644 --- a/internal/cmd/kms/version/disable/disable_test.go +++ b/internal/cmd/kms/version/disable/disable_test.go @@ -7,7 +7,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/kms" + kms "github.com/stackitcloud/stackit-sdk-go/services/kms/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" @@ -25,7 +25,7 @@ type testCtxKey struct{} var ( testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") - testClient = &kms.APIClient{} + testClient = &kms.APIClient{DefaultAPI: &kms.DefaultAPIService{}} testProjectId = uuid.NewString() testKeyRingId = uuid.NewString() testKeyId = uuid.NewString() @@ -76,7 +76,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { // Request func fixtureRequest(mods ...func(request *kms.ApiDisableVersionRequest)) kms.ApiDisableVersionRequest { - request := testClient.DisableVersion(testCtx, testProjectId, testRegion, testKeyRingId, testKeyId, testVersionNumber) + request := testClient.DefaultAPI.DisableVersion(testCtx, testProjectId, testRegion, testKeyRingId, testKeyId, testVersionNumber) for _, mod := range mods { mod(&request) } @@ -269,7 +269,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, kms.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/kms/version/enable/enable.go b/internal/cmd/kms/version/enable/enable.go index 909cf3a32..7c7ff24c5 100644 --- a/internal/cmd/kms/version/enable/enable.go +++ b/internal/cmd/kms/version/enable/enable.go @@ -8,8 +8,8 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/types" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/kms" - "github.com/stackitcloud/stackit-sdk-go/services/kms/wait" + kms "github.com/stackitcloud/stackit-sdk-go/services/kms/v1api" + "github.com/stackitcloud/stackit-sdk-go/services/kms/v1api/wait" "github.com/stackitcloud/stackit-cli/internal/pkg/args" "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -19,7 +19,6 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/print" "github.com/stackitcloud/stackit-cli/internal/pkg/services/kms/client" "github.com/stackitcloud/stackit-cli/internal/pkg/spinner" - "github.com/stackitcloud/stackit-cli/internal/pkg/utils" ) const ( @@ -72,7 +71,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { // Wait for async operation, if async mode not enabled if !model.Async { err := spinner.Run(params.Printer, "Enabling key version", func() error { - _, err = wait.EnableKeyVersionWaitHandler(ctx, apiClient, model.ProjectId, model.Region, model.KeyRingId, model.KeyId, model.VersionNumber).WaitWithContext(ctx) + _, err = wait.EnableKeyVersionWaitHandler(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, model.KeyRingId, model.KeyId, model.VersionNumber).WaitWithContext(ctx) return err }) if err != nil { @@ -81,7 +80,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } // Get the key version in its state afterwards - resp, err := apiClient.GetVersionExecute(ctx, model.ProjectId, model.Region, model.KeyRingId, model.KeyId, model.VersionNumber) + resp, err := apiClient.DefaultAPI.GetVersion(ctx, model.ProjectId, model.Region, model.KeyRingId, model.KeyId, model.VersionNumber).Execute() if err != nil { params.Printer.Debug(print.ErrorLevel, "get key version: %v", err) } @@ -121,7 +120,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *kms.APIClient) kms.ApiEnableVersionRequest { - return apiClient.EnableVersion(ctx, model.ProjectId, model.Region, model.KeyRingId, model.KeyId, model.VersionNumber) + return apiClient.DefaultAPI.EnableVersion(ctx, model.ProjectId, model.Region, model.KeyRingId, model.KeyId, model.VersionNumber) } func configureFlags(cmd *cobra.Command) { @@ -142,7 +141,7 @@ func outputResult(p *print.Printer, outputFormat string, async bool, resp *kms.V if async { operationState = "Triggered enable of" } - p.Outputf("%s version %d of the key %q\n", operationState, utils.PtrValue(resp.Number), utils.PtrValue(resp.KeyId)) + p.Outputf("%s version %d of the key %q\n", operationState, resp.Number, resp.KeyId) return nil }) } diff --git a/internal/cmd/kms/version/enable/enable_test.go b/internal/cmd/kms/version/enable/enable_test.go index 2c29f82a3..7617208d8 100644 --- a/internal/cmd/kms/version/enable/enable_test.go +++ b/internal/cmd/kms/version/enable/enable_test.go @@ -7,7 +7,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/kms" + kms "github.com/stackitcloud/stackit-sdk-go/services/kms/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" @@ -25,7 +25,7 @@ type testCtxKey struct{} var ( testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") - testClient = &kms.APIClient{} + testClient = &kms.APIClient{DefaultAPI: &kms.DefaultAPIService{}} testProjectId = uuid.NewString() testKeyRingId = uuid.NewString() testKeyId = uuid.NewString() @@ -76,7 +76,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { // Request func fixtureRequest(mods ...func(request *kms.ApiEnableVersionRequest)) kms.ApiEnableVersionRequest { - request := testClient.EnableVersion(testCtx, testProjectId, testRegion, testKeyRingId, testKeyId, testVersionNumber) + request := testClient.DefaultAPI.EnableVersion(testCtx, testProjectId, testRegion, testKeyRingId, testKeyId, testVersionNumber) for _, mod := range mods { mod(&request) } @@ -269,7 +269,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, kms.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/kms/version/list/list.go b/internal/cmd/kms/version/list/list.go index bae8aa2e2..c1600d020 100644 --- a/internal/cmd/kms/version/list/list.go +++ b/internal/cmd/kms/version/list/list.go @@ -7,7 +7,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/types" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/kms" + kms "github.com/stackitcloud/stackit-sdk-go/services/kms/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/args" "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -90,14 +90,14 @@ func parseInput(p *print.Printer, cmd *cobra.Command) (*inputModel, error) { } func buildRequest(ctx context.Context, model *inputModel, apiClient *kms.APIClient) kms.ApiListVersionsRequest { - return apiClient.ListVersions(ctx, model.ProjectId, model.Region, model.KeyRingId, model.KeyId) + return apiClient.DefaultAPI.ListVersions(ctx, model.ProjectId, model.Region, model.KeyRingId, model.KeyId) } func outputResult(p *print.Printer, outputFormat, projectId, keyId string, resp *kms.VersionList) error { if resp == nil || resp.Versions == nil { return fmt.Errorf("response is nil / empty") } - versions := *resp.Versions + versions := resp.Versions return p.OutputResult(outputFormat, versions, func() error { if len(versions) == 0 { @@ -109,11 +109,11 @@ func outputResult(p *print.Printer, outputFormat, projectId, keyId string, resp for _, version := range versions { table.AddRow( - utils.PtrString(version.KeyId), - utils.PtrString(version.Number), - utils.PtrString(version.CreatedAt), + version.KeyId, + version.Number, + version.CreatedAt, utils.PtrString(version.DestroyDate), - utils.PtrString(version.State), + version.State, ) } diff --git a/internal/cmd/kms/version/list/list_test.go b/internal/cmd/kms/version/list/list_test.go index a9a9c113e..479d5e19b 100644 --- a/internal/cmd/kms/version/list/list_test.go +++ b/internal/cmd/kms/version/list/list_test.go @@ -8,7 +8,7 @@ import ( "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/kms" + kms "github.com/stackitcloud/stackit-sdk-go/services/kms/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/print" @@ -23,7 +23,7 @@ type testCtxKey struct{} var ( testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") - testClient = &kms.APIClient{} + testClient = &kms.APIClient{DefaultAPI: &kms.DefaultAPIService{}} testProjectId = uuid.NewString() testKeyRingId = uuid.NewString() testKeyId = uuid.NewString() @@ -62,7 +62,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { // Request func fixtureRequest(mods ...func(request *kms.ApiListVersionsRequest)) kms.ApiListVersionsRequest { - request := testClient.ListVersions(testCtx, testProjectId, testRegion, testKeyRingId, testKeyId) + request := testClient.DefaultAPI.ListVersions(testCtx, testProjectId, testRegion, testKeyRingId, testKeyId) for _, mod := range mods { mod(&request) } @@ -219,7 +219,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, kms.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) @@ -252,19 +252,19 @@ func TestOutputResult(t *testing.T) { }, { description: "default output", - resp: &kms.VersionList{Versions: &[]kms.Version{}}, + resp: &kms.VersionList{Versions: []kms.Version{}}, projectLabel: "my-project", wantErr: false, }, { description: "json output", - resp: &kms.VersionList{Versions: &[]kms.Version{}}, + resp: &kms.VersionList{Versions: []kms.Version{}}, outputFormat: print.JSONOutputFormat, wantErr: false, }, { description: "yaml output", - resp: &kms.VersionList{Versions: &[]kms.Version{}}, + resp: &kms.VersionList{Versions: []kms.Version{}}, outputFormat: print.YAMLOutputFormat, wantErr: false, }, diff --git a/internal/cmd/kms/version/restore/restore.go b/internal/cmd/kms/version/restore/restore.go index c8a850a62..2aba9b04b 100644 --- a/internal/cmd/kms/version/restore/restore.go +++ b/internal/cmd/kms/version/restore/restore.go @@ -8,7 +8,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/types" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/kms" + kms "github.com/stackitcloud/stackit-sdk-go/services/kms/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/args" "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -17,7 +17,6 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/print" "github.com/stackitcloud/stackit-cli/internal/pkg/services/kms/client" - "github.com/stackitcloud/stackit-cli/internal/pkg/utils" ) const ( @@ -68,7 +67,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } // Grab the key after the restore was applied to display the new state to the user. - resp, err := apiClient.GetVersionExecute(ctx, model.ProjectId, model.Region, model.KeyRingId, model.KeyId, model.VersionNumber) + resp, err := apiClient.DefaultAPI.GetVersion(ctx, model.ProjectId, model.Region, model.KeyRingId, model.KeyId, model.VersionNumber).Execute() if err != nil { params.Printer.Debug(print.ErrorLevel, "get key version: %v", err) } @@ -108,7 +107,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *kms.APIClient) kms.ApiRestoreVersionRequest { - return apiClient.RestoreVersion(ctx, model.ProjectId, model.Region, model.KeyRingId, model.KeyId, model.VersionNumber) + return apiClient.DefaultAPI.RestoreVersion(ctx, model.ProjectId, model.Region, model.KeyRingId, model.KeyId, model.VersionNumber) } func configureFlags(cmd *cobra.Command) { @@ -125,7 +124,7 @@ func outputResult(p *print.Printer, outputFormat string, resp *kms.Version) erro } return p.OutputResult(outputFormat, resp, func() error { - p.Outputf("Restored version %d of the key %q\n", utils.PtrValue(resp.Number), utils.PtrValue(resp.KeyId)) + p.Outputf("Restored version %d of the key %q\n", resp.Number, resp.KeyId) return nil }) } diff --git a/internal/cmd/kms/version/restore/restore_test.go b/internal/cmd/kms/version/restore/restore_test.go index efea70cf1..8268f1d56 100644 --- a/internal/cmd/kms/version/restore/restore_test.go +++ b/internal/cmd/kms/version/restore/restore_test.go @@ -7,7 +7,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/kms" + kms "github.com/stackitcloud/stackit-sdk-go/services/kms/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" @@ -25,7 +25,7 @@ type testCtxKey struct{} var ( testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") - testClient = &kms.APIClient{} + testClient = &kms.APIClient{DefaultAPI: &kms.DefaultAPIService{}} testProjectId = uuid.NewString() testKeyRingId = uuid.NewString() testKeyId = uuid.NewString() @@ -76,7 +76,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { // Request func fixtureRequest(mods ...func(request *kms.ApiRestoreVersionRequest)) kms.ApiRestoreVersionRequest { - request := testClient.RestoreVersion(testCtx, testProjectId, testRegion, testKeyRingId, testKeyId, testVersionNumber) + request := testClient.DefaultAPI.RestoreVersion(testCtx, testProjectId, testRegion, testKeyRingId, testKeyId, testVersionNumber) for _, mod := range mods { mod(&request) } @@ -269,7 +269,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, kms.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/kms/wrappingkey/create/create.go b/internal/cmd/kms/wrappingkey/create/create.go index 3397f112f..e2c3ddba1 100644 --- a/internal/cmd/kms/wrappingkey/create/create.go +++ b/internal/cmd/kms/wrappingkey/create/create.go @@ -13,8 +13,8 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/services/kms/client" "github.com/stackitcloud/stackit-cli/internal/pkg/spinner" - "github.com/stackitcloud/stackit-sdk-go/services/kms" - "github.com/stackitcloud/stackit-sdk-go/services/kms/wait" + kms "github.com/stackitcloud/stackit-sdk-go/services/kms/v1api" + "github.com/stackitcloud/stackit-sdk-go/services/kms/v1api/wait" "github.com/stackitcloud/stackit-cli/internal/pkg/examples" "github.com/stackitcloud/stackit-cli/internal/pkg/flags" @@ -26,22 +26,36 @@ import ( const ( keyRingIdFlag = "keyring-id" - algorithmFlag = "algorithm" descriptionFlag = "description" displayNameFlag = "name" - purposeFlag = "purpose" - protectionFlag = "protection" +) + +var ( + algorithmFlag = flags.StringEnumFlag( + "algorithm", + kms.AllowedWrappingAlgorithmEnumValues, + "En-/Decryption / signing algorithm.", + ) + purposeFlag = flags.StringEnumFlag( + "purpose", + kms.AllowedWrappingPurposeEnumValues, + "Purpose of the key.", + ) + protectionFlag = flags.StringEnumFlag( + "protection", + kms.AllowedProtectionEnumValues, + "The underlying system that is responsible for protecting the key material.") ) type inputModel struct { *globalflags.GlobalFlagModel KeyRingId string - Algorithm *string + Algorithm kms.WrappingAlgorithm Description *string Name *string - Purpose *string - Protection *string + Purpose kms.WrappingPurpose + Protection kms.Protection } func NewCmd(params *types.CmdParams) *cobra.Command { @@ -77,7 +91,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } // Call API - req, _ := buildRequest(ctx, model, apiClient) + req, _ := buildRequest(ctx, model, apiClient.DefaultAPI) wrappingKey, err := req.Execute() if err != nil { return fmt.Errorf("create KMS wrapping key: %w", err) @@ -86,7 +100,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { // Wait for async operation, if async mode not enabled if !model.Async { err := spinner.Run(params.Printer, "Creating wrapping key", func() error { - _, err = wait.CreateWrappingKeyWaitHandler(ctx, apiClient, model.ProjectId, model.Region, *wrappingKey.KeyRingId, *wrappingKey.Id).WaitWithContext(ctx) + _, err = wait.CreateWrappingKeyWaitHandler(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, wrappingKey.KeyRingId, wrappingKey.Id).WaitWithContext(ctx) return err }) if err != nil { @@ -111,11 +125,11 @@ func parseInput(p *print.Printer, cmd *cobra.Command) (*inputModel, error) { model := inputModel{ GlobalFlagModel: globalFlags, KeyRingId: flags.FlagToStringValue(p, cmd, keyRingIdFlag), - Algorithm: flags.FlagToStringPointer(p, cmd, algorithmFlag), + Algorithm: algorithmFlag.Get(), Name: flags.FlagToStringPointer(p, cmd, displayNameFlag), Description: flags.FlagToStringPointer(p, cmd, descriptionFlag), - Purpose: flags.FlagToStringPointer(p, cmd, purposeFlag), - Protection: flags.FlagToStringPointer(p, cmd, protectionFlag), + Purpose: purposeFlag.Get(), + Protection: protectionFlag.Get(), } p.DebugInputModel(model) @@ -130,11 +144,11 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient kmsWrappingK req := apiClient.CreateWrappingKey(ctx, model.ProjectId, model.Region, model.KeyRingId) req = req.CreateWrappingKeyPayload(kms.CreateWrappingKeyPayload{ - DisplayName: model.Name, + DisplayName: utils.PtrString(model.Name), Description: model.Description, - Algorithm: kms.CreateWrappingKeyPayloadGetAlgorithmAttributeType(model.Algorithm), - Purpose: kms.CreateWrappingKeyPayloadGetPurposeAttributeType(model.Purpose), - Protection: kms.CreateWrappingKeyPayloadGetProtectionAttributeType(model.Protection), + Algorithm: model.Algorithm, + Purpose: model.Purpose, + Protection: model.Protection, }) return req, nil } @@ -149,39 +163,21 @@ func outputResult(p *print.Printer, model *inputModel, resp *kms.WrappingKey) er if model.Async { operationState = "Triggered creation of" } - p.Outputf("%s wrapping key. Wrapping key ID: %s\n", operationState, utils.PtrString(resp.Id)) + p.Outputf("%s wrapping key. Wrapping key ID: %s\n", operationState, resp.Id) return nil }) } func configureFlags(cmd *cobra.Command) { - // Algorithm - var algorithmFlagOptions []string - for _, val := range kms.AllowedWrappingAlgorithmEnumValues { - algorithmFlagOptions = append(algorithmFlagOptions, string(val)) - } - cmd.Flags().Var(flags.EnumFlag(false, "", algorithmFlagOptions...), algorithmFlag, fmt.Sprintf("En-/Decryption / signing algorithm. Possible values: %q", algorithmFlagOptions)) - - // Purpose - var purposeFlagOptions []string - for _, val := range kms.AllowedWrappingPurposeEnumValues { - purposeFlagOptions = append(purposeFlagOptions, string(val)) - } - cmd.Flags().Var(flags.EnumFlag(false, "", purposeFlagOptions...), purposeFlag, fmt.Sprintf("Purpose of the wrapping key. Possible values: %q", purposeFlagOptions)) - - // Protection - // backend was deprectaed in /v1beta, but protection is a required attribute with value "software" - var protectionFlagOptions []string - for _, val := range kms.AllowedProtectionEnumValues { - protectionFlagOptions = append(protectionFlagOptions, string(val)) - } - cmd.Flags().Var(flags.EnumFlag(false, "", protectionFlagOptions...), protectionFlag, fmt.Sprintf("The underlying system that is responsible for protecting the wrapping key material. Possible values: %q", purposeFlagOptions)) + algorithmFlag.Register(cmd) + purposeFlag.Register(cmd) + protectionFlag.Register(cmd) // All further non Enum Flags cmd.Flags().Var(flags.UUIDFlag(), keyRingIdFlag, "ID of the KMS key ring") cmd.Flags().String(displayNameFlag, "", "The display name to distinguish multiple wrapping keys") cmd.Flags().String(descriptionFlag, "", "Optional description of the wrapping key") - err := flags.MarkFlagsRequired(cmd, keyRingIdFlag, algorithmFlag, purposeFlag, displayNameFlag, protectionFlag) + err := flags.MarkFlagsRequired(cmd, keyRingIdFlag, algorithmFlag.Name(), purposeFlag.Name(), displayNameFlag, protectionFlag.Name()) cobra.CheckErr(err) } diff --git a/internal/cmd/kms/wrappingkey/create/create_test.go b/internal/cmd/kms/wrappingkey/create/create_test.go index ef2fc98d0..981e60637 100644 --- a/internal/cmd/kms/wrappingkey/create/create_test.go +++ b/internal/cmd/kms/wrappingkey/create/create_test.go @@ -8,7 +8,7 @@ import ( "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/kms" + kms "github.com/stackitcloud/stackit-sdk-go/services/kms/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/print" @@ -18,18 +18,18 @@ import ( const ( testRegion = "eu01" - testAlgorithm = "rsa_2048_oaep_sha256" + testAlgorithm = kms.WRAPPINGALGORITHM_RSA_2048_OAEP_SHA256 testDisplayName = "my-key" - testPurpose = "wrap_asymmetric_key" + testPurpose = kms.WRAPPINGPURPOSE_WRAP_ASYMMETRIC_KEY testDescription = "my key description" - testProtection = "software" + testProtection = kms.PROTECTION_SOFTWARE ) type testCtxKey struct{} var ( testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") - testClient = &kms.APIClient{} + testClient = &kms.APIClient{DefaultAPI: &kms.DefaultAPIService{}} testProjectId = uuid.NewString() testKeyRingId = uuid.NewString() ) @@ -40,11 +40,11 @@ func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]st globalflags.ProjectIdFlag: testProjectId, globalflags.RegionFlag: testRegion, keyRingIdFlag: testKeyRingId, - algorithmFlag: testAlgorithm, + algorithmFlag.Name(): string(testAlgorithm), displayNameFlag: testDisplayName, - purposeFlag: testPurpose, + purposeFlag.Name(): string(testPurpose), descriptionFlag: testDescription, - protectionFlag: testProtection, + protectionFlag.Name(): string(testProtection), } for _, mod := range mods { mod(flagValues) @@ -61,11 +61,11 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { Verbosity: globalflags.VerbosityDefault, }, KeyRingId: testKeyRingId, - Algorithm: utils.Ptr(testAlgorithm), + Algorithm: testAlgorithm, Name: utils.Ptr(testDisplayName), - Purpose: utils.Ptr(testPurpose), + Purpose: testPurpose, Description: utils.Ptr(testDescription), - Protection: utils.Ptr(testProtection), + Protection: testProtection, } for _, mod := range mods { mod(model) @@ -75,13 +75,13 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { // Request func fixtureRequest(mods ...func(request *kms.ApiCreateWrappingKeyRequest)) kms.ApiCreateWrappingKeyRequest { - request := testClient.CreateWrappingKey(testCtx, testProjectId, testRegion, testKeyRingId) + request := testClient.DefaultAPI.CreateWrappingKey(testCtx, testProjectId, testRegion, testKeyRingId) request = request.CreateWrappingKeyPayload(kms.CreateWrappingKeyPayload{ - Algorithm: kms.CreateWrappingKeyPayloadGetAlgorithmAttributeType(utils.Ptr(testAlgorithm)), - DisplayName: utils.Ptr(testDisplayName), - Purpose: kms.CreateWrappingKeyPayloadGetPurposeAttributeType(utils.Ptr(testPurpose)), + Algorithm: testAlgorithm, + DisplayName: testDisplayName, + Purpose: testPurpose, Description: utils.Ptr(testDescription), - Protection: kms.CreateWrappingKeyPayloadGetProtectionAttributeType(utils.Ptr(testProtection)), + Protection: testProtection, }) for _, mod := range mods { @@ -156,7 +156,7 @@ func TestParseInput(t *testing.T) { { description: "algorithm missing (required)", flagValues: fixtureFlagValues(func(flagValues map[string]string) { - delete(flagValues, algorithmFlag) + delete(flagValues, algorithmFlag.Name()) }), isValid: false, }, @@ -170,14 +170,14 @@ func TestParseInput(t *testing.T) { { description: "purpose missing (required)", flagValues: fixtureFlagValues(func(flagValues map[string]string) { - delete(flagValues, purposeFlag) + delete(flagValues, purposeFlag.Name()) }), isValid: false, }, { description: "protection missing (required)", flagValues: fixtureFlagValues(func(flagValues map[string]string) { - delete(flagValues, protectionFlag) + delete(flagValues, protectionFlag.Name()) }), isValid: false, }, @@ -248,24 +248,24 @@ func TestBuildRequest(t *testing.T) { model.Description = nil }), expectedRequest: fixtureRequest().CreateWrappingKeyPayload(kms.CreateWrappingKeyPayload{ - Algorithm: kms.CreateWrappingKeyPayloadGetAlgorithmAttributeType(utils.Ptr(testAlgorithm)), - DisplayName: utils.Ptr(testDisplayName), - Purpose: kms.CreateWrappingKeyPayloadGetPurposeAttributeType(utils.Ptr(testPurpose)), - Protection: kms.CreateWrappingKeyPayloadGetProtectionAttributeType(utils.Ptr(testProtection)), + Algorithm: testAlgorithm, + DisplayName: testDisplayName, + Purpose: testPurpose, + Protection: testProtection, }), }, } for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { - request, err := buildRequest(testCtx, tt.model, testClient) + request, err := buildRequest(testCtx, tt.model, testClient.DefaultAPI) if err != nil { t.Fatalf("error building request: %v", err) } diff := cmp.Diff(tt.expectedRequest, request, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, kms.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/kms/wrappingkey/delete/delete.go b/internal/cmd/kms/wrappingkey/delete/delete.go index cd1ce3f6a..d51d6fab8 100644 --- a/internal/cmd/kms/wrappingkey/delete/delete.go +++ b/internal/cmd/kms/wrappingkey/delete/delete.go @@ -17,7 +17,7 @@ import ( kmsUtils "github.com/stackitcloud/stackit-cli/internal/pkg/services/kms/utils" "github.com/stackitcloud/stackit-cli/internal/pkg/utils" - "github.com/stackitcloud/stackit-sdk-go/services/kms" + kms "github.com/stackitcloud/stackit-sdk-go/services/kms/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/services/kms/client" ) @@ -58,7 +58,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return err } - wrappingKeyName, err := kmsUtils.GetWrappingKeyName(ctx, apiClient, model.ProjectId, model.Region, model.KeyRingId, model.WrappingKeyId) + wrappingKeyName, err := kmsUtils.GetWrappingKeyName(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, model.KeyRingId, model.WrappingKeyId) if err != nil { params.Printer.Debug(print.ErrorLevel, "get wrapping key name: %v", err) wrappingKeyName = model.WrappingKeyId @@ -108,7 +108,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *kms.APIClient) kms.ApiDeleteWrappingKeyRequest { - req := apiClient.DeleteWrappingKey(ctx, model.ProjectId, model.Region, model.KeyRingId, model.WrappingKeyId) + req := apiClient.DefaultAPI.DeleteWrappingKey(ctx, model.ProjectId, model.Region, model.KeyRingId, model.WrappingKeyId) return req } diff --git a/internal/cmd/kms/wrappingkey/delete/delete_test.go b/internal/cmd/kms/wrappingkey/delete/delete_test.go index 54bb33f4c..225a73c06 100644 --- a/internal/cmd/kms/wrappingkey/delete/delete_test.go +++ b/internal/cmd/kms/wrappingkey/delete/delete_test.go @@ -7,7 +7,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/kms" + kms "github.com/stackitcloud/stackit-sdk-go/services/kms/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" @@ -22,7 +22,7 @@ type testCtxKey struct{} var ( testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") - testClient = &kms.APIClient{} + testClient = &kms.APIClient{DefaultAPI: &kms.DefaultAPIService{}} testProjectId = uuid.NewString() testKeyRingId = uuid.NewString() testWrappingKeyId = uuid.NewString() @@ -71,7 +71,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { // Request func fixtureRequest(mods ...func(request *kms.ApiDeleteWrappingKeyRequest)) kms.ApiDeleteWrappingKeyRequest { - request := testClient.DeleteWrappingKey(testCtx, testProjectId, testRegion, testKeyRingId, testWrappingKeyId) + request := testClient.DefaultAPI.DeleteWrappingKey(testCtx, testProjectId, testRegion, testKeyRingId, testWrappingKeyId) for _, mod := range mods { mod(&request) } @@ -232,7 +232,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(tt.expectedRequest, request, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, kms.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/kms/wrappingkey/describe/describe.go b/internal/cmd/kms/wrappingkey/describe/describe.go index e58e9fa81..861341140 100644 --- a/internal/cmd/kms/wrappingkey/describe/describe.go +++ b/internal/cmd/kms/wrappingkey/describe/describe.go @@ -7,7 +7,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/types" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/kms" + kms "github.com/stackitcloud/stackit-sdk-go/services/kms/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/args" "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -91,7 +91,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *kms.APIClient) kms.ApiGetWrappingKeyRequest { - return apiClient.GetWrappingKey(ctx, model.ProjectId, model.Region, model.KeyRingID, model.WrappingKeyID) + return apiClient.DefaultAPI.GetWrappingKey(ctx, model.ProjectId, model.Region, model.KeyRingID, model.WrappingKeyID) } func outputResult(p *print.Printer, outputFormat string, wrappingKey *kms.WrappingKey) error { @@ -100,29 +100,29 @@ func outputResult(p *print.Printer, outputFormat string, wrappingKey *kms.Wrappi } return p.OutputResult(outputFormat, wrappingKey, func() error { table := tables.NewTable() - table.AddRow("ID", utils.PtrString(wrappingKey.Id)) + table.AddRow("ID", wrappingKey.Id) table.AddSeparator() - table.AddRow("DISPLAY NAME", utils.PtrString(wrappingKey.DisplayName)) + table.AddRow("DISPLAY NAME", wrappingKey.DisplayName) table.AddSeparator() - table.AddRow("CREATED AT", utils.PtrString(wrappingKey.CreatedAt)) + table.AddRow("CREATED AT", wrappingKey.CreatedAt) table.AddSeparator() - table.AddRow("STATE", utils.PtrString(wrappingKey.State)) + table.AddRow("STATE", wrappingKey.State) table.AddSeparator() table.AddRow("DESCRIPTION", utils.PtrString(wrappingKey.Description)) table.AddSeparator() - table.AddRow("ACCESS SCOPE", utils.PtrString(wrappingKey.AccessScope)) + table.AddRow("ACCESS SCOPE", wrappingKey.AccessScope) table.AddSeparator() - table.AddRow("ALGORITHM", utils.PtrString(wrappingKey.Algorithm)) + table.AddRow("ALGORITHM", wrappingKey.Algorithm) table.AddSeparator() - table.AddRow("EXPIRES AT", utils.PtrString(wrappingKey.ExpiresAt)) + table.AddRow("EXPIRES AT", wrappingKey.ExpiresAt) table.AddSeparator() - table.AddRow("KEYRING ID", utils.PtrString(wrappingKey.KeyRingId)) + table.AddRow("KEYRING ID", wrappingKey.KeyRingId) table.AddSeparator() - table.AddRow("PROTECTION", utils.PtrString(wrappingKey.Protection)) + table.AddRow("PROTECTION", wrappingKey.Protection) table.AddSeparator() table.AddRow("PUBLIC KEY", utils.PtrString(wrappingKey.PublicKey)) table.AddSeparator() - table.AddRow("PURPOSE", utils.PtrString(wrappingKey.Purpose)) + table.AddRow("PURPOSE", wrappingKey.Purpose) err := table.Display(p) if err != nil { diff --git a/internal/cmd/kms/wrappingkey/describe/describe_test.go b/internal/cmd/kms/wrappingkey/describe/describe_test.go index b625f77dd..b34d292f4 100644 --- a/internal/cmd/kms/wrappingkey/describe/describe_test.go +++ b/internal/cmd/kms/wrappingkey/describe/describe_test.go @@ -9,7 +9,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/kms" + kms "github.com/stackitcloud/stackit-sdk-go/services/kms/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" @@ -20,7 +20,7 @@ import ( type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &kms.APIClient{} +var testClient = &kms.APIClient{DefaultAPI: &kms.DefaultAPIService{}} var testProjectId = uuid.NewString() var testKeyRingID = uuid.NewString() var testWrappingKeyID = uuid.NewString() @@ -123,10 +123,10 @@ func TestParseInput(t *testing.T) { func TestBuildRequest(t *testing.T) { got := buildRequest(testCtx, fixtureInputModel(), testClient) - want := testClient.GetWrappingKey(testCtx, testProjectId, testRegion, testKeyRingID, testWrappingKeyID) + want := testClient.DefaultAPI.GetWrappingKey(testCtx, testProjectId, testRegion, testKeyRingID, testWrappingKeyID) diff := cmp.Diff(got, want, cmp.AllowUnexported(want), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, kms.DefaultAPIService{}), ) if diff != "" { t.Fatalf("buildRequest() mismatch (-want +got):\n%s", diff) @@ -149,18 +149,18 @@ func TestOutputResult(t *testing.T) { description: "table format", outputFmt: "table", keyRing: &kms.WrappingKey{ - Id: utils.Ptr(testWrappingKeyID), - DisplayName: utils.Ptr("Test Key Ring"), - CreatedAt: utils.Ptr(testTime), + Id: testWrappingKeyID, + DisplayName: "Test Key Ring", + CreatedAt: testTime, Description: utils.Ptr("This is a test key ring."), - State: utils.Ptr(kms.WRAPPINGKEYSTATE_ACTIVE), - AccessScope: utils.Ptr(kms.ACCESSSCOPE_PUBLIC), - Algorithm: utils.Ptr(kms.WRAPPINGALGORITHM__2048_OAEP_SHA256), - ExpiresAt: utils.Ptr(testTime), - KeyRingId: utils.Ptr(testKeyRingID), - Protection: utils.Ptr(kms.PROTECTION_SOFTWARE), + State: kms.WRAPPINGKEYSTATE_ACTIVE, + AccessScope: kms.ACCESSSCOPE_PUBLIC, + Algorithm: kms.WRAPPINGALGORITHM_RSA_2048_OAEP_SHA256, + ExpiresAt: testTime, + KeyRingId: testKeyRingID, + Protection: kms.PROTECTION_SOFTWARE, PublicKey: utils.Ptr("-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQ...\n-----END PUBLIC KEY-----"), - Purpose: utils.Ptr(kms.WRAPPINGPURPOSE_ASYMMETRIC_KEY), + Purpose: kms.WRAPPINGPURPOSE_WRAP_ASYMMETRIC_KEY, }, expected: fmt.Sprintf(` ID │ %-46s diff --git a/internal/cmd/kms/wrappingkey/list/list.go b/internal/cmd/kms/wrappingkey/list/list.go index 6d64940ed..06b6ea4b7 100644 --- a/internal/cmd/kms/wrappingkey/list/list.go +++ b/internal/cmd/kms/wrappingkey/list/list.go @@ -7,7 +7,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/types" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/kms" + kms "github.com/stackitcloud/stackit-sdk-go/services/kms/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/args" "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -17,7 +17,6 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/print" "github.com/stackitcloud/stackit-cli/internal/pkg/services/kms/client" "github.com/stackitcloud/stackit-cli/internal/pkg/tables" - "github.com/stackitcloud/stackit-cli/internal/pkg/utils" ) const ( @@ -87,7 +86,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command) (*inputModel, error) { } func buildRequest(ctx context.Context, model *inputModel, apiClient *kms.APIClient) kms.ApiListWrappingKeysRequest { - req := apiClient.ListWrappingKeys(ctx, model.ProjectId, model.Region, model.KeyRingId) + req := apiClient.DefaultAPI.ListWrappingKeys(ctx, model.ProjectId, model.Region, model.KeyRingId) return req } @@ -102,7 +101,7 @@ func outputResult(p *print.Printer, outputFormat, keyRingId string, resp *kms.Wr return fmt.Errorf("response is nil / empty") } - wrappingKeys := *resp.WrappingKeys + wrappingKeys := resp.WrappingKeys return p.OutputResult(outputFormat, wrappingKeys, func() error { if len(wrappingKeys) == 0 { @@ -115,12 +114,12 @@ func outputResult(p *print.Printer, outputFormat, keyRingId string, resp *kms.Wr for i := range wrappingKeys { wrappingKey := wrappingKeys[i] table.AddRow( - utils.PtrString(wrappingKey.Id), - utils.PtrString(wrappingKey.DisplayName), - utils.PtrString(wrappingKey.Purpose), - utils.PtrString(wrappingKey.Algorithm), - utils.PtrString(wrappingKey.ExpiresAt), - utils.PtrString(wrappingKey.State), + wrappingKey.Id, + wrappingKey.DisplayName, + wrappingKey.Purpose, + wrappingKey.Algorithm, + wrappingKey.ExpiresAt, + wrappingKey.State, ) } diff --git a/internal/cmd/kms/wrappingkey/list/list_test.go b/internal/cmd/kms/wrappingkey/list/list_test.go index c2b5b98d2..d13f01ca7 100644 --- a/internal/cmd/kms/wrappingkey/list/list_test.go +++ b/internal/cmd/kms/wrappingkey/list/list_test.go @@ -8,7 +8,7 @@ import ( "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/kms" + kms "github.com/stackitcloud/stackit-sdk-go/services/kms/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/print" @@ -23,7 +23,7 @@ type testCtxKey struct{} var ( testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") - testClient = &kms.APIClient{} + testClient = &kms.APIClient{DefaultAPI: &kms.DefaultAPIService{}} testProjectId = uuid.NewString() testKeyRingId = uuid.NewString() ) @@ -59,7 +59,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { // Request func fixtureRequest(mods ...func(request *kms.ApiListWrappingKeysRequest)) kms.ApiListWrappingKeysRequest { - request := testClient.ListWrappingKeys(testCtx, testProjectId, testRegion, testKeyRingId) + request := testClient.DefaultAPI.ListWrappingKeys(testCtx, testProjectId, testRegion, testKeyRingId) for _, mod := range mods { mod(&request) } @@ -194,7 +194,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, kms.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) @@ -220,19 +220,19 @@ func TestOutputResult(t *testing.T) { }, { description: "default output", - resp: &kms.WrappingKeyList{WrappingKeys: &[]kms.WrappingKey{}}, + resp: &kms.WrappingKeyList{WrappingKeys: []kms.WrappingKey{}}, projectLabel: "my-project", wantErr: false, }, { description: "json output", - resp: &kms.WrappingKeyList{WrappingKeys: &[]kms.WrappingKey{}}, + resp: &kms.WrappingKeyList{WrappingKeys: []kms.WrappingKey{}}, outputFormat: print.JSONOutputFormat, wantErr: false, }, { description: "yaml output", - resp: &kms.WrappingKeyList{WrappingKeys: &[]kms.WrappingKey{}}, + resp: &kms.WrappingKeyList{WrappingKeys: []kms.WrappingKey{}}, outputFormat: print.YAMLOutputFormat, wantErr: false, }, diff --git a/internal/pkg/services/kms/client/client.go b/internal/pkg/services/kms/client/client.go index ecb2111a2..7dc5dc29d 100644 --- a/internal/pkg/services/kms/client/client.go +++ b/internal/pkg/services/kms/client/client.go @@ -6,9 +6,9 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/print" "github.com/spf13/viper" - "github.com/stackitcloud/stackit-sdk-go/services/kms" + kms "github.com/stackitcloud/stackit-sdk-go/services/kms/v1api" ) func ConfigureClient(p *print.Printer, cliVersion string) (*kms.APIClient, error) { - return genericclient.ConfigureClientGeneric(p, cliVersion, viper.GetString(config.KMSCustomEndpointKey), false, genericclient.CreateApiClient[*kms.APIClient](kms.NewAPIClient)) + return genericclient.ConfigureClientGeneric(p, cliVersion, viper.GetString(config.KMSCustomEndpointKey), false, kms.NewAPIClient) } diff --git a/internal/pkg/services/kms/utils/utils.go b/internal/pkg/services/kms/utils/utils.go index 5630e27d6..c0b303b94 100644 --- a/internal/pkg/services/kms/utils/utils.go +++ b/internal/pkg/services/kms/utils/utils.go @@ -5,30 +5,24 @@ import ( "fmt" "time" - "github.com/stackitcloud/stackit-sdk-go/services/kms" + kms "github.com/stackitcloud/stackit-sdk-go/services/kms/v1api" ) -type KMSClient interface { - GetKeyExecute(ctx context.Context, projectId string, regionId string, keyRingId string, keyId string) (*kms.Key, error) - GetKeyRingExecute(ctx context.Context, projectId string, regionId string, keyRingId string) (*kms.KeyRing, error) - GetWrappingKeyExecute(ctx context.Context, projectId string, regionId string, keyRingId string, wrappingKeyId string) (*kms.WrappingKey, error) -} - -func GetKeyName(ctx context.Context, apiClient KMSClient, projectId, region, keyRingId, keyId string) (string, error) { - resp, err := apiClient.GetKeyExecute(ctx, projectId, region, keyRingId, keyId) +func GetKeyName(ctx context.Context, apiClient kms.DefaultAPI, projectId, region, keyRingId, keyId string) (string, error) { + resp, err := apiClient.GetKey(ctx, projectId, region, keyRingId, keyId).Execute() if err != nil { return "", fmt.Errorf("get KMS Key: %w", err) } - if resp == nil || resp.DisplayName == nil { + if resp == nil { return "", fmt.Errorf("response is nil / empty") } - return *resp.DisplayName, nil + return resp.DisplayName, nil } -func GetKeyDeletionDate(ctx context.Context, apiClient KMSClient, projectId, region, keyRingId, keyId string) (time.Time, error) { - resp, err := apiClient.GetKeyExecute(ctx, projectId, region, keyRingId, keyId) +func GetKeyDeletionDate(ctx context.Context, apiClient kms.DefaultAPI, projectId, region, keyRingId, keyId string) (time.Time, error) { + resp, err := apiClient.GetKey(ctx, projectId, region, keyRingId, keyId).Execute() if err != nil { return time.Now(), fmt.Errorf("get KMS Key: %w", err) } @@ -40,28 +34,28 @@ func GetKeyDeletionDate(ctx context.Context, apiClient KMSClient, projectId, reg return *resp.DeletionDate, nil } -func GetKeyRingName(ctx context.Context, apiClient KMSClient, projectId, id, region string) (string, error) { - resp, err := apiClient.GetKeyRingExecute(ctx, projectId, region, id) +func GetKeyRingName(ctx context.Context, apiClient kms.DefaultAPI, projectId, id, region string) (string, error) { + resp, err := apiClient.GetKeyRing(ctx, projectId, region, id).Execute() if err != nil { return "", fmt.Errorf("get KMS key ring: %w", err) } - if resp == nil || resp.DisplayName == nil { + if resp == nil { return "", fmt.Errorf("response is nil / empty") } - return *resp.DisplayName, nil + return resp.DisplayName, nil } -func GetWrappingKeyName(ctx context.Context, apiClient KMSClient, projectId, region, keyRingId, wrappingKeyId string) (string, error) { - resp, err := apiClient.GetWrappingKeyExecute(ctx, projectId, region, keyRingId, wrappingKeyId) +func GetWrappingKeyName(ctx context.Context, apiClient kms.DefaultAPI, projectId, region, keyRingId, wrappingKeyId string) (string, error) { + resp, err := apiClient.GetWrappingKey(ctx, projectId, region, keyRingId, wrappingKeyId).Execute() if err != nil { return "", fmt.Errorf("get KMS Wrapping Key: %w", err) } - if resp == nil || resp.DisplayName == nil { + if resp == nil { return "", fmt.Errorf("response is nil / empty") } - return *resp.DisplayName, nil + return resp.DisplayName, nil } diff --git a/internal/pkg/services/kms/utils/utils_test.go b/internal/pkg/services/kms/utils/utils_test.go index 339cb2d3a..365d4ef30 100644 --- a/internal/pkg/services/kms/utils/utils_test.go +++ b/internal/pkg/services/kms/utils/utils_test.go @@ -7,7 +7,9 @@ import ( "time" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/kms" + kms "github.com/stackitcloud/stackit-sdk-go/services/kms/v1api" + + "github.com/stackitcloud/stackit-cli/internal/pkg/utils" ) var ( @@ -33,26 +35,27 @@ type kmsClientMocked struct { getWrappingKeyResp *kms.WrappingKey } -// Implement the KMSClient interface methods for the mock. -func (m *kmsClientMocked) GetKeyExecute(_ context.Context, _, _, _, _ string) (*kms.Key, error) { - if m.getKeyFails { - return nil, fmt.Errorf("could not get key") - } - return m.getKeyResp, nil -} - -func (m *kmsClientMocked) GetKeyRingExecute(_ context.Context, _, _, _ string) (*kms.KeyRing, error) { - if m.getKeyRingFails { - return nil, fmt.Errorf("could not get key ring") - } - return m.getKeyRingResp, nil -} - -func (m *kmsClientMocked) GetWrappingKeyExecute(_ context.Context, _, _, _, _ string) (*kms.WrappingKey, error) { - if m.getWrappingKeyFails { - return nil, fmt.Errorf("could not get wrapping key") +func (m *kmsClientMocked) newMock() kms.DefaultAPI { + return kms.DefaultAPIServiceMock{ + GetKeyExecuteMock: utils.Ptr(func(_ kms.ApiGetKeyRequest) (*kms.Key, error) { + if m.getKeyFails { + return nil, fmt.Errorf("could not get key") + } + return m.getKeyResp, nil + }), + GetKeyRingExecuteMock: utils.Ptr(func(_ kms.ApiGetKeyRingRequest) (*kms.KeyRing, error) { + if m.getKeyRingFails { + return nil, fmt.Errorf("could not get key ring") + } + return m.getKeyRingResp, nil + }), + GetWrappingKeyExecuteMock: utils.Ptr(func(_ kms.ApiGetWrappingKeyRequest) (*kms.WrappingKey, error) { + if m.getWrappingKeyFails { + return nil, fmt.Errorf("could not get wrapping key") + } + return m.getWrappingKeyResp, nil + }), } - return m.getWrappingKeyResp, nil } func TestGetKeyName(t *testing.T) { @@ -68,7 +71,7 @@ func TestGetKeyName(t *testing.T) { { description: "base", getKeyResp: &kms.Key{ - DisplayName: &keyName, + DisplayName: keyName, }, isValid: true, expectedOutput: testKeyName, @@ -87,7 +90,7 @@ func TestGetKeyName(t *testing.T) { getKeyResp: tt.getKeyResp, } - output, err := GetKeyName(context.Background(), client, testProjectId, testRegion, testKeyRingId, testKeyId) + output, err := GetKeyName(context.Background(), client.newMock(), testProjectId, testRegion, testKeyRingId, testKeyId) if tt.isValid && err != nil { t.Errorf("failed on valid input: %v", err) @@ -138,7 +141,7 @@ func TestGetKeyDeletionDate(t *testing.T) { getKeyResp: tt.getKeyResp, } - output, err := GetKeyDeletionDate(context.Background(), client, testProjectId, testRegion, testKeyRingId, testKeyId) + output, err := GetKeyDeletionDate(context.Background(), client.newMock(), testProjectId, testRegion, testKeyRingId, testKeyId) if tt.isValid && err != nil { t.Errorf("failed on valid input: %v", err) @@ -170,7 +173,7 @@ func TestGetKeyRingName(t *testing.T) { { description: "base", getKeyRingResp: &kms.KeyRing{ - DisplayName: &keyRingName, + DisplayName: keyRingName, }, isValid: true, expectedOutput: testKeyRingName, @@ -189,7 +192,7 @@ func TestGetKeyRingName(t *testing.T) { getKeyRingResp: tt.getKeyRingResp, } - output, err := GetKeyRingName(context.Background(), client, testProjectId, testKeyRingId, testRegion) + output, err := GetKeyRingName(context.Background(), client.newMock(), testProjectId, testKeyRingId, testRegion) if tt.isValid && err != nil { t.Errorf("failed on valid input: %v", err) @@ -219,7 +222,7 @@ func TestGetWrappingKeyName(t *testing.T) { { description: "base", getWrappingKeyResp: &kms.WrappingKey{ - DisplayName: &wrappingKeyName, + DisplayName: wrappingKeyName, }, isValid: true, expectedOutput: testWrappingKeyName, @@ -238,7 +241,7 @@ func TestGetWrappingKeyName(t *testing.T) { getWrappingKeyResp: tt.getWrappingKeyResp, } - output, err := GetWrappingKeyName(context.Background(), client, testProjectId, testRegion, testKeyRingId, testWrappingKeyId) + output, err := GetWrappingKeyName(context.Background(), client.newMock(), testProjectId, testRegion, testKeyRingId, testWrappingKeyId) if tt.isValid && err != nil { t.Errorf("failed on valid input: %v", err) From 7f11150374bc67fca9d08f952b937ba3ea6f832c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=B6kce=20G=C3=B6k=20Klingel?= <161626272+GokceGK@users.noreply.github.com> Date: Tue, 16 Jun 2026 16:08:04 +0200 Subject: [PATCH 04/44] fix(iaas): update examples and fix the payload for boot volumes (#1436) relates to STACKITCLI-404 --- docs/stackit_server_create.md | 26 +++++++-------------- internal/cmd/server/create/create.go | 35 +++++++++++----------------- 2 files changed, 22 insertions(+), 39 deletions(-) diff --git a/docs/stackit_server_create.md b/docs/stackit_server_create.md index d807bcc3c..f3d1557ea 100644 --- a/docs/stackit_server_create.md +++ b/docs/stackit_server_create.md @@ -13,35 +13,26 @@ stackit server create [flags] ### Examples ``` - Create a server from an image with id xxx - $ stackit server create --machine-type t1.1 --name server1 --image-id xxx - - Create a server with labels from an image with id xxx - $ stackit server create --machine-type t1.1 --name server1 --image-id xxx --labels key=value,foo=bar - - Create a server with a boot volume - $ stackit server create --machine-type t1.1 --name server1 --boot-volume-source-id xxx --boot-volume-source-type image --boot-volume-size 64 + Create a server with a boot volume with source type image + $ stackit server create --machine-type g2i.1 --name server1 --network-id yyy --boot-volume-source-id xxx --boot-volume-source-type image --boot-volume-size 64 Create a server with a boot volume from an existing volume - $ stackit server create --machine-type t1.1 --name server1 --boot-volume-source-id xxx --boot-volume-source-type volume + $ stackit server create --machine-type g2i.1 --name server1 --network-id yyy --boot-volume-source-id xxx --boot-volume-source-type volume Create a server with a keypair - $ stackit server create --machine-type t1.1 --name server1 --image-id xxx --keypair-name example - - Create a server with a network - $ stackit server create --machine-type t1.1 --name server1 --image-id xxx --network-id yyy + $ stackit server create --machine-type g2i.1 --name server1 --network-id yyy --boot-volume-source-id xxx --boot-volume-source-type image --boot-volume-size 64 --keypair-name example Create a server with a network interface - $ stackit server create --machine-type t1.1 --name server1 --boot-volume-source-id xxx --boot-volume-source-type image --boot-volume-size 64 --network-interface-ids yyy + $ stackit server create --machine-type g2i.1 --name server1 --boot-volume-source-id xxx --boot-volume-source-type image --boot-volume-size 64 --network-interface-ids yyy Create a server with an attached volume - $ stackit server create --machine-type t1.1 --name server1 --boot-volume-source-id xxx --boot-volume-source-type image --boot-volume-size 64 --volumes yyy + $ stackit server create --machine-type g2i.1 --name server1 --network-id yyy --boot-volume-source-id xxx --boot-volume-source-type image --boot-volume-size 64 --volumes zzz Create a server with user data (cloud-init) - $ stackit server create --machine-type t1.1 --name server1 --boot-volume-source-id xxx --boot-volume-source-type image --boot-volume-size 64 --user-data @path/to/file.yaml + $ stackit server create --machine-type g2i.1 --name server1 --network-id yyy --boot-volume-source-id xxx --boot-volume-source-type image --boot-volume-size 64 --user-data @path/to/file.yaml Create a server with provisioned agent - $ stackit server create --machine-type t1.1 --name server1 --boot-volume-source-id xxx --boot-volume-source-type image --boot-volume-size 64 --network-id yyy --agent-provisioning-policy ALWAYS + $ stackit server create --machine-type g2i.1 --name server1 --network-id yyy --boot-volume-source-id xxx --boot-volume-source-type image --boot-volume-size 64 --agent-provisioning-policy ALWAYS ``` ### Options @@ -56,7 +47,6 @@ stackit server create [flags] --boot-volume-source-id string ID of the source object of boot volume. It can be either an image or volume ID --boot-volume-source-type string Type of the source object of boot volume. It can be either 'image' or 'volume' -h, --help Help for "stackit server create" - --image-id string The image ID to be used for an ephemeral disk on the server. Either 'image-id' or 'boot-volume-...' flags are required --keypair-name string The name of the SSH keypair used during the server creation --labels stringToString Labels are key-value string pairs which can be attached to a server. E.g. '--labels key1=value1,key2=value2,...' (default []) --machine-type string Name of the type of the machine for the server. Possible values are documented in https://docs.stackit.cloud/products/compute-engine/server/basics/machine-types/ diff --git a/internal/cmd/server/create/create.go b/internal/cmd/server/create/create.go index 0f7e68f33..a9d5f5152 100644 --- a/internal/cmd/server/create/create.go +++ b/internal/cmd/server/create/create.go @@ -76,44 +76,32 @@ func NewCmd(params *types.CmdParams) *cobra.Command { Args: args.NoArgs, Example: examples.Build( examples.NewExample( - `Create a server from an image with id xxx`, - `$ stackit server create --machine-type t1.1 --name server1 --image-id xxx`, - ), - examples.NewExample( - `Create a server with labels from an image with id xxx`, - `$ stackit server create --machine-type t1.1 --name server1 --image-id xxx --labels key=value,foo=bar`, - ), - examples.NewExample( - `Create a server with a boot volume`, - `$ stackit server create --machine-type t1.1 --name server1 --boot-volume-source-id xxx --boot-volume-source-type image --boot-volume-size 64`, + `Create a server with a boot volume with source type image`, + `$ stackit server create --machine-type g2i.1 --name server1 --network-id yyy --boot-volume-source-id xxx --boot-volume-source-type image --boot-volume-size 64`, ), examples.NewExample( `Create a server with a boot volume from an existing volume`, - `$ stackit server create --machine-type t1.1 --name server1 --boot-volume-source-id xxx --boot-volume-source-type volume`, + `$ stackit server create --machine-type g2i.1 --name server1 --network-id yyy --boot-volume-source-id xxx --boot-volume-source-type volume`, ), examples.NewExample( `Create a server with a keypair`, - `$ stackit server create --machine-type t1.1 --name server1 --image-id xxx --keypair-name example`, - ), - examples.NewExample( - `Create a server with a network`, - `$ stackit server create --machine-type t1.1 --name server1 --image-id xxx --network-id yyy`, + `$ stackit server create --machine-type g2i.1 --name server1 --network-id yyy --boot-volume-source-id xxx --boot-volume-source-type image --boot-volume-size 64 --keypair-name example`, ), examples.NewExample( `Create a server with a network interface`, - `$ stackit server create --machine-type t1.1 --name server1 --boot-volume-source-id xxx --boot-volume-source-type image --boot-volume-size 64 --network-interface-ids yyy`, + `$ stackit server create --machine-type g2i.1 --name server1 --boot-volume-source-id xxx --boot-volume-source-type image --boot-volume-size 64 --network-interface-ids yyy`, ), examples.NewExample( `Create a server with an attached volume`, - `$ stackit server create --machine-type t1.1 --name server1 --boot-volume-source-id xxx --boot-volume-source-type image --boot-volume-size 64 --volumes yyy`, + `$ stackit server create --machine-type g2i.1 --name server1 --network-id yyy --boot-volume-source-id xxx --boot-volume-source-type image --boot-volume-size 64 --volumes zzz`, ), examples.NewExample( `Create a server with user data (cloud-init)`, - `$ stackit server create --machine-type t1.1 --name server1 --boot-volume-source-id xxx --boot-volume-source-type image --boot-volume-size 64 --user-data @path/to/file.yaml`, + `$ stackit server create --machine-type g2i.1 --name server1 --network-id yyy --boot-volume-source-id xxx --boot-volume-source-type image --boot-volume-size 64 --user-data @path/to/file.yaml`, ), examples.NewExample( `Create a server with provisioned agent`, - `$ stackit server create --machine-type t1.1 --name server1 --boot-volume-source-id xxx --boot-volume-source-type image --boot-volume-size 64 --network-id yyy --agent-provisioning-policy ALWAYS`, + `$ stackit server create --machine-type g2i.1 --name server1 --network-id yyy --boot-volume-source-id xxx --boot-volume-source-type image --boot-volume-size 64 --agent-provisioning-policy ALWAYS`, ), ), RunE: func(cmd *cobra.Command, args []string) error { @@ -194,6 +182,11 @@ func configureFlags(cmd *cobra.Command) { cmd.MarkFlagsMutuallyExclusive(imageIdFlag, bootVolumeSourceTypeFlag) cmd.MarkFlagsMutuallyExclusive(networkIdFlag, networkInterfaceIdsFlag) cmd.MarkFlagsOneRequired(networkIdFlag, networkInterfaceIdsFlag) + + // hide image-id flag from help command to prevent users from using it alone which leads to errors, because it works only with small images + // instead of using image-id alone, boot-volume flags can be used with type image + cobra.CheckErr(cmd.Flags().MarkHidden(imageIdFlag)) + cobra.CheckErr(err) } @@ -306,7 +299,7 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient *iaas.APICli } } - if model.BootVolumePerformanceClass != nil || model.BootVolumeSize != nil || model.BootVolumeDeleteOnTermination != nil { + if model.BootVolumePerformanceClass != nil || model.BootVolumeSize != nil || model.BootVolumeDeleteOnTermination != nil || (model.BootVolumeSourceId != "" && model.BootVolumeSourceType != "") { payload.BootVolume = &iaas.BootVolume{ PerformanceClass: model.BootVolumePerformanceClass, Size: model.BootVolumeSize, From 3235d448bf3ef93e9141c3d382d971c61eec7c73 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 16 Jun 2026 14:40:55 +0000 Subject: [PATCH 05/44] chore(deps): bump actions/stale from 10.2.0 to 10.3.0 (#1423) --- .github/workflows/stale.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/stale.yaml b/.github/workflows/stale.yaml index c3d20304d..eecf81410 100644 --- a/.github/workflows/stale.yaml +++ b/.github/workflows/stale.yaml @@ -24,7 +24,7 @@ jobs: timeout-minutes: 10 steps: - name: "Mark old PRs as stale" - uses: actions/stale@v10.2.0 + uses: actions/stale@v10.3.0 with: repo-token: ${{ secrets.GITHUB_TOKEN }} stale-pr-message: "This PR was marked as stale after ${{ env.DAYS_BEFORE_PR_STALE }} days of inactivity and will be closed after another ${{ env.DAYS_BEFORE_PR_CLOSE }} days of further inactivity. If this PR should be kept open, just add a comment, remove the stale label or push new commits to it." From 520e89c229dff52becc8c7a02402436f4f2aeb09 Mon Sep 17 00:00:00 2001 From: Marcel Jacek <72880145+marceljk@users.noreply.github.com> Date: Tue, 16 Jun 2026 17:08:55 +0200 Subject: [PATCH 06/44] fix(iaas): wrong encoding and decoding of user data attribute in server commands (#1439) relates to STACKITCLI-412 --- internal/cmd/server/create/create.go | 8 +- internal/cmd/server/create/create_test.go | 13 +- internal/cmd/server/describe/describe.go | 7 +- internal/cmd/server/list/list.go | 7 +- internal/pkg/utils/utils.go | 100 +------ internal/pkg/utils/utils_test.go | 308 ---------------------- 6 files changed, 22 insertions(+), 421 deletions(-) diff --git a/internal/cmd/server/create/create.go b/internal/cmd/server/create/create.go index a9d5f5152..d476c1883 100644 --- a/internal/cmd/server/create/create.go +++ b/internal/cmd/server/create/create.go @@ -2,6 +2,7 @@ package create import ( "context" + "encoding/base64" "fmt" "github.com/stackitcloud/stackit-cli/internal/pkg/types" @@ -275,6 +276,11 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, func buildRequest(ctx context.Context, model *inputModel, apiClient *iaas.APIClient) iaas.ApiCreateServerRequest { req := apiClient.DefaultAPI.CreateServer(ctx, model.ProjectId, model.Region) + var userData *string + if model.UserData != nil { + userData = utils.Ptr(base64.StdEncoding.EncodeToString([]byte(*model.UserData))) + } + payload := iaas.CreateServerPayload{ Name: model.Name, MachineType: model.MachineType, @@ -285,7 +291,7 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient *iaas.APICli KeypairName: model.KeypairName, SecurityGroups: model.SecurityGroups, ServiceAccountMails: model.ServiceAccountMails, - UserData: model.UserData, + UserData: userData, Volumes: model.Volumes, Labels: model.Labels, } diff --git a/internal/cmd/server/create/create_test.go b/internal/cmd/server/create/create_test.go index a554eb508..3eecfa4e5 100644 --- a/internal/cmd/server/create/create_test.go +++ b/internal/cmd/server/create/create_test.go @@ -125,7 +125,7 @@ func fixturePayload(mods ...func(payload *iaas.CreateServerPayload)) iaas.Create KeypairName: utils.Ptr("test-keypair-name"), SecurityGroups: []string{"test-security-groups"}, ServiceAccountMails: []string{"test-service-account"}, - UserData: utils.Ptr("test-user-data"), + UserData: utils.Ptr("dGVzdC11c2VyLWRhdGE="), Volumes: []string{testVolumeId}, BootVolume: &iaas.BootVolume{ PerformanceClass: utils.Ptr("test-perf-class"), @@ -397,6 +397,17 @@ func TestBuildRequest(t *testing.T) { *request = request.CreateServerPayload(payload) }), }, + { + description: "with user data", + model: fixtureInputModel(func(model *inputModel) { + model.UserData = utils.Ptr("cloud-init data") + }), + expectedRequest: fixtureRequest(func(request *iaas.ApiCreateServerRequest) { + payload := fixturePayload() + payload.UserData = utils.Ptr("Y2xvdWQtaW5pdCBkYXRh") + *request = request.CreateServerPayload(payload) + }), + }, } for _, tt := range tests { diff --git a/internal/cmd/server/describe/describe.go b/internal/cmd/server/describe/describe.go index 37f20e04b..0bfe115fb 100644 --- a/internal/cmd/server/describe/describe.go +++ b/internal/cmd/server/describe/describe.go @@ -111,12 +111,7 @@ func outputResult(p *print.Printer, outputFormat string, server *iaas.Server) er return nil case print.YAMLOutputFormat: - // This is a temporary workaround to get the desired base64 encoded yaml output for userdata - // and will be replaced by a fix in the Go-SDK - // ref: https://jira.schwarz/browse/STACKITSDK-246 - patchedServer := utils.ConvertToBase64PatchedServer(server) - - details, err := yaml.MarshalWithOptions(patchedServer, yaml.IndentSequence(true), yaml.UseJSONMarshaler()) + details, err := yaml.MarshalWithOptions(server, yaml.IndentSequence(true), yaml.UseJSONMarshaler()) if err != nil { return fmt.Errorf("marshal server: %w", err) } diff --git a/internal/cmd/server/list/list.go b/internal/cmd/server/list/list.go index 6bf36485c..a7791b99a 100644 --- a/internal/cmd/server/list/list.go +++ b/internal/cmd/server/list/list.go @@ -148,12 +148,7 @@ func outputResult(p *print.Printer, outputFormat, projectLabel string, servers [ return nil case print.YAMLOutputFormat: - // This is a temporary workaround to get the desired base64 encoded yaml output for userdata - // and will be replaced by a fix in the Go-SDK - // ref: https://jira.schwarz/browse/STACKITSDK-246 - patchedServers := utils.ConvertToBase64PatchedServers(servers) - - details, err := yaml.MarshalWithOptions(patchedServers, yaml.IndentSequence(true), yaml.UseJSONMarshaler()) + details, err := yaml.MarshalWithOptions(servers, yaml.IndentSequence(true), yaml.UseJSONMarshaler()) if err != nil { return fmt.Errorf("marshal server: %w", err) } diff --git a/internal/pkg/utils/utils.go b/internal/pkg/utils/utils.go index 69d3b32c3..bb2b36561 100644 --- a/internal/pkg/utils/utils.go +++ b/internal/pkg/utils/utils.go @@ -12,8 +12,8 @@ import ( "github.com/inhies/go-bytesize" "github.com/spf13/cobra" "github.com/spf13/viper" + sdkConfig "github.com/stackitcloud/stackit-sdk-go/core/config" - iaas "github.com/stackitcloud/stackit-sdk-go/services/iaas/v2api" "github.com/stackitcloud/stackit-cli/internal/pkg/config" ) @@ -165,104 +165,6 @@ func ConvertStringMapToInterfaceMap(m *map[string]string) *map[string]interface{ return &result } -// Base64Bytes implements yaml.Marshaler to convert []byte to base64 strings -// ref: https://carlosbecker.com/posts/go-custom-marshaling -type Base64Bytes []byte - -// MarshalYAML implements yaml.Marshaler -func (b Base64Bytes) MarshalYAML() (interface{}, error) { - if len(b) == 0 { - return "", nil - } - return base64.StdEncoding.EncodeToString(b), nil -} - -type Base64PatchedServer struct { - Id *string `json:"id,omitempty"` - Name *string `json:"name,omitempty"` - Status *string `json:"status,omitempty"` - AvailabilityZone *string `json:"availabilityZone,omitempty"` - BootVolume *iaas.BootVolume `json:"bootVolume,omitempty"` - CreatedAt *time.Time `json:"createdAt,omitempty"` - ErrorMessage *string `json:"errorMessage,omitempty"` - PowerStatus *string `json:"powerStatus,omitempty"` - AffinityGroup *string `json:"affinityGroup,omitempty"` - ImageId *string `json:"imageId,omitempty"` - KeypairName *string `json:"keypairName,omitempty"` - MachineType *string `json:"machineType,omitempty"` - Labels map[string]interface{} `json:"labels,omitempty"` - LaunchedAt *time.Time `json:"launchedAt,omitempty"` - MaintenanceWindow *iaas.ServerMaintenance `json:"maintenanceWindow,omitempty"` - Metadata map[string]interface{} `json:"metadata,omitempty"` - Networking *iaas.ServerNetworking `json:"networking,omitempty"` - Nics []iaas.ServerNetwork `json:"nics,omitempty"` - SecurityGroups []string `json:"securityGroups,omitempty"` - ServiceAccountMails []string `json:"serviceAccountMails,omitempty"` - UpdatedAt *time.Time `json:"updatedAt,omitempty"` - UserData *Base64Bytes `json:"userData,omitempty"` - Volumes []string `json:"volumes,omitempty"` - Agent *iaas.ServerAgent `json:"agent,omitempty"` -} - -// ConvertToBase64PatchedServer converts an iaas.Server to Base64PatchedServer -// This is a temporary workaround to get the desired base64 encoded yaml output for userdata -// and will be replaced by a fix in the Go-SDK -// ref: https://jira.schwarz/browse/STACKITSDK-246 -func ConvertToBase64PatchedServer(server *iaas.Server) *Base64PatchedServer { - if server == nil { - return nil - } - - var userData *Base64Bytes - if server.UserData != nil { - userData = Ptr(Base64Bytes(*server.UserData)) - } - - return &Base64PatchedServer{ - Id: server.Id, - Name: &server.Name, - Status: server.Status, - AvailabilityZone: server.AvailabilityZone, - BootVolume: server.BootVolume, - CreatedAt: server.CreatedAt, - ErrorMessage: server.ErrorMessage, - PowerStatus: server.PowerStatus, - AffinityGroup: server.AffinityGroup, - ImageId: server.ImageId, - KeypairName: server.KeypairName, - MachineType: &server.MachineType, - Labels: server.Labels, - LaunchedAt: server.LaunchedAt, - MaintenanceWindow: server.MaintenanceWindow, - Metadata: server.Metadata, - Networking: server.Networking, - Nics: server.Nics, - SecurityGroups: server.SecurityGroups, - ServiceAccountMails: server.ServiceAccountMails, - UpdatedAt: server.UpdatedAt, - UserData: userData, - Volumes: server.Volumes, - Agent: server.Agent, - } -} - -// ConvertToBase64PatchedServers converts a slice of iaas.Server to a slice of Base64PatchedServer -// This is a temporary workaround to get the desired base64 encoded yaml output for userdata -// and will be replaced by a fix in the Go-SDK -// ref: https://jira.schwarz/browse/STACKITSDK-246 -func ConvertToBase64PatchedServers(servers []iaas.Server) []Base64PatchedServer { - if servers == nil { - return nil - } - - result := make([]Base64PatchedServer, len(servers)) - for i := range servers { - result[i] = *ConvertToBase64PatchedServer(&servers[i]) - } - - return result -} - // GetSliceFromPointer returns the value of a pointer to a slice of type T. // If the pointer is nil, it returns an empty slice. func GetSliceFromPointer[T any](s *[]T) []T { diff --git a/internal/pkg/utils/utils_test.go b/internal/pkg/utils/utils_test.go index a36e336ec..df6a6c414 100644 --- a/internal/pkg/utils/utils_test.go +++ b/internal/pkg/utils/utils_test.go @@ -3,11 +3,8 @@ package utils import ( "reflect" "testing" - "time" - "github.com/google/go-cmp/cmp" sdkConfig "github.com/stackitcloud/stackit-sdk-go/core/config" - iaas "github.com/stackitcloud/stackit-sdk-go/services/iaas/v2api" "github.com/spf13/viper" @@ -268,311 +265,6 @@ func TestConvertStringMapToInterfaceMap(t *testing.T) { } } -func TestConvertToBase64PatchedServer(t *testing.T) { - now := time.Now() - userData := "test" - emptyUserData := "" - - tests := []struct { - name string - input *iaas.Server - expected *Base64PatchedServer - }{ - { - name: "nil input", - input: nil, - expected: nil, - }, - { - name: "server with user data", - input: &iaas.Server{ - Id: Ptr("server-123"), - Name: "test-server", - Status: Ptr("ACTIVE"), - AvailabilityZone: Ptr("eu01-1"), - MachineType: "t1.1", - UserData: &userData, - CreatedAt: &now, - PowerStatus: Ptr("RUNNING"), - AffinityGroup: Ptr("group-1"), - ImageId: Ptr("image-123"), - KeypairName: Ptr("keypair-1"), - }, - expected: &Base64PatchedServer{ - Id: Ptr("server-123"), - Name: Ptr("test-server"), - Status: Ptr("ACTIVE"), - AvailabilityZone: Ptr("eu01-1"), - MachineType: Ptr("t1.1"), - UserData: Ptr(Base64Bytes(userData)), - CreatedAt: &now, - PowerStatus: Ptr("RUNNING"), - AffinityGroup: Ptr("group-1"), - ImageId: Ptr("image-123"), - KeypairName: Ptr("keypair-1"), - }, - }, - { - name: "server with empty user data", - input: &iaas.Server{ - Id: Ptr("server-456"), - Name: "test-server-2", - Status: Ptr("STOPPED"), - AvailabilityZone: Ptr("eu01-2"), - MachineType: "t1.2", - UserData: &emptyUserData, - }, - expected: &Base64PatchedServer{ - Id: Ptr("server-456"), - Name: Ptr("test-server-2"), - Status: Ptr("STOPPED"), - AvailabilityZone: Ptr("eu01-2"), - MachineType: Ptr("t1.2"), - UserData: Ptr(Base64Bytes(emptyUserData)), - }, - }, - { - name: "server without user data", - input: &iaas.Server{ - Id: Ptr("server-789"), - Name: "test-server-3", - Status: Ptr("CREATING"), - AvailabilityZone: Ptr("eu01-3"), - MachineType: "t1.3", - UserData: nil, - }, - expected: &Base64PatchedServer{ - Id: Ptr("server-789"), - Name: Ptr("test-server-3"), - Status: Ptr("CREATING"), - AvailabilityZone: Ptr("eu01-3"), - MachineType: Ptr("t1.3"), - UserData: nil, - }, - }, - { - name: "server with agent", - input: &iaas.Server{ - Id: Ptr("server-456"), - Name: "test-server-2", - Status: Ptr("STOPPED"), - AvailabilityZone: Ptr("eu01-2"), - MachineType: "t1.2", - UserData: &emptyUserData, - Agent: &iaas.ServerAgent{Provisioned: Ptr(true)}, - }, - expected: &Base64PatchedServer{ - Id: Ptr("server-456"), - Name: Ptr("test-server-2"), - Status: Ptr("STOPPED"), - AvailabilityZone: Ptr("eu01-2"), - MachineType: Ptr("t1.2"), - UserData: Ptr(Base64Bytes(emptyUserData)), - Agent: Ptr(iaas.ServerAgent{Provisioned: Ptr(true)}), - }, - }, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - result := ConvertToBase64PatchedServer(tt.input) - - if diff := cmp.Diff(tt.expected, result); diff != "" { - t.Errorf("ConvertToBase64PatchedServer() mismatch (-want +got):\n%s", diff) - } - }) - } -} - -func TestConvertToBase64PatchedServers(t *testing.T) { - now := time.Now() - userData1 := "test1" - userData2 := "test2" - emptyUserData := "" - - tests := []struct { - name string - input []iaas.Server - expected []Base64PatchedServer - }{ - { - name: "nil input", - input: nil, - expected: nil, - }, - { - name: "empty slice", - input: []iaas.Server{}, - expected: []Base64PatchedServer{}, - }, - { - name: "single server with user data", - input: []iaas.Server{ - { - Id: Ptr("server-1"), - Name: "test-server-1", - Status: Ptr("ACTIVE"), - MachineType: "t1.1", - AvailabilityZone: Ptr("eu01-1"), - UserData: &userData1, - CreatedAt: &now, - }, - }, - expected: []Base64PatchedServer{ - { - Id: Ptr("server-1"), - Name: Ptr("test-server-1"), - Status: Ptr("ACTIVE"), - MachineType: Ptr("t1.1"), - AvailabilityZone: Ptr("eu01-1"), - UserData: Ptr(Base64Bytes(userData1)), - CreatedAt: &now, - }, - }, - }, - { - name: "multiple servers mixed", - input: []iaas.Server{ - { - Id: Ptr("server-1"), - Name: "test-server-1", - Status: Ptr("ACTIVE"), - MachineType: "t1.1", - AvailabilityZone: Ptr("eu01-1"), - UserData: &userData1, - CreatedAt: &now, - }, - { - Id: Ptr("server-2"), - Name: "test-server-2", - Status: Ptr("STOPPED"), - MachineType: "t1.2", - AvailabilityZone: Ptr("eu01-2"), - UserData: &userData2, - }, - { - Id: Ptr("server-3"), - Name: "test-server-3", - Status: Ptr("CREATING"), - MachineType: "t1.3", - AvailabilityZone: Ptr("eu01-3"), - UserData: &emptyUserData, - }, - { - Id: Ptr("server-4"), - Name: "test-server-4", - Status: Ptr("ERROR"), - MachineType: "t1.4", - AvailabilityZone: Ptr("eu01-4"), - UserData: nil, - }, - }, - expected: []Base64PatchedServer{ - { - Id: Ptr("server-1"), - Name: Ptr("test-server-1"), - Status: Ptr("ACTIVE"), - MachineType: Ptr("t1.1"), - AvailabilityZone: Ptr("eu01-1"), - UserData: Ptr(Base64Bytes(userData1)), - CreatedAt: &now, - }, - { - Id: Ptr("server-2"), - Name: Ptr("test-server-2"), - Status: Ptr("STOPPED"), - MachineType: Ptr("t1.2"), - AvailabilityZone: Ptr("eu01-2"), - UserData: Ptr(Base64Bytes(userData2)), - }, - { - Id: Ptr("server-3"), - Name: Ptr("test-server-3"), - Status: Ptr("CREATING"), - MachineType: Ptr("t1.3"), - AvailabilityZone: Ptr("eu01-3"), - UserData: Ptr(Base64Bytes(emptyUserData)), - }, - { - Id: Ptr("server-4"), - Name: Ptr("test-server-4"), - Status: Ptr("ERROR"), - MachineType: Ptr("t1.4"), - AvailabilityZone: Ptr("eu01-4"), - UserData: nil, - }, - }, - }, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - result := ConvertToBase64PatchedServers(tt.input) - - if result == nil && tt.expected == nil { - return - } - - if (result == nil && tt.expected != nil) || (result != nil && tt.expected == nil) { - t.Errorf("ConvertToBase64PatchedServers() = %v, want %v", result, tt.expected) - return - } - - if len(result) != len(tt.expected) { - t.Errorf("ConvertToBase64PatchedServers() length = %d, want %d", len(result), len(tt.expected)) - return - } - - for i, server := range result { - if !reflect.DeepEqual(server, tt.expected[i]) { - t.Errorf("ConvertToBase64PatchedServers() [%d] = %v, want %v", i, server, tt.expected[i]) - } - } - }) - } -} - -func TestBase64Bytes_MarshalYAML(t *testing.T) { - tests := []struct { - name string - input Base64Bytes - expected interface{} - }{ - { - name: "empty bytes", - input: Base64Bytes{}, - expected: "", - }, - { - name: "nil bytes", - input: Base64Bytes(nil), - expected: "", - }, - { - name: "simple text", - input: Base64Bytes("test"), - expected: "dGVzdA==", - }, - { - name: "special characters", - input: Base64Bytes("test@#$%"), - expected: "dGVzdEAjJCU=", - }, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - result, err := tt.input.MarshalYAML() - if err != nil { - t.Errorf("MarshalYAML() error = %v", err) - return - } - if result != tt.expected { - t.Errorf("MarshalYAML() = %v, want %v", result, tt.expected) - } - }) - } -} func TestGetSliceFromPointer(t *testing.T) { tests := []struct { name string From f388e861e2815ed9163cbcbe22088cd7e27f9cc5 Mon Sep 17 00:00:00 2001 From: Jan Obernberger <52105660+j1n-o9r@users.noreply.github.com> Date: Mon, 22 Jun 2026 12:29:17 +0200 Subject: [PATCH 07/44] chore(loadbalancer): remove local interface (#1443) --- .../observability-credentials/update/update.go | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/internal/cmd/load-balancer/observability-credentials/update/update.go b/internal/cmd/load-balancer/observability-credentials/update/update.go index 77e63bd2f..5dadff828 100644 --- a/internal/cmd/load-balancer/observability-credentials/update/update.go +++ b/internal/cmd/load-balancer/observability-credentials/update/update.go @@ -28,16 +28,6 @@ const ( credentialsRefArg = "CREDENTIALS_REF" //nolint:gosec // linter false positive ) -// enforce implementation of interfaces -var ( - _ loadBalancerClient = loadbalancer.APIClient{}.DefaultAPI -) - -type loadBalancerClient interface { - UpdateCredentials(ctx context.Context, projectId, region, credentialsRef string) loadbalancer.ApiUpdateCredentialsRequest - GetCredentials(ctx context.Context, projectId string, region string, credentialsRef string) loadbalancer.ApiGetCredentialsRequest -} - type inputModel struct { *globalflags.GlobalFlagModel CredentialsRef string @@ -138,7 +128,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu }, nil } -func buildRequest(ctx context.Context, model *inputModel, apiClient loadBalancerClient) (loadbalancer.ApiUpdateCredentialsRequest, error) { +func buildRequest(ctx context.Context, model *inputModel, apiClient loadbalancer.DefaultAPI) (loadbalancer.ApiUpdateCredentialsRequest, error) { req := apiClient.UpdateCredentials(ctx, model.ProjectId, model.Region, model.CredentialsRef) currentCredentials, err := apiClient.GetCredentials(ctx, model.ProjectId, model.Region, model.CredentialsRef).Execute() From 436a71191cc7a6e323a8a7cb6845fa1f1e270775 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 25 Jun 2026 09:25:47 +0200 Subject: [PATCH 08/44] chore(deps): bump actions/setup-go from 6 to 6.4.0 (#1446) --- .github/workflows/ci.yaml | 2 +- .github/workflows/release.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 92e3791e1..5eddad4b4 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -20,7 +20,7 @@ jobs: uses: actions/checkout@v6.0.3 - name: Install go - uses: actions/setup-go@v6 + uses: actions/setup-go@v6.4.0 with: go-version-file: "go.mod" cache: true diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index e8f2d7dee..ae308c4fc 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -29,7 +29,7 @@ jobs: fetch-depth: 0 - name: Install go - uses: actions/setup-go@v6 + uses: actions/setup-go@v6.4.0 with: go-version-file: "go.mod" cache: true From 225fe4be13c2f4eaceffd66028c659ed38d69f61 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 25 Jun 2026 07:32:07 +0000 Subject: [PATCH 09/44] chore(deps): bump actions/checkout from 6.0.3 to 7.0.0 (#1445) --- .github/workflows/ci.yaml | 4 ++-- .github/workflows/release.yaml | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 5eddad4b4..ed4736434 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -17,7 +17,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v6.0.3 + uses: actions/checkout@v7.0.0 - name: Install go uses: actions/setup-go@v6.4.0 @@ -47,7 +47,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v6.0.3 + uses: actions/checkout@v7.0.0 - name: Check GoReleaser uses: goreleaser/goreleaser-action@v7.2.2 diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index ae308c4fc..9f43854e3 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -23,7 +23,7 @@ jobs: SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_TOKEN }} steps: - name: Checkout - uses: actions/checkout@v6.0.3 + uses: actions/checkout@v7.0.0 with: # Allow goreleaser to access older tag information. fetch-depth: 0 @@ -106,7 +106,7 @@ jobs: AWS_SECRET_ACCESS_KEY: ${{ secrets.OBJECT_STORAGE_SECRET_ACCESS_KEY }} steps: - name: Checkout - uses: actions/checkout@v6.0.3 + uses: actions/checkout@v7.0.0 # use the artifacts from the "goreleaser" job - name: Download artifacts from workflow @@ -144,7 +144,7 @@ jobs: AWS_ENDPOINT_URL: https://object.storage.eu01.onstackit.cloud steps: - name: Checkout - uses: actions/checkout@v6.0.3 + uses: actions/checkout@v7.0.0 - name: Download artifacts from workflow uses: actions/download-artifact@v8 From c54ca1a18023bba5bafb442bd8f5947fa1ef5788 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=B6kce=20G=C3=B6k=20Klingel?= <161626272+GokceGK@users.noreply.github.com> Date: Mon, 29 Jun 2026 14:49:20 +0200 Subject: [PATCH 10/44] chore(dns): migrate to new SDK structure (#1438) relates to STACKITCLI-362 --- docs/stackit_dns_record-set_create.md | 2 +- docs/stackit_dns_record-set_update.md | 2 +- docs/stackit_dns_zone_create.md | 10 +-- docs/stackit_dns_zone_update.md | 10 +-- go.mod | 2 +- go.sum | 4 +- internal/cmd/dns/record-set/create/create.go | 43 +++++----- .../cmd/dns/record-set/create/create_test.go | 34 ++++---- internal/cmd/dns/record-set/delete/delete.go | 12 +-- .../cmd/dns/record-set/delete/delete_test.go | 8 +- .../cmd/dns/record-set/describe/describe.go | 22 ++--- .../dns/record-set/describe/describe_test.go | 10 +-- internal/cmd/dns/record-set/list/list.go | 27 +++---- internal/cmd/dns/record-set/list/list_test.go | 16 ++-- internal/cmd/dns/record-set/update/update.go | 26 +++--- .../cmd/dns/record-set/update/update_test.go | 20 ++--- internal/cmd/dns/zone/clone/clone.go | 16 ++-- internal/cmd/dns/zone/clone/clone_test.go | 16 ++-- internal/cmd/dns/zone/create/create.go | 71 ++++++++-------- internal/cmd/dns/zone/create/create_test.go | 80 +++++++++---------- internal/cmd/dns/zone/delete/delete.go | 10 +-- internal/cmd/dns/zone/delete/delete_test.go | 8 +- internal/cmd/dns/zone/describe/describe.go | 28 +++---- .../cmd/dns/zone/describe/describe_test.go | 8 +- internal/cmd/dns/zone/list/list.go | 21 ++--- internal/cmd/dns/zone/list/list_test.go | 16 ++-- internal/cmd/dns/zone/update/update.go | 44 +++++----- internal/cmd/dns/zone/update/update_test.go | 56 +++++++------ internal/pkg/services/dns/client/client.go | 2 +- internal/pkg/services/dns/utils/utils.go | 25 +++--- internal/pkg/services/dns/utils/utils_test.go | 53 ++++++------ 31 files changed, 346 insertions(+), 356 deletions(-) diff --git a/docs/stackit_dns_record-set_create.md b/docs/stackit_dns_record-set_create.md index 4f51534ad..8f33edd6d 100644 --- a/docs/stackit_dns_record-set_create.md +++ b/docs/stackit_dns_record-set_create.md @@ -24,7 +24,7 @@ stackit dns record-set create [flags] -h, --help Help for "stackit dns record-set create" --name string Name of the record, should be compliant with RFC1035, Section 2.3.4 --record strings Records belonging to the record set - --ttl int Time to live, if not provided defaults to the zone's default TTL + --ttl int32 Time to live, if not provided defaults to the zone's default TTL --type string Record type, one of ["A" "AAAA" "SOA" "CNAME" "NS" "MX" "TXT" "SRV" "PTR" "ALIAS" "DNAME" "CAA" "DNSKEY" "DS" "LOC" "NAPTR" "SSHFP" "TLSA" "URI" "CERT" "SVCB" "TYPE" "CSYNC" "HINFO" "HTTPS"] (default "A") --zone-id string Zone ID ``` diff --git a/docs/stackit_dns_record-set_update.md b/docs/stackit_dns_record-set_update.md index 9d369c4f6..87215ddfa 100644 --- a/docs/stackit_dns_record-set_update.md +++ b/docs/stackit_dns_record-set_update.md @@ -24,7 +24,7 @@ stackit dns record-set update RECORD_SET_ID [flags] -h, --help Help for "stackit dns record-set update" --name string Name of the record, should be compliant with RFC1035, Section 2.3.4 --record strings Records belonging to the record set. If this flag is used, records already created that aren't set when running the command will be deleted - --ttl int Time to live, if not provided defaults to the zone's default TTL + --ttl int32 Time to live, if not provided defaults to the zone's default TTL --zone-id string Zone ID ``` diff --git a/docs/stackit_dns_zone_create.md b/docs/stackit_dns_zone_create.md index 0a0efde1c..c261fa689 100644 --- a/docs/stackit_dns_zone_create.md +++ b/docs/stackit_dns_zone_create.md @@ -25,17 +25,17 @@ stackit dns zone create [flags] ``` --acl string Access control list --contact-email string Contact email for the zone - --default-ttl int Default time to live (default 1000) + --default-ttl int32 Default time to live (default 1000) --description string Description of the zone --dns-name string Fully qualified domain name of the DNS zone - --expire-time int Expire time + --expire-time int32 Expire time -h, --help Help for "stackit dns zone create" --is-reverse-zone Is reverse zone --name string User given name of the zone - --negative-cache int Negative cache + --negative-cache int32 Negative cache --primary strings Primary name server for secondary zone - --refresh-time int Refresh time - --retry-time int Retry time + --refresh-time int32 Refresh time + --retry-time int32 Retry time --type string Zone type, one of: ["primary" "secondary"] ``` diff --git a/docs/stackit_dns_zone_update.md b/docs/stackit_dns_zone_update.md index 240885c1b..35e375998 100644 --- a/docs/stackit_dns_zone_update.md +++ b/docs/stackit_dns_zone_update.md @@ -22,15 +22,15 @@ stackit dns zone update ZONE_ID [flags] ``` --acl string Access control list --contact-email string Contact email for the zone - --default-ttl int Default time to live (default 1000) + --default-ttl int32 Default time to live (default 1000) --description string Description of the zone - --expire-time int Expire time + --expire-time int32 Expire time -h, --help Help for "stackit dns zone update" --name string User given name of the zone - --negative-cache int Negative cache + --negative-cache int32 Negative cache --primary strings Primary name server for secondary zone - --refresh-time int Refresh time - --retry-time int Retry time + --refresh-time int32 Refresh time + --retry-time int32 Retry time ``` ### Options inherited from parent commands diff --git a/go.mod b/go.mod index 1ba8fc21a..0c13822ad 100644 --- a/go.mod +++ b/go.mod @@ -19,7 +19,7 @@ require ( github.com/stackitcloud/stackit-sdk-go/services/alb v0.14.2 github.com/stackitcloud/stackit-sdk-go/services/authorization v0.12.0 github.com/stackitcloud/stackit-sdk-go/services/cdn v1.16.0 - github.com/stackitcloud/stackit-sdk-go/services/dns v0.17.6 + github.com/stackitcloud/stackit-sdk-go/services/dns v0.21.0 github.com/stackitcloud/stackit-sdk-go/services/edge v0.4.3 github.com/stackitcloud/stackit-sdk-go/services/git v0.14.0 github.com/stackitcloud/stackit-sdk-go/services/iaas v1.12.0 diff --git a/go.sum b/go.sum index e08536c68..4e08a22b7 100644 --- a/go.sum +++ b/go.sum @@ -602,8 +602,8 @@ github.com/stackitcloud/stackit-sdk-go/services/authorization v0.12.0 h1:HxPgBu0 github.com/stackitcloud/stackit-sdk-go/services/authorization v0.12.0/go.mod h1:uYI9pHAA2g84jJN25ejFUxa0/JtfpPZqMDkctQ1BzJk= github.com/stackitcloud/stackit-sdk-go/services/cdn v1.16.0 h1:Wqxx0PDTL2F5gqI5jjznuJY0TdqECltjA0aa/rHY63U= github.com/stackitcloud/stackit-sdk-go/services/cdn v1.16.0/go.mod h1:MHB1N3EQ9GuAduAQoNS+gb1MjrWJieszbpOso9TQv5s= -github.com/stackitcloud/stackit-sdk-go/services/dns v0.17.6 h1:GBRb49x5Nax/oQQaaf2F3kKwv8DQQOL0TQOC0C/v/Ew= -github.com/stackitcloud/stackit-sdk-go/services/dns v0.17.6/go.mod h1:IX9iL3MigDZUmzwswTJMfYvyi118KAHrFMfjJUy5NYk= +github.com/stackitcloud/stackit-sdk-go/services/dns v0.21.0 h1:ZVkptfVCAqpaPWkE+WIopM9XdzqgbVcwmX5L1jZqqx8= +github.com/stackitcloud/stackit-sdk-go/services/dns v0.21.0/go.mod h1:FiYSv3D9rzgEVzi8Mpq5oYZBosrasa5uUYqVdEIbM1U= github.com/stackitcloud/stackit-sdk-go/services/edge v0.4.3 h1:TxChb2qbO82JiQEBYClSSD5HZxqKeKJ6dIvkEUCJmbs= github.com/stackitcloud/stackit-sdk-go/services/edge v0.4.3/go.mod h1:KVWvQHb7CQLD9DzA4Np3WmakiCCsrHaCXvFEnOQ7nPk= github.com/stackitcloud/stackit-sdk-go/services/git v0.14.0 h1:VZBneGprCmHqckcSMPs3puBlK8rBpLMtYKmBktwdoVE= diff --git a/internal/cmd/dns/record-set/create/create.go b/internal/cmd/dns/record-set/create/create.go index 1cf8c448b..d3a86eb4e 100644 --- a/internal/cmd/dns/record-set/create/create.go +++ b/internal/cmd/dns/record-set/create/create.go @@ -4,12 +4,15 @@ import ( "context" "fmt" - "github.com/stackitcloud/stackit-sdk-go/services/dns/wait" + sdkUtils "github.com/stackitcloud/stackit-sdk-go/core/utils" + "github.com/stackitcloud/stackit-sdk-go/services/dns/v1api/wait" + + "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/stackitcloud/stackit-cli/internal/pkg/types" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/dns" + dns "github.com/stackitcloud/stackit-sdk-go/services/dns/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/args" "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -20,7 +23,6 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/services/dns/client" dnsUtils "github.com/stackitcloud/stackit-cli/internal/pkg/services/dns/utils" "github.com/stackitcloud/stackit-cli/internal/pkg/spinner" - "github.com/stackitcloud/stackit-cli/internal/pkg/utils" ) const ( @@ -41,8 +43,8 @@ type inputModel struct { Comment *string Name *string Records []string - TTL *int64 - Type dns.CreateRecordSetPayloadTypes + TTL *int32 + Type dns.CreateRecordSetPayloadType } func NewCmd(params *types.CmdParams) *cobra.Command { @@ -69,7 +71,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return err } - zoneLabel, err := dnsUtils.GetZoneName(ctx, apiClient, model.ProjectId, model.ZoneId) + zoneLabel, err := dnsUtils.GetZoneName(ctx, apiClient.DefaultAPI, model.ProjectId, model.ZoneId) if err != nil { params.Printer.Debug(print.ErrorLevel, "get zone name: %v", err) zoneLabel = model.ZoneId @@ -87,12 +89,12 @@ func NewCmd(params *types.CmdParams) *cobra.Command { if err != nil { return fmt.Errorf("create DNS record set: %w", err) } - recordSetId := *resp.Rrset.Id + recordSetId := resp.Rrset.Id // Wait for async operation, if async mode not enabled if !model.Async { err := spinner.Run(params.Printer, "Creating record set", func() error { - _, err = wait.CreateRecordSetWaitHandler(ctx, apiClient, model.ProjectId, model.ZoneId, recordSetId).WaitWithContext(ctx) + _, err = wait.CreateRecordSetWaitHandler(ctx, apiClient.DefaultAPI, model.ProjectId, model.ZoneId, recordSetId).WaitWithContext(ctx) return err }) if err != nil { @@ -108,17 +110,12 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } func configureFlags(cmd *cobra.Command) { - var typeFlagOptions []string - for _, val := range dns.AllowedCreateRecordSetPayloadTypesEnumValues { - typeFlagOptions = append(typeFlagOptions, string(val)) - } - cmd.Flags().Var(flags.UUIDFlag(), zoneIdFlag, "Zone ID") cmd.Flags().String(commentFlag, "", "User comment") cmd.Flags().String(nameFlag, "", "Name of the record, should be compliant with RFC1035, Section 2.3.4") - cmd.Flags().Int64(ttlFlag, 0, "Time to live, if not provided defaults to the zone's default TTL") + cmd.Flags().Int32(ttlFlag, 0, "Time to live, if not provided defaults to the zone's default TTL") cmd.Flags().StringSlice(recordFlag, []string{}, "Records belonging to the record set") - cmd.Flags().Var(flags.EnumFlag(false, string(defaultType), typeFlagOptions...), typeFlag, fmt.Sprintf("Record type, one of %q", typeFlagOptions)) + cmd.Flags().Var(flags.EnumFlag(false, string(defaultType), sdkUtils.EnumSliceToStringSlice(dns.AllowedCreateRecordSetPayloadTypeEnumValues)...), typeFlag, fmt.Sprintf("Record type, one of %q", utils.FormatPossibleValues(sdkUtils.EnumSliceToStringSlice(dns.AllowedCreateRecordSetPayloadTypeEnumValues)...))) err := flags.MarkFlagsRequired(cmd, zoneIdFlag, nameFlag, recordFlag) cobra.CheckErr(err) @@ -138,8 +135,8 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, Comment: flags.FlagToStringPointer(p, cmd, commentFlag), Name: flags.FlagToStringPointer(p, cmd, nameFlag), Records: flags.FlagToStringSliceValue(p, cmd, recordFlag), - TTL: flags.FlagToInt64Pointer(p, cmd, ttlFlag), - Type: dns.CreateRecordSetPayloadTypes(recordType), + TTL: flags.FlagToInt32Pointer(p, cmd, ttlFlag), + Type: dns.CreateRecordSetPayloadType(recordType), } if model.Type == txtType { @@ -163,16 +160,16 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, func buildRequest(ctx context.Context, model *inputModel, apiClient *dns.APIClient) dns.ApiCreateRecordSetRequest { records := make([]dns.RecordPayload, 0) for _, r := range model.Records { - records = append(records, dns.RecordPayload{Content: utils.Ptr(r)}) + records = append(records, dns.RecordPayload{Content: r}) } - req := apiClient.CreateRecordSet(ctx, model.ProjectId, model.ZoneId) + req := apiClient.DefaultAPI.CreateRecordSet(ctx, model.ProjectId, model.ZoneId) req = req.CreateRecordSetPayload(dns.CreateRecordSetPayload{ Comment: model.Comment, - Name: model.Name, - Records: &records, + Name: *model.Name, + Records: records, Ttl: model.TTL, - Type: &model.Type, + Type: model.Type, }) return req } @@ -186,7 +183,7 @@ func outputResult(p *print.Printer, model *inputModel, zoneLabel string, resp *d if model.Async { operationState = "Triggered creation of" } - p.Outputf("%s record set for zone %s. Record set ID: %s\n", operationState, zoneLabel, utils.PtrString(resp.Rrset.Id)) + p.Outputf("%s record set for zone %s. Record set ID: %s\n", operationState, zoneLabel, resp.Rrset.Id) return nil }) } diff --git a/internal/cmd/dns/record-set/create/create_test.go b/internal/cmd/dns/record-set/create/create_test.go index 483c47d76..03c8a637c 100644 --- a/internal/cmd/dns/record-set/create/create_test.go +++ b/internal/cmd/dns/record-set/create/create_test.go @@ -9,7 +9,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/dns" + dns "github.com/stackitcloud/stackit-sdk-go/services/dns/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" @@ -20,7 +20,7 @@ import ( type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &dns.APIClient{} +var testClient = &dns.APIClient{DefaultAPI: &dns.DefaultAPIService{}} var testProjectId = uuid.NewString() var testZoneId = uuid.NewString() @@ -56,7 +56,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { Name: utils.Ptr("example.com"), Comment: utils.Ptr("comment"), Records: []string{"1.1.1.1"}, - TTL: utils.Ptr(int64(3600)), + TTL: utils.Ptr(int32(3600)), Type: "SOA", } for _, mod := range mods { @@ -66,15 +66,15 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *dns.ApiCreateRecordSetRequest)) dns.ApiCreateRecordSetRequest { - request := testClient.CreateRecordSet(testCtx, testProjectId, testZoneId) + request := testClient.DefaultAPI.CreateRecordSet(testCtx, testProjectId, testZoneId) request = request.CreateRecordSetPayload(dns.CreateRecordSetPayload{ - Name: utils.Ptr("example.com"), + Name: "example.com", Comment: utils.Ptr("comment"), - Records: &[]dns.RecordPayload{ - {Content: utils.Ptr("1.1.1.1")}, + Records: []dns.RecordPayload{ + {Content: "1.1.1.1"}, }, - Ttl: utils.Ptr(int64(3600)), - Type: dns.CREATERECORDSETPAYLOADTYPE_SOA.Ptr(), + Ttl: utils.Ptr(int32(3600)), + Type: dns.CREATERECORDSETPAYLOADTYPE_SOA, }) for _, mod := range mods { mod(&request) @@ -142,7 +142,7 @@ func TestParseInput(t *testing.T) { Name: utils.Ptr(""), Comment: utils.Ptr(""), Records: []string{"1.1.1.1"}, - TTL: utils.Ptr(int64(0)), + TTL: utils.Ptr(int32(0)), Type: defaultType, }, }, @@ -297,13 +297,13 @@ func TestBuildRequest(t *testing.T) { Records: []string{"1.1.1.1"}, Type: defaultType, }, - expectedRequest: testClient.CreateRecordSet(testCtx, testProjectId, testZoneId). + expectedRequest: testClient.DefaultAPI.CreateRecordSet(testCtx, testProjectId, testZoneId). CreateRecordSetPayload(dns.CreateRecordSetPayload{ - Name: utils.Ptr("example.com"), - Records: &[]dns.RecordPayload{ - {Content: utils.Ptr("1.1.1.1")}, + Name: "example.com", + Records: []dns.RecordPayload{ + {Content: "1.1.1.1"}, }, - Type: utils.Ptr(defaultType), + Type: defaultType, }), }, } @@ -313,7 +313,7 @@ func TestBuildRequest(t *testing.T) { request := buildRequest(testCtx, tt.model, testClient) diff := cmp.Diff(request, tt.expectedRequest, - cmp.AllowUnexported(tt.expectedRequest), + cmp.AllowUnexported(tt.expectedRequest, dns.DefaultAPIService{}), cmpopts.EquateComparable(testCtx), ) if diff != "" { @@ -343,7 +343,7 @@ func TestOutputResult(t *testing.T) { name: "only record set as argument", args: args{ model: fixtureInputModel(), - resp: &dns.RecordSetResponse{Rrset: &dns.RecordSet{}}, + resp: &dns.RecordSetResponse{Rrset: dns.RecordSet{}}, }, wantErr: false, }, diff --git a/internal/cmd/dns/record-set/delete/delete.go b/internal/cmd/dns/record-set/delete/delete.go index ff1478ccc..85448ecbf 100644 --- a/internal/cmd/dns/record-set/delete/delete.go +++ b/internal/cmd/dns/record-set/delete/delete.go @@ -18,8 +18,8 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/dns" - "github.com/stackitcloud/stackit-sdk-go/services/dns/wait" + dns "github.com/stackitcloud/stackit-sdk-go/services/dns/v1api" + "github.com/stackitcloud/stackit-sdk-go/services/dns/v1api/wait" ) const ( @@ -58,13 +58,13 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return err } - zoneLabel, err := dnsUtils.GetZoneName(ctx, apiClient, model.ProjectId, model.ZoneId) + zoneLabel, err := dnsUtils.GetZoneName(ctx, apiClient.DefaultAPI, model.ProjectId, model.ZoneId) if err != nil { params.Printer.Debug(print.ErrorLevel, "get zone name: %v", err) zoneLabel = model.ZoneId } - recordSetLabel, err := dnsUtils.GetRecordSetName(ctx, apiClient, model.ProjectId, model.ZoneId, model.RecordSetId) + recordSetLabel, err := dnsUtils.GetRecordSetName(ctx, apiClient.DefaultAPI, model.ProjectId, model.ZoneId, model.RecordSetId) if err != nil { params.Printer.Debug(print.ErrorLevel, "get record set name: %v", err) recordSetLabel = model.RecordSetId @@ -89,7 +89,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { // Wait for async operation, if async mode not enabled if !model.Async { err := spinner.Run(params.Printer, "Deleting record set", func() error { - _, err = wait.DeleteRecordSetWaitHandler(ctx, apiClient, model.ProjectId, model.ZoneId, model.RecordSetId).WaitWithContext(ctx) + _, err = wait.DeleteRecordSetWaitHandler(ctx, apiClient.DefaultAPI, model.ProjectId, model.ZoneId, model.RecordSetId).WaitWithContext(ctx) return err }) if err != nil { @@ -135,6 +135,6 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *dns.APIClient) dns.ApiDeleteRecordSetRequest { - req := apiClient.DeleteRecordSet(ctx, model.ProjectId, model.ZoneId, model.RecordSetId) + req := apiClient.DefaultAPI.DeleteRecordSet(ctx, model.ProjectId, model.ZoneId, model.RecordSetId) return req } diff --git a/internal/cmd/dns/record-set/delete/delete_test.go b/internal/cmd/dns/record-set/delete/delete_test.go index 46a5c6d28..13b08f852 100644 --- a/internal/cmd/dns/record-set/delete/delete_test.go +++ b/internal/cmd/dns/record-set/delete/delete_test.go @@ -10,13 +10,13 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/dns" + dns "github.com/stackitcloud/stackit-sdk-go/services/dns/v1api" ) type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &dns.APIClient{} +var testClient = &dns.APIClient{DefaultAPI: &dns.DefaultAPIService{}} var testProjectId = uuid.NewString() var testZoneId = uuid.NewString() var testRecordSetId = uuid.NewString() @@ -58,7 +58,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *dns.ApiDeleteRecordSetRequest)) dns.ApiDeleteRecordSetRequest { - request := testClient.DeleteRecordSet(testCtx, testProjectId, testZoneId, testRecordSetId) + request := testClient.DefaultAPI.DeleteRecordSet(testCtx, testProjectId, testZoneId, testRecordSetId) for _, mod := range mods { mod(&request) } @@ -187,7 +187,7 @@ func TestBuildRequest(t *testing.T) { request := buildRequest(testCtx, tt.model, testClient) diff := cmp.Diff(request, tt.expectedRequest, - cmp.AllowUnexported(tt.expectedRequest), + cmp.AllowUnexported(tt.expectedRequest, dns.DefaultAPIService{}), cmpopts.EquateComparable(testCtx), ) if diff != "" { diff --git a/internal/cmd/dns/record-set/describe/describe.go b/internal/cmd/dns/record-set/describe/describe.go index dabe1d5c1..6c7bde12e 100644 --- a/internal/cmd/dns/record-set/describe/describe.go +++ b/internal/cmd/dns/record-set/describe/describe.go @@ -18,7 +18,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/dns" + dns "github.com/stackitcloud/stackit-sdk-go/services/dns/v1api" ) const ( @@ -68,7 +68,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } recordSet := resp.Rrset - return outputResult(params.Printer, model.OutputFormat, recordSet) + return outputResult(params.Printer, model.OutputFormat, &recordSet) }, } configureFlags(cmd) @@ -101,7 +101,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *dns.APIClient) dns.ApiGetRecordSetRequest { - req := apiClient.GetRecordSet(ctx, model.ProjectId, model.ZoneId, model.RecordSetId) + req := apiClient.DefaultAPI.GetRecordSet(ctx, model.ProjectId, model.ZoneId, model.RecordSetId) return req } @@ -111,22 +111,22 @@ func outputResult(p *print.Printer, outputFormat string, recordSet *dns.RecordSe } return p.OutputResult(outputFormat, recordSet, func() error { - recordsData := make([]string, 0, len(*recordSet.Records)) - for _, r := range *recordSet.Records { - recordsData = append(recordsData, *r.Content) + recordsData := make([]string, 0, len(recordSet.Records)) + for _, r := range recordSet.Records { + recordsData = append(recordsData, r.Content) } recordsDataJoin := strings.Join(recordsData, ", ") table := tables.NewTable() - table.AddRow("ID", utils.PtrString(recordSet.Id)) + table.AddRow("ID", recordSet.Id) table.AddSeparator() - table.AddRow("NAME", utils.PtrString(recordSet.Name)) + table.AddRow("NAME", recordSet.Name) table.AddSeparator() - table.AddRow("STATE", utils.PtrString(recordSet.State)) + table.AddRow("STATE", recordSet.State) table.AddSeparator() - table.AddRow("TTL", utils.PtrString(recordSet.Ttl)) + table.AddRow("TTL", recordSet.Ttl) table.AddSeparator() - table.AddRow("TYPE", utils.PtrString(recordSet.Type)) + table.AddRow("TYPE", recordSet.Type) table.AddSeparator() table.AddRow("RECORDS DATA", recordsDataJoin) err := table.Display(p) diff --git a/internal/cmd/dns/record-set/describe/describe_test.go b/internal/cmd/dns/record-set/describe/describe_test.go index 72b8d07fd..e0d3ce184 100644 --- a/internal/cmd/dns/record-set/describe/describe_test.go +++ b/internal/cmd/dns/record-set/describe/describe_test.go @@ -7,7 +7,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/dns" + dns "github.com/stackitcloud/stackit-sdk-go/services/dns/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" @@ -17,7 +17,7 @@ import ( type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &dns.APIClient{} +var testClient = &dns.APIClient{DefaultAPI: &dns.DefaultAPIService{}} var testProjectId = uuid.NewString() var testZoneId = uuid.NewString() var testRecordSetId = uuid.NewString() @@ -59,7 +59,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *dns.ApiGetRecordSetRequest)) dns.ApiGetRecordSetRequest { - request := testClient.GetRecordSet(testCtx, testProjectId, testZoneId, testRecordSetId) + request := testClient.DefaultAPI.GetRecordSet(testCtx, testProjectId, testZoneId, testRecordSetId) for _, mod := range mods { mod(&request) } @@ -188,7 +188,7 @@ func TestBuildRequest(t *testing.T) { request := buildRequest(testCtx, tt.model, testClient) diff := cmp.Diff(request, tt.expectedRequest, - cmp.AllowUnexported(tt.expectedRequest), + cmp.AllowUnexported(tt.expectedRequest, dns.DefaultAPIService{}), cmpopts.EquateComparable(testCtx), ) if diff != "" { @@ -216,7 +216,7 @@ func TestOutputResult(t *testing.T) { { name: "only record set as argument", args: args{ - recordSet: &dns.RecordSet{Records: &[]dns.Record{}}, + recordSet: &dns.RecordSet{Records: []dns.Record{}}, }, wantErr: false, }, diff --git a/internal/cmd/dns/record-set/list/list.go b/internal/cmd/dns/record-set/list/list.go index dfd02612c..64f984a8a 100644 --- a/internal/cmd/dns/record-set/list/list.go +++ b/internal/cmd/dns/record-set/list/list.go @@ -9,7 +9,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/types" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/dns" + dns "github.com/stackitcloud/stackit-sdk-go/services/dns/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/args" "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -20,7 +20,6 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/services/dns/client" dnsUtils "github.com/stackitcloud/stackit-cli/internal/pkg/services/dns/utils" "github.com/stackitcloud/stackit-cli/internal/pkg/tables" - "github.com/stackitcloud/stackit-cli/internal/pkg/utils" ) const ( @@ -88,12 +87,12 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } // Fetch record sets - recordSets, err := fetchRecordSets(ctx, model, apiClient) + recordSets, err := fetchRecordSets(ctx, model, apiClient.DefaultAPI) if err != nil { return err } - zoneLabel, err := dnsUtils.GetZoneName(ctx, apiClient, model.ProjectId, model.ZoneId) + zoneLabel, err := dnsUtils.GetZoneName(ctx, apiClient.DefaultAPI, model.ProjectId, model.ZoneId) if err != nil { params.Printer.Debug(print.ErrorLevel, "get zone name: %v", err) zoneLabel = model.ZoneId @@ -184,7 +183,7 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient dnsClient, p req = req.NameLike(*model.NameLike) } if model.OrderByName != nil { - req = req.OrderByName(strings.ToUpper(*model.OrderByName)) + req = req.OrderByName(dns.ListRecordSetsOrderByNameParameter(strings.ToUpper(*model.OrderByName))) } // check integer overflows @@ -220,7 +219,7 @@ func fetchRecordSets(ctx context.Context, model *inputModel, apiClient dnsClient if err != nil { return nil, fmt.Errorf("get DNS record sets: %w", err) } - respRecordSets := *resp.RrSets + respRecordSets := resp.RrSets if len(respRecordSets) == 0 { break } @@ -250,17 +249,17 @@ func outputResult(p *print.Printer, outputFormat, zoneLabel string, recordSets [ table.SetHeader("ID", "NAME", "STATUS", "TTL", "TYPE", "RECORD DATA") for i := range recordSets { rs := recordSets[i] - recordData := make([]string, 0, len(*rs.Records)) - for _, r := range *rs.Records { - recordData = append(recordData, *r.Content) + recordData := make([]string, 0, len(rs.Records)) + for _, r := range rs.Records { + recordData = append(recordData, r.Content) } recordDataJoin := strings.Join(recordData, ", ") table.AddRow( - utils.PtrString(rs.Id), - utils.PtrString(rs.Name), - utils.PtrString(rs.State), - utils.PtrString(rs.Ttl), - utils.PtrString(rs.Type), + rs.Id, + rs.Name, + rs.State, + rs.Ttl, + rs.Type, recordDataJoin, ) } diff --git a/internal/cmd/dns/record-set/list/list_test.go b/internal/cmd/dns/record-set/list/list_test.go index 99b9f4233..08bad82db 100644 --- a/internal/cmd/dns/record-set/list/list_test.go +++ b/internal/cmd/dns/record-set/list/list_test.go @@ -12,7 +12,7 @@ import ( "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" sdkConfig "github.com/stackitcloud/stackit-sdk-go/core/config" - "github.com/stackitcloud/stackit-sdk-go/services/dns" + dns "github.com/stackitcloud/stackit-sdk-go/services/dns/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" @@ -23,7 +23,7 @@ import ( type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &dns.APIClient{} +var testClient = &dns.APIClient{DefaultAPI: &dns.DefaultAPIService{}} var testProjectId = uuid.NewString() var testZoneId = uuid.NewString() @@ -58,7 +58,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *dns.ApiListRecordSetsRequest)) dns.ApiListRecordSetsRequest { - request := testClient.ListRecordSets(testCtx, testProjectId, testZoneId) + request := testClient.DefaultAPI.ListRecordSets(testCtx, testProjectId, testZoneId) request = request.NameLike("some-pattern") request = request.OrderByName("ASC") request = request.PageSize(pageSizeDefault) @@ -273,16 +273,16 @@ func TestBuildRequest(t *testing.T) { PageSize: 10, }, page: 1, - expectedRequest: testClient.ListRecordSets(testCtx, testProjectId, testZoneId).Page(1).PageSize(10).StateNeq(deleteSucceededState), + expectedRequest: testClient.DefaultAPI.ListRecordSets(testCtx, testProjectId, testZoneId).Page(1).PageSize(10).StateNeq(deleteSucceededState), }, } for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { - request := buildRequest(testCtx, tt.model, testClient, tt.page) + request := buildRequest(testCtx, tt.model, testClient.DefaultAPI, tt.page) diff := cmp.Diff(request, tt.expectedRequest, - cmp.AllowUnexported(tt.expectedRequest), + cmp.AllowUnexported(tt.expectedRequest, dns.DefaultAPIService{}), cmpopts.EquateComparable(testCtx), ) if diff != "" { @@ -420,7 +420,7 @@ func TestFetchRecordSets(t *testing.T) { recordSets := make([]dns.RecordSet, numItemsToReturn) mockedResp := dns.ListRecordSetsResponse{ - RrSets: &recordSets, + RrSets: recordSets, } mockedRespBytes, err := json.Marshal(mockedResp) @@ -443,7 +443,7 @@ func TestFetchRecordSets(t *testing.T) { t.Fatalf("Failed to initialize client: %v", err) } - recordSets, err := fetchRecordSets(testCtx, tt.model, client) + recordSets, err := fetchRecordSets(testCtx, tt.model, client.DefaultAPI) if err != nil { if !tt.apiCallFails { t.Fatalf("did not fail on invalid input") diff --git a/internal/cmd/dns/record-set/update/update.go b/internal/cmd/dns/record-set/update/update.go index 6246ff58f..749d0456a 100644 --- a/internal/cmd/dns/record-set/update/update.go +++ b/internal/cmd/dns/record-set/update/update.go @@ -18,8 +18,8 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/dns" - "github.com/stackitcloud/stackit-sdk-go/services/dns/wait" + dns "github.com/stackitcloud/stackit-sdk-go/services/dns/v1api" + "github.com/stackitcloud/stackit-sdk-go/services/dns/v1api/wait" ) const ( @@ -40,7 +40,7 @@ type inputModel struct { Comment *string Name *string Records *[]string - TTL *int64 + TTL *int32 Type *string } @@ -68,19 +68,19 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return err } - zoneLabel, err := dnsUtils.GetZoneName(ctx, apiClient, model.ProjectId, model.ZoneId) + zoneLabel, err := dnsUtils.GetZoneName(ctx, apiClient.DefaultAPI, model.ProjectId, model.ZoneId) if err != nil { params.Printer.Debug(print.ErrorLevel, "get zone name: %v", err) zoneLabel = model.ZoneId } - recordSetLabel, err := dnsUtils.GetRecordSetName(ctx, apiClient, model.ProjectId, model.ZoneId, model.RecordSetId) + recordSetLabel, err := dnsUtils.GetRecordSetName(ctx, apiClient.DefaultAPI, model.ProjectId, model.ZoneId, model.RecordSetId) if err != nil { params.Printer.Debug(print.ErrorLevel, "get record set name: %v", err) recordSetLabel = model.RecordSetId } - typeLabel, err := dnsUtils.GetRecordSetType(ctx, apiClient, model.ProjectId, model.ZoneId, model.RecordSetId) + typeLabel, err := dnsUtils.GetRecordSetType(ctx, apiClient.DefaultAPI, model.ProjectId, model.ZoneId, model.RecordSetId) if err != nil { params.Printer.Debug(print.ErrorLevel, "get record set type: %v", err) } @@ -109,7 +109,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { // Wait for async operation, if async mode not enabled if !model.Async { err := spinner.Run(params.Printer, "Updating record set", func() error { - _, err = wait.PartialUpdateRecordSetWaitHandler(ctx, apiClient, model.ProjectId, model.ZoneId, model.RecordSetId).WaitWithContext(ctx) + _, err = wait.PartialUpdateRecordSetWaitHandler(ctx, apiClient.DefaultAPI, model.ProjectId, model.ZoneId, model.RecordSetId).WaitWithContext(ctx) return err }) if err != nil { @@ -133,7 +133,7 @@ func configureFlags(cmd *cobra.Command) { cmd.Flags().Var(flags.UUIDFlag(), zoneIdFlag, "Zone ID") cmd.Flags().String(commentFlag, "", "User comment") cmd.Flags().String(nameFlag, "", "Name of the record, should be compliant with RFC1035, Section 2.3.4") - cmd.Flags().Int64(ttlFlag, 0, "Time to live, if not provided defaults to the zone's default TTL") + cmd.Flags().Int32(ttlFlag, 0, "Time to live, if not provided defaults to the zone's default TTL") cmd.Flags().StringSlice(recordFlag, []string{}, "Records belonging to the record set. If this flag is used, records already created that aren't set when running the command will be deleted") err := flags.MarkFlagsRequired(cmd, zoneIdFlag) @@ -152,7 +152,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu comment := flags.FlagToStringPointer(p, cmd, commentFlag) name := flags.FlagToStringPointer(p, cmd, nameFlag) records := flags.FlagToStringSlicePointer(p, cmd, recordFlag) - ttl := flags.FlagToInt64Pointer(p, cmd, ttlFlag) + ttl := flags.FlagToInt32Pointer(p, cmd, ttlFlag) if comment == nil && name == nil && records == nil && ttl == nil { return nil, &errors.EmptyUpdateError{} @@ -194,15 +194,15 @@ func parseTxtRecord(records *[]string) error { } func buildRequest(ctx context.Context, model *inputModel, apiClient *dns.APIClient) dns.ApiPartialUpdateRecordSetRequest { - var records *[]dns.RecordPayload = nil + var records []dns.RecordPayload = nil if model.Records != nil { - records = utils.Ptr(make([]dns.RecordPayload, 0)) + records = make([]dns.RecordPayload, 0) for _, r := range *model.Records { - records = utils.Ptr(append(*records, dns.RecordPayload{Content: utils.Ptr(r)})) + records = append(records, dns.RecordPayload{Content: r}) } } - req := apiClient.PartialUpdateRecordSet(ctx, model.ProjectId, model.ZoneId, model.RecordSetId) + req := apiClient.DefaultAPI.PartialUpdateRecordSet(ctx, model.ProjectId, model.ZoneId, model.RecordSetId) req = req.PartialUpdateRecordSetPayload(dns.PartialUpdateRecordSetPayload{ Comment: model.Comment, Name: model.Name, diff --git a/internal/cmd/dns/record-set/update/update_test.go b/internal/cmd/dns/record-set/update/update_test.go index 80bb01c97..03586da3c 100644 --- a/internal/cmd/dns/record-set/update/update_test.go +++ b/internal/cmd/dns/record-set/update/update_test.go @@ -11,13 +11,13 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/dns" + dns "github.com/stackitcloud/stackit-sdk-go/services/dns/v1api" ) type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &dns.APIClient{} +var testClient = &dns.APIClient{DefaultAPI: &dns.DefaultAPIService{}} var testProjectId = uuid.NewString() var testZoneId = uuid.NewString() var testRecordSetId = uuid.NewString() @@ -65,7 +65,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { Name: utils.Ptr("example.com"), Comment: utils.Ptr("comment"), Records: &[]string{"1.1.1.1"}, - TTL: utils.Ptr(int64(3600)), + TTL: utils.Ptr(int32(3600)), } for _, mod := range mods { mod(model) @@ -74,14 +74,14 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *dns.ApiPartialUpdateRecordSetRequest)) dns.ApiPartialUpdateRecordSetRequest { - request := testClient.PartialUpdateRecordSet(testCtx, testProjectId, testZoneId, testRecordSetId) + request := testClient.DefaultAPI.PartialUpdateRecordSet(testCtx, testProjectId, testZoneId, testRecordSetId) request = request.PartialUpdateRecordSetPayload(dns.PartialUpdateRecordSetPayload{ Name: utils.Ptr("example.com"), Comment: utils.Ptr("comment"), - Records: &[]dns.RecordPayload{ - {Content: utils.Ptr("1.1.1.1")}, + Records: []dns.RecordPayload{ + {Content: "1.1.1.1"}, }, - Ttl: utils.Ptr(int64(3600)), + Ttl: utils.Ptr(int32(3600)), }) req := &request for _, mod := range mods { @@ -163,7 +163,7 @@ func TestParseInput(t *testing.T) { Name: utils.Ptr(""), Comment: utils.Ptr(""), Records: &[]string{"1.1.1.1"}, - TTL: utils.Ptr(int64(0)), + TTL: utils.Ptr(int32(0)), }, }, { @@ -398,7 +398,7 @@ func TestBuildRequest(t *testing.T) { ZoneId: testZoneId, RecordSetId: testRecordSetId, }, - expectedRequest: testClient.PartialUpdateRecordSet(testCtx, testProjectId, testZoneId, testRecordSetId). + expectedRequest: testClient.DefaultAPI.PartialUpdateRecordSet(testCtx, testProjectId, testZoneId, testRecordSetId). PartialUpdateRecordSetPayload(dns.PartialUpdateRecordSetPayload{}), }, } @@ -408,7 +408,7 @@ func TestBuildRequest(t *testing.T) { request := buildRequest(testCtx, tt.model, testClient) diff := cmp.Diff(request, tt.expectedRequest, - cmp.AllowUnexported(tt.expectedRequest), + cmp.AllowUnexported(tt.expectedRequest, dns.DefaultAPIService{}), cmpopts.EquateComparable(testCtx), ) if diff != "" { diff --git a/internal/cmd/dns/zone/clone/clone.go b/internal/cmd/dns/zone/clone/clone.go index de171a2be..e56e9de89 100644 --- a/internal/cmd/dns/zone/clone/clone.go +++ b/internal/cmd/dns/zone/clone/clone.go @@ -18,8 +18,8 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/dns" - "github.com/stackitcloud/stackit-sdk-go/services/dns/wait" + dns "github.com/stackitcloud/stackit-sdk-go/services/dns/v1api" + "github.com/stackitcloud/stackit-sdk-go/services/dns/v1api/wait" ) const ( @@ -69,7 +69,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return err } - zoneLabel, err := dnsUtils.GetZoneName(ctx, apiClient, model.ProjectId, model.ZoneId) + zoneLabel, err := dnsUtils.GetZoneName(ctx, apiClient.DefaultAPI, model.ProjectId, model.ZoneId) if err != nil { params.Printer.Debug(print.ErrorLevel, "get zone name: %v", err) zoneLabel = model.ZoneId @@ -87,12 +87,12 @@ func NewCmd(params *types.CmdParams) *cobra.Command { if err != nil { return fmt.Errorf("clone DNS zone: %w", err) } - zoneId := *resp.Zone.Id + zoneId := resp.Zone.Id // Wait for async operation, if async mode not enabled if !model.Async { err := spinner.Run(params.Printer, "Cloning zone", func() error { - _, err = wait.CreateZoneWaitHandler(ctx, apiClient, model.ProjectId, zoneId).WaitWithContext(ctx) + _, err = wait.CreateZoneWaitHandler(ctx, apiClient.DefaultAPI, model.ProjectId, zoneId).WaitWithContext(ctx) return err }) if err != nil { @@ -139,10 +139,10 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *dns.APIClient) dns.ApiCloneZoneRequest { - req := apiClient.CloneZone(ctx, model.ProjectId, model.ZoneId) + req := apiClient.DefaultAPI.CloneZone(ctx, model.ProjectId, model.ZoneId) req = req.CloneZonePayload(dns.CloneZonePayload{ Name: model.Name, - DnsName: model.DnsName, + DnsName: *model.DnsName, Description: model.Description, AdjustRecords: model.AdjustRecords, }) @@ -158,7 +158,7 @@ func outputResult(p *print.Printer, model *inputModel, projectLabel string, resp if model.Async { operationState = "Triggered cloning of" } - p.Outputf("%s zone for project %q. Zone ID: %s\n", operationState, projectLabel, utils.PtrString(resp.Zone.Id)) + p.Outputf("%s zone for project %q. Zone ID: %s\n", operationState, projectLabel, resp.Zone.Id) return nil }) } diff --git a/internal/cmd/dns/zone/clone/clone_test.go b/internal/cmd/dns/zone/clone/clone_test.go index 9e1f9ff06..7490434f7 100644 --- a/internal/cmd/dns/zone/clone/clone_test.go +++ b/internal/cmd/dns/zone/clone/clone_test.go @@ -7,7 +7,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/dns" + dns "github.com/stackitcloud/stackit-sdk-go/services/dns/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" @@ -18,7 +18,7 @@ import ( type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &dns.APIClient{} +var testClient = &dns.APIClient{DefaultAPI: &dns.DefaultAPIService{}} var testProjectId = uuid.NewString() var testZoneId = uuid.NewString() @@ -65,10 +65,10 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *dns.ApiCloneZoneRequest)) dns.ApiCloneZoneRequest { - request := testClient.CloneZone(testCtx, testProjectId, testZoneId) + request := testClient.DefaultAPI.CloneZone(testCtx, testProjectId, testZoneId) request = request.CloneZonePayload(dns.CloneZonePayload{ Name: utils.Ptr("example"), - DnsName: utils.Ptr("example.com"), + DnsName: "example.com", Description: utils.Ptr("Example"), AdjustRecords: utils.Ptr(false), }) @@ -196,9 +196,9 @@ func TestBuildRequest(t *testing.T) { DnsName: utils.Ptr("example.com"), ZoneId: testZoneId, }, - expectedRequest: testClient.CloneZone(testCtx, testProjectId, testZoneId). + expectedRequest: testClient.DefaultAPI.CloneZone(testCtx, testProjectId, testZoneId). CloneZonePayload(dns.CloneZonePayload{ - DnsName: utils.Ptr("example.com"), + DnsName: "example.com", }), }, } @@ -208,7 +208,7 @@ func TestBuildRequest(t *testing.T) { request := buildRequest(testCtx, tt.model, testClient) diff := cmp.Diff(request, tt.expectedRequest, - cmp.AllowUnexported(tt.expectedRequest), + cmp.AllowUnexported(tt.expectedRequest, dns.DefaultAPIService{}), cmpopts.EquateComparable(testCtx), ) if diff != "" { @@ -238,7 +238,7 @@ func TestOutputResult(t *testing.T) { name: "only zone response as argument", args: args{ model: fixtureInputModel(), - resp: &dns.ZoneResponse{Zone: &dns.Zone{}}, + resp: &dns.ZoneResponse{Zone: dns.Zone{}}, }, wantErr: false, }, diff --git a/internal/cmd/dns/zone/create/create.go b/internal/cmd/dns/zone/create/create.go index 5b68f97b8..0770b4e82 100644 --- a/internal/cmd/dns/zone/create/create.go +++ b/internal/cmd/dns/zone/create/create.go @@ -4,7 +4,10 @@ import ( "context" "fmt" + sdkUtils "github.com/stackitcloud/stackit-sdk-go/core/utils" + "github.com/stackitcloud/stackit-cli/internal/pkg/types" + "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/stackitcloud/stackit-cli/internal/pkg/args" "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -15,11 +18,10 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/projectname" "github.com/stackitcloud/stackit-cli/internal/pkg/services/dns/client" "github.com/stackitcloud/stackit-cli/internal/pkg/spinner" - "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/dns" - "github.com/stackitcloud/stackit-sdk-go/services/dns/wait" + dns "github.com/stackitcloud/stackit-sdk-go/services/dns/v1api" + "github.com/stackitcloud/stackit-sdk-go/services/dns/v1api/wait" ) const ( @@ -40,17 +42,17 @@ const ( type inputModel struct { *globalflags.GlobalFlagModel - Name *string - DnsName *string - DefaultTTL *int64 - Primaries *[]string + Name string + DnsName string + DefaultTTL *int32 + Primaries []string Acl *string - Type *dns.CreateZonePayloadTypes - RetryTime *int64 - RefreshTime *int64 - NegativeCache *int64 + Type *dns.CreateZonePayloadType + RetryTime *int32 + RefreshTime *int32 + NegativeCache *int32 IsReverseZone *bool - ExpireTime *int64 + ExpireTime *int32 Description *string ContactEmail *string } @@ -100,12 +102,12 @@ func NewCmd(params *types.CmdParams) *cobra.Command { if err != nil { return fmt.Errorf("create DNS zone: %w", err) } - zoneId := *resp.Zone.Id + zoneId := resp.Zone.Id // Wait for async operation, if async mode not enabled if !model.Async { err := spinner.Run(params.Printer, "Creating zone", func() error { - _, err = wait.CreateZoneWaitHandler(ctx, apiClient, model.ProjectId, zoneId).WaitWithContext(ctx) + _, err = wait.CreateZoneWaitHandler(ctx, apiClient.DefaultAPI, model.ProjectId, zoneId).WaitWithContext(ctx) return err }) if err != nil { @@ -121,22 +123,17 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } func configureFlags(cmd *cobra.Command) { - var typeFlagOptions []string - for _, val := range dns.AllowedCreateZonePayloadTypesEnumValues { - typeFlagOptions = append(typeFlagOptions, string(val)) - } - cmd.Flags().String(nameFlag, "", "User given name of the zone") cmd.Flags().String(dnsNameFlag, "", "Fully qualified domain name of the DNS zone") - cmd.Flags().Int64(defaultTTLFlag, 1000, "Default time to live") + cmd.Flags().Int32(defaultTTLFlag, 1000, "Default time to live") cmd.Flags().StringSlice(primaryFlag, []string{}, "Primary name server for secondary zone") cmd.Flags().String(aclFlag, "", "Access control list") - cmd.Flags().Var(flags.EnumFlag(false, "", append(typeFlagOptions, "")...), typeFlag, fmt.Sprintf("Zone type, one of: %q", typeFlagOptions)) - cmd.Flags().Int64(retryTimeFlag, 0, "Retry time") - cmd.Flags().Int64(refreshTimeFlag, 0, "Refresh time") - cmd.Flags().Int64(negativeCacheFlag, 0, "Negative cache") + cmd.Flags().Var(flags.EnumFlag(false, "", append(sdkUtils.EnumSliceToStringSlice(dns.AllowedCreateZonePayloadTypeEnumValues), "")...), typeFlag, fmt.Sprintf("Zone type, one of: %q", utils.FormatPossibleValues(sdkUtils.EnumSliceToStringSlice(dns.AllowedCreateZonePayloadTypeEnumValues)...))) + cmd.Flags().Int32(retryTimeFlag, 0, "Retry time") + cmd.Flags().Int32(refreshTimeFlag, 0, "Refresh time") + cmd.Flags().Int32(negativeCacheFlag, 0, "Negative cache") cmd.Flags().Bool(isReverseZoneFlag, false, "Is reverse zone") - cmd.Flags().Int64(expireTimeFlag, 0, "Expire time") + cmd.Flags().Int32(expireTimeFlag, 0, "Expire time") cmd.Flags().String(descriptionFlag, "", "Description of the zone") cmd.Flags().String(contactEmailFlag, "", "Contact email for the zone") @@ -150,24 +147,24 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, return nil, &errors.ProjectIdError{} } - var zoneType *dns.CreateZonePayloadTypes + var zoneType *dns.CreateZonePayloadType if zoneTypeString := flags.FlagToStringPointer(p, cmd, typeFlag); zoneTypeString != nil && *zoneTypeString != "" { - zoneType = dns.CreateZonePayloadTypes(*zoneTypeString).Ptr() + zoneType = dns.CreateZonePayloadType(*zoneTypeString).Ptr() } model := inputModel{ GlobalFlagModel: globalFlags, - Name: flags.FlagToStringPointer(p, cmd, nameFlag), - DnsName: flags.FlagToStringPointer(p, cmd, dnsNameFlag), - DefaultTTL: flags.FlagToInt64Pointer(p, cmd, defaultTTLFlag), - Primaries: flags.FlagToStringSlicePointer(p, cmd, primaryFlag), + Name: flags.FlagToStringValue(p, cmd, nameFlag), + DnsName: flags.FlagToStringValue(p, cmd, dnsNameFlag), + DefaultTTL: flags.FlagToInt32Pointer(p, cmd, defaultTTLFlag), + Primaries: flags.FlagToStringSliceValue(p, cmd, primaryFlag), Acl: flags.FlagToStringPointer(p, cmd, aclFlag), Type: zoneType, - RetryTime: flags.FlagToInt64Pointer(p, cmd, retryTimeFlag), - RefreshTime: flags.FlagToInt64Pointer(p, cmd, refreshTimeFlag), - NegativeCache: flags.FlagToInt64Pointer(p, cmd, negativeCacheFlag), + RetryTime: flags.FlagToInt32Pointer(p, cmd, retryTimeFlag), + RefreshTime: flags.FlagToInt32Pointer(p, cmd, refreshTimeFlag), + NegativeCache: flags.FlagToInt32Pointer(p, cmd, negativeCacheFlag), IsReverseZone: flags.FlagToBoolPointer(p, cmd, isReverseZoneFlag), - ExpireTime: flags.FlagToInt64Pointer(p, cmd, expireTimeFlag), + ExpireTime: flags.FlagToInt32Pointer(p, cmd, expireTimeFlag), Description: flags.FlagToStringPointer(p, cmd, descriptionFlag), ContactEmail: flags.FlagToStringPointer(p, cmd, contactEmailFlag), } @@ -177,7 +174,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, } func buildRequest(ctx context.Context, model *inputModel, apiClient *dns.APIClient) dns.ApiCreateZoneRequest { - req := apiClient.CreateZone(ctx, model.ProjectId) + req := apiClient.DefaultAPI.CreateZone(ctx, model.ProjectId) req = req.CreateZonePayload(dns.CreateZonePayload{ Name: model.Name, DnsName: model.DnsName, @@ -205,7 +202,7 @@ func outputResult(p *print.Printer, model *inputModel, projectLabel string, resp if model.Async { operationState = "Triggered creation of" } - p.Outputf("%s zone for project %q. Zone ID: %s\n", operationState, projectLabel, utils.PtrString(resp.Zone.Id)) + p.Outputf("%s zone for project %q. Zone ID: %s\n", operationState, projectLabel, resp.Zone.Id) return nil }) } diff --git a/internal/cmd/dns/zone/create/create_test.go b/internal/cmd/dns/zone/create/create_test.go index aed0ffe2e..84ecf724d 100644 --- a/internal/cmd/dns/zone/create/create_test.go +++ b/internal/cmd/dns/zone/create/create_test.go @@ -7,7 +7,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/dns" + dns "github.com/stackitcloud/stackit-sdk-go/services/dns/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" @@ -18,7 +18,7 @@ import ( type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &dns.APIClient{} +var testClient = &dns.APIClient{DefaultAPI: &dns.DefaultAPIService{}} var testProjectId = uuid.NewString() func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string { @@ -50,17 +50,17 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { ProjectId: testProjectId, Verbosity: globalflags.VerbosityDefault, }, - Name: utils.Ptr("example"), - DnsName: utils.Ptr("example.com"), - DefaultTTL: utils.Ptr(int64(3600)), - Primaries: utils.Ptr([]string{"1.1.1.1"}), + Name: "example", + DnsName: "example.com", + DefaultTTL: utils.Ptr(int32(3600)), + Primaries: []string{"1.1.1.1"}, Acl: utils.Ptr("0.0.0.0/0"), Type: dns.CREATEZONEPAYLOADTYPE_PRIMARY.Ptr(), - RetryTime: utils.Ptr(int64(600)), - RefreshTime: utils.Ptr(int64(3600)), - NegativeCache: utils.Ptr(int64(60)), + RetryTime: utils.Ptr(int32(600)), + RefreshTime: utils.Ptr(int32(3600)), + NegativeCache: utils.Ptr(int32(60)), IsReverseZone: utils.Ptr(false), - ExpireTime: utils.Ptr(int64(36000000)), + ExpireTime: utils.Ptr(int32(36000000)), Description: utils.Ptr("Example"), ContactEmail: utils.Ptr("example@example.com"), } @@ -71,19 +71,19 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *dns.ApiCreateZoneRequest)) dns.ApiCreateZoneRequest { - request := testClient.CreateZone(testCtx, testProjectId) + request := testClient.DefaultAPI.CreateZone(testCtx, testProjectId) request = request.CreateZonePayload(dns.CreateZonePayload{ - Name: utils.Ptr("example"), - DnsName: utils.Ptr("example.com"), - DefaultTTL: utils.Ptr(int64(3600)), - Primaries: utils.Ptr([]string{"1.1.1.1"}), + Name: "example", + DnsName: "example.com", + DefaultTTL: utils.Ptr(int32(3600)), + Primaries: []string{"1.1.1.1"}, Acl: utils.Ptr("0.0.0.0/0"), Type: dns.CREATEZONEPAYLOADTYPE_PRIMARY.Ptr(), - RetryTime: utils.Ptr(int64(600)), - RefreshTime: utils.Ptr(int64(3600)), - NegativeCache: utils.Ptr(int64(60)), + RetryTime: utils.Ptr(int32(600)), + RefreshTime: utils.Ptr(int32(3600)), + NegativeCache: utils.Ptr(int32(60)), IsReverseZone: utils.Ptr(false), - ExpireTime: utils.Ptr(int64(36000000)), + ExpireTime: utils.Ptr(int32(36000000)), Description: utils.Ptr("Example"), ContactEmail: utils.Ptr("example@example.com"), }) @@ -126,8 +126,8 @@ func TestParseInput(t *testing.T) { ProjectId: testProjectId, Verbosity: globalflags.VerbosityDefault, }, - Name: utils.Ptr("example"), - DnsName: utils.Ptr("example.com"), + Name: "example", + DnsName: "example.com", }, }, { @@ -153,17 +153,17 @@ func TestParseInput(t *testing.T) { ProjectId: testProjectId, Verbosity: globalflags.VerbosityDefault, }, - Name: utils.Ptr(""), - DnsName: utils.Ptr(""), - DefaultTTL: utils.Ptr(int64(0)), + Name: "", + DnsName: "", + DefaultTTL: utils.Ptr(int32(0)), Primaries: nil, Acl: utils.Ptr(""), Type: nil, - RetryTime: utils.Ptr(int64(0)), - RefreshTime: utils.Ptr(int64(0)), - NegativeCache: utils.Ptr(int64(0)), + RetryTime: utils.Ptr(int32(0)), + RefreshTime: utils.Ptr(int32(0)), + NegativeCache: utils.Ptr(int32(0)), IsReverseZone: utils.Ptr(false), - ExpireTime: utils.Ptr(int64(0)), + ExpireTime: utils.Ptr(int32(0)), Description: utils.Ptr(""), ContactEmail: utils.Ptr(""), }, @@ -195,9 +195,8 @@ func TestParseInput(t *testing.T) { primaryFlagValues: []string{"1.2.3.4", "5.6.7.8"}, isValid: true, expectedModel: fixtureInputModel(func(model *inputModel) { - model.Primaries = utils.Ptr( - append(*model.Primaries, "1.2.3.4", "5.6.7.8"), - ) + model.Primaries = + append(model.Primaries, "1.2.3.4", "5.6.7.8") }), }, { @@ -206,9 +205,8 @@ func TestParseInput(t *testing.T) { primaryFlagValues: []string{"1.2.3.4,5.6.7.8"}, isValid: true, expectedModel: fixtureInputModel(func(model *inputModel) { - model.Primaries = utils.Ptr( - append(*model.Primaries, "1.2.3.4", "5.6.7.8"), - ) + model.Primaries = + append(model.Primaries, "1.2.3.4", "5.6.7.8") }), }, } @@ -240,13 +238,13 @@ func TestBuildRequest(t *testing.T) { ProjectId: testProjectId, Verbosity: globalflags.VerbosityDefault, }, - Name: utils.Ptr("example"), - DnsName: utils.Ptr("example.com"), + Name: "example", + DnsName: "example.com", }, - expectedRequest: testClient.CreateZone(testCtx, testProjectId). + expectedRequest: testClient.DefaultAPI.CreateZone(testCtx, testProjectId). CreateZonePayload(dns.CreateZonePayload{ - Name: utils.Ptr("example"), - DnsName: utils.Ptr("example.com"), + Name: "example", + DnsName: "example.com", }), }, } @@ -256,7 +254,7 @@ func TestBuildRequest(t *testing.T) { request := buildRequest(testCtx, tt.model, testClient) diff := cmp.Diff(request, tt.expectedRequest, - cmp.AllowUnexported(tt.expectedRequest), + cmp.AllowUnexported(tt.expectedRequest, dns.DefaultAPIService{}), cmpopts.EquateComparable(testCtx), ) if diff != "" { @@ -286,7 +284,7 @@ func TestOutputResult(t *testing.T) { name: "only zone response as argument", args: args{ model: fixtureInputModel(), - resp: &dns.ZoneResponse{Zone: &dns.Zone{}}, + resp: &dns.ZoneResponse{Zone: dns.Zone{}}, }, wantErr: false, }, diff --git a/internal/cmd/dns/zone/delete/delete.go b/internal/cmd/dns/zone/delete/delete.go index 9945054ee..a299dd074 100644 --- a/internal/cmd/dns/zone/delete/delete.go +++ b/internal/cmd/dns/zone/delete/delete.go @@ -17,8 +17,8 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/dns" - "github.com/stackitcloud/stackit-sdk-go/services/dns/wait" + dns "github.com/stackitcloud/stackit-sdk-go/services/dns/v1api" + "github.com/stackitcloud/stackit-sdk-go/services/dns/v1api/wait" ) const ( @@ -54,7 +54,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return err } - zoneLabel, err := dnsUtils.GetZoneName(ctx, apiClient, model.ProjectId, model.ZoneId) + zoneLabel, err := dnsUtils.GetZoneName(ctx, apiClient.DefaultAPI, model.ProjectId, model.ZoneId) if err != nil { params.Printer.Debug(print.ErrorLevel, "get zone name: %v", err) zoneLabel = model.ZoneId @@ -78,7 +78,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { // Wait for async operation, if async mode not enabled if !model.Async { err := spinner.Run(params.Printer, "Deleting zone", func() error { - _, err = wait.DeleteZoneWaitHandler(ctx, apiClient, model.ProjectId, model.ZoneId).WaitWithContext(ctx) + _, err = wait.DeleteZoneWaitHandler(ctx, apiClient.DefaultAPI, model.ProjectId, model.ZoneId).WaitWithContext(ctx) return err }) if err != nil { @@ -114,6 +114,6 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *dns.APIClient) dns.ApiDeleteZoneRequest { - req := apiClient.DeleteZone(ctx, model.ProjectId, model.ZoneId) + req := apiClient.DefaultAPI.DeleteZone(ctx, model.ProjectId, model.ZoneId) return req } diff --git a/internal/cmd/dns/zone/delete/delete_test.go b/internal/cmd/dns/zone/delete/delete_test.go index 32eabe63b..51f5ec826 100644 --- a/internal/cmd/dns/zone/delete/delete_test.go +++ b/internal/cmd/dns/zone/delete/delete_test.go @@ -10,13 +10,13 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/dns" + dns "github.com/stackitcloud/stackit-sdk-go/services/dns/v1api" ) type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &dns.APIClient{} +var testClient = &dns.APIClient{DefaultAPI: &dns.DefaultAPIService{}} var testProjectId = uuid.NewString() var testZoneId = uuid.NewString() @@ -55,7 +55,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *dns.ApiDeleteZoneRequest)) dns.ApiDeleteZoneRequest { - request := testClient.DeleteZone(testCtx, testProjectId, testZoneId) + request := testClient.DefaultAPI.DeleteZone(testCtx, testProjectId, testZoneId) for _, mod := range mods { mod(&request) } @@ -160,7 +160,7 @@ func TestBuildRequest(t *testing.T) { request := buildRequest(testCtx, tt.model, testClient) diff := cmp.Diff(request, tt.expectedRequest, - cmp.AllowUnexported(tt.expectedRequest), + cmp.AllowUnexported(tt.expectedRequest, dns.DefaultAPIService{}), cmpopts.EquateComparable(testCtx), ) if diff != "" { diff --git a/internal/cmd/dns/zone/describe/describe.go b/internal/cmd/dns/zone/describe/describe.go index 51d2fcc8e..66a28b029 100644 --- a/internal/cmd/dns/zone/describe/describe.go +++ b/internal/cmd/dns/zone/describe/describe.go @@ -16,7 +16,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/dns" + dns "github.com/stackitcloud/stackit-sdk-go/services/dns/v1api" ) const ( @@ -62,7 +62,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } zone := resp.Zone - return outputResult(params.Printer, model.OutputFormat, zone) + return outputResult(params.Printer, model.OutputFormat, &zone) }, } return cmd @@ -86,7 +86,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *dns.APIClient) dns.ApiGetZoneRequest { - req := apiClient.GetZone(ctx, model.ProjectId, model.ZoneId) + req := apiClient.DefaultAPI.GetZone(ctx, model.ProjectId, model.ZoneId) return req } @@ -97,17 +97,17 @@ func outputResult(p *print.Printer, outputFormat string, zone *dns.Zone) error { return p.OutputResult(outputFormat, zone, func() error { table := tables.NewTable() - table.AddRow("ID", utils.PtrString(zone.Id)) + table.AddRow("ID", zone.Id) table.AddSeparator() - table.AddRow("NAME", utils.PtrString(zone.Name)) + table.AddRow("NAME", zone.Name) table.AddSeparator() table.AddRow("DESCRIPTION", utils.PtrString(zone.Description)) table.AddSeparator() - table.AddRow("STATE", utils.PtrString(zone.State)) + table.AddRow("STATE", zone.State) table.AddSeparator() - table.AddRow("TYPE", utils.PtrString(zone.Type)) + table.AddRow("TYPE", zone.Type) table.AddSeparator() - table.AddRow("DNS NAME", utils.PtrString(zone.DnsName)) + table.AddRow("DNS NAME", zone.DnsName) table.AddSeparator() table.AddRow("REVERSE ZONE", utils.PtrString(zone.IsReverseZone)) table.AddSeparator() @@ -115,17 +115,17 @@ func outputResult(p *print.Printer, outputFormat string, zone *dns.Zone) error { table.AddSeparator() table.AddRow("CONTACT EMAIL", utils.PtrString(zone.ContactEmail)) table.AddSeparator() - table.AddRow("DEFAULT TTL", utils.PtrString(zone.DefaultTTL)) + table.AddRow("DEFAULT TTL", zone.DefaultTTL) table.AddSeparator() - table.AddRow("SERIAL NUMBER", utils.PtrString(zone.SerialNumber)) + table.AddRow("SERIAL NUMBER", zone.SerialNumber) table.AddSeparator() - table.AddRow("REFRESH TIME", utils.PtrString(zone.RefreshTime)) + table.AddRow("REFRESH TIME", zone.RefreshTime) table.AddSeparator() - table.AddRow("RETRY TIME", utils.PtrString(zone.RetryTime)) + table.AddRow("RETRY TIME", zone.RetryTime) table.AddSeparator() - table.AddRow("EXPIRE TIME", utils.PtrString(zone.ExpireTime)) + table.AddRow("EXPIRE TIME", zone.ExpireTime) table.AddSeparator() - table.AddRow("NEGATIVE CACHE", utils.PtrString(zone.NegativeCache)) + table.AddRow("NEGATIVE CACHE", zone.NegativeCache) err := table.Display(p) if err != nil { return fmt.Errorf("render table: %w", err) diff --git a/internal/cmd/dns/zone/describe/describe_test.go b/internal/cmd/dns/zone/describe/describe_test.go index e0f868150..fbf60363b 100644 --- a/internal/cmd/dns/zone/describe/describe_test.go +++ b/internal/cmd/dns/zone/describe/describe_test.go @@ -7,7 +7,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/dns" + dns "github.com/stackitcloud/stackit-sdk-go/services/dns/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" @@ -17,7 +17,7 @@ import ( type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &dns.APIClient{} +var testClient = &dns.APIClient{DefaultAPI: &dns.DefaultAPIService{}} var testProjectId = uuid.NewString() var testZoneId = uuid.NewString() @@ -56,7 +56,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *dns.ApiGetZoneRequest)) dns.ApiGetZoneRequest { - request := testClient.GetZone(testCtx, testProjectId, testZoneId) + request := testClient.DefaultAPI.GetZone(testCtx, testProjectId, testZoneId) for _, mod := range mods { mod(&request) } @@ -161,7 +161,7 @@ func TestBuildRequest(t *testing.T) { request := buildRequest(testCtx, tt.model, testClient) diff := cmp.Diff(request, tt.expectedRequest, - cmp.AllowUnexported(tt.expectedRequest), + cmp.AllowUnexported(tt.expectedRequest, dns.DefaultAPIService{}), cmpopts.EquateComparable(testCtx), ) if diff != "" { diff --git a/internal/cmd/dns/zone/list/list.go b/internal/cmd/dns/zone/list/list.go index 1a2640fe4..05ba02073 100644 --- a/internal/cmd/dns/zone/list/list.go +++ b/internal/cmd/dns/zone/list/list.go @@ -7,6 +7,7 @@ import ( "strings" "github.com/stackitcloud/stackit-cli/internal/pkg/types" + "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/stackitcloud/stackit-cli/internal/pkg/args" "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -17,10 +18,9 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/projectname" "github.com/stackitcloud/stackit-cli/internal/pkg/services/dns/client" "github.com/stackitcloud/stackit-cli/internal/pkg/tables" - "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/dns" + dns "github.com/stackitcloud/stackit-sdk-go/services/dns/v1api" ) const ( @@ -83,7 +83,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } // Fetch zones - zones, err := fetchZones(ctx, model, apiClient) + zones, err := fetchZones(ctx, model, apiClient.DefaultAPI) if err != nil { return err } @@ -168,7 +168,7 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient dnsClient, p req = req.NameLike(*model.NameLike) } if model.OrderByName != nil { - req = req.OrderByName(strings.ToUpper(*model.OrderByName)) + req = req.OrderByName(dns.ListZonesOrderByNameParameter(strings.ToUpper(*model.OrderByName))) } if !model.IncludeDeleted { req = req.StateNeq(deleteSucceededState) @@ -207,7 +207,7 @@ func fetchZones(ctx context.Context, model *inputModel, apiClient dnsClient) ([] if err != nil { return nil, fmt.Errorf("get DNS zones: %w", err) } - respZones := *resp.Zones + respZones := resp.Zones if len(respZones) == 0 { break } @@ -237,11 +237,12 @@ func outputResult(p *print.Printer, outputFormat, projectLabel string, zones []d table.SetHeader("ID", "NAME", "STATE", "TYPE", "DNS NAME", "RECORD COUNT") for i := range zones { z := zones[i] - table.AddRow(utils.PtrString(z.Id), - utils.PtrString(z.Name), - utils.PtrString(z.State), - utils.PtrString(z.Type), - utils.PtrString(z.DnsName), + table.AddRow( + z.Id, + z.Name, + z.State, + z.Type, + z.DnsName, utils.PtrString(z.RecordCount), ) } diff --git a/internal/cmd/dns/zone/list/list_test.go b/internal/cmd/dns/zone/list/list_test.go index f6bd66efe..d2413643e 100644 --- a/internal/cmd/dns/zone/list/list_test.go +++ b/internal/cmd/dns/zone/list/list_test.go @@ -12,7 +12,7 @@ import ( "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" sdkConfig "github.com/stackitcloud/stackit-sdk-go/core/config" - "github.com/stackitcloud/stackit-sdk-go/services/dns" + dns "github.com/stackitcloud/stackit-sdk-go/services/dns/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" @@ -23,7 +23,7 @@ import ( type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &dns.APIClient{} +var testClient = &dns.APIClient{DefaultAPI: &dns.DefaultAPIService{}} var testProjectId = uuid.NewString() func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string { @@ -55,7 +55,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *dns.ApiListZonesRequest)) dns.ApiListZonesRequest { - request := testClient.ListZones(testCtx, testProjectId) + request := testClient.DefaultAPI.ListZones(testCtx, testProjectId) request = request.NameLike("some-pattern") request = request.OrderByName("ASC") request = request.PageSize(pageSizeDefault) @@ -267,16 +267,16 @@ func TestBuildRequest(t *testing.T) { PageSize: pageSizeDefault, }, page: 1, - expectedRequest: testClient.ListZones(testCtx, testProjectId).Page(1).PageSize(pageSizeDefault).StateNeq(deleteSucceededState), + expectedRequest: testClient.DefaultAPI.ListZones(testCtx, testProjectId).Page(1).PageSize(pageSizeDefault).StateNeq(deleteSucceededState), }, } for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { - request := buildRequest(testCtx, tt.model, testClient, tt.page) + request := buildRequest(testCtx, tt.model, testClient.DefaultAPI, tt.page) diff := cmp.Diff(request, tt.expectedRequest, - cmp.AllowUnexported(tt.expectedRequest), + cmp.AllowUnexported(tt.expectedRequest, dns.DefaultAPIService{}), cmpopts.EquateComparable(testCtx), ) if diff != "" { @@ -414,7 +414,7 @@ func TestFetchZones(t *testing.T) { zones := make([]dns.Zone, numItemsToReturn) mockedResp := dns.ListZonesResponse{ - Zones: &zones, + Zones: zones, } mockedRespBytes, err := json.Marshal(mockedResp) @@ -437,7 +437,7 @@ func TestFetchZones(t *testing.T) { t.Fatalf("Failed to initialize client: %v", err) } - zones, err := fetchZones(testCtx, tt.model, client) + zones, err := fetchZones(testCtx, tt.model, client.DefaultAPI) if err != nil { if !tt.apiCallFails { t.Fatalf("did not fail on invalid input") diff --git a/internal/cmd/dns/zone/update/update.go b/internal/cmd/dns/zone/update/update.go index c44ba724b..d700214ff 100644 --- a/internal/cmd/dns/zone/update/update.go +++ b/internal/cmd/dns/zone/update/update.go @@ -18,8 +18,8 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/dns" - "github.com/stackitcloud/stackit-sdk-go/services/dns/wait" + dns "github.com/stackitcloud/stackit-sdk-go/services/dns/v1api" + "github.com/stackitcloud/stackit-sdk-go/services/dns/v1api/wait" ) const ( @@ -41,13 +41,13 @@ type inputModel struct { *globalflags.GlobalFlagModel ZoneId string Name *string - DefaultTTL *int64 - Primaries *[]string + DefaultTTL *int32 + Primaries []string Acl *string - RetryTime *int64 - RefreshTime *int64 - NegativeCache *int64 - ExpireTime *int64 + RetryTime *int32 + RefreshTime *int32 + NegativeCache *int32 + ExpireTime *int32 Description *string ContactEmail *string } @@ -76,7 +76,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return err } - zoneLabel, err := dnsUtils.GetZoneName(ctx, apiClient, model.ProjectId, model.ZoneId) + zoneLabel, err := dnsUtils.GetZoneName(ctx, apiClient.DefaultAPI, model.ProjectId, model.ZoneId) if err != nil { params.Printer.Debug(print.ErrorLevel, "get zone name: %v", err) zoneLabel = model.ZoneId @@ -101,7 +101,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { // Wait for async operation, if async mode not enabled if !model.Async { err := spinner.Run(params.Printer, "Updating zone", func() error { - _, err = wait.PartialUpdateZoneWaitHandler(ctx, apiClient, model.ProjectId, model.ZoneId).WaitWithContext(ctx) + _, err = wait.PartialUpdateZoneWaitHandler(ctx, apiClient.DefaultAPI, model.ProjectId, model.ZoneId).WaitWithContext(ctx) return err }) if err != nil { @@ -123,13 +123,13 @@ func NewCmd(params *types.CmdParams) *cobra.Command { func configureFlags(cmd *cobra.Command) { cmd.Flags().String(nameFlag, "", "User given name of the zone") - cmd.Flags().Int64(defaultTTLFlag, 1000, "Default time to live") + cmd.Flags().Int32(defaultTTLFlag, 1000, "Default time to live") cmd.Flags().StringSlice(primaryFlag, []string{}, "Primary name server for secondary zone") cmd.Flags().String(aclFlag, "", "Access control list") - cmd.Flags().Int64(retryTimeFlag, 0, "Retry time") - cmd.Flags().Int64(refreshTimeFlag, 0, "Refresh time") - cmd.Flags().Int64(negativeCacheFlag, 0, "Negative cache") - cmd.Flags().Int64(expireTimeFlag, 0, "Expire time") + cmd.Flags().Int32(retryTimeFlag, 0, "Retry time") + cmd.Flags().Int32(refreshTimeFlag, 0, "Refresh time") + cmd.Flags().Int32(negativeCacheFlag, 0, "Negative cache") + cmd.Flags().Int32(expireTimeFlag, 0, "Expire time") cmd.Flags().String(descriptionFlag, "", "Description of the zone") cmd.Flags().String(contactEmailFlag, "", "Contact email for the zone") } @@ -143,13 +143,13 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } name := flags.FlagToStringPointer(p, cmd, nameFlag) - defaultTTL := flags.FlagToInt64Pointer(p, cmd, defaultTTLFlag) - primaries := flags.FlagToStringSlicePointer(p, cmd, primaryFlag) + defaultTTL := flags.FlagToInt32Pointer(p, cmd, defaultTTLFlag) + primaries := flags.FlagToStringSliceValue(p, cmd, primaryFlag) acl := flags.FlagToStringPointer(p, cmd, aclFlag) - retryTime := flags.FlagToInt64Pointer(p, cmd, retryTimeFlag) - refreshTime := flags.FlagToInt64Pointer(p, cmd, refreshTimeFlag) - negativeCache := flags.FlagToInt64Pointer(p, cmd, negativeCacheFlag) - expireTime := flags.FlagToInt64Pointer(p, cmd, expireTimeFlag) + retryTime := flags.FlagToInt32Pointer(p, cmd, retryTimeFlag) + refreshTime := flags.FlagToInt32Pointer(p, cmd, refreshTimeFlag) + negativeCache := flags.FlagToInt32Pointer(p, cmd, negativeCacheFlag) + expireTime := flags.FlagToInt32Pointer(p, cmd, expireTimeFlag) description := flags.FlagToStringPointer(p, cmd, descriptionFlag) contactEmail := flags.FlagToStringPointer(p, cmd, contactEmailFlag) @@ -180,7 +180,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *dns.APIClient) dns.ApiPartialUpdateZoneRequest { - req := apiClient.PartialUpdateZone(ctx, model.ProjectId, model.ZoneId) + req := apiClient.DefaultAPI.PartialUpdateZone(ctx, model.ProjectId, model.ZoneId) req = req.PartialUpdateZonePayload(dns.PartialUpdateZonePayload{ Name: model.Name, DefaultTTL: model.DefaultTTL, diff --git a/internal/cmd/dns/zone/update/update_test.go b/internal/cmd/dns/zone/update/update_test.go index fef73853f..0dda139c0 100644 --- a/internal/cmd/dns/zone/update/update_test.go +++ b/internal/cmd/dns/zone/update/update_test.go @@ -11,13 +11,13 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/dns" + dns "github.com/stackitcloud/stackit-sdk-go/services/dns/v1api" ) type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &dns.APIClient{} +var testClient = &dns.APIClient{DefaultAPI: &dns.DefaultAPIService{}} var testProjectId = uuid.NewString() var testZoneId = uuid.NewString() @@ -59,13 +59,13 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { }, ZoneId: testZoneId, Name: utils.Ptr("example"), - DefaultTTL: utils.Ptr(int64(3600)), - Primaries: utils.Ptr([]string{"1.1.1.1"}), + DefaultTTL: utils.Ptr(int32(3600)), + Primaries: []string{"1.1.1.1"}, Acl: utils.Ptr("0.0.0.0/0"), - RetryTime: utils.Ptr(int64(600)), - RefreshTime: utils.Ptr(int64(3600)), - NegativeCache: utils.Ptr(int64(60)), - ExpireTime: utils.Ptr(int64(36000000)), + RetryTime: utils.Ptr(int32(600)), + RefreshTime: utils.Ptr(int32(3600)), + NegativeCache: utils.Ptr(int32(60)), + ExpireTime: utils.Ptr(int32(36000000)), Description: utils.Ptr("Example"), ContactEmail: utils.Ptr("example@example.com"), } @@ -76,16 +76,16 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *dns.ApiPartialUpdateZoneRequest)) dns.ApiPartialUpdateZoneRequest { - request := testClient.PartialUpdateZone(testCtx, testProjectId, testZoneId) + request := testClient.DefaultAPI.PartialUpdateZone(testCtx, testProjectId, testZoneId) request = request.PartialUpdateZonePayload(dns.PartialUpdateZonePayload{ Name: utils.Ptr("example"), - DefaultTTL: utils.Ptr(int64(3600)), - Primaries: utils.Ptr([]string{"1.1.1.1"}), + DefaultTTL: utils.Ptr(int32(3600)), + Primaries: []string{"1.1.1.1"}, Acl: utils.Ptr("0.0.0.0/0"), - RetryTime: utils.Ptr(int64(600)), - RefreshTime: utils.Ptr(int64(3600)), - NegativeCache: utils.Ptr(int64(60)), - ExpireTime: utils.Ptr(int64(36000000)), + RetryTime: utils.Ptr(int32(600)), + RefreshTime: utils.Ptr(int32(3600)), + NegativeCache: utils.Ptr(int32(60)), + ExpireTime: utils.Ptr(int32(36000000)), Description: utils.Ptr("Example"), ContactEmail: utils.Ptr("example@example.com"), }) @@ -168,13 +168,13 @@ func TestParseInput(t *testing.T) { }, ZoneId: testZoneId, Name: utils.Ptr(""), - DefaultTTL: utils.Ptr(int64(0)), - Primaries: utils.Ptr([]string{}), + DefaultTTL: utils.Ptr(int32(0)), + Primaries: []string{}, Acl: utils.Ptr(""), - RetryTime: utils.Ptr(int64(0)), - RefreshTime: utils.Ptr(int64(0)), - NegativeCache: utils.Ptr(int64(0)), - ExpireTime: utils.Ptr(int64(0)), + RetryTime: utils.Ptr(int32(0)), + RefreshTime: utils.Ptr(int32(0)), + NegativeCache: utils.Ptr(int32(0)), + ExpireTime: utils.Ptr(int32(0)), Description: utils.Ptr(""), ContactEmail: utils.Ptr(""), }, @@ -222,9 +222,8 @@ func TestParseInput(t *testing.T) { primaryFlagValues: []string{"1.2.3.4", "5.6.7.8"}, isValid: true, expectedModel: fixtureInputModel(func(model *inputModel) { - model.Primaries = utils.Ptr( - append(*model.Primaries, "1.2.3.4", "5.6.7.8"), - ) + model.Primaries = + append(model.Primaries, "1.2.3.4", "5.6.7.8") }), }, { @@ -234,9 +233,8 @@ func TestParseInput(t *testing.T) { primaryFlagValues: []string{"1.2.3.4,5.6.7.8"}, isValid: true, expectedModel: fixtureInputModel(func(model *inputModel) { - model.Primaries = utils.Ptr( - append(*model.Primaries, "1.2.3.4", "5.6.7.8"), - ) + model.Primaries = + append(model.Primaries, "1.2.3.4", "5.6.7.8") }), }, } @@ -325,7 +323,7 @@ func TestBuildRequest(t *testing.T) { }, ZoneId: testZoneId, }, - expectedRequest: testClient.PartialUpdateZone(testCtx, testProjectId, testZoneId). + expectedRequest: testClient.DefaultAPI.PartialUpdateZone(testCtx, testProjectId, testZoneId). PartialUpdateZonePayload(dns.PartialUpdateZonePayload{}), }, } @@ -335,7 +333,7 @@ func TestBuildRequest(t *testing.T) { request := buildRequest(testCtx, tt.model, testClient) diff := cmp.Diff(request, tt.expectedRequest, - cmp.AllowUnexported(tt.expectedRequest), + cmp.AllowUnexported(tt.expectedRequest, dns.DefaultAPIService{}), cmpopts.EquateComparable(testCtx), ) if diff != "" { diff --git a/internal/pkg/services/dns/client/client.go b/internal/pkg/services/dns/client/client.go index 478fa0a53..7e101b00a 100644 --- a/internal/pkg/services/dns/client/client.go +++ b/internal/pkg/services/dns/client/client.go @@ -7,7 +7,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/print" "github.com/spf13/viper" - "github.com/stackitcloud/stackit-sdk-go/services/dns" + dns "github.com/stackitcloud/stackit-sdk-go/services/dns/v1api" ) func ConfigureClient(p *print.Printer, cliVersion string) (*dns.APIClient, error) { diff --git a/internal/pkg/services/dns/utils/utils.go b/internal/pkg/services/dns/utils/utils.go index 030c86b55..f58f9c453 100644 --- a/internal/pkg/services/dns/utils/utils.go +++ b/internal/pkg/services/dns/utils/utils.go @@ -5,38 +5,33 @@ import ( "fmt" "math" - "github.com/stackitcloud/stackit-sdk-go/services/dns" + dns "github.com/stackitcloud/stackit-sdk-go/services/dns/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/utils" ) -type DNSClient interface { - GetZoneExecute(ctx context.Context, projectId, zoneId string) (*dns.ZoneResponse, error) - GetRecordSetExecute(ctx context.Context, projectId, zoneId, recordSetId string) (*dns.RecordSetResponse, error) -} - -func GetZoneName(ctx context.Context, apiClient DNSClient, projectId, zoneId string) (string, error) { - resp, err := apiClient.GetZoneExecute(ctx, projectId, zoneId) +func GetZoneName(ctx context.Context, apiClient dns.DefaultAPI, projectId, zoneId string) (string, error) { + resp, err := apiClient.GetZone(ctx, projectId, zoneId).Execute() if err != nil { return "", fmt.Errorf("get DNS zone: %w", err) } - return *resp.Zone.Name, nil + return resp.Zone.Name, nil } -func GetRecordSetName(ctx context.Context, apiClient DNSClient, projectId, zoneId, recordSetId string) (string, error) { - resp, err := apiClient.GetRecordSetExecute(ctx, projectId, zoneId, recordSetId) +func GetRecordSetName(ctx context.Context, apiClient dns.DefaultAPI, projectId, zoneId, recordSetId string) (string, error) { + resp, err := apiClient.GetRecordSet(ctx, projectId, zoneId, recordSetId).Execute() if err != nil { return "", fmt.Errorf("get DNS recordset: %w", err) } - return *resp.Rrset.Name, nil + return resp.Rrset.Name, nil } -func GetRecordSetType(ctx context.Context, apiClient DNSClient, projectId, zoneId, recordSetId string) (*string, error) { - resp, err := apiClient.GetRecordSetExecute(ctx, projectId, zoneId, recordSetId) +func GetRecordSetType(ctx context.Context, apiClient dns.DefaultAPI, projectId, zoneId, recordSetId string) (*string, error) { + resp, err := apiClient.GetRecordSet(ctx, projectId, zoneId, recordSetId).Execute() if err != nil { return utils.Ptr(""), fmt.Errorf("get DNS recordset: %w", err) } - return (*string)(resp.Rrset.Type), nil + return utils.Ptr(string(resp.Rrset.Type)), nil } func FormatTxtRecord(input string) (string, error) { diff --git a/internal/pkg/services/dns/utils/utils_test.go b/internal/pkg/services/dns/utils/utils_test.go index b7c91bff9..0330ce992 100644 --- a/internal/pkg/services/dns/utils/utils_test.go +++ b/internal/pkg/services/dns/utils/utils_test.go @@ -6,7 +6,7 @@ import ( "testing" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/dns" + dns "github.com/stackitcloud/stackit-sdk-go/services/dns/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/utils" ) @@ -28,25 +28,30 @@ const ( testRecordSetType = "A" ) -type dnsClientMocked struct { +type mockSettings struct { getZoneFails bool getZoneResp *dns.ZoneResponse getRecordSetFails bool getRecordSetResp *dns.RecordSetResponse } -func (m *dnsClientMocked) GetZoneExecute(_ context.Context, _, _ string) (*dns.ZoneResponse, error) { - if m.getZoneFails { - return nil, fmt.Errorf("could not get zone") - } - return m.getZoneResp, nil -} +func newAPIMock(settings *mockSettings) dns.DefaultAPI { + return &dns.DefaultAPIServiceMock{ + GetZoneExecuteMock: utils.Ptr(func(_ dns.ApiGetZoneRequest) (*dns.ZoneResponse, error) { + if settings.getZoneFails { + return nil, fmt.Errorf("could not get zone") + } + + return settings.getZoneResp, nil + }), + GetRecordSetExecuteMock: utils.Ptr(func(_ dns.ApiGetRecordSetRequest) (*dns.RecordSetResponse, error) { + if settings.getRecordSetFails { + return nil, fmt.Errorf("could not get record set") + } -func (m *dnsClientMocked) GetRecordSetExecute(_ context.Context, _, _, _ string) (*dns.RecordSetResponse, error) { - if m.getRecordSetFails { - return nil, fmt.Errorf("could not get record set") + return settings.getRecordSetResp, nil + }), } - return m.getRecordSetResp, nil } func TestGetZoneName(t *testing.T) { @@ -60,8 +65,8 @@ func TestGetZoneName(t *testing.T) { { description: "base", getZoneResp: &dns.ZoneResponse{ - Zone: &dns.Zone{ - Name: utils.Ptr(testZoneName), + Zone: dns.Zone{ + Name: testZoneName, }, }, isValid: true, @@ -76,10 +81,10 @@ func TestGetZoneName(t *testing.T) { for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { - client := &dnsClientMocked{ + client := newAPIMock(&mockSettings{ getZoneFails: tt.getZoneFails, getZoneResp: tt.getZoneResp, - } + }) output, err := GetZoneName(context.Background(), client, testProjectId, testZoneId) @@ -110,8 +115,8 @@ func TestGetRecordSetName(t *testing.T) { { description: "base", getRecordSetResp: &dns.RecordSetResponse{ - Rrset: &dns.RecordSet{ - Name: utils.Ptr(testRecordSetName), + Rrset: dns.RecordSet{ + Name: testRecordSetName, }, }, isValid: true, @@ -126,10 +131,10 @@ func TestGetRecordSetName(t *testing.T) { for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { - client := &dnsClientMocked{ + client := newAPIMock(&mockSettings{ getRecordSetFails: tt.getRecordSetFails, getRecordSetResp: tt.getRecordSetResp, - } + }) output, err := GetRecordSetName(context.Background(), client, testProjectId, testZoneId, testRecordSetId) @@ -160,8 +165,8 @@ func TestGetRecordSetType(t *testing.T) { { description: "base", getRecordSetResp: &dns.RecordSetResponse{ - Rrset: &dns.RecordSet{ - Name: utils.Ptr(testRecordSetType), + Rrset: dns.RecordSet{ + Name: testRecordSetType, }, }, isValid: true, @@ -176,10 +181,10 @@ func TestGetRecordSetType(t *testing.T) { for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { - client := &dnsClientMocked{ + client := newAPIMock(&mockSettings{ getRecordSetFails: tt.getRecordSetFails, getRecordSetResp: tt.getRecordSetResp, - } + }) output, err := GetRecordSetName(context.Background(), client, testProjectId, testZoneId, testRecordSetId) From 09c6c7343e2b29860cf55bceef105d7f426bf87b Mon Sep 17 00:00:00 2001 From: Alexander Dahmen Date: Wed, 1 Jul 2026 14:04:33 +0200 Subject: [PATCH 11/44] fix(intake): set region to false in ConfigureClient (#1451) Signed-off-by: Alexander Dahmen --- internal/pkg/services/intake/client/client.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/pkg/services/intake/client/client.go b/internal/pkg/services/intake/client/client.go index be6080862..7f2495356 100644 --- a/internal/pkg/services/intake/client/client.go +++ b/internal/pkg/services/intake/client/client.go @@ -11,5 +11,5 @@ import ( // ConfigureClient creates and configures a new Intake API client func ConfigureClient(p *print.Printer, cliVersion string) (*intake.APIClient, error) { - return genericclient.ConfigureClientGeneric(p, cliVersion, viper.GetString(config.IntakeCustomEndpointKey), true, genericclient.CreateApiClient[*intake.APIClient](intake.NewAPIClient)) + return genericclient.ConfigureClientGeneric(p, cliVersion, viper.GetString(config.IntakeCustomEndpointKey), false, genericclient.CreateApiClient[*intake.APIClient](intake.NewAPIClient)) } From ff16fb4a88f7272587e9081f7cb908b289294bc5 Mon Sep 17 00:00:00 2001 From: Roger Zaragoza Date: Thu, 2 Jul 2026 10:25:49 +0200 Subject: [PATCH 12/44] feat(intake): add force flag for deleting intake runners (#1442) * feat(intake): add force flag for deleting intake runners Adds a flag to enable calling delete intake runner API with force flag. relates to STACKITINT-1392 * feat(intake): improve varible names readability --- docs/stackit_beta_intake_runner_delete.md | 6 ++++- .../cmd/beta/intake/runner/delete/delete.go | 22 +++++++++++++++++-- .../beta/intake/runner/delete/delete_test.go | 18 +++++++++++++++ 3 files changed, 43 insertions(+), 3 deletions(-) diff --git a/docs/stackit_beta_intake_runner_delete.md b/docs/stackit_beta_intake_runner_delete.md index 0fa94ae5f..c97d388cd 100644 --- a/docs/stackit_beta_intake_runner_delete.md +++ b/docs/stackit_beta_intake_runner_delete.md @@ -15,12 +15,16 @@ stackit beta intake runner delete RUNNER_ID [flags] ``` Delete an Intake Runner with ID "xxx" $ stackit beta intake runner delete xxx + + Delete an Intake Runner with ID "xxx", along with all associated Intakes and Intake Users that would stop the removal of the Intake + $ stackit beta intake runner delete xxx --force ``` ### Options ``` - -h, --help Help for "stackit beta intake runner delete" + --force When true, also removes all associated Intakes and Intake Users that would stop the removal of the Intake + -h, --help Help for "stackit beta intake runner delete" ``` ### Options inherited from parent commands diff --git a/internal/cmd/beta/intake/runner/delete/delete.go b/internal/cmd/beta/intake/runner/delete/delete.go index 794122083..fe54853d5 100644 --- a/internal/cmd/beta/intake/runner/delete/delete.go +++ b/internal/cmd/beta/intake/runner/delete/delete.go @@ -4,6 +4,7 @@ import ( "context" "fmt" + "github.com/stackitcloud/stackit-cli/internal/pkg/flags" "github.com/stackitcloud/stackit-cli/internal/pkg/types" "github.com/spf13/cobra" @@ -21,13 +22,15 @@ import ( ) const ( - runnerIdArg = "RUNNER_ID" + runnerIdArg = "RUNNER_ID" + forceDeleteFlag = "force" ) // inputModel struct holds all the input parameters for the command type inputModel struct { *globalflags.GlobalFlagModel - RunnerId string + RunnerId string + ForceDelete bool } // NewCmd creates a new cobra command for deleting an Intake Runner @@ -41,6 +44,9 @@ func NewCmd(p *types.CmdParams) *cobra.Command { examples.NewExample( `Delete an Intake Runner with ID "xxx"`, `$ stackit beta intake runner delete xxx`), + examples.NewExample( + `Delete an Intake Runner with ID "xxx", along with all associated Intakes and Intake Users that would stop the removal of the Intake`, + `$ stackit beta intake runner delete xxx --force`), ), RunE: func(cmd *cobra.Command, args []string) error { ctx := context.Background() @@ -56,6 +62,9 @@ func NewCmd(p *types.CmdParams) *cobra.Command { } prompt := fmt.Sprintf("Are you sure you want to delete Intake Runner %q?", model.RunnerId) + if model.ForceDelete { + prompt = fmt.Sprintf("%s This will also remove all Intakes and Intake Users that would stop the removal of the Intake", prompt) + } err = p.Printer.PromptForConfirmation(prompt) if err != nil { return err @@ -87,9 +96,14 @@ func NewCmd(p *types.CmdParams) *cobra.Command { return nil }, } + configureFlags(cmd) return cmd } +func configureFlags(cmd *cobra.Command) { + cmd.Flags().Bool(forceDeleteFlag, false, "When true, also removes all associated Intakes and Intake Users that would stop the removal of the Intake") +} + // parseInput parses the command arguments and flags into a standardized model func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inputModel, error) { runnerId := inputArgs[0] @@ -102,6 +116,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu model := inputModel{ GlobalFlagModel: globalFlags, RunnerId: runnerId, + ForceDelete: flags.FlagToBoolValue(p, cmd, forceDeleteFlag), } p.DebugInputModel(model) @@ -111,5 +126,8 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu // buildRequest creates the API request to delete an Intake Runner func buildRequest(ctx context.Context, model *inputModel, apiClient *intake.APIClient) intake.ApiDeleteIntakeRunnerRequest { req := apiClient.DefaultAPI.DeleteIntakeRunner(ctx, model.ProjectId, model.Region, model.RunnerId) + if model.ForceDelete { + return req.Force(true) + } return req } diff --git a/internal/cmd/beta/intake/runner/delete/delete_test.go b/internal/cmd/beta/intake/runner/delete/delete_test.go index a4d5048fd..2bc4709ca 100644 --- a/internal/cmd/beta/intake/runner/delete/delete_test.go +++ b/internal/cmd/beta/intake/runner/delete/delete_test.go @@ -94,6 +94,17 @@ func TestParseInput(t *testing.T) { isValid: true, expectedModel: fixtureInputModel(), }, + { + description: "with force", + argValues: fixtureArgValues(), + flagValues: fixtureFlagValues(func(flagValues map[string]string) { + flagValues[forceDeleteFlag] = "true" + }), + isValid: true, + expectedModel: fixtureInputModel(func(model *inputModel) { + model.ForceDelete = true + }), + }, { description: "no arg values", argValues: []string{}, @@ -140,6 +151,13 @@ func TestBuildRequest(t *testing.T) { model: fixtureInputModel(), expectedRequest: fixtureRequest(), }, + { + description: "with force", + model: fixtureInputModel(func(model *inputModel) { + model.ForceDelete = true + }), + expectedRequest: fixtureRequest().Force(true), + }, } for _, tt := range tests { From ca535dd7969de4fbb85536f9a19c6ff931a6ac60 Mon Sep 17 00:00:00 2001 From: cgoetz-inovex Date: Thu, 2 Jul 2026 11:14:44 +0200 Subject: [PATCH 13/44] Refac/no issue use generic enum flags for string backed enums (#1441) * refac(flags): use generic enum flags * fix(flags): improve docs, regenerate docs, fmt * refac(flags): delete non generic enum flags * Apply suggestions from code review Co-authored-by: Marcel Jacek <72880145+marceljk@users.noreply.github.com> * fix(docs): regenerate * fix(alb): fmt * fix(dns): fix merge * fix(dns): regenerate docs --------- Co-authored-by: Marcel Jacek <72880145+marceljk@users.noreply.github.com> --- docs/stackit.md | 4 +- docs/stackit_affinity-group.md | 4 +- docs/stackit_affinity-group_create.md | 4 +- docs/stackit_affinity-group_delete.md | 4 +- docs/stackit_affinity-group_describe.md | 4 +- docs/stackit_affinity-group_list.md | 4 +- docs/stackit_auth.md | 4 +- docs/stackit_auth_activate-service-account.md | 4 +- docs/stackit_auth_get-access-token.md | 4 +- docs/stackit_auth_login.md | 4 +- docs/stackit_auth_logout.md | 4 +- docs/stackit_beta.md | 4 +- docs/stackit_beta_alb.md | 4 +- docs/stackit_beta_alb_create.md | 4 +- docs/stackit_beta_alb_delete.md | 4 +- docs/stackit_beta_alb_describe.md | 4 +- docs/stackit_beta_alb_list.md | 4 +- ...ckit_beta_alb_observability-credentials.md | 4 +- ..._beta_alb_observability-credentials_add.md | 4 +- ...ta_alb_observability-credentials_delete.md | 4 +- ..._alb_observability-credentials_describe.md | 4 +- ...beta_alb_observability-credentials_list.md | 4 +- ...ta_alb_observability-credentials_update.md | 4 +- docs/stackit_beta_alb_plans.md | 4 +- docs/stackit_beta_alb_pool.md | 4 +- docs/stackit_beta_alb_pool_update.md | 4 +- docs/stackit_beta_alb_quotas.md | 4 +- docs/stackit_beta_alb_template.md | 8 +- docs/stackit_beta_alb_update.md | 4 +- docs/stackit_beta_cdn.md | 4 +- docs/stackit_beta_cdn_distribution.md | 4 +- docs/stackit_beta_cdn_distribution_create.md | 6 +- docs/stackit_beta_cdn_distribution_delete.md | 4 +- .../stackit_beta_cdn_distribution_describe.md | 4 +- docs/stackit_beta_cdn_distribution_list.md | 6 +- docs/stackit_beta_cdn_distribution_update.md | 6 +- docs/stackit_beta_edge-cloud.md | 4 +- docs/stackit_beta_edge-cloud_instance.md | 4 +- ...stackit_beta_edge-cloud_instance_create.md | 4 +- ...stackit_beta_edge-cloud_instance_delete.md | 4 +- ...ackit_beta_edge-cloud_instance_describe.md | 4 +- docs/stackit_beta_edge-cloud_instance_list.md | 4 +- ...stackit_beta_edge-cloud_instance_update.md | 4 +- docs/stackit_beta_edge-cloud_kubeconfig.md | 4 +- ...ackit_beta_edge-cloud_kubeconfig_create.md | 4 +- docs/stackit_beta_edge-cloud_plans.md | 4 +- docs/stackit_beta_edge-cloud_plans_list.md | 4 +- docs/stackit_beta_edge-cloud_token.md | 4 +- docs/stackit_beta_edge-cloud_token_create.md | 4 +- docs/stackit_beta_intake.md | 4 +- docs/stackit_beta_intake_create.md | 4 +- docs/stackit_beta_intake_delete.md | 4 +- docs/stackit_beta_intake_describe.md | 4 +- docs/stackit_beta_intake_list.md | 4 +- docs/stackit_beta_intake_runner.md | 4 +- docs/stackit_beta_intake_runner_create.md | 4 +- docs/stackit_beta_intake_runner_delete.md | 4 +- docs/stackit_beta_intake_runner_describe.md | 4 +- docs/stackit_beta_intake_runner_list.md | 4 +- docs/stackit_beta_intake_runner_update.md | 4 +- docs/stackit_beta_intake_update.md | 4 +- docs/stackit_beta_intake_user.md | 4 +- docs/stackit_beta_intake_user_create.md | 4 +- docs/stackit_beta_intake_user_delete.md | 4 +- docs/stackit_beta_intake_user_describe.md | 4 +- docs/stackit_beta_intake_user_list.md | 4 +- docs/stackit_beta_intake_user_update.md | 4 +- docs/stackit_beta_sfs.md | 4 +- docs/stackit_beta_sfs_export-policy.md | 4 +- docs/stackit_beta_sfs_export-policy_create.md | 4 +- docs/stackit_beta_sfs_export-policy_delete.md | 4 +- ...stackit_beta_sfs_export-policy_describe.md | 4 +- docs/stackit_beta_sfs_export-policy_list.md | 4 +- docs/stackit_beta_sfs_export-policy_update.md | 4 +- docs/stackit_beta_sfs_performance-class.md | 4 +- ...stackit_beta_sfs_performance-class_list.md | 4 +- docs/stackit_beta_sfs_project-lock.md | 4 +- .../stackit_beta_sfs_project-lock_describe.md | 4 +- docs/stackit_beta_sfs_project-lock_lock.md | 4 +- docs/stackit_beta_sfs_project-lock_unlock.md | 4 +- docs/stackit_beta_sfs_resource-pool.md | 4 +- docs/stackit_beta_sfs_resource-pool_create.md | 4 +- docs/stackit_beta_sfs_resource-pool_delete.md | 4 +- ...stackit_beta_sfs_resource-pool_describe.md | 4 +- docs/stackit_beta_sfs_resource-pool_list.md | 4 +- docs/stackit_beta_sfs_resource-pool_update.md | 4 +- docs/stackit_beta_sfs_share.md | 4 +- docs/stackit_beta_sfs_share_create.md | 4 +- docs/stackit_beta_sfs_share_delete.md | 4 +- docs/stackit_beta_sfs_share_describe.md | 4 +- docs/stackit_beta_sfs_share_list.md | 4 +- docs/stackit_beta_sfs_share_update.md | 4 +- docs/stackit_beta_sfs_snapshot-policy.md | 4 +- ...ackit_beta_sfs_snapshot-policy_describe.md | 4 +- docs/stackit_beta_sfs_snapshot-policy_list.md | 6 +- docs/stackit_beta_sfs_snapshot.md | 4 +- docs/stackit_beta_sfs_snapshot_create.md | 4 +- docs/stackit_beta_sfs_snapshot_delete.md | 4 +- docs/stackit_beta_sfs_snapshot_describe.md | 4 +- docs/stackit_beta_sfs_snapshot_list.md | 4 +- docs/stackit_beta_sfs_snapshot_update.md | 4 +- docs/stackit_beta_sqlserverflex.md | 4 +- docs/stackit_beta_sqlserverflex_database.md | 4 +- ...ckit_beta_sqlserverflex_database_create.md | 4 +- ...ckit_beta_sqlserverflex_database_delete.md | 4 +- ...it_beta_sqlserverflex_database_describe.md | 4 +- ...tackit_beta_sqlserverflex_database_list.md | 4 +- docs/stackit_beta_sqlserverflex_instance.md | 4 +- ...ckit_beta_sqlserverflex_instance_create.md | 4 +- ...ckit_beta_sqlserverflex_instance_delete.md | 4 +- ...it_beta_sqlserverflex_instance_describe.md | 4 +- ...tackit_beta_sqlserverflex_instance_list.md | 4 +- ...ckit_beta_sqlserverflex_instance_update.md | 4 +- docs/stackit_beta_sqlserverflex_options.md | 4 +- docs/stackit_beta_sqlserverflex_user.md | 4 +- .../stackit_beta_sqlserverflex_user_create.md | 4 +- .../stackit_beta_sqlserverflex_user_delete.md | 4 +- ...tackit_beta_sqlserverflex_user_describe.md | 4 +- docs/stackit_beta_sqlserverflex_user_list.md | 4 +- ..._beta_sqlserverflex_user_reset-password.md | 4 +- docs/stackit_beta_vpn.md | 4 +- docs/stackit_beta_vpn_connection.md | 4 +- docs/stackit_beta_vpn_connection_create.md | 36 +-- docs/stackit_beta_vpn_connection_delete.md | 4 +- docs/stackit_beta_vpn_connection_describe.md | 4 +- docs/stackit_beta_vpn_connection_list.md | 4 +- docs/stackit_beta_vpn_connection_status.md | 4 +- docs/stackit_config.md | 4 +- docs/stackit_config_list.md | 4 +- docs/stackit_config_profile.md | 4 +- docs/stackit_config_profile_create.md | 4 +- docs/stackit_config_profile_delete.md | 4 +- docs/stackit_config_profile_export.md | 4 +- docs/stackit_config_profile_import.md | 4 +- docs/stackit_config_profile_list.md | 4 +- docs/stackit_config_profile_set.md | 4 +- docs/stackit_config_profile_unset.md | 4 +- docs/stackit_config_set.md | 4 +- docs/stackit_curl.md | 6 +- docs/stackit_dns.md | 4 +- docs/stackit_dns_record-set.md | 4 +- docs/stackit_dns_record-set_create.md | 6 +- docs/stackit_dns_record-set_delete.md | 4 +- docs/stackit_dns_record-set_describe.md | 4 +- docs/stackit_dns_record-set_list.md | 6 +- docs/stackit_dns_record-set_update.md | 4 +- docs/stackit_dns_zone.md | 4 +- docs/stackit_dns_zone_clone.md | 4 +- docs/stackit_dns_zone_create.md | 6 +- docs/stackit_dns_zone_delete.md | 4 +- docs/stackit_dns_zone_describe.md | 4 +- docs/stackit_dns_zone_list.md | 6 +- docs/stackit_dns_zone_update.md | 4 +- docs/stackit_git.md | 4 +- docs/stackit_git_flavor.md | 4 +- docs/stackit_git_flavor_list.md | 4 +- docs/stackit_git_instance.md | 4 +- docs/stackit_git_instance_create.md | 4 +- docs/stackit_git_instance_delete.md | 4 +- docs/stackit_git_instance_describe.md | 4 +- docs/stackit_git_instance_list.md | 4 +- docs/stackit_image.md | 4 +- docs/stackit_image_create.md | 4 +- docs/stackit_image_delete.md | 4 +- docs/stackit_image_describe.md | 4 +- docs/stackit_image_list.md | 4 +- docs/stackit_image_update.md | 4 +- docs/stackit_key-pair.md | 4 +- docs/stackit_key-pair_create.md | 4 +- docs/stackit_key-pair_delete.md | 4 +- docs/stackit_key-pair_describe.md | 4 +- docs/stackit_key-pair_list.md | 4 +- docs/stackit_key-pair_update.md | 4 +- docs/stackit_kms.md | 4 +- docs/stackit_kms_key.md | 4 +- docs/stackit_kms_key_create.md | 10 +- docs/stackit_kms_key_delete.md | 4 +- docs/stackit_kms_key_describe.md | 4 +- docs/stackit_kms_key_import.md | 4 +- docs/stackit_kms_key_list.md | 4 +- docs/stackit_kms_key_restore.md | 4 +- docs/stackit_kms_key_rotate.md | 4 +- docs/stackit_kms_keyring.md | 4 +- docs/stackit_kms_keyring_create.md | 4 +- docs/stackit_kms_keyring_delete.md | 4 +- docs/stackit_kms_keyring_describe.md | 4 +- docs/stackit_kms_keyring_list.md | 4 +- docs/stackit_kms_version.md | 4 +- docs/stackit_kms_version_destroy.md | 4 +- docs/stackit_kms_version_disable.md | 4 +- docs/stackit_kms_version_enable.md | 4 +- docs/stackit_kms_version_list.md | 4 +- docs/stackit_kms_version_restore.md | 4 +- docs/stackit_kms_wrapping-key.md | 4 +- docs/stackit_kms_wrapping-key_create.md | 10 +- docs/stackit_kms_wrapping-key_delete.md | 4 +- docs/stackit_kms_wrapping-key_describe.md | 4 +- docs/stackit_kms_wrapping-key_list.md | 4 +- docs/stackit_load-balancer.md | 4 +- docs/stackit_load-balancer_create.md | 4 +- docs/stackit_load-balancer_delete.md | 4 +- docs/stackit_load-balancer_describe.md | 4 +- .../stackit_load-balancer_generate-payload.md | 4 +- docs/stackit_load-balancer_list.md | 4 +- ...load-balancer_observability-credentials.md | 4 +- ...-balancer_observability-credentials_add.md | 4 +- ...ancer_observability-credentials_cleanup.md | 4 +- ...lancer_observability-credentials_delete.md | 4 +- ...ncer_observability-credentials_describe.md | 4 +- ...balancer_observability-credentials_list.md | 4 +- ...lancer_observability-credentials_update.md | 4 +- docs/stackit_load-balancer_quota.md | 4 +- docs/stackit_load-balancer_target-pool.md | 4 +- ...it_load-balancer_target-pool_add-target.md | 4 +- ...ckit_load-balancer_target-pool_describe.md | 4 +- ...load-balancer_target-pool_remove-target.md | 4 +- docs/stackit_load-balancer_update.md | 4 +- docs/stackit_logme.md | 4 +- docs/stackit_logme_credentials.md | 4 +- docs/stackit_logme_credentials_create.md | 4 +- docs/stackit_logme_credentials_delete.md | 4 +- docs/stackit_logme_credentials_describe.md | 4 +- docs/stackit_logme_credentials_list.md | 4 +- docs/stackit_logme_instance.md | 4 +- docs/stackit_logme_instance_create.md | 4 +- docs/stackit_logme_instance_delete.md | 4 +- docs/stackit_logme_instance_describe.md | 4 +- docs/stackit_logme_instance_list.md | 4 +- docs/stackit_logme_instance_update.md | 4 +- docs/stackit_logme_plans.md | 4 +- docs/stackit_logs.md | 4 +- docs/stackit_logs_access-token.md | 4 +- docs/stackit_logs_access-token_create.md | 4 +- ...it_logs_access-token_delete-all-expired.md | 4 +- docs/stackit_logs_access-token_delete-all.md | 4 +- docs/stackit_logs_access-token_delete.md | 4 +- docs/stackit_logs_access-token_describe.md | 4 +- docs/stackit_logs_access-token_list.md | 4 +- docs/stackit_logs_access-token_update.md | 4 +- docs/stackit_logs_instance.md | 4 +- docs/stackit_logs_instance_create.md | 4 +- docs/stackit_logs_instance_delete.md | 4 +- docs/stackit_logs_instance_describe.md | 4 +- docs/stackit_logs_instance_list.md | 4 +- docs/stackit_logs_instance_update.md | 4 +- docs/stackit_mariadb.md | 4 +- docs/stackit_mariadb_credentials.md | 4 +- docs/stackit_mariadb_credentials_create.md | 4 +- docs/stackit_mariadb_credentials_delete.md | 4 +- docs/stackit_mariadb_credentials_describe.md | 4 +- docs/stackit_mariadb_credentials_list.md | 4 +- docs/stackit_mariadb_instance.md | 4 +- docs/stackit_mariadb_instance_create.md | 4 +- docs/stackit_mariadb_instance_delete.md | 4 +- docs/stackit_mariadb_instance_describe.md | 4 +- docs/stackit_mariadb_instance_list.md | 4 +- docs/stackit_mariadb_instance_update.md | 4 +- docs/stackit_mariadb_plans.md | 4 +- docs/stackit_mongodbflex.md | 4 +- docs/stackit_mongodbflex_backup.md | 4 +- docs/stackit_mongodbflex_backup_describe.md | 4 +- docs/stackit_mongodbflex_backup_list.md | 4 +- ...stackit_mongodbflex_backup_restore-jobs.md | 4 +- docs/stackit_mongodbflex_backup_restore.md | 4 +- docs/stackit_mongodbflex_backup_schedule.md | 4 +- ...ckit_mongodbflex_backup_update-schedule.md | 4 +- docs/stackit_mongodbflex_instance.md | 4 +- docs/stackit_mongodbflex_instance_create.md | 6 +- docs/stackit_mongodbflex_instance_delete.md | 4 +- docs/stackit_mongodbflex_instance_describe.md | 4 +- docs/stackit_mongodbflex_instance_list.md | 4 +- docs/stackit_mongodbflex_instance_update.md | 6 +- docs/stackit_mongodbflex_options.md | 4 +- docs/stackit_mongodbflex_user.md | 4 +- docs/stackit_mongodbflex_user_create.md | 6 +- docs/stackit_mongodbflex_user_delete.md | 4 +- docs/stackit_mongodbflex_user_describe.md | 4 +- docs/stackit_mongodbflex_user_list.md | 4 +- ...stackit_mongodbflex_user_reset-password.md | 4 +- docs/stackit_mongodbflex_user_update.md | 6 +- docs/stackit_network-area.md | 4 +- docs/stackit_network-area_create.md | 4 +- docs/stackit_network-area_delete.md | 4 +- docs/stackit_network-area_describe.md | 4 +- docs/stackit_network-area_list.md | 4 +- docs/stackit_network-area_network-range.md | 4 +- ...ackit_network-area_network-range_create.md | 4 +- ...ackit_network-area_network-range_delete.md | 4 +- ...kit_network-area_network-range_describe.md | 4 +- ...stackit_network-area_network-range_list.md | 4 +- docs/stackit_network-area_region.md | 4 +- docs/stackit_network-area_region_create.md | 4 +- docs/stackit_network-area_region_delete.md | 4 +- docs/stackit_network-area_region_describe.md | 4 +- docs/stackit_network-area_region_list.md | 4 +- docs/stackit_network-area_region_update.md | 4 +- docs/stackit_network-area_route.md | 4 +- docs/stackit_network-area_route_create.md | 4 +- docs/stackit_network-area_route_delete.md | 4 +- docs/stackit_network-area_route_describe.md | 4 +- docs/stackit_network-area_route_list.md | 4 +- docs/stackit_network-area_route_update.md | 4 +- docs/stackit_network-area_routing-table.md | 4 +- ...ackit_network-area_routing-table_create.md | 4 +- ...ackit_network-area_routing-table_delete.md | 4 +- ...kit_network-area_routing-table_describe.md | 4 +- ...stackit_network-area_routing-table_list.md | 4 +- ...tackit_network-area_routing-table_route.md | 4 +- ...network-area_routing-table_route_create.md | 8 +- ...network-area_routing-table_route_delete.md | 4 +- ...twork-area_routing-table_route_describe.md | 4 +- ...t_network-area_routing-table_route_list.md | 4 +- ...network-area_routing-table_route_update.md | 4 +- ...ackit_network-area_routing-table_update.md | 4 +- docs/stackit_network-area_update.md | 4 +- docs/stackit_network-interface.md | 4 +- docs/stackit_network-interface_create.md | 4 +- docs/stackit_network-interface_delete.md | 4 +- docs/stackit_network-interface_describe.md | 4 +- docs/stackit_network-interface_list.md | 4 +- docs/stackit_network-interface_update.md | 4 +- docs/stackit_network.md | 4 +- docs/stackit_network_create.md | 4 +- docs/stackit_network_delete.md | 4 +- docs/stackit_network_describe.md | 4 +- docs/stackit_network_list.md | 4 +- docs/stackit_network_update.md | 4 +- docs/stackit_object-storage.md | 4 +- docs/stackit_object-storage_bucket.md | 4 +- docs/stackit_object-storage_bucket_create.md | 4 +- docs/stackit_object-storage_bucket_delete.md | 4 +- .../stackit_object-storage_bucket_describe.md | 4 +- docs/stackit_object-storage_bucket_list.md | 4 +- .../stackit_object-storage_compliance-lock.md | 4 +- ...object-storage_compliance-lock_describe.md | 4 +- ...kit_object-storage_compliance-lock_lock.md | 4 +- ...t_object-storage_compliance-lock_unlock.md | 4 +- ...tackit_object-storage_credentials-group.md | 4 +- ...object-storage_credentials-group_create.md | 4 +- ...object-storage_credentials-group_delete.md | 4 +- ...t_object-storage_credentials-group_list.md | 4 +- docs/stackit_object-storage_credentials.md | 4 +- ...ackit_object-storage_credentials_create.md | 4 +- ...ackit_object-storage_credentials_delete.md | 4 +- ...stackit_object-storage_credentials_list.md | 4 +- docs/stackit_object-storage_disable.md | 4 +- docs/stackit_object-storage_enable.md | 4 +- docs/stackit_observability.md | 4 +- docs/stackit_observability_credentials.md | 4 +- ...tackit_observability_credentials_create.md | 4 +- ...tackit_observability_credentials_delete.md | 4 +- .../stackit_observability_credentials_list.md | 4 +- docs/stackit_observability_grafana.md | 4 +- .../stackit_observability_grafana_describe.md | 4 +- ...bservability_grafana_public-read-access.md | 4 +- ...lity_grafana_public-read-access_disable.md | 4 +- ...ility_grafana_public-read-access_enable.md | 4 +- ...it_observability_grafana_single-sign-on.md | 4 +- ...vability_grafana_single-sign-on_disable.md | 4 +- ...rvability_grafana_single-sign-on_enable.md | 4 +- docs/stackit_observability_instance.md | 4 +- docs/stackit_observability_instance_create.md | 4 +- docs/stackit_observability_instance_delete.md | 4 +- ...stackit_observability_instance_describe.md | 4 +- docs/stackit_observability_instance_list.md | 4 +- docs/stackit_observability_instance_update.md | 4 +- docs/stackit_observability_plans.md | 4 +- docs/stackit_observability_scrape-config.md | 4 +- ...ckit_observability_scrape-config_create.md | 4 +- ...ckit_observability_scrape-config_delete.md | 4 +- ...it_observability_scrape-config_describe.md | 4 +- ...vability_scrape-config_generate-payload.md | 4 +- ...tackit_observability_scrape-config_list.md | 4 +- ...ckit_observability_scrape-config_update.md | 4 +- docs/stackit_opensearch.md | 4 +- docs/stackit_opensearch_credentials.md | 4 +- docs/stackit_opensearch_credentials_create.md | 4 +- docs/stackit_opensearch_credentials_delete.md | 4 +- ...stackit_opensearch_credentials_describe.md | 4 +- docs/stackit_opensearch_credentials_list.md | 4 +- docs/stackit_opensearch_instance.md | 4 +- docs/stackit_opensearch_instance_create.md | 4 +- docs/stackit_opensearch_instance_delete.md | 4 +- docs/stackit_opensearch_instance_describe.md | 4 +- docs/stackit_opensearch_instance_list.md | 4 +- docs/stackit_opensearch_instance_update.md | 4 +- docs/stackit_opensearch_plans.md | 4 +- docs/stackit_organization.md | 4 +- docs/stackit_organization_describe.md | 4 +- docs/stackit_organization_list.md | 4 +- docs/stackit_organization_member.md | 4 +- docs/stackit_organization_member_add.md | 4 +- docs/stackit_organization_member_list.md | 6 +- docs/stackit_organization_member_remove.md | 4 +- docs/stackit_organization_role.md | 4 +- docs/stackit_organization_role_list.md | 4 +- docs/stackit_postgresflex.md | 4 +- docs/stackit_postgresflex_backup.md | 4 +- docs/stackit_postgresflex_backup_describe.md | 4 +- docs/stackit_postgresflex_backup_list.md | 4 +- ...kit_postgresflex_backup_update-schedule.md | 4 +- docs/stackit_postgresflex_instance.md | 4 +- docs/stackit_postgresflex_instance_clone.md | 4 +- docs/stackit_postgresflex_instance_create.md | 6 +- docs/stackit_postgresflex_instance_delete.md | 4 +- .../stackit_postgresflex_instance_describe.md | 4 +- docs/stackit_postgresflex_instance_list.md | 4 +- docs/stackit_postgresflex_instance_update.md | 6 +- docs/stackit_postgresflex_options.md | 4 +- docs/stackit_postgresflex_user.md | 4 +- docs/stackit_postgresflex_user_create.md | 6 +- docs/stackit_postgresflex_user_delete.md | 4 +- docs/stackit_postgresflex_user_describe.md | 4 +- docs/stackit_postgresflex_user_list.md | 4 +- ...tackit_postgresflex_user_reset-password.md | 4 +- docs/stackit_postgresflex_user_update.md | 6 +- docs/stackit_project.md | 4 +- docs/stackit_project_create.md | 4 +- docs/stackit_project_delete.md | 4 +- docs/stackit_project_describe.md | 4 +- docs/stackit_project_list.md | 4 +- docs/stackit_project_member.md | 4 +- docs/stackit_project_member_add.md | 4 +- docs/stackit_project_member_list.md | 6 +- docs/stackit_project_member_remove.md | 4 +- docs/stackit_project_role.md | 4 +- docs/stackit_project_role_list.md | 4 +- docs/stackit_project_update.md | 4 +- docs/stackit_public-ip.md | 4 +- docs/stackit_public-ip_associate.md | 4 +- docs/stackit_public-ip_create.md | 4 +- docs/stackit_public-ip_delete.md | 4 +- docs/stackit_public-ip_describe.md | 4 +- docs/stackit_public-ip_disassociate.md | 4 +- docs/stackit_public-ip_list.md | 4 +- docs/stackit_public-ip_ranges.md | 4 +- docs/stackit_public-ip_ranges_list.md | 4 +- docs/stackit_public-ip_update.md | 4 +- docs/stackit_quota.md | 4 +- docs/stackit_quota_list.md | 4 +- docs/stackit_rabbitmq.md | 4 +- docs/stackit_rabbitmq_credentials.md | 4 +- docs/stackit_rabbitmq_credentials_create.md | 4 +- docs/stackit_rabbitmq_credentials_delete.md | 4 +- docs/stackit_rabbitmq_credentials_describe.md | 4 +- docs/stackit_rabbitmq_credentials_list.md | 4 +- docs/stackit_rabbitmq_instance.md | 4 +- docs/stackit_rabbitmq_instance_create.md | 4 +- docs/stackit_rabbitmq_instance_delete.md | 4 +- docs/stackit_rabbitmq_instance_describe.md | 4 +- docs/stackit_rabbitmq_instance_list.md | 4 +- docs/stackit_rabbitmq_instance_update.md | 4 +- docs/stackit_rabbitmq_plans.md | 4 +- docs/stackit_redis.md | 4 +- docs/stackit_redis_credentials.md | 4 +- docs/stackit_redis_credentials_create.md | 4 +- docs/stackit_redis_credentials_delete.md | 4 +- docs/stackit_redis_credentials_describe.md | 4 +- docs/stackit_redis_credentials_list.md | 4 +- docs/stackit_redis_instance.md | 4 +- docs/stackit_redis_instance_create.md | 4 +- docs/stackit_redis_instance_delete.md | 4 +- docs/stackit_redis_instance_describe.md | 4 +- docs/stackit_redis_instance_list.md | 4 +- docs/stackit_redis_instance_update.md | 4 +- docs/stackit_redis_plans.md | 4 +- docs/stackit_secrets-manager.md | 4 +- docs/stackit_secrets-manager_instance.md | 4 +- ...stackit_secrets-manager_instance_create.md | 4 +- ...stackit_secrets-manager_instance_delete.md | 4 +- ...ackit_secrets-manager_instance_describe.md | 4 +- docs/stackit_secrets-manager_instance_list.md | 4 +- ...stackit_secrets-manager_instance_update.md | 4 +- docs/stackit_secrets-manager_user.md | 4 +- docs/stackit_secrets-manager_user_create.md | 4 +- docs/stackit_secrets-manager_user_delete.md | 4 +- docs/stackit_secrets-manager_user_describe.md | 4 +- docs/stackit_secrets-manager_user_list.md | 4 +- docs/stackit_secrets-manager_user_update.md | 4 +- docs/stackit_security-group.md | 4 +- docs/stackit_security-group_create.md | 4 +- docs/stackit_security-group_delete.md | 4 +- docs/stackit_security-group_describe.md | 4 +- docs/stackit_security-group_list.md | 4 +- docs/stackit_security-group_rule.md | 4 +- docs/stackit_security-group_rule_create.md | 4 +- docs/stackit_security-group_rule_delete.md | 4 +- docs/stackit_security-group_rule_describe.md | 4 +- docs/stackit_security-group_rule_list.md | 4 +- docs/stackit_security-group_update.md | 4 +- docs/stackit_server.md | 4 +- docs/stackit_server_backup.md | 4 +- docs/stackit_server_backup_create.md | 4 +- docs/stackit_server_backup_delete.md | 4 +- docs/stackit_server_backup_describe.md | 4 +- docs/stackit_server_backup_disable.md | 4 +- docs/stackit_server_backup_enable.md | 4 +- docs/stackit_server_backup_list.md | 4 +- docs/stackit_server_backup_restore.md | 4 +- docs/stackit_server_backup_schedule.md | 4 +- docs/stackit_server_backup_schedule_create.md | 4 +- docs/stackit_server_backup_schedule_delete.md | 4 +- ...stackit_server_backup_schedule_describe.md | 4 +- docs/stackit_server_backup_schedule_list.md | 4 +- docs/stackit_server_backup_schedule_update.md | 4 +- docs/stackit_server_backup_volume-backup.md | 4 +- ...ckit_server_backup_volume-backup_delete.md | 4 +- ...kit_server_backup_volume-backup_restore.md | 4 +- docs/stackit_server_command.md | 4 +- docs/stackit_server_command_create.md | 4 +- docs/stackit_server_command_describe.md | 4 +- docs/stackit_server_command_list.md | 4 +- docs/stackit_server_command_template.md | 4 +- ...tackit_server_command_template_describe.md | 4 +- docs/stackit_server_command_template_list.md | 4 +- docs/stackit_server_console.md | 4 +- docs/stackit_server_create.md | 6 +- docs/stackit_server_deallocate.md | 4 +- docs/stackit_server_delete.md | 4 +- docs/stackit_server_describe.md | 4 +- docs/stackit_server_list.md | 4 +- docs/stackit_server_log.md | 4 +- docs/stackit_server_machine-type.md | 4 +- docs/stackit_server_machine-type_describe.md | 4 +- docs/stackit_server_machine-type_list.md | 4 +- docs/stackit_server_network-interface.md | 4 +- ...stackit_server_network-interface_attach.md | 4 +- ...stackit_server_network-interface_detach.md | 4 +- docs/stackit_server_network-interface_list.md | 4 +- docs/stackit_server_os-update.md | 4 +- docs/stackit_server_os-update_create.md | 4 +- docs/stackit_server_os-update_describe.md | 4 +- docs/stackit_server_os-update_disable.md | 4 +- docs/stackit_server_os-update_enable.md | 4 +- docs/stackit_server_os-update_list.md | 4 +- docs/stackit_server_os-update_schedule.md | 4 +- ...tackit_server_os-update_schedule_create.md | 4 +- ...tackit_server_os-update_schedule_delete.md | 4 +- ...ckit_server_os-update_schedule_describe.md | 4 +- .../stackit_server_os-update_schedule_list.md | 4 +- ...tackit_server_os-update_schedule_update.md | 4 +- docs/stackit_server_public-ip.md | 4 +- docs/stackit_server_public-ip_attach.md | 4 +- docs/stackit_server_public-ip_detach.md | 4 +- docs/stackit_server_reboot.md | 4 +- docs/stackit_server_rescue.md | 4 +- docs/stackit_server_resize.md | 4 +- docs/stackit_server_security-group.md | 4 +- docs/stackit_server_security-group_attach.md | 4 +- docs/stackit_server_security-group_detach.md | 4 +- docs/stackit_server_service-account.md | 4 +- docs/stackit_server_service-account_attach.md | 4 +- docs/stackit_server_service-account_detach.md | 4 +- docs/stackit_server_service-account_list.md | 4 +- docs/stackit_server_start.md | 4 +- docs/stackit_server_stop.md | 4 +- docs/stackit_server_unrescue.md | 4 +- docs/stackit_server_update.md | 4 +- docs/stackit_server_volume.md | 4 +- docs/stackit_server_volume_attach.md | 4 +- docs/stackit_server_volume_describe.md | 4 +- docs/stackit_server_volume_detach.md | 4 +- docs/stackit_server_volume_list.md | 4 +- docs/stackit_server_volume_update.md | 4 +- docs/stackit_service-account.md | 4 +- docs/stackit_service-account_create.md | 4 +- docs/stackit_service-account_delete.md | 4 +- docs/stackit_service-account_get-jwks.md | 4 +- docs/stackit_service-account_key.md | 4 +- docs/stackit_service-account_key_create.md | 4 +- docs/stackit_service-account_key_delete.md | 4 +- docs/stackit_service-account_key_describe.md | 4 +- docs/stackit_service-account_key_list.md | 4 +- docs/stackit_service-account_key_update.md | 4 +- docs/stackit_service-account_list.md | 4 +- docs/stackit_service-account_token.md | 4 +- docs/stackit_service-account_token_create.md | 4 +- docs/stackit_service-account_token_list.md | 4 +- docs/stackit_service-account_token_revoke.md | 4 +- docs/stackit_ske.md | 4 +- docs/stackit_ske_cluster.md | 4 +- docs/stackit_ske_cluster_create.md | 4 +- docs/stackit_ske_cluster_delete.md | 4 +- docs/stackit_ske_cluster_describe.md | 4 +- docs/stackit_ske_cluster_generate-payload.md | 4 +- docs/stackit_ske_cluster_hibernate.md | 4 +- docs/stackit_ske_cluster_list.md | 4 +- docs/stackit_ske_cluster_maintenance.md | 4 +- docs/stackit_ske_cluster_reconcile.md | 4 +- docs/stackit_ske_cluster_update.md | 4 +- docs/stackit_ske_cluster_wakeup.md | 4 +- docs/stackit_ske_credentials.md | 4 +- ...ackit_ske_credentials_complete-rotation.md | 4 +- .../stackit_ske_credentials_start-rotation.md | 4 +- docs/stackit_ske_describe.md | 4 +- docs/stackit_ske_disable.md | 4 +- docs/stackit_ske_enable.md | 4 +- docs/stackit_ske_kubeconfig.md | 4 +- docs/stackit_ske_kubeconfig_create.md | 6 +- docs/stackit_ske_kubeconfig_login.md | 4 +- docs/stackit_ske_options.md | 4 +- .../stackit_ske_options_availability-zones.md | 4 +- ...stackit_ske_options_kubernetes-versions.md | 4 +- docs/stackit_ske_options_machine-images.md | 4 +- docs/stackit_ske_options_machine-types.md | 4 +- docs/stackit_ske_options_volume-types.md | 4 +- docs/stackit_volume.md | 4 +- docs/stackit_volume_backup.md | 4 +- docs/stackit_volume_backup_create.md | 6 +- docs/stackit_volume_backup_delete.md | 4 +- docs/stackit_volume_backup_describe.md | 4 +- docs/stackit_volume_backup_list.md | 4 +- docs/stackit_volume_backup_restore.md | 4 +- docs/stackit_volume_backup_update.md | 4 +- docs/stackit_volume_create.md | 4 +- docs/stackit_volume_delete.md | 4 +- docs/stackit_volume_describe.md | 4 +- docs/stackit_volume_list.md | 4 +- docs/stackit_volume_performance-class.md | 4 +- ...ackit_volume_performance-class_describe.md | 4 +- docs/stackit_volume_performance-class_list.md | 4 +- docs/stackit_volume_resize.md | 4 +- docs/stackit_volume_snapshot.md | 4 +- docs/stackit_volume_snapshot_create.md | 4 +- docs/stackit_volume_snapshot_delete.md | 4 +- docs/stackit_volume_snapshot_describe.md | 4 +- docs/stackit_volume_snapshot_list.md | 4 +- docs/stackit_volume_snapshot_update.md | 4 +- docs/stackit_volume_update.md | 4 +- internal/cmd/beta/alb/template/template.go | 28 +- .../cmd/beta/alb/template/template_test.go | 22 +- .../beta/cdn/distribution/create/create.go | 20 +- .../cdn/distribution/create/create_test.go | 6 +- .../cmd/beta/cdn/distribution/list/list.go | 14 +- .../beta/cdn/distribution/list/list_test.go | 18 +- .../beta/cdn/distribution/update/update.go | 16 +- .../cdn/distribution/update/update_test.go | 4 +- .../cmd/beta/edge/kubeconfig/create/create.go | 4 +- .../edge/kubeconfig/create/create_test.go | 4 +- internal/cmd/beta/edge/token/create/create.go | 2 +- .../cmd/beta/sfs/snapshot-policy/list/list.go | 16 +- .../sfs/snapshot-policy/list/list_test.go | 19 +- .../cmd/beta/vpn/connection/create/create.go | 8 +- .../cmd/config/profile/create/create_test.go | 2 +- .../cmd/config/profile/delete/delete_test.go | 2 +- internal/cmd/config/profile/set/set_test.go | 2 +- internal/cmd/config/unset/unset.go | 15 +- internal/cmd/curl/curl.go | 39 +-- internal/cmd/curl/curl_test.go | 13 +- internal/cmd/dns/record-set/create/create.go | 17 +- .../cmd/dns/record-set/create/create_test.go | 16 +- internal/cmd/dns/record-set/list/list.go | 28 +- internal/cmd/dns/record-set/list/list_test.go | 8 +- internal/cmd/dns/zone/create/create.go | 20 +- internal/cmd/dns/zone/create/create_test.go | 4 +- internal/cmd/dns/zone/list/list.go | 14 +- internal/cmd/dns/zone/list/list_test.go | 8 +- internal/cmd/kms/key/create/create.go | 6 +- internal/cmd/kms/wrappingkey/create/create.go | 6 +- .../cmd/mongodbflex/instance/create/create.go | 14 +- .../instance/create/create_test.go | 4 +- .../cmd/mongodbflex/instance/update/update.go | 13 +- .../instance/update/update_test.go | 3 +- .../cmd/mongodbflex/user/create/create.go | 13 +- .../mongodbflex/user/create/create_test.go | 5 +- .../cmd/mongodbflex/user/update/update.go | 13 +- .../mongodbflex/user/update/update_test.go | 6 +- .../routingtable/route/create/create.go | 35 ++- .../routingtable/route/create/create_test.go | 44 +-- internal/cmd/organization/member/list/list.go | 14 +- .../cmd/organization/member/list/list_test.go | 4 +- .../postgresflex/instance/create/create.go | 16 +- .../instance/create/create_test.go | 4 +- .../postgresflex/instance/update/update.go | 13 +- .../instance/update/update_test.go | 3 +- .../cmd/postgresflex/user/create/create.go | 13 +- .../postgresflex/user/create/create_test.go | 6 +- .../cmd/postgresflex/user/update/update.go | 13 +- .../postgresflex/user/update/update_test.go | 6 +- internal/cmd/project/member/list/list.go | 14 +- internal/cmd/project/member/list/list_test.go | 4 +- internal/cmd/server/create/create.go | 13 +- internal/cmd/server/create/create_test.go | 44 +-- .../cmd/ske/kubeconfig/create/create_test.go | 2 +- internal/cmd/volume/backup/create/create.go | 21 +- .../cmd/volume/backup/create/create_test.go | 12 +- internal/pkg/flags/enum.go | 65 ----- internal/pkg/flags/enumslice.go | 76 ----- internal/pkg/flags/flags_test.go | 263 ------------------ internal/pkg/flags/string_enum.go | 51 ++-- internal/pkg/flags/string_enum_test.go | 8 +- internal/pkg/flags/string_enumslice.go | 34 ++- internal/pkg/flags/string_enumslice_test.go | 6 +- internal/pkg/globalflags/global_flags.go | 40 ++- internal/pkg/testutils/parse_input.go | 9 + internal/pkg/testutils/testutils.go | 15 + 696 files changed, 1830 insertions(+), 2082 deletions(-) delete mode 100644 internal/pkg/flags/enum.go delete mode 100644 internal/pkg/flags/enumslice.go diff --git a/docs/stackit.md b/docs/stackit.md index 88f1a5707..e00b8b8ac 100644 --- a/docs/stackit.md +++ b/docs/stackit.md @@ -17,10 +17,10 @@ stackit [flags] -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously -h, --help Help for "stackit" - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") -v, --version Show "stackit" version ``` diff --git a/docs/stackit_affinity-group.md b/docs/stackit_affinity-group.md index 9603fe20f..62422e9ef 100644 --- a/docs/stackit_affinity-group.md +++ b/docs/stackit_affinity-group.md @@ -21,10 +21,10 @@ stackit affinity-group [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_affinity-group_create.md b/docs/stackit_affinity-group_create.md index fb63f39cf..8e42fd586 100644 --- a/docs/stackit_affinity-group_create.md +++ b/docs/stackit_affinity-group_create.md @@ -30,10 +30,10 @@ stackit affinity-group create [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_affinity-group_delete.md b/docs/stackit_affinity-group_delete.md index 4baa73768..511f768cd 100644 --- a/docs/stackit_affinity-group_delete.md +++ b/docs/stackit_affinity-group_delete.md @@ -28,10 +28,10 @@ stackit affinity-group delete AFFINITY_GROUP [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_affinity-group_describe.md b/docs/stackit_affinity-group_describe.md index 79276bba0..acee8ff04 100644 --- a/docs/stackit_affinity-group_describe.md +++ b/docs/stackit_affinity-group_describe.md @@ -28,10 +28,10 @@ stackit affinity-group describe AFFINITY_GROUP_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_affinity-group_list.md b/docs/stackit_affinity-group_list.md index ea96c20ac..439f90684 100644 --- a/docs/stackit_affinity-group_list.md +++ b/docs/stackit_affinity-group_list.md @@ -32,10 +32,10 @@ stackit affinity-group list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_auth.md b/docs/stackit_auth.md index 3f9406c46..708ec5d5a 100644 --- a/docs/stackit_auth.md +++ b/docs/stackit_auth.md @@ -21,10 +21,10 @@ stackit auth [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_auth_activate-service-account.md b/docs/stackit_auth_activate-service-account.md index 3d154ebfb..df85aa682 100644 --- a/docs/stackit_auth_activate-service-account.md +++ b/docs/stackit_auth_activate-service-account.md @@ -43,10 +43,10 @@ stackit auth activate-service-account [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_auth_get-access-token.md b/docs/stackit_auth_get-access-token.md index cc5218002..5e671612b 100644 --- a/docs/stackit_auth_get-access-token.md +++ b/docs/stackit_auth_get-access-token.md @@ -28,10 +28,10 @@ stackit auth get-access-token [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_auth_login.md b/docs/stackit_auth_login.md index 3cd888bd2..232c2cbe3 100644 --- a/docs/stackit_auth_login.md +++ b/docs/stackit_auth_login.md @@ -31,10 +31,10 @@ stackit auth login [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_auth_logout.md b/docs/stackit_auth_logout.md index 4361a9925..836cc92e7 100644 --- a/docs/stackit_auth_logout.md +++ b/docs/stackit_auth_logout.md @@ -28,10 +28,10 @@ stackit auth logout [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta.md b/docs/stackit_beta.md index d79fd6e9f..52221ace6 100644 --- a/docs/stackit_beta.md +++ b/docs/stackit_beta.md @@ -32,10 +32,10 @@ stackit beta [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_alb.md b/docs/stackit_beta_alb.md index a4e8d9866..d21262d78 100644 --- a/docs/stackit_beta_alb.md +++ b/docs/stackit_beta_alb.md @@ -21,10 +21,10 @@ stackit beta alb [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_alb_create.md b/docs/stackit_beta_alb_create.md index d33b66ab2..6133a5a7e 100644 --- a/docs/stackit_beta_alb_create.md +++ b/docs/stackit_beta_alb_create.md @@ -29,10 +29,10 @@ stackit beta alb create [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_alb_delete.md b/docs/stackit_beta_alb_delete.md index a83567e86..f4298611e 100644 --- a/docs/stackit_beta_alb_delete.md +++ b/docs/stackit_beta_alb_delete.md @@ -28,10 +28,10 @@ stackit beta alb delete LOADBALANCER_NAME_ARG [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_alb_describe.md b/docs/stackit_beta_alb_describe.md index 008ba874c..363446c6a 100644 --- a/docs/stackit_beta_alb_describe.md +++ b/docs/stackit_beta_alb_describe.md @@ -28,10 +28,10 @@ stackit beta alb describe LOADBALANCER_NAME_ARG [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_alb_list.md b/docs/stackit_beta_alb_list.md index 639b541dd..86d133543 100644 --- a/docs/stackit_beta_alb_list.md +++ b/docs/stackit_beta_alb_list.md @@ -32,10 +32,10 @@ stackit beta alb list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_alb_observability-credentials.md b/docs/stackit_beta_alb_observability-credentials.md index f704d001a..457c579c3 100644 --- a/docs/stackit_beta_alb_observability-credentials.md +++ b/docs/stackit_beta_alb_observability-credentials.md @@ -21,10 +21,10 @@ stackit beta alb observability-credentials [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_alb_observability-credentials_add.md b/docs/stackit_beta_alb_observability-credentials_add.md index c17dd31cb..3325a9e35 100644 --- a/docs/stackit_beta_alb_observability-credentials_add.md +++ b/docs/stackit_beta_alb_observability-credentials_add.md @@ -31,10 +31,10 @@ stackit beta alb observability-credentials add [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_alb_observability-credentials_delete.md b/docs/stackit_beta_alb_observability-credentials_delete.md index 8cdbdde27..d6aef99f9 100644 --- a/docs/stackit_beta_alb_observability-credentials_delete.md +++ b/docs/stackit_beta_alb_observability-credentials_delete.md @@ -28,10 +28,10 @@ stackit beta alb observability-credentials delete CREDENTIAL_REF [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_alb_observability-credentials_describe.md b/docs/stackit_beta_alb_observability-credentials_describe.md index 9eafb8d93..87399832c 100644 --- a/docs/stackit_beta_alb_observability-credentials_describe.md +++ b/docs/stackit_beta_alb_observability-credentials_describe.md @@ -28,10 +28,10 @@ stackit beta alb observability-credentials describe CREDENTIAL_REF [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_alb_observability-credentials_list.md b/docs/stackit_beta_alb_observability-credentials_list.md index 9a71757b2..0e09fd572 100644 --- a/docs/stackit_beta_alb_observability-credentials_list.md +++ b/docs/stackit_beta_alb_observability-credentials_list.md @@ -35,10 +35,10 @@ stackit beta alb observability-credentials list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_alb_observability-credentials_update.md b/docs/stackit_beta_alb_observability-credentials_update.md index 88666470f..df10c38b4 100644 --- a/docs/stackit_beta_alb_observability-credentials_update.md +++ b/docs/stackit_beta_alb_observability-credentials_update.md @@ -31,10 +31,10 @@ stackit beta alb observability-credentials update CREDENTIAL_REF_ARG [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_alb_plans.md b/docs/stackit_beta_alb_plans.md index 3e46e1185..322f9da33 100644 --- a/docs/stackit_beta_alb_plans.md +++ b/docs/stackit_beta_alb_plans.md @@ -28,10 +28,10 @@ stackit beta alb plans [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_alb_pool.md b/docs/stackit_beta_alb_pool.md index 1553d06bc..aa1adcdc8 100644 --- a/docs/stackit_beta_alb_pool.md +++ b/docs/stackit_beta_alb_pool.md @@ -21,10 +21,10 @@ stackit beta alb pool [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_alb_pool_update.md b/docs/stackit_beta_alb_pool_update.md index 717c7546e..5f54f5aa7 100644 --- a/docs/stackit_beta_alb_pool_update.md +++ b/docs/stackit_beta_alb_pool_update.md @@ -30,10 +30,10 @@ stackit beta alb pool update [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_alb_quotas.md b/docs/stackit_beta_alb_quotas.md index 26f9168ce..b02c5ebf4 100644 --- a/docs/stackit_beta_alb_quotas.md +++ b/docs/stackit_beta_alb_quotas.md @@ -28,10 +28,10 @@ stackit beta alb quotas [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_alb_template.md b/docs/stackit_beta_alb_template.md index e914e3024..d7576b11c 100644 --- a/docs/stackit_beta_alb_template.md +++ b/docs/stackit_beta_alb_template.md @@ -23,9 +23,9 @@ stackit beta alb template [flags] ### Options ``` - -f, --format string Defines the output format ('yaml' or 'json'), default is 'json' (default "json") + -f, --format string Defines the output format (one of: [json, yaml]) (default "json") -h, --help Help for "stackit beta alb template" - -t, --type string Defines the output type ('alb' or 'pool'), default is 'alb' (default "alb") + -t, --type string Defines the output type (one of: [alb, pool]) (default "alb") ``` ### Options inherited from parent commands @@ -33,10 +33,10 @@ stackit beta alb template [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_alb_update.md b/docs/stackit_beta_alb_update.md index 36c4a8dd7..e0daa7f31 100644 --- a/docs/stackit_beta_alb_update.md +++ b/docs/stackit_beta_alb_update.md @@ -29,10 +29,10 @@ stackit beta alb update [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_cdn.md b/docs/stackit_beta_cdn.md index b0a99f688..682968d9e 100644 --- a/docs/stackit_beta_cdn.md +++ b/docs/stackit_beta_cdn.md @@ -21,10 +21,10 @@ stackit beta cdn [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_cdn_distribution.md b/docs/stackit_beta_cdn_distribution.md index c9c26a931..3afc9949a 100644 --- a/docs/stackit_beta_cdn_distribution.md +++ b/docs/stackit_beta_cdn_distribution.md @@ -21,10 +21,10 @@ stackit beta cdn distribution [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_cdn_distribution_create.md b/docs/stackit_beta_cdn_distribution_create.md index d14f16f21..85fbc3c2a 100644 --- a/docs/stackit_beta_cdn_distribution_create.md +++ b/docs/stackit_beta_cdn_distribution_create.md @@ -50,7 +50,7 @@ stackit beta cdn distribution create [flags] --loki-username string Username for log sink --monthly-limit-bytes int Monthly limit in bytes for the CDN distribution --optimizer Enable optimizer for the CDN distribution (paid feature). - --regions strings Regions in which content should be cached, multiple of: ["EU" "US" "AF" "SA" "ASIA"] (default []) + --regions strings Regions in which content should be cached, multiple values accepted, (multiple of: [EU, US, AF, SA, ASIA]) (default []) ``` ### Options inherited from parent commands @@ -58,10 +58,10 @@ stackit beta cdn distribution create [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_cdn_distribution_delete.md b/docs/stackit_beta_cdn_distribution_delete.md index 7313b5a39..7b55d2012 100644 --- a/docs/stackit_beta_cdn_distribution_delete.md +++ b/docs/stackit_beta_cdn_distribution_delete.md @@ -28,10 +28,10 @@ stackit beta cdn distribution delete [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_cdn_distribution_describe.md b/docs/stackit_beta_cdn_distribution_describe.md index 1e8f68a7e..5f3959207 100644 --- a/docs/stackit_beta_cdn_distribution_describe.md +++ b/docs/stackit_beta_cdn_distribution_describe.md @@ -32,10 +32,10 @@ stackit beta cdn distribution describe [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_cdn_distribution_list.md b/docs/stackit_beta_cdn_distribution_list.md index 4fc5d2750..9c952b629 100644 --- a/docs/stackit_beta_cdn_distribution_list.md +++ b/docs/stackit_beta_cdn_distribution_list.md @@ -25,7 +25,7 @@ stackit beta cdn distribution list [flags] ``` -- int Limit the output to the first n elements -h, --help Help for "stackit beta cdn distribution list" - --sort-by string Sort entries by a specific field, one of ["id" "createdAt" "updatedAt" "originUrl" "status" "originUrlRelated"] (default "createdAt") + --sort-by string Sort entries by a specific field, (one of: [id, createdAt, updatedAt, originUrl, status, originUrlRelated]) (default "createdAt") ``` ### Options inherited from parent commands @@ -33,10 +33,10 @@ stackit beta cdn distribution list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_cdn_distribution_update.md b/docs/stackit_beta_cdn_distribution_update.md index b7e8de147..156741aad 100644 --- a/docs/stackit_beta_cdn_distribution_update.md +++ b/docs/stackit_beta_cdn_distribution_update.md @@ -39,7 +39,7 @@ stackit beta cdn distribution update [flags] --loki-username string Username for log sink --monthly-limit-bytes int Monthly limit in bytes for the CDN distribution --optimizer Enable optimizer for the CDN distribution (paid feature). - --regions strings Regions in which content should be cached, multiple of: ["EU" "US" "AF" "SA" "ASIA"] (default []) + --regions strings Regions in which content should be cached, (multiple of: [EU, US, AF, SA, ASIA]) (default []) ``` ### Options inherited from parent commands @@ -47,10 +47,10 @@ stackit beta cdn distribution update [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_edge-cloud.md b/docs/stackit_beta_edge-cloud.md index 161433446..399471609 100644 --- a/docs/stackit_beta_edge-cloud.md +++ b/docs/stackit_beta_edge-cloud.md @@ -21,10 +21,10 @@ stackit beta edge-cloud [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_edge-cloud_instance.md b/docs/stackit_beta_edge-cloud_instance.md index 853ac56f0..8f2098058 100644 --- a/docs/stackit_beta_edge-cloud_instance.md +++ b/docs/stackit_beta_edge-cloud_instance.md @@ -21,10 +21,10 @@ stackit beta edge-cloud instance [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_edge-cloud_instance_create.md b/docs/stackit_beta_edge-cloud_instance_create.md index 78c123ec1..fad42e2b0 100644 --- a/docs/stackit_beta_edge-cloud_instance_create.md +++ b/docs/stackit_beta_edge-cloud_instance_create.md @@ -31,10 +31,10 @@ stackit beta edge-cloud instance create [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_edge-cloud_instance_delete.md b/docs/stackit_beta_edge-cloud_instance_delete.md index b8aa5834d..20a900f8b 100644 --- a/docs/stackit_beta_edge-cloud_instance_delete.md +++ b/docs/stackit_beta_edge-cloud_instance_delete.md @@ -33,10 +33,10 @@ stackit beta edge-cloud instance delete [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_edge-cloud_instance_describe.md b/docs/stackit_beta_edge-cloud_instance_describe.md index 534bc9cf0..e7621706b 100644 --- a/docs/stackit_beta_edge-cloud_instance_describe.md +++ b/docs/stackit_beta_edge-cloud_instance_describe.md @@ -33,10 +33,10 @@ stackit beta edge-cloud instance describe [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_edge-cloud_instance_list.md b/docs/stackit_beta_edge-cloud_instance_list.md index e605d6f64..ab6a99842 100644 --- a/docs/stackit_beta_edge-cloud_instance_list.md +++ b/docs/stackit_beta_edge-cloud_instance_list.md @@ -32,10 +32,10 @@ stackit beta edge-cloud instance list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_edge-cloud_instance_update.md b/docs/stackit_beta_edge-cloud_instance_update.md index 9f3cb39b7..935ac1f07 100644 --- a/docs/stackit_beta_edge-cloud_instance_update.md +++ b/docs/stackit_beta_edge-cloud_instance_update.md @@ -38,10 +38,10 @@ stackit beta edge-cloud instance update [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_edge-cloud_kubeconfig.md b/docs/stackit_beta_edge-cloud_kubeconfig.md index be5078f00..8f875e404 100644 --- a/docs/stackit_beta_edge-cloud_kubeconfig.md +++ b/docs/stackit_beta_edge-cloud_kubeconfig.md @@ -21,10 +21,10 @@ stackit beta edge-cloud kubeconfig [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_edge-cloud_kubeconfig_create.md b/docs/stackit_beta_edge-cloud_kubeconfig_create.md index 2d9a5ad40..8627501f7 100644 --- a/docs/stackit_beta_edge-cloud_kubeconfig_create.md +++ b/docs/stackit_beta_edge-cloud_kubeconfig_create.md @@ -49,10 +49,10 @@ stackit beta edge-cloud kubeconfig create [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_edge-cloud_plans.md b/docs/stackit_beta_edge-cloud_plans.md index c58e5a8e1..cf92d0a42 100644 --- a/docs/stackit_beta_edge-cloud_plans.md +++ b/docs/stackit_beta_edge-cloud_plans.md @@ -21,10 +21,10 @@ stackit beta edge-cloud plans [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_edge-cloud_plans_list.md b/docs/stackit_beta_edge-cloud_plans_list.md index a57c7e197..8caba32ba 100644 --- a/docs/stackit_beta_edge-cloud_plans_list.md +++ b/docs/stackit_beta_edge-cloud_plans_list.md @@ -32,10 +32,10 @@ stackit beta edge-cloud plans list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_edge-cloud_token.md b/docs/stackit_beta_edge-cloud_token.md index ba7fe0b3a..a6061a060 100644 --- a/docs/stackit_beta_edge-cloud_token.md +++ b/docs/stackit_beta_edge-cloud_token.md @@ -21,10 +21,10 @@ stackit beta edge-cloud token [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_edge-cloud_token_create.md b/docs/stackit_beta_edge-cloud_token_create.md index 4d96d548c..139fa20d0 100644 --- a/docs/stackit_beta_edge-cloud_token_create.md +++ b/docs/stackit_beta_edge-cloud_token_create.md @@ -37,10 +37,10 @@ stackit beta edge-cloud token create [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_intake.md b/docs/stackit_beta_intake.md index fa29e493f..cf8770f31 100644 --- a/docs/stackit_beta_intake.md +++ b/docs/stackit_beta_intake.md @@ -21,10 +21,10 @@ stackit beta intake [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_intake_create.md b/docs/stackit_beta_intake_create.md index 58e872d10..9057ff00b 100644 --- a/docs/stackit_beta_intake_create.md +++ b/docs/stackit_beta_intake_create.md @@ -47,10 +47,10 @@ stackit beta intake create [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_intake_delete.md b/docs/stackit_beta_intake_delete.md index 305b81f90..6d6308b54 100644 --- a/docs/stackit_beta_intake_delete.md +++ b/docs/stackit_beta_intake_delete.md @@ -28,10 +28,10 @@ stackit beta intake delete INTAKE_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_intake_describe.md b/docs/stackit_beta_intake_describe.md index 9d13cc023..837e3906d 100644 --- a/docs/stackit_beta_intake_describe.md +++ b/docs/stackit_beta_intake_describe.md @@ -31,10 +31,10 @@ stackit beta intake describe INTAKE_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_intake_list.md b/docs/stackit_beta_intake_list.md index 5086a65fe..3a0fd8332 100644 --- a/docs/stackit_beta_intake_list.md +++ b/docs/stackit_beta_intake_list.md @@ -35,10 +35,10 @@ stackit beta intake list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_intake_runner.md b/docs/stackit_beta_intake_runner.md index 7d5c60ff3..222ba1437 100644 --- a/docs/stackit_beta_intake_runner.md +++ b/docs/stackit_beta_intake_runner.md @@ -21,10 +21,10 @@ stackit beta intake runner [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_intake_runner_create.md b/docs/stackit_beta_intake_runner_create.md index c38cce74c..0043ced1d 100644 --- a/docs/stackit_beta_intake_runner_create.md +++ b/docs/stackit_beta_intake_runner_create.md @@ -36,10 +36,10 @@ stackit beta intake runner create [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_intake_runner_delete.md b/docs/stackit_beta_intake_runner_delete.md index c97d388cd..ac87d1c08 100644 --- a/docs/stackit_beta_intake_runner_delete.md +++ b/docs/stackit_beta_intake_runner_delete.md @@ -32,10 +32,10 @@ stackit beta intake runner delete RUNNER_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_intake_runner_describe.md b/docs/stackit_beta_intake_runner_describe.md index 11814b10d..234247d43 100644 --- a/docs/stackit_beta_intake_runner_describe.md +++ b/docs/stackit_beta_intake_runner_describe.md @@ -31,10 +31,10 @@ stackit beta intake runner describe RUNNER_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_intake_runner_list.md b/docs/stackit_beta_intake_runner_list.md index aaf5c9e59..10a5f4d71 100644 --- a/docs/stackit_beta_intake_runner_list.md +++ b/docs/stackit_beta_intake_runner_list.md @@ -35,10 +35,10 @@ stackit beta intake runner list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_intake_runner_update.md b/docs/stackit_beta_intake_runner_update.md index 007a1aaf8..222c207f4 100644 --- a/docs/stackit_beta_intake_runner_update.md +++ b/docs/stackit_beta_intake_runner_update.md @@ -36,10 +36,10 @@ stackit beta intake runner update RUNNER_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_intake_update.md b/docs/stackit_beta_intake_update.md index 3b36ac0b7..167ff47a3 100644 --- a/docs/stackit_beta_intake_update.md +++ b/docs/stackit_beta_intake_update.md @@ -42,10 +42,10 @@ stackit beta intake update INTAKE_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_intake_user.md b/docs/stackit_beta_intake_user.md index a09b51fb1..229a9e659 100644 --- a/docs/stackit_beta_intake_user.md +++ b/docs/stackit_beta_intake_user.md @@ -21,10 +21,10 @@ stackit beta intake user [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_intake_user_create.md b/docs/stackit_beta_intake_user_create.md index 0912dfaaa..fd7b6a93f 100644 --- a/docs/stackit_beta_intake_user_create.md +++ b/docs/stackit_beta_intake_user_create.md @@ -37,10 +37,10 @@ stackit beta intake user create [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_intake_user_delete.md b/docs/stackit_beta_intake_user_delete.md index cf6fad990..3a748f34d 100644 --- a/docs/stackit_beta_intake_user_delete.md +++ b/docs/stackit_beta_intake_user_delete.md @@ -29,10 +29,10 @@ stackit beta intake user delete USER_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_intake_user_describe.md b/docs/stackit_beta_intake_user_describe.md index 18f04e693..ff7b04f0f 100644 --- a/docs/stackit_beta_intake_user_describe.md +++ b/docs/stackit_beta_intake_user_describe.md @@ -32,10 +32,10 @@ stackit beta intake user describe USER_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_intake_user_list.md b/docs/stackit_beta_intake_user_list.md index b1a25a14a..4ff4a4ad8 100644 --- a/docs/stackit_beta_intake_user_list.md +++ b/docs/stackit_beta_intake_user_list.md @@ -36,10 +36,10 @@ stackit beta intake user list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_intake_user_update.md b/docs/stackit_beta_intake_user_update.md index 6df5dafd2..c33b57d06 100644 --- a/docs/stackit_beta_intake_user_update.md +++ b/docs/stackit_beta_intake_user_update.md @@ -37,10 +37,10 @@ stackit beta intake user update USER_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_sfs.md b/docs/stackit_beta_sfs.md index 2444ee5ab..09ab6238c 100644 --- a/docs/stackit_beta_sfs.md +++ b/docs/stackit_beta_sfs.md @@ -21,10 +21,10 @@ stackit beta sfs [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_sfs_export-policy.md b/docs/stackit_beta_sfs_export-policy.md index cc51bb921..1ddb33704 100644 --- a/docs/stackit_beta_sfs_export-policy.md +++ b/docs/stackit_beta_sfs_export-policy.md @@ -21,10 +21,10 @@ stackit beta sfs export-policy [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_sfs_export-policy_create.md b/docs/stackit_beta_sfs_export-policy_create.md index d226921bb..94e9117ff 100644 --- a/docs/stackit_beta_sfs_export-policy_create.md +++ b/docs/stackit_beta_sfs_export-policy_create.md @@ -33,10 +33,10 @@ stackit beta sfs export-policy create [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_sfs_export-policy_delete.md b/docs/stackit_beta_sfs_export-policy_delete.md index 51d5c74d6..3209a00ed 100644 --- a/docs/stackit_beta_sfs_export-policy_delete.md +++ b/docs/stackit_beta_sfs_export-policy_delete.md @@ -28,10 +28,10 @@ stackit beta sfs export-policy delete EXPORT_POLICY_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_sfs_export-policy_describe.md b/docs/stackit_beta_sfs_export-policy_describe.md index b6d327299..43f1e4618 100644 --- a/docs/stackit_beta_sfs_export-policy_describe.md +++ b/docs/stackit_beta_sfs_export-policy_describe.md @@ -28,10 +28,10 @@ stackit beta sfs export-policy describe EXPORT_POLICY_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_sfs_export-policy_list.md b/docs/stackit_beta_sfs_export-policy_list.md index 0611395c7..7d9fb3cd4 100644 --- a/docs/stackit_beta_sfs_export-policy_list.md +++ b/docs/stackit_beta_sfs_export-policy_list.md @@ -32,10 +32,10 @@ stackit beta sfs export-policy list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_sfs_export-policy_update.md b/docs/stackit_beta_sfs_export-policy_update.md index e610996f9..e7317bc3e 100644 --- a/docs/stackit_beta_sfs_export-policy_update.md +++ b/docs/stackit_beta_sfs_export-policy_update.md @@ -33,10 +33,10 @@ stackit beta sfs export-policy update EXPORT_POLICY_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_sfs_performance-class.md b/docs/stackit_beta_sfs_performance-class.md index cd7dc2763..183a5a4af 100644 --- a/docs/stackit_beta_sfs_performance-class.md +++ b/docs/stackit_beta_sfs_performance-class.md @@ -21,10 +21,10 @@ stackit beta sfs performance-class [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_sfs_performance-class_list.md b/docs/stackit_beta_sfs_performance-class_list.md index 14c264a8a..b2289b77a 100644 --- a/docs/stackit_beta_sfs_performance-class_list.md +++ b/docs/stackit_beta_sfs_performance-class_list.md @@ -28,10 +28,10 @@ stackit beta sfs performance-class list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_sfs_project-lock.md b/docs/stackit_beta_sfs_project-lock.md index d2e769a6f..7cf93b099 100644 --- a/docs/stackit_beta_sfs_project-lock.md +++ b/docs/stackit_beta_sfs_project-lock.md @@ -21,10 +21,10 @@ stackit beta sfs project-lock [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_sfs_project-lock_describe.md b/docs/stackit_beta_sfs_project-lock_describe.md index eb3713cbc..aac9b0d32 100644 --- a/docs/stackit_beta_sfs_project-lock_describe.md +++ b/docs/stackit_beta_sfs_project-lock_describe.md @@ -28,10 +28,10 @@ stackit beta sfs project-lock describe [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_sfs_project-lock_lock.md b/docs/stackit_beta_sfs_project-lock_lock.md index 9cdbcf402..e2d61b91a 100644 --- a/docs/stackit_beta_sfs_project-lock_lock.md +++ b/docs/stackit_beta_sfs_project-lock_lock.md @@ -28,10 +28,10 @@ stackit beta sfs project-lock lock [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_sfs_project-lock_unlock.md b/docs/stackit_beta_sfs_project-lock_unlock.md index c3673f51d..778204f42 100644 --- a/docs/stackit_beta_sfs_project-lock_unlock.md +++ b/docs/stackit_beta_sfs_project-lock_unlock.md @@ -28,10 +28,10 @@ stackit beta sfs project-lock unlock [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_sfs_resource-pool.md b/docs/stackit_beta_sfs_resource-pool.md index 425fa76a2..d74e254a0 100644 --- a/docs/stackit_beta_sfs_resource-pool.md +++ b/docs/stackit_beta_sfs_resource-pool.md @@ -21,10 +21,10 @@ stackit beta sfs resource-pool [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_sfs_resource-pool_create.md b/docs/stackit_beta_sfs_resource-pool_create.md index 4c0e9ada1..9c5b95b89 100644 --- a/docs/stackit_beta_sfs_resource-pool_create.md +++ b/docs/stackit_beta_sfs_resource-pool_create.md @@ -50,10 +50,10 @@ stackit beta sfs resource-pool create [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_sfs_resource-pool_delete.md b/docs/stackit_beta_sfs_resource-pool_delete.md index 97c52a8ae..79e109c8d 100644 --- a/docs/stackit_beta_sfs_resource-pool_delete.md +++ b/docs/stackit_beta_sfs_resource-pool_delete.md @@ -28,10 +28,10 @@ stackit beta sfs resource-pool delete [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_sfs_resource-pool_describe.md b/docs/stackit_beta_sfs_resource-pool_describe.md index 9b04e42bb..5543271b8 100644 --- a/docs/stackit_beta_sfs_resource-pool_describe.md +++ b/docs/stackit_beta_sfs_resource-pool_describe.md @@ -28,10 +28,10 @@ stackit beta sfs resource-pool describe [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_sfs_resource-pool_list.md b/docs/stackit_beta_sfs_resource-pool_list.md index 103d9cc47..f8f710fb3 100644 --- a/docs/stackit_beta_sfs_resource-pool_list.md +++ b/docs/stackit_beta_sfs_resource-pool_list.md @@ -35,10 +35,10 @@ stackit beta sfs resource-pool list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_sfs_resource-pool_update.md b/docs/stackit_beta_sfs_resource-pool_update.md index 7738e0e5c..a6e293e82 100644 --- a/docs/stackit_beta_sfs_resource-pool_update.md +++ b/docs/stackit_beta_sfs_resource-pool_update.md @@ -48,10 +48,10 @@ stackit beta sfs resource-pool update [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_sfs_share.md b/docs/stackit_beta_sfs_share.md index e0b76d63e..7c2f4dd72 100644 --- a/docs/stackit_beta_sfs_share.md +++ b/docs/stackit_beta_sfs_share.md @@ -21,10 +21,10 @@ stackit beta sfs share [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_sfs_share_create.md b/docs/stackit_beta_sfs_share_create.md index f59b25b1c..8e06f59fe 100644 --- a/docs/stackit_beta_sfs_share_create.md +++ b/docs/stackit_beta_sfs_share_create.md @@ -35,10 +35,10 @@ stackit beta sfs share create [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_sfs_share_delete.md b/docs/stackit_beta_sfs_share_delete.md index f669a175e..2008d2343 100644 --- a/docs/stackit_beta_sfs_share_delete.md +++ b/docs/stackit_beta_sfs_share_delete.md @@ -29,10 +29,10 @@ stackit beta sfs share delete SHARE_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_sfs_share_describe.md b/docs/stackit_beta_sfs_share_describe.md index a303e263a..8c4a982a8 100644 --- a/docs/stackit_beta_sfs_share_describe.md +++ b/docs/stackit_beta_sfs_share_describe.md @@ -29,10 +29,10 @@ stackit beta sfs share describe SHARE_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_sfs_share_list.md b/docs/stackit_beta_sfs_share_list.md index b100d94fc..d547e5f29 100644 --- a/docs/stackit_beta_sfs_share_list.md +++ b/docs/stackit_beta_sfs_share_list.md @@ -33,10 +33,10 @@ stackit beta sfs share list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_sfs_share_update.md b/docs/stackit_beta_sfs_share_update.md index 8af76527d..b07168083 100644 --- a/docs/stackit_beta_sfs_share_update.md +++ b/docs/stackit_beta_sfs_share_update.md @@ -34,10 +34,10 @@ stackit beta sfs share update SHARE_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_sfs_snapshot-policy.md b/docs/stackit_beta_sfs_snapshot-policy.md index af7be8d24..dbb461462 100644 --- a/docs/stackit_beta_sfs_snapshot-policy.md +++ b/docs/stackit_beta_sfs_snapshot-policy.md @@ -21,10 +21,10 @@ stackit beta sfs snapshot-policy [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_sfs_snapshot-policy_describe.md b/docs/stackit_beta_sfs_snapshot-policy_describe.md index c2a751fcc..0354fe982 100644 --- a/docs/stackit_beta_sfs_snapshot-policy_describe.md +++ b/docs/stackit_beta_sfs_snapshot-policy_describe.md @@ -28,10 +28,10 @@ stackit beta sfs snapshot-policy describe SNAPSHOT_POLICY_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_sfs_snapshot-policy_list.md b/docs/stackit_beta_sfs_snapshot-policy_list.md index 4f773705c..474ee9a91 100644 --- a/docs/stackit_beta_sfs_snapshot-policy_list.md +++ b/docs/stackit_beta_sfs_snapshot-policy_list.md @@ -30,7 +30,7 @@ stackit beta sfs snapshot-policy list [flags] ``` -h, --help Help for "stackit beta sfs snapshot-policy list" - --immutable string Immutable snapshot policy, one of ["all" "immutable-only" "mutable-only"] (default "all") + --immutable string Immutable snapshot policy, (one of: [all, immutable-only, mutable-only]) (default "all") --limit int Maximum number of entries to list ``` @@ -39,10 +39,10 @@ stackit beta sfs snapshot-policy list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_sfs_snapshot.md b/docs/stackit_beta_sfs_snapshot.md index 4428dd9b8..f9f5cc3e7 100644 --- a/docs/stackit_beta_sfs_snapshot.md +++ b/docs/stackit_beta_sfs_snapshot.md @@ -21,10 +21,10 @@ stackit beta sfs snapshot [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_sfs_snapshot_create.md b/docs/stackit_beta_sfs_snapshot_create.md index 4d1bc519b..a9dfb5dd0 100644 --- a/docs/stackit_beta_sfs_snapshot_create.md +++ b/docs/stackit_beta_sfs_snapshot_create.md @@ -38,10 +38,10 @@ stackit beta sfs snapshot create [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_sfs_snapshot_delete.md b/docs/stackit_beta_sfs_snapshot_delete.md index 286d98e28..865a107fa 100644 --- a/docs/stackit_beta_sfs_snapshot_delete.md +++ b/docs/stackit_beta_sfs_snapshot_delete.md @@ -29,10 +29,10 @@ stackit beta sfs snapshot delete SNAPSHOT_NAME [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_sfs_snapshot_describe.md b/docs/stackit_beta_sfs_snapshot_describe.md index a12e42dd7..2cfeaf8be 100644 --- a/docs/stackit_beta_sfs_snapshot_describe.md +++ b/docs/stackit_beta_sfs_snapshot_describe.md @@ -29,10 +29,10 @@ stackit beta sfs snapshot describe SNAPSHOT_NAME [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_sfs_snapshot_list.md b/docs/stackit_beta_sfs_snapshot_list.md index 4c8b0c986..99fd96c39 100644 --- a/docs/stackit_beta_sfs_snapshot_list.md +++ b/docs/stackit_beta_sfs_snapshot_list.md @@ -30,10 +30,10 @@ stackit beta sfs snapshot list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_sfs_snapshot_update.md b/docs/stackit_beta_sfs_snapshot_update.md index 3d59f9513..a325cb178 100644 --- a/docs/stackit_beta_sfs_snapshot_update.md +++ b/docs/stackit_beta_sfs_snapshot_update.md @@ -34,10 +34,10 @@ stackit beta sfs snapshot update SNAPSHOT_NAME [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_sqlserverflex.md b/docs/stackit_beta_sqlserverflex.md index 1e630a067..88f836410 100644 --- a/docs/stackit_beta_sqlserverflex.md +++ b/docs/stackit_beta_sqlserverflex.md @@ -21,10 +21,10 @@ stackit beta sqlserverflex [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_sqlserverflex_database.md b/docs/stackit_beta_sqlserverflex_database.md index 19a1d9052..a0cd73855 100644 --- a/docs/stackit_beta_sqlserverflex_database.md +++ b/docs/stackit_beta_sqlserverflex_database.md @@ -21,10 +21,10 @@ stackit beta sqlserverflex database [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_sqlserverflex_database_create.md b/docs/stackit_beta_sqlserverflex_database_create.md index a34712040..ea1e13797 100644 --- a/docs/stackit_beta_sqlserverflex_database_create.md +++ b/docs/stackit_beta_sqlserverflex_database_create.md @@ -31,10 +31,10 @@ stackit beta sqlserverflex database create DATABASE_NAME [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_sqlserverflex_database_delete.md b/docs/stackit_beta_sqlserverflex_database_delete.md index ebd5ab0a1..343c22956 100644 --- a/docs/stackit_beta_sqlserverflex_database_delete.md +++ b/docs/stackit_beta_sqlserverflex_database_delete.md @@ -30,10 +30,10 @@ stackit beta sqlserverflex database delete DATABASE_NAME [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_sqlserverflex_database_describe.md b/docs/stackit_beta_sqlserverflex_database_describe.md index 290284e23..07262c6e1 100644 --- a/docs/stackit_beta_sqlserverflex_database_describe.md +++ b/docs/stackit_beta_sqlserverflex_database_describe.md @@ -32,10 +32,10 @@ stackit beta sqlserverflex database describe DATABASE_NAME [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_sqlserverflex_database_list.md b/docs/stackit_beta_sqlserverflex_database_list.md index 73797c240..044800699 100644 --- a/docs/stackit_beta_sqlserverflex_database_list.md +++ b/docs/stackit_beta_sqlserverflex_database_list.md @@ -36,10 +36,10 @@ stackit beta sqlserverflex database list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_sqlserverflex_instance.md b/docs/stackit_beta_sqlserverflex_instance.md index 5ab816add..227b3a487 100644 --- a/docs/stackit_beta_sqlserverflex_instance.md +++ b/docs/stackit_beta_sqlserverflex_instance.md @@ -21,10 +21,10 @@ stackit beta sqlserverflex instance [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_sqlserverflex_instance_create.md b/docs/stackit_beta_sqlserverflex_instance_create.md index bc101f06a..002538b2f 100644 --- a/docs/stackit_beta_sqlserverflex_instance_create.md +++ b/docs/stackit_beta_sqlserverflex_instance_create.md @@ -46,10 +46,10 @@ stackit beta sqlserverflex instance create [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_sqlserverflex_instance_delete.md b/docs/stackit_beta_sqlserverflex_instance_delete.md index 548bfb952..1e4d05649 100644 --- a/docs/stackit_beta_sqlserverflex_instance_delete.md +++ b/docs/stackit_beta_sqlserverflex_instance_delete.md @@ -28,10 +28,10 @@ stackit beta sqlserverflex instance delete INSTANCE_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_sqlserverflex_instance_describe.md b/docs/stackit_beta_sqlserverflex_instance_describe.md index 42e6a2e3d..5f1ab6ed4 100644 --- a/docs/stackit_beta_sqlserverflex_instance_describe.md +++ b/docs/stackit_beta_sqlserverflex_instance_describe.md @@ -31,10 +31,10 @@ stackit beta sqlserverflex instance describe INSTANCE_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_sqlserverflex_instance_list.md b/docs/stackit_beta_sqlserverflex_instance_list.md index 133a1836d..c6ffaaaf1 100644 --- a/docs/stackit_beta_sqlserverflex_instance_list.md +++ b/docs/stackit_beta_sqlserverflex_instance_list.md @@ -35,10 +35,10 @@ stackit beta sqlserverflex instance list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_sqlserverflex_instance_update.md b/docs/stackit_beta_sqlserverflex_instance_update.md index 39f8b672d..b4d901af3 100644 --- a/docs/stackit_beta_sqlserverflex_instance_update.md +++ b/docs/stackit_beta_sqlserverflex_instance_update.md @@ -38,10 +38,10 @@ stackit beta sqlserverflex instance update INSTANCE_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_sqlserverflex_options.md b/docs/stackit_beta_sqlserverflex_options.md index b7035249e..8caf2ad97 100644 --- a/docs/stackit_beta_sqlserverflex_options.md +++ b/docs/stackit_beta_sqlserverflex_options.md @@ -46,10 +46,10 @@ stackit beta sqlserverflex options [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_sqlserverflex_user.md b/docs/stackit_beta_sqlserverflex_user.md index b922dba2a..d0c71e9d7 100644 --- a/docs/stackit_beta_sqlserverflex_user.md +++ b/docs/stackit_beta_sqlserverflex_user.md @@ -21,10 +21,10 @@ stackit beta sqlserverflex user [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_sqlserverflex_user_create.md b/docs/stackit_beta_sqlserverflex_user_create.md index 47aa6a5e3..5ddc1ad26 100644 --- a/docs/stackit_beta_sqlserverflex_user_create.md +++ b/docs/stackit_beta_sqlserverflex_user_create.md @@ -42,10 +42,10 @@ stackit beta sqlserverflex user create [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_sqlserverflex_user_delete.md b/docs/stackit_beta_sqlserverflex_user_delete.md index 9ec1d1581..78a9ade81 100644 --- a/docs/stackit_beta_sqlserverflex_user_delete.md +++ b/docs/stackit_beta_sqlserverflex_user_delete.md @@ -30,10 +30,10 @@ stackit beta sqlserverflex user delete USER_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_sqlserverflex_user_describe.md b/docs/stackit_beta_sqlserverflex_user_describe.md index b4499f2fa..b62e40039 100644 --- a/docs/stackit_beta_sqlserverflex_user_describe.md +++ b/docs/stackit_beta_sqlserverflex_user_describe.md @@ -34,10 +34,10 @@ stackit beta sqlserverflex user describe USER_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_sqlserverflex_user_list.md b/docs/stackit_beta_sqlserverflex_user_list.md index 5a7b79d61..616cd0a74 100644 --- a/docs/stackit_beta_sqlserverflex_user_list.md +++ b/docs/stackit_beta_sqlserverflex_user_list.md @@ -36,10 +36,10 @@ stackit beta sqlserverflex user list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_sqlserverflex_user_reset-password.md b/docs/stackit_beta_sqlserverflex_user_reset-password.md index 210e885bc..feb99fd6a 100644 --- a/docs/stackit_beta_sqlserverflex_user_reset-password.md +++ b/docs/stackit_beta_sqlserverflex_user_reset-password.md @@ -30,10 +30,10 @@ stackit beta sqlserverflex user reset-password USER_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_vpn.md b/docs/stackit_beta_vpn.md index c15583893..861daa4dd 100644 --- a/docs/stackit_beta_vpn.md +++ b/docs/stackit_beta_vpn.md @@ -21,10 +21,10 @@ stackit beta vpn [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_vpn_connection.md b/docs/stackit_beta_vpn_connection.md index 033fbf7bd..2385727d5 100644 --- a/docs/stackit_beta_vpn_connection.md +++ b/docs/stackit_beta_vpn_connection.md @@ -21,10 +21,10 @@ stackit beta vpn connection [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_vpn_connection_create.md b/docs/stackit_beta_vpn_connection_create.md index 1525fd345..221fbb822 100644 --- a/docs/stackit_beta_vpn_connection_create.md +++ b/docs/stackit_beta_vpn_connection_create.md @@ -34,20 +34,20 @@ stackit beta vpn connection create [flags] The peering object defines the point-to-point IP configuration for the Tunnel Interface. These addresses serve as next-hop identifiers and are used for BGP peering sessions and can be used in Static Route-Based connectivity. --tunnel1-peering-remote-address string Tunnel 1 Peering Remote Address --tunnel1-phase1-dh-groups strings Tunnel 1 Phase 1 DH Groups. - The Diffie-Hellman Group. Required, except if AEAD algorithms are selected. (possible values: [modp1024, modp2048, ecp256, ecp384, modp2048s256]) (default []) - --tunnel1-phase1-encryption-algorithms strings Required: Tunnel 1 Phase 1 Encryption Algorithms (possible values: [aes256, aes128gcm16, aes256gcm16]) (default []) - --tunnel1-phase1-integrity-algorithms strings Required: Tunnel 1 Phase 1 Integrity Algorithms (possible values: [sha1, sha2_256, sha2_384]) (default []) + The Diffie-Hellman Group. Required, except if AEAD algorithms are selected. (multiple of: [modp1024, modp2048, ecp256, ecp384, modp2048s256]) (default []) + --tunnel1-phase1-encryption-algorithms strings Required: Tunnel 1 Phase 1 Encryption Algorithms (multiple of: [aes256, aes128gcm16, aes256gcm16]) (default []) + --tunnel1-phase1-integrity-algorithms strings Required: Tunnel 1 Phase 1 Integrity Algorithms (multiple of: [sha1, sha2_256, sha2_384]) (default []) --tunnel1-phase1-rekey-time int Tunnel 1 Phase 1 Rekey Time. Time to schedule a IKE re-keying (in seconds). - --tunnel1-phase2-dh-groups strings Tunnel 1 Phase 2 DH Groups (possible values: [modp1024, modp2048, ecp256, ecp384, modp2048s256]) (default []) + --tunnel1-phase2-dh-groups strings Tunnel 1 Phase 2 DH Groups (multiple of: [modp1024, modp2048, ecp256, ecp384, modp2048s256]) (default []) --tunnel1-phase2-dpd-action string Tunnel 1 Phase 2 DPD Action. - Action to perform for this CHILD_SA on DPD timeout. "clear": Closes the CHILD_SA and does not take further action. "restart": immediately tries to re-negotiate the CILD_SA under a fresh IKE_SA. (possible values: [clear, restart]) - --tunnel1-phase2-encryption-algorithms strings Required: Tunnel 1 Phase 2 Encryption Algorithms (possible values: [aes256, aes128gcm16, aes256gcm16]) (default []) - --tunnel1-phase2-integrity-algorithms strings Required: Tunnel 1 Phase 2 Integrity Algorithms (possible values: [sha1, sha2_256, sha2_384]) (default []) + Action to perform for this CHILD_SA on DPD timeout. "clear": Closes the CHILD_SA and does not take further action. "restart": immediately tries to re-negotiate the CILD_SA under a fresh IKE_SA. (one of: [clear, restart]) + --tunnel1-phase2-encryption-algorithms strings Required: Tunnel 1 Phase 2 Encryption Algorithms (multiple of: [aes256, aes128gcm16, aes256gcm16]) (default []) + --tunnel1-phase2-integrity-algorithms strings Required: Tunnel 1 Phase 2 Integrity Algorithms (multiple of: [sha1, sha2_256, sha2_384]) (default []) --tunnel1-phase2-rekey-time int Tunnel 1 Phase 2 Rekey Time. Time to schedule a Child SA re-keying (in seconds). --tunnel1-phase2-start-action string Tunnel 1 Phase 2 Start Action. - Action to perform after loading the connection configuration. "none": The connection will be loaded but needs to be manually initiated. "start": initiates the connection actively. (possible values: [none, start]) + Action to perform after loading the connection configuration. "none": The connection will be loaded but needs to be manually initiated. "start": initiates the connection actively. (one of: [none, start]) --tunnel1-pre-shared-key string Required: Tunnel 1 Pre Shared Key. A Pre-Shared Key for authentication. Required in create-requests, optional in update-requests and omitted in every response. --tunnel1-remote-address string Tunnel 1 Remote Address @@ -56,22 +56,22 @@ stackit beta vpn connection create [flags] The peering object defines the point-to-point IP configuration for the Tunnel Interface. These addresses serve as next-hop identifiers and are used for BGP peering sessions and can be used in Static Route-Based connectivity. --tunnel2-peering-remote-address string Tunnel 2 Peering Remote Address --tunnel2-phase1-dh-groups strings Tunnel 2 Phase 1 DH Groups - The Diffie-Hellman Group. Required, except if AEAD algorithms are selected. (possible values: [modp1024, modp2048, ecp256, ecp384, modp2048s256]) (default []) - --tunnel2-phase1-encryption-algorithms strings Required: Tunnel 2 Phase 1 Encryption Algorithms (possible values: [aes256, aes128gcm16, aes256gcm16]) (default []) - --tunnel2-phase1-integrity-algorithms strings Required: Tunnel 2 Phase 1 Integrity Algorithms (possible values: [sha1, sha2_256, sha2_384]) (default []) + The Diffie-Hellman Group. Required, except if AEAD algorithms are selected. (multiple of: [modp1024, modp2048, ecp256, ecp384, modp2048s256]) (default []) + --tunnel2-phase1-encryption-algorithms strings Required: Tunnel 2 Phase 1 Encryption Algorithms (multiple of: [aes256, aes128gcm16, aes256gcm16]) (default []) + --tunnel2-phase1-integrity-algorithms strings Required: Tunnel 2 Phase 1 Integrity Algorithms (multiple of: [sha1, sha2_256, sha2_384]) (default []) --tunnel2-phase1-rekey-time int Tunnel 2 Phase 1 Rekey Time. Time to schedule a IKE re-keying (in seconds). - --tunnel2-phase2-dh-groups strings Tunnel 2 Phase 2 DH Groups (possible values: [modp1024, modp2048, ecp256, ecp384, modp2048s256]) (default []) + --tunnel2-phase2-dh-groups strings Tunnel 2 Phase 2 DH Groups (multiple of: [modp1024, modp2048, ecp256, ecp384, modp2048s256]) (default []) --tunnel2-phase2-dpd-action string Tunnel 2 Phase 2 DPD Action. - Action to perform for this CHILD_SA on DPD timeout. "clear": Closes the CHILD_SA and does not take further action. "restart": immediately tries to re-negotiate the CILD_SA under a fresh IKE_SA. (possible values: [clear, restart]) - --tunnel2-phase2-encryption-algorithms strings Required: Tunnel 2 Phase 2 Encryption Algorithms (possible values: [aes256, aes128gcm16, aes256gcm16]) (default []) - --tunnel2-phase2-integrity-algorithms strings Required: Tunnel 2 Phase 2 Integrity Algorithms (possible values: [sha1, sha2_256, sha2_384]) (default []) + Action to perform for this CHILD_SA on DPD timeout. "clear": Closes the CHILD_SA and does not take further action. "restart": immediately tries to re-negotiate the CILD_SA under a fresh IKE_SA. (one of: [clear, restart]) + --tunnel2-phase2-encryption-algorithms strings Required: Tunnel 2 Phase 2 Encryption Algorithms (multiple of: [aes256, aes128gcm16, aes256gcm16]) (default []) + --tunnel2-phase2-integrity-algorithms strings Required: Tunnel 2 Phase 2 Integrity Algorithms (multiple of: [sha1, sha2_256, sha2_384]) (default []) --tunnel2-phase2-rekey-time int Tunnel 2 Phase 2 Rekey Time. Time to schedule a Child SA re-keying (in seconds). --tunnel2-phase2-start-action string Tunnel 2 Phase 2 Start Action. Default: "start" Enum: "none" "start" - Action to perform after loading the connection configuration. "none": The connection will be loaded but needs to be manually initiated. "start": initiates the connection actively. (possible values: [none, start]) + Action to perform after loading the connection configuration. "none": The connection will be loaded but needs to be manually initiated. "start": initiates the connection actively. (one of: [none, start]) --tunnel2-pre-shared-key string Required: Tunnel 2 Pre Shared Key. A Pre-Shared Key for authentication. Required in create-requests, optional in update-requests and omitted in every response. --tunnel2-remote-address string Tunnel 2 Remote Address @@ -82,10 +82,10 @@ stackit beta vpn connection create [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_vpn_connection_delete.md b/docs/stackit_beta_vpn_connection_delete.md index 724c0f42a..b66d0dc2f 100644 --- a/docs/stackit_beta_vpn_connection_delete.md +++ b/docs/stackit_beta_vpn_connection_delete.md @@ -29,10 +29,10 @@ stackit beta vpn connection delete CONNECTION_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_vpn_connection_describe.md b/docs/stackit_beta_vpn_connection_describe.md index ddfb63f1c..dc1ddd391 100644 --- a/docs/stackit_beta_vpn_connection_describe.md +++ b/docs/stackit_beta_vpn_connection_describe.md @@ -29,10 +29,10 @@ stackit beta vpn connection describe CONNECTION_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_vpn_connection_list.md b/docs/stackit_beta_vpn_connection_list.md index 6f5bff9bb..bf1b935ba 100644 --- a/docs/stackit_beta_vpn_connection_list.md +++ b/docs/stackit_beta_vpn_connection_list.md @@ -29,10 +29,10 @@ stackit beta vpn connection list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_beta_vpn_connection_status.md b/docs/stackit_beta_vpn_connection_status.md index a3325b019..8137de7ef 100644 --- a/docs/stackit_beta_vpn_connection_status.md +++ b/docs/stackit_beta_vpn_connection_status.md @@ -29,10 +29,10 @@ stackit beta vpn connection status CONNECTION_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_config.md b/docs/stackit_config.md index 664b5dcd7..e97811c2b 100644 --- a/docs/stackit_config.md +++ b/docs/stackit_config.md @@ -26,10 +26,10 @@ stackit config [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_config_list.md b/docs/stackit_config_list.md index 6d08e1888..a3277fd02 100644 --- a/docs/stackit_config_list.md +++ b/docs/stackit_config_list.md @@ -37,10 +37,10 @@ stackit config list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_config_profile.md b/docs/stackit_config_profile.md index 6407d11db..03ad96466 100644 --- a/docs/stackit_config_profile.md +++ b/docs/stackit_config_profile.md @@ -24,10 +24,10 @@ stackit config profile [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_config_profile_create.md b/docs/stackit_config_profile_create.md index abc5004ad..ac44cdfd3 100644 --- a/docs/stackit_config_profile_create.md +++ b/docs/stackit_config_profile_create.md @@ -39,10 +39,10 @@ stackit config profile create PROFILE [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_config_profile_delete.md b/docs/stackit_config_profile_delete.md index 770e3563e..1e71abba3 100644 --- a/docs/stackit_config_profile_delete.md +++ b/docs/stackit_config_profile_delete.md @@ -29,10 +29,10 @@ stackit config profile delete PROFILE [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_config_profile_export.md b/docs/stackit_config_profile_export.md index 906a20eac..9dda31cfb 100644 --- a/docs/stackit_config_profile_export.md +++ b/docs/stackit_config_profile_export.md @@ -32,10 +32,10 @@ stackit config profile export PROFILE_NAME [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_config_profile_import.md b/docs/stackit_config_profile_import.md index 86f253fc8..a4b474cbe 100644 --- a/docs/stackit_config_profile_import.md +++ b/docs/stackit_config_profile_import.md @@ -34,10 +34,10 @@ stackit config profile import [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_config_profile_list.md b/docs/stackit_config_profile_list.md index ba39080d0..caee7de76 100644 --- a/docs/stackit_config_profile_list.md +++ b/docs/stackit_config_profile_list.md @@ -31,10 +31,10 @@ stackit config profile list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_config_profile_set.md b/docs/stackit_config_profile_set.md index 64f6126b2..249e6149a 100644 --- a/docs/stackit_config_profile_set.md +++ b/docs/stackit_config_profile_set.md @@ -31,10 +31,10 @@ stackit config profile set PROFILE [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_config_profile_unset.md b/docs/stackit_config_profile_unset.md index 5895391b0..31035e56d 100644 --- a/docs/stackit_config_profile_unset.md +++ b/docs/stackit_config_profile_unset.md @@ -29,10 +29,10 @@ stackit config profile unset [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_config_set.md b/docs/stackit_config_set.md index c1f104958..2a49e8ea6 100644 --- a/docs/stackit_config_set.md +++ b/docs/stackit_config_set.md @@ -70,10 +70,10 @@ stackit config set [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_curl.md b/docs/stackit_curl.md index ef387edb5..573235b54 100644 --- a/docs/stackit_curl.md +++ b/docs/stackit_curl.md @@ -35,7 +35,7 @@ stackit curl URL [flags] -h, --help Help for "stackit curl" --include If set, response headers are added to the output --output string Writes output to provided file instead of printing to console - -X, --request string HTTP method, defaults to GET + -X, --request string HTTP method, defaults to GET (one of: [GET, HEAD, POST, PUT, PATCH, DELETE, CONNECT, OPTIONS, TRACE]) (default "GET") ``` ### Options inherited from parent commands @@ -43,10 +43,10 @@ stackit curl URL [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_dns.md b/docs/stackit_dns.md index a3e7279ba..7f26e9946 100644 --- a/docs/stackit_dns.md +++ b/docs/stackit_dns.md @@ -21,10 +21,10 @@ stackit dns [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_dns_record-set.md b/docs/stackit_dns_record-set.md index 8796d62f2..434405a94 100644 --- a/docs/stackit_dns_record-set.md +++ b/docs/stackit_dns_record-set.md @@ -21,10 +21,10 @@ stackit dns record-set [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_dns_record-set_create.md b/docs/stackit_dns_record-set_create.md index 8f33edd6d..adb18a589 100644 --- a/docs/stackit_dns_record-set_create.md +++ b/docs/stackit_dns_record-set_create.md @@ -25,7 +25,7 @@ stackit dns record-set create [flags] --name string Name of the record, should be compliant with RFC1035, Section 2.3.4 --record strings Records belonging to the record set --ttl int32 Time to live, if not provided defaults to the zone's default TTL - --type string Record type, one of ["A" "AAAA" "SOA" "CNAME" "NS" "MX" "TXT" "SRV" "PTR" "ALIAS" "DNAME" "CAA" "DNSKEY" "DS" "LOC" "NAPTR" "SSHFP" "TLSA" "URI" "CERT" "SVCB" "TYPE" "CSYNC" "HINFO" "HTTPS"] (default "A") + --type string Record type, (one of: [A, AAAA, SOA, CNAME, NS, MX, TXT, SRV, PTR, ALIAS, DNAME, CAA, DNSKEY, DS, LOC, NAPTR, SSHFP, TLSA, URI, CERT, SVCB, TYPE, CSYNC, HINFO, HTTPS]) (default "A") --zone-id string Zone ID ``` @@ -34,10 +34,10 @@ stackit dns record-set create [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_dns_record-set_delete.md b/docs/stackit_dns_record-set_delete.md index 487c5a621..a4c5710eb 100644 --- a/docs/stackit_dns_record-set_delete.md +++ b/docs/stackit_dns_record-set_delete.md @@ -29,10 +29,10 @@ stackit dns record-set delete RECORD_SET_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_dns_record-set_describe.md b/docs/stackit_dns_record-set_describe.md index fb9ab8873..b22e68990 100644 --- a/docs/stackit_dns_record-set_describe.md +++ b/docs/stackit_dns_record-set_describe.md @@ -32,10 +32,10 @@ stackit dns record-set describe RECORD_SET_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_dns_record-set_list.md b/docs/stackit_dns_record-set_list.md index 75cc555a2..a1d49fcdf 100644 --- a/docs/stackit_dns_record-set_list.md +++ b/docs/stackit_dns_record-set_list.md @@ -38,7 +38,7 @@ stackit dns record-set list [flags] --inactive Filter for inactive record sets. Deleted record sets are always inactive and will be included when this flag is set --limit int Maximum number of entries to list --name-like string Filter by name - --order-by-name string Order by name, one of ["asc" "desc"] + --order-by-name string Order by name, (one of: [asc, desc]) --page-size int Number of items fetched in each API call. Does not affect the number of items in the command output (default 100) --zone-id string Zone ID ``` @@ -48,10 +48,10 @@ stackit dns record-set list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_dns_record-set_update.md b/docs/stackit_dns_record-set_update.md index 87215ddfa..0e93ba01d 100644 --- a/docs/stackit_dns_record-set_update.md +++ b/docs/stackit_dns_record-set_update.md @@ -33,10 +33,10 @@ stackit dns record-set update RECORD_SET_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_dns_zone.md b/docs/stackit_dns_zone.md index a5e705ded..4693699e7 100644 --- a/docs/stackit_dns_zone.md +++ b/docs/stackit_dns_zone.md @@ -21,10 +21,10 @@ stackit dns zone [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_dns_zone_clone.md b/docs/stackit_dns_zone_clone.md index 2b944f077..3dacbe2a2 100644 --- a/docs/stackit_dns_zone_clone.md +++ b/docs/stackit_dns_zone_clone.md @@ -38,10 +38,10 @@ stackit dns zone clone ZONE_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_dns_zone_create.md b/docs/stackit_dns_zone_create.md index c261fa689..0f089de3c 100644 --- a/docs/stackit_dns_zone_create.md +++ b/docs/stackit_dns_zone_create.md @@ -36,7 +36,7 @@ stackit dns zone create [flags] --primary strings Primary name server for secondary zone --refresh-time int32 Refresh time --retry-time int32 Retry time - --type string Zone type, one of: ["primary" "secondary"] + --type string Zone type, (one of: [primary, secondary, ]) ``` ### Options inherited from parent commands @@ -44,10 +44,10 @@ stackit dns zone create [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_dns_zone_delete.md b/docs/stackit_dns_zone_delete.md index 466d51f72..c401b7b45 100644 --- a/docs/stackit_dns_zone_delete.md +++ b/docs/stackit_dns_zone_delete.md @@ -28,10 +28,10 @@ stackit dns zone delete ZONE_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_dns_zone_describe.md b/docs/stackit_dns_zone_describe.md index 896a3ef9d..f9815abc3 100644 --- a/docs/stackit_dns_zone_describe.md +++ b/docs/stackit_dns_zone_describe.md @@ -31,10 +31,10 @@ stackit dns zone describe ZONE_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_dns_zone_list.md b/docs/stackit_dns_zone_list.md index bb9e01fd1..c108de65d 100644 --- a/docs/stackit_dns_zone_list.md +++ b/docs/stackit_dns_zone_list.md @@ -35,7 +35,7 @@ stackit dns zone list [flags] --include-deleted Includes successfully deleted zones (if unset, these are filtered out) --limit int Maximum number of entries to list --name-like string Filter by name - --order-by-name string Order by name, one of ["asc" "desc"] + --order-by-name string Order by name, (one of: [asc, desc]) --page-size int Number of items fetched in each API call. Does not affect the number of items in the command output (default 100) ``` @@ -44,10 +44,10 @@ stackit dns zone list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_dns_zone_update.md b/docs/stackit_dns_zone_update.md index 35e375998..7e0e00bcf 100644 --- a/docs/stackit_dns_zone_update.md +++ b/docs/stackit_dns_zone_update.md @@ -38,10 +38,10 @@ stackit dns zone update ZONE_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_git.md b/docs/stackit_git.md index 2a9b072e2..333e61dca 100644 --- a/docs/stackit_git.md +++ b/docs/stackit_git.md @@ -21,10 +21,10 @@ stackit git [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_git_flavor.md b/docs/stackit_git_flavor.md index c2ec85a08..c89bc0254 100644 --- a/docs/stackit_git_flavor.md +++ b/docs/stackit_git_flavor.md @@ -21,10 +21,10 @@ stackit git flavor [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_git_flavor_list.md b/docs/stackit_git_flavor_list.md index a8fc54b0f..194582097 100644 --- a/docs/stackit_git_flavor_list.md +++ b/docs/stackit_git_flavor_list.md @@ -32,10 +32,10 @@ stackit git flavor list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_git_instance.md b/docs/stackit_git_instance.md index 44e55ae8b..077695d87 100644 --- a/docs/stackit_git_instance.md +++ b/docs/stackit_git_instance.md @@ -21,10 +21,10 @@ stackit git instance [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_git_instance_create.md b/docs/stackit_git_instance_create.md index a82c92ec4..c5d42ec3c 100644 --- a/docs/stackit_git_instance_create.md +++ b/docs/stackit_git_instance_create.md @@ -37,10 +37,10 @@ stackit git instance create [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_git_instance_delete.md b/docs/stackit_git_instance_delete.md index df0a6d46a..681e379fd 100644 --- a/docs/stackit_git_instance_delete.md +++ b/docs/stackit_git_instance_delete.md @@ -28,10 +28,10 @@ stackit git instance delete INSTANCE_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_git_instance_describe.md b/docs/stackit_git_instance_describe.md index 90716803e..c355957ea 100644 --- a/docs/stackit_git_instance_describe.md +++ b/docs/stackit_git_instance_describe.md @@ -28,10 +28,10 @@ stackit git instance describe INSTANCE_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_git_instance_list.md b/docs/stackit_git_instance_list.md index e512621d2..06d33564a 100644 --- a/docs/stackit_git_instance_list.md +++ b/docs/stackit_git_instance_list.md @@ -32,10 +32,10 @@ stackit git instance list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_image.md b/docs/stackit_image.md index 4120c26e6..eec4b558b 100644 --- a/docs/stackit_image.md +++ b/docs/stackit_image.md @@ -21,10 +21,10 @@ stackit image [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_image_create.md b/docs/stackit_image_create.md index eb8a0a3e9..172eea4a3 100644 --- a/docs/stackit_image_create.md +++ b/docs/stackit_image_create.md @@ -56,10 +56,10 @@ stackit image create [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_image_delete.md b/docs/stackit_image_delete.md index bbe36d37d..b8e38c272 100644 --- a/docs/stackit_image_delete.md +++ b/docs/stackit_image_delete.md @@ -28,10 +28,10 @@ stackit image delete IMAGE_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_image_describe.md b/docs/stackit_image_describe.md index 35403a150..513448e72 100644 --- a/docs/stackit_image_describe.md +++ b/docs/stackit_image_describe.md @@ -28,10 +28,10 @@ stackit image describe IMAGE_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_image_list.md b/docs/stackit_image_list.md index 28b759eb0..24c2a8e42 100644 --- a/docs/stackit_image_list.md +++ b/docs/stackit_image_list.md @@ -40,10 +40,10 @@ stackit image list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_image_update.md b/docs/stackit_image_update.md index d088d9962..c2064e263 100644 --- a/docs/stackit_image_update.md +++ b/docs/stackit_image_update.md @@ -51,10 +51,10 @@ stackit image update IMAGE_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_key-pair.md b/docs/stackit_key-pair.md index 6e3aff7fb..3049d79fc 100644 --- a/docs/stackit_key-pair.md +++ b/docs/stackit_key-pair.md @@ -21,10 +21,10 @@ stackit key-pair [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_key-pair_create.md b/docs/stackit_key-pair_create.md index 04fbb9561..d33b5f993 100644 --- a/docs/stackit_key-pair_create.md +++ b/docs/stackit_key-pair_create.md @@ -40,10 +40,10 @@ stackit key-pair create [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_key-pair_delete.md b/docs/stackit_key-pair_delete.md index b9dc10cda..9c22abd45 100644 --- a/docs/stackit_key-pair_delete.md +++ b/docs/stackit_key-pair_delete.md @@ -28,10 +28,10 @@ stackit key-pair delete KEY_PAIR_NAME [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_key-pair_describe.md b/docs/stackit_key-pair_describe.md index fa68ec225..90b13df32 100644 --- a/docs/stackit_key-pair_describe.md +++ b/docs/stackit_key-pair_describe.md @@ -32,10 +32,10 @@ stackit key-pair describe KEY_PAIR_NAME [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_key-pair_list.md b/docs/stackit_key-pair_list.md index f4af20042..a8c1c162f 100644 --- a/docs/stackit_key-pair_list.md +++ b/docs/stackit_key-pair_list.md @@ -39,10 +39,10 @@ stackit key-pair list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_key-pair_update.md b/docs/stackit_key-pair_update.md index 6c7399dd0..d2f31fb9e 100644 --- a/docs/stackit_key-pair_update.md +++ b/docs/stackit_key-pair_update.md @@ -29,10 +29,10 @@ stackit key-pair update KEY_PAIR_NAME [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_kms.md b/docs/stackit_kms.md index d1adc5024..24f9ac3ad 100644 --- a/docs/stackit_kms.md +++ b/docs/stackit_kms.md @@ -21,10 +21,10 @@ stackit kms [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_kms_key.md b/docs/stackit_kms_key.md index 3cdfbdf00..2a1c0ff65 100644 --- a/docs/stackit_kms_key.md +++ b/docs/stackit_kms_key.md @@ -21,10 +21,10 @@ stackit kms key [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_kms_key_create.md b/docs/stackit_kms_key_create.md index 4948416f5..3b6bfc18f 100644 --- a/docs/stackit_kms_key_create.md +++ b/docs/stackit_kms_key_create.md @@ -35,14 +35,14 @@ stackit kms key create [flags] ### Options ``` - --algorithm string En-/Decryption / signing algorithm. (possible values: [aes_256_gcm, rsa_2048_oaep_sha256, rsa_3072_oaep_sha256, rsa_4096_oaep_sha256, rsa_4096_oaep_sha512, hmac_sha256, hmac_sha384, hmac_sha512, ecdsa_p256_sha256, ecdsa_p384_sha384, ecdsa_p521_sha512]) + --algorithm string En-/Decryption / signing algorithm. (one of: [aes_256_gcm, rsa_2048_oaep_sha256, rsa_3072_oaep_sha256, rsa_4096_oaep_sha256, rsa_4096_oaep_sha512, hmac_sha256, hmac_sha384, hmac_sha512, ecdsa_p256_sha256, ecdsa_p384_sha384, ecdsa_p521_sha512]) --description string Optional description of the key -h, --help Help for "stackit kms key create" --import-only States whether versions can be created or only imported --keyring-id string ID of the KMS key ring --name string The display name to distinguish multiple keys - --protection string The underlying system that is responsible for protecting the key material. (possible values: [software]) - --purpose string Purpose of the key. (possible values: [symmetric_encrypt_decrypt, asymmetric_encrypt_decrypt, message_authentication_code, asymmetric_sign_verify]) + --protection string The underlying system that is responsible for protecting the key material. (one of: [software]) + --purpose string Purpose of the key. (one of: [symmetric_encrypt_decrypt, asymmetric_encrypt_decrypt, message_authentication_code, asymmetric_sign_verify]) ``` ### Options inherited from parent commands @@ -50,10 +50,10 @@ stackit kms key create [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_kms_key_delete.md b/docs/stackit_kms_key_delete.md index 4a5418843..2871be570 100644 --- a/docs/stackit_kms_key_delete.md +++ b/docs/stackit_kms_key_delete.md @@ -29,10 +29,10 @@ stackit kms key delete KEY_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_kms_key_describe.md b/docs/stackit_kms_key_describe.md index d2921c47c..1d87c1bee 100644 --- a/docs/stackit_kms_key_describe.md +++ b/docs/stackit_kms_key_describe.md @@ -29,10 +29,10 @@ stackit kms key describe KEY_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_kms_key_import.md b/docs/stackit_kms_key_import.md index 99953dacc..adc649962 100644 --- a/docs/stackit_kms_key_import.md +++ b/docs/stackit_kms_key_import.md @@ -34,10 +34,10 @@ stackit kms key import KEY_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_kms_key_list.md b/docs/stackit_kms_key_list.md index 336d37a6a..af99df0ba 100644 --- a/docs/stackit_kms_key_list.md +++ b/docs/stackit_kms_key_list.md @@ -32,10 +32,10 @@ stackit kms key list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_kms_key_restore.md b/docs/stackit_kms_key_restore.md index ebe902801..18a20eb69 100644 --- a/docs/stackit_kms_key_restore.md +++ b/docs/stackit_kms_key_restore.md @@ -29,10 +29,10 @@ stackit kms key restore KEY_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_kms_key_rotate.md b/docs/stackit_kms_key_rotate.md index a9152ccf3..1ef49d35d 100644 --- a/docs/stackit_kms_key_rotate.md +++ b/docs/stackit_kms_key_rotate.md @@ -29,10 +29,10 @@ stackit kms key rotate KEY_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_kms_keyring.md b/docs/stackit_kms_keyring.md index 00202422e..979eb7ffe 100644 --- a/docs/stackit_kms_keyring.md +++ b/docs/stackit_kms_keyring.md @@ -21,10 +21,10 @@ stackit kms keyring [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_kms_keyring_create.md b/docs/stackit_kms_keyring_create.md index e07deb467..fdc6ff42a 100644 --- a/docs/stackit_kms_keyring_create.md +++ b/docs/stackit_kms_keyring_create.md @@ -36,10 +36,10 @@ stackit kms keyring create [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_kms_keyring_delete.md b/docs/stackit_kms_keyring_delete.md index e60c0b44a..bf43c1968 100644 --- a/docs/stackit_kms_keyring_delete.md +++ b/docs/stackit_kms_keyring_delete.md @@ -28,10 +28,10 @@ stackit kms keyring delete KEYRING-ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_kms_keyring_describe.md b/docs/stackit_kms_keyring_describe.md index f36bf9030..0ed1f688d 100644 --- a/docs/stackit_kms_keyring_describe.md +++ b/docs/stackit_kms_keyring_describe.md @@ -28,10 +28,10 @@ stackit kms keyring describe KEYRING_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_kms_keyring_list.md b/docs/stackit_kms_keyring_list.md index 65f3ab323..9b8398439 100644 --- a/docs/stackit_kms_keyring_list.md +++ b/docs/stackit_kms_keyring_list.md @@ -31,10 +31,10 @@ stackit kms keyring list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_kms_version.md b/docs/stackit_kms_version.md index 06b3f23b5..d14706eb9 100644 --- a/docs/stackit_kms_version.md +++ b/docs/stackit_kms_version.md @@ -21,10 +21,10 @@ stackit kms version [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_kms_version_destroy.md b/docs/stackit_kms_version_destroy.md index 3145408c1..b9742f909 100644 --- a/docs/stackit_kms_version_destroy.md +++ b/docs/stackit_kms_version_destroy.md @@ -30,10 +30,10 @@ stackit kms version destroy VERSION_NUMBER [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_kms_version_disable.md b/docs/stackit_kms_version_disable.md index 0239dd4c1..bb0f1e911 100644 --- a/docs/stackit_kms_version_disable.md +++ b/docs/stackit_kms_version_disable.md @@ -30,10 +30,10 @@ stackit kms version disable VERSION_NUMBER [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_kms_version_enable.md b/docs/stackit_kms_version_enable.md index bdb59e5d5..b080abbff 100644 --- a/docs/stackit_kms_version_enable.md +++ b/docs/stackit_kms_version_enable.md @@ -30,10 +30,10 @@ stackit kms version enable VERSION_NUMBER [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_kms_version_list.md b/docs/stackit_kms_version_list.md index 15522ab18..c29e1af42 100644 --- a/docs/stackit_kms_version_list.md +++ b/docs/stackit_kms_version_list.md @@ -33,10 +33,10 @@ stackit kms version list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_kms_version_restore.md b/docs/stackit_kms_version_restore.md index b2bb1519c..0f016b960 100644 --- a/docs/stackit_kms_version_restore.md +++ b/docs/stackit_kms_version_restore.md @@ -30,10 +30,10 @@ stackit kms version restore VERSION_NUMBER [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_kms_wrapping-key.md b/docs/stackit_kms_wrapping-key.md index eec6e11a5..e95accf98 100644 --- a/docs/stackit_kms_wrapping-key.md +++ b/docs/stackit_kms_wrapping-key.md @@ -21,10 +21,10 @@ stackit kms wrapping-key [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_kms_wrapping-key_create.md b/docs/stackit_kms_wrapping-key_create.md index 1ba75e7c8..eb74a0374 100644 --- a/docs/stackit_kms_wrapping-key_create.md +++ b/docs/stackit_kms_wrapping-key_create.md @@ -23,13 +23,13 @@ stackit kms wrapping-key create [flags] ### Options ``` - --algorithm string En-/Decryption / signing algorithm. (possible values: [rsa_2048_oaep_sha256, rsa_3072_oaep_sha256, rsa_4096_oaep_sha256, rsa_4096_oaep_sha512, rsa_2048_oaep_sha256_aes_256_key_wrap, rsa_3072_oaep_sha256_aes_256_key_wrap, rsa_4096_oaep_sha256_aes_256_key_wrap, rsa_4096_oaep_sha512_aes_256_key_wrap]) + --algorithm string En-/Decryption / signing algorithm. (one of: [rsa_2048_oaep_sha256, rsa_3072_oaep_sha256, rsa_4096_oaep_sha256, rsa_4096_oaep_sha512, rsa_2048_oaep_sha256_aes_256_key_wrap, rsa_3072_oaep_sha256_aes_256_key_wrap, rsa_4096_oaep_sha256_aes_256_key_wrap, rsa_4096_oaep_sha512_aes_256_key_wrap]) --description string Optional description of the wrapping key -h, --help Help for "stackit kms wrapping-key create" --keyring-id string ID of the KMS key ring --name string The display name to distinguish multiple wrapping keys - --protection string The underlying system that is responsible for protecting the key material. (possible values: [software]) - --purpose string Purpose of the key. (possible values: [wrap_symmetric_key, wrap_asymmetric_key]) + --protection string The underlying system that is responsible for protecting the key material. (one of: [software]) + --purpose string Purpose of the key. (one of: [wrap_symmetric_key, wrap_asymmetric_key]) ``` ### Options inherited from parent commands @@ -37,10 +37,10 @@ stackit kms wrapping-key create [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_kms_wrapping-key_delete.md b/docs/stackit_kms_wrapping-key_delete.md index 7504c1782..e1346d0ce 100644 --- a/docs/stackit_kms_wrapping-key_delete.md +++ b/docs/stackit_kms_wrapping-key_delete.md @@ -29,10 +29,10 @@ stackit kms wrapping-key delete WRAPPING_KEY_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_kms_wrapping-key_describe.md b/docs/stackit_kms_wrapping-key_describe.md index 2d1f484b4..da0a587f9 100644 --- a/docs/stackit_kms_wrapping-key_describe.md +++ b/docs/stackit_kms_wrapping-key_describe.md @@ -29,10 +29,10 @@ stackit kms wrapping-key describe WRAPPING_KEY_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_kms_wrapping-key_list.md b/docs/stackit_kms_wrapping-key_list.md index bc9d5dce0..9d33332bd 100644 --- a/docs/stackit_kms_wrapping-key_list.md +++ b/docs/stackit_kms_wrapping-key_list.md @@ -32,10 +32,10 @@ stackit kms wrapping-key list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_load-balancer.md b/docs/stackit_load-balancer.md index 77c14b00f..d320049b9 100644 --- a/docs/stackit_load-balancer.md +++ b/docs/stackit_load-balancer.md @@ -21,10 +21,10 @@ stackit load-balancer [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_load-balancer_create.md b/docs/stackit_load-balancer_create.md index 2f1e303ce..a76a826e0 100644 --- a/docs/stackit_load-balancer_create.md +++ b/docs/stackit_load-balancer_create.md @@ -39,10 +39,10 @@ stackit load-balancer create [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_load-balancer_delete.md b/docs/stackit_load-balancer_delete.md index 07ee2712c..79ef95344 100644 --- a/docs/stackit_load-balancer_delete.md +++ b/docs/stackit_load-balancer_delete.md @@ -28,10 +28,10 @@ stackit load-balancer delete LOAD_BALANCER_NAME [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_load-balancer_describe.md b/docs/stackit_load-balancer_describe.md index 8f3bd5da1..42abb7dee 100644 --- a/docs/stackit_load-balancer_describe.md +++ b/docs/stackit_load-balancer_describe.md @@ -31,10 +31,10 @@ stackit load-balancer describe LOAD_BALANCER_NAME [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_load-balancer_generate-payload.md b/docs/stackit_load-balancer_generate-payload.md index 0dbc9b457..44291dc38 100644 --- a/docs/stackit_load-balancer_generate-payload.md +++ b/docs/stackit_load-balancer_generate-payload.md @@ -41,10 +41,10 @@ stackit load-balancer generate-payload [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_load-balancer_list.md b/docs/stackit_load-balancer_list.md index 3cc3749e9..1eefe0b1a 100644 --- a/docs/stackit_load-balancer_list.md +++ b/docs/stackit_load-balancer_list.md @@ -35,10 +35,10 @@ stackit load-balancer list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_load-balancer_observability-credentials.md b/docs/stackit_load-balancer_observability-credentials.md index ae2e58a8e..c6dd0c4bc 100644 --- a/docs/stackit_load-balancer_observability-credentials.md +++ b/docs/stackit_load-balancer_observability-credentials.md @@ -21,10 +21,10 @@ stackit load-balancer observability-credentials [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_load-balancer_observability-credentials_add.md b/docs/stackit_load-balancer_observability-credentials_add.md index 18144470f..f5164bf93 100644 --- a/docs/stackit_load-balancer_observability-credentials_add.md +++ b/docs/stackit_load-balancer_observability-credentials_add.md @@ -34,10 +34,10 @@ stackit load-balancer observability-credentials add [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_load-balancer_observability-credentials_cleanup.md b/docs/stackit_load-balancer_observability-credentials_cleanup.md index 58fcbe82e..e873c9b51 100644 --- a/docs/stackit_load-balancer_observability-credentials_cleanup.md +++ b/docs/stackit_load-balancer_observability-credentials_cleanup.md @@ -28,10 +28,10 @@ stackit load-balancer observability-credentials cleanup [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_load-balancer_observability-credentials_delete.md b/docs/stackit_load-balancer_observability-credentials_delete.md index a2fcf8018..e94be6d34 100644 --- a/docs/stackit_load-balancer_observability-credentials_delete.md +++ b/docs/stackit_load-balancer_observability-credentials_delete.md @@ -28,10 +28,10 @@ stackit load-balancer observability-credentials delete CREDENTIALS_REF [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_load-balancer_observability-credentials_describe.md b/docs/stackit_load-balancer_observability-credentials_describe.md index c8ed19750..38602a204 100644 --- a/docs/stackit_load-balancer_observability-credentials_describe.md +++ b/docs/stackit_load-balancer_observability-credentials_describe.md @@ -28,10 +28,10 @@ stackit load-balancer observability-credentials describe CREDENTIALS_REF [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_load-balancer_observability-credentials_list.md b/docs/stackit_load-balancer_observability-credentials_list.md index 2e86129d0..14e7599f3 100644 --- a/docs/stackit_load-balancer_observability-credentials_list.md +++ b/docs/stackit_load-balancer_observability-credentials_list.md @@ -43,10 +43,10 @@ stackit load-balancer observability-credentials list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_load-balancer_observability-credentials_update.md b/docs/stackit_load-balancer_observability-credentials_update.md index e89f89047..1e19bd14d 100644 --- a/docs/stackit_load-balancer_observability-credentials_update.md +++ b/docs/stackit_load-balancer_observability-credentials_update.md @@ -34,10 +34,10 @@ stackit load-balancer observability-credentials update CREDENTIALS_REF [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_load-balancer_quota.md b/docs/stackit_load-balancer_quota.md index 62541ec3e..15864f7fe 100644 --- a/docs/stackit_load-balancer_quota.md +++ b/docs/stackit_load-balancer_quota.md @@ -28,10 +28,10 @@ stackit load-balancer quota [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_load-balancer_target-pool.md b/docs/stackit_load-balancer_target-pool.md index 8356f0436..47d7753cd 100644 --- a/docs/stackit_load-balancer_target-pool.md +++ b/docs/stackit_load-balancer_target-pool.md @@ -21,10 +21,10 @@ stackit load-balancer target-pool [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_load-balancer_target-pool_add-target.md b/docs/stackit_load-balancer_target-pool_add-target.md index b6e1e8109..157375bed 100644 --- a/docs/stackit_load-balancer_target-pool_add-target.md +++ b/docs/stackit_load-balancer_target-pool_add-target.md @@ -32,10 +32,10 @@ stackit load-balancer target-pool add-target TARGET_IP [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_load-balancer_target-pool_describe.md b/docs/stackit_load-balancer_target-pool_describe.md index 67fbe0580..a4b663fd9 100644 --- a/docs/stackit_load-balancer_target-pool_describe.md +++ b/docs/stackit_load-balancer_target-pool_describe.md @@ -32,10 +32,10 @@ stackit load-balancer target-pool describe TARGET_POOL_NAME [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_load-balancer_target-pool_remove-target.md b/docs/stackit_load-balancer_target-pool_remove-target.md index 2d95b7abf..cf4ec0a70 100644 --- a/docs/stackit_load-balancer_target-pool_remove-target.md +++ b/docs/stackit_load-balancer_target-pool_remove-target.md @@ -30,10 +30,10 @@ stackit load-balancer target-pool remove-target TARGET_IP [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_load-balancer_update.md b/docs/stackit_load-balancer_update.md index c80707cca..98e18d6cf 100644 --- a/docs/stackit_load-balancer_update.md +++ b/docs/stackit_load-balancer_update.md @@ -39,10 +39,10 @@ stackit load-balancer update LOAD_BALANCER_NAME [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_logme.md b/docs/stackit_logme.md index edd1ec1e7..71fde4711 100644 --- a/docs/stackit_logme.md +++ b/docs/stackit_logme.md @@ -21,10 +21,10 @@ stackit logme [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_logme_credentials.md b/docs/stackit_logme_credentials.md index f510d9854..3044a375d 100644 --- a/docs/stackit_logme_credentials.md +++ b/docs/stackit_logme_credentials.md @@ -21,10 +21,10 @@ stackit logme credentials [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_logme_credentials_create.md b/docs/stackit_logme_credentials_create.md index f20a9c583..7203c396f 100644 --- a/docs/stackit_logme_credentials_create.md +++ b/docs/stackit_logme_credentials_create.md @@ -33,10 +33,10 @@ stackit logme credentials create [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_logme_credentials_delete.md b/docs/stackit_logme_credentials_delete.md index 0925c4cbd..5ed60f9eb 100644 --- a/docs/stackit_logme_credentials_delete.md +++ b/docs/stackit_logme_credentials_delete.md @@ -29,10 +29,10 @@ stackit logme credentials delete CREDENTIALS_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_logme_credentials_describe.md b/docs/stackit_logme_credentials_describe.md index 96940297b..b6d79f7ff 100644 --- a/docs/stackit_logme_credentials_describe.md +++ b/docs/stackit_logme_credentials_describe.md @@ -32,10 +32,10 @@ stackit logme credentials describe CREDENTIALS_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_logme_credentials_list.md b/docs/stackit_logme_credentials_list.md index 3cd2a5164..9dac8453e 100644 --- a/docs/stackit_logme_credentials_list.md +++ b/docs/stackit_logme_credentials_list.md @@ -36,10 +36,10 @@ stackit logme credentials list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_logme_instance.md b/docs/stackit_logme_instance.md index 54144eb80..7de2cf05e 100644 --- a/docs/stackit_logme_instance.md +++ b/docs/stackit_logme_instance.md @@ -21,10 +21,10 @@ stackit logme instance [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_logme_instance_create.md b/docs/stackit_logme_instance_create.md index a0af8584d..f7e8d4327 100644 --- a/docs/stackit_logme_instance_create.md +++ b/docs/stackit_logme_instance_create.md @@ -45,10 +45,10 @@ stackit logme instance create [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_logme_instance_delete.md b/docs/stackit_logme_instance_delete.md index 34e9a8fc9..aed7fab3e 100644 --- a/docs/stackit_logme_instance_delete.md +++ b/docs/stackit_logme_instance_delete.md @@ -28,10 +28,10 @@ stackit logme instance delete INSTANCE_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_logme_instance_describe.md b/docs/stackit_logme_instance_describe.md index c9f0f9bcc..3c86c04ce 100644 --- a/docs/stackit_logme_instance_describe.md +++ b/docs/stackit_logme_instance_describe.md @@ -31,10 +31,10 @@ stackit logme instance describe INSTANCE_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_logme_instance_list.md b/docs/stackit_logme_instance_list.md index 20673a368..04ab54703 100644 --- a/docs/stackit_logme_instance_list.md +++ b/docs/stackit_logme_instance_list.md @@ -35,10 +35,10 @@ stackit logme instance list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_logme_instance_update.md b/docs/stackit_logme_instance_update.md index 02e3bb975..27e3bcf8a 100644 --- a/docs/stackit_logme_instance_update.md +++ b/docs/stackit_logme_instance_update.md @@ -41,10 +41,10 @@ stackit logme instance update INSTANCE_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_logme_plans.md b/docs/stackit_logme_plans.md index 87f7db2a3..cc44ce3b4 100644 --- a/docs/stackit_logme_plans.md +++ b/docs/stackit_logme_plans.md @@ -35,10 +35,10 @@ stackit logme plans [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_logs.md b/docs/stackit_logs.md index f01dc7d0d..a1cea5280 100644 --- a/docs/stackit_logs.md +++ b/docs/stackit_logs.md @@ -21,10 +21,10 @@ stackit logs [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_logs_access-token.md b/docs/stackit_logs_access-token.md index a42baa613..6c8edc0a6 100644 --- a/docs/stackit_logs_access-token.md +++ b/docs/stackit_logs_access-token.md @@ -21,10 +21,10 @@ stackit logs access-token [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_logs_access-token_create.md b/docs/stackit_logs_access-token_create.md index 947260d03..d55edbeb1 100644 --- a/docs/stackit_logs_access-token_create.md +++ b/docs/stackit_logs_access-token_create.md @@ -39,10 +39,10 @@ stackit logs access-token create [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_logs_access-token_delete-all-expired.md b/docs/stackit_logs_access-token_delete-all-expired.md index b63792e63..31e4ac22e 100644 --- a/docs/stackit_logs_access-token_delete-all-expired.md +++ b/docs/stackit_logs_access-token_delete-all-expired.md @@ -29,10 +29,10 @@ stackit logs access-token delete-all-expired [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_logs_access-token_delete-all.md b/docs/stackit_logs_access-token_delete-all.md index de546fdef..ce7fbe835 100644 --- a/docs/stackit_logs_access-token_delete-all.md +++ b/docs/stackit_logs_access-token_delete-all.md @@ -29,10 +29,10 @@ stackit logs access-token delete-all [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_logs_access-token_delete.md b/docs/stackit_logs_access-token_delete.md index 99d700c81..1af40862e 100644 --- a/docs/stackit_logs_access-token_delete.md +++ b/docs/stackit_logs_access-token_delete.md @@ -29,10 +29,10 @@ stackit logs access-token delete ACCESS_TOKEN_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_logs_access-token_describe.md b/docs/stackit_logs_access-token_describe.md index 1e690bcda..24cb0ae33 100644 --- a/docs/stackit_logs_access-token_describe.md +++ b/docs/stackit_logs_access-token_describe.md @@ -32,10 +32,10 @@ stackit logs access-token describe ACCESS_TOKEN_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_logs_access-token_list.md b/docs/stackit_logs_access-token_list.md index 0fc6b899e..ba26517e8 100644 --- a/docs/stackit_logs_access-token_list.md +++ b/docs/stackit_logs_access-token_list.md @@ -36,10 +36,10 @@ stackit logs access-token list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_logs_access-token_update.md b/docs/stackit_logs_access-token_update.md index 10bc62701..d6e218261 100644 --- a/docs/stackit_logs_access-token_update.md +++ b/docs/stackit_logs_access-token_update.md @@ -34,10 +34,10 @@ stackit logs access-token update ACCESS_TOKEN_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_logs_instance.md b/docs/stackit_logs_instance.md index 546eb96b6..75a00812a 100644 --- a/docs/stackit_logs_instance.md +++ b/docs/stackit_logs_instance.md @@ -21,10 +21,10 @@ stackit logs instance [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_logs_instance_create.md b/docs/stackit_logs_instance_create.md index e68a37824..65c5e48ae 100644 --- a/docs/stackit_logs_instance_create.md +++ b/docs/stackit_logs_instance_create.md @@ -38,10 +38,10 @@ stackit logs instance create [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_logs_instance_delete.md b/docs/stackit_logs_instance_delete.md index 30eecdb7c..64e60b3e1 100644 --- a/docs/stackit_logs_instance_delete.md +++ b/docs/stackit_logs_instance_delete.md @@ -28,10 +28,10 @@ stackit logs instance delete INSTANCE_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_logs_instance_describe.md b/docs/stackit_logs_instance_describe.md index f35dfc430..ceccab5ce 100644 --- a/docs/stackit_logs_instance_describe.md +++ b/docs/stackit_logs_instance_describe.md @@ -31,10 +31,10 @@ stackit logs instance describe INSTANCE_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_logs_instance_list.md b/docs/stackit_logs_instance_list.md index 4a21422bb..5a35c2e10 100644 --- a/docs/stackit_logs_instance_list.md +++ b/docs/stackit_logs_instance_list.md @@ -32,10 +32,10 @@ stackit logs instance list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_logs_instance_update.md b/docs/stackit_logs_instance_update.md index a4fdd5a33..0157806f3 100644 --- a/docs/stackit_logs_instance_update.md +++ b/docs/stackit_logs_instance_update.md @@ -38,10 +38,10 @@ stackit logs instance update INSTANCE_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_mariadb.md b/docs/stackit_mariadb.md index b40107270..7638f6ce0 100644 --- a/docs/stackit_mariadb.md +++ b/docs/stackit_mariadb.md @@ -21,10 +21,10 @@ stackit mariadb [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_mariadb_credentials.md b/docs/stackit_mariadb_credentials.md index ccfa3e470..42b3ae183 100644 --- a/docs/stackit_mariadb_credentials.md +++ b/docs/stackit_mariadb_credentials.md @@ -21,10 +21,10 @@ stackit mariadb credentials [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_mariadb_credentials_create.md b/docs/stackit_mariadb_credentials_create.md index e611ebeff..ff3a9ac84 100644 --- a/docs/stackit_mariadb_credentials_create.md +++ b/docs/stackit_mariadb_credentials_create.md @@ -33,10 +33,10 @@ stackit mariadb credentials create [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_mariadb_credentials_delete.md b/docs/stackit_mariadb_credentials_delete.md index e1b7bbee7..a8cc050b3 100644 --- a/docs/stackit_mariadb_credentials_delete.md +++ b/docs/stackit_mariadb_credentials_delete.md @@ -29,10 +29,10 @@ stackit mariadb credentials delete CREDENTIALS_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_mariadb_credentials_describe.md b/docs/stackit_mariadb_credentials_describe.md index 12f440607..5099afaf7 100644 --- a/docs/stackit_mariadb_credentials_describe.md +++ b/docs/stackit_mariadb_credentials_describe.md @@ -32,10 +32,10 @@ stackit mariadb credentials describe CREDENTIALS_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_mariadb_credentials_list.md b/docs/stackit_mariadb_credentials_list.md index 99120fda8..7cf303afa 100644 --- a/docs/stackit_mariadb_credentials_list.md +++ b/docs/stackit_mariadb_credentials_list.md @@ -36,10 +36,10 @@ stackit mariadb credentials list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_mariadb_instance.md b/docs/stackit_mariadb_instance.md index 3ace44fc6..d40fbdf1a 100644 --- a/docs/stackit_mariadb_instance.md +++ b/docs/stackit_mariadb_instance.md @@ -21,10 +21,10 @@ stackit mariadb instance [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_mariadb_instance_create.md b/docs/stackit_mariadb_instance_create.md index 63bb11865..f37668d28 100644 --- a/docs/stackit_mariadb_instance_create.md +++ b/docs/stackit_mariadb_instance_create.md @@ -45,10 +45,10 @@ stackit mariadb instance create [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_mariadb_instance_delete.md b/docs/stackit_mariadb_instance_delete.md index 39ea03e35..6dbb5b29c 100644 --- a/docs/stackit_mariadb_instance_delete.md +++ b/docs/stackit_mariadb_instance_delete.md @@ -28,10 +28,10 @@ stackit mariadb instance delete INSTANCE_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_mariadb_instance_describe.md b/docs/stackit_mariadb_instance_describe.md index e864c29a6..7937de78b 100644 --- a/docs/stackit_mariadb_instance_describe.md +++ b/docs/stackit_mariadb_instance_describe.md @@ -31,10 +31,10 @@ stackit mariadb instance describe INSTANCE_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_mariadb_instance_list.md b/docs/stackit_mariadb_instance_list.md index 2990fbc24..640bebf97 100644 --- a/docs/stackit_mariadb_instance_list.md +++ b/docs/stackit_mariadb_instance_list.md @@ -35,10 +35,10 @@ stackit mariadb instance list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_mariadb_instance_update.md b/docs/stackit_mariadb_instance_update.md index 2de6c1026..d6fbc7c49 100644 --- a/docs/stackit_mariadb_instance_update.md +++ b/docs/stackit_mariadb_instance_update.md @@ -41,10 +41,10 @@ stackit mariadb instance update INSTANCE_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_mariadb_plans.md b/docs/stackit_mariadb_plans.md index f17b09ecd..698f15e80 100644 --- a/docs/stackit_mariadb_plans.md +++ b/docs/stackit_mariadb_plans.md @@ -35,10 +35,10 @@ stackit mariadb plans [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_mongodbflex.md b/docs/stackit_mongodbflex.md index 7f0746976..2d741af26 100644 --- a/docs/stackit_mongodbflex.md +++ b/docs/stackit_mongodbflex.md @@ -21,10 +21,10 @@ stackit mongodbflex [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_mongodbflex_backup.md b/docs/stackit_mongodbflex_backup.md index e89b79ae5..e837c07c8 100644 --- a/docs/stackit_mongodbflex_backup.md +++ b/docs/stackit_mongodbflex_backup.md @@ -21,10 +21,10 @@ stackit mongodbflex backup [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_mongodbflex_backup_describe.md b/docs/stackit_mongodbflex_backup_describe.md index 287f325b4..fbf984060 100644 --- a/docs/stackit_mongodbflex_backup_describe.md +++ b/docs/stackit_mongodbflex_backup_describe.md @@ -32,10 +32,10 @@ stackit mongodbflex backup describe BACKUP_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_mongodbflex_backup_list.md b/docs/stackit_mongodbflex_backup_list.md index 87fa406ea..ac975f3ab 100644 --- a/docs/stackit_mongodbflex_backup_list.md +++ b/docs/stackit_mongodbflex_backup_list.md @@ -36,10 +36,10 @@ stackit mongodbflex backup list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_mongodbflex_backup_restore-jobs.md b/docs/stackit_mongodbflex_backup_restore-jobs.md index c91bcaf2f..95be4e8b8 100644 --- a/docs/stackit_mongodbflex_backup_restore-jobs.md +++ b/docs/stackit_mongodbflex_backup_restore-jobs.md @@ -36,10 +36,10 @@ stackit mongodbflex backup restore-jobs [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_mongodbflex_backup_restore.md b/docs/stackit_mongodbflex_backup_restore.md index b506f1ce6..127f11dc1 100644 --- a/docs/stackit_mongodbflex_backup_restore.md +++ b/docs/stackit_mongodbflex_backup_restore.md @@ -40,10 +40,10 @@ stackit mongodbflex backup restore [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_mongodbflex_backup_schedule.md b/docs/stackit_mongodbflex_backup_schedule.md index fff1ef32c..befd7ee44 100644 --- a/docs/stackit_mongodbflex_backup_schedule.md +++ b/docs/stackit_mongodbflex_backup_schedule.md @@ -32,10 +32,10 @@ stackit mongodbflex backup schedule [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_mongodbflex_backup_update-schedule.md b/docs/stackit_mongodbflex_backup_update-schedule.md index cfa492a84..0d8f83731 100644 --- a/docs/stackit_mongodbflex_backup_update-schedule.md +++ b/docs/stackit_mongodbflex_backup_update-schedule.md @@ -40,10 +40,10 @@ stackit mongodbflex backup update-schedule [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_mongodbflex_instance.md b/docs/stackit_mongodbflex_instance.md index 962f4bc8e..9c85c8f34 100644 --- a/docs/stackit_mongodbflex_instance.md +++ b/docs/stackit_mongodbflex_instance.md @@ -21,10 +21,10 @@ stackit mongodbflex instance [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_mongodbflex_instance_create.md b/docs/stackit_mongodbflex_instance_create.md index 151ff2dad..773482bfb 100644 --- a/docs/stackit_mongodbflex_instance_create.md +++ b/docs/stackit_mongodbflex_instance_create.md @@ -35,7 +35,7 @@ stackit mongodbflex instance create [flags] --ram int Amount of RAM (in GB) --storage-class string Storage class (default "premium-perf2-mongodb") --storage-size int Storage size (in GB) (default 10) - --type string Instance type, one of ["Replica" "Sharded" "Single"] (default "Replica") + --type string Instance type, (one of: [Replica, Sharded, Single]) (default "Replica") --version string MongoDB version. Defaults to the latest version available ``` @@ -44,10 +44,10 @@ stackit mongodbflex instance create [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_mongodbflex_instance_delete.md b/docs/stackit_mongodbflex_instance_delete.md index 39d313068..44a50e866 100644 --- a/docs/stackit_mongodbflex_instance_delete.md +++ b/docs/stackit_mongodbflex_instance_delete.md @@ -28,10 +28,10 @@ stackit mongodbflex instance delete INSTANCE_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_mongodbflex_instance_describe.md b/docs/stackit_mongodbflex_instance_describe.md index b37bd3605..5910be339 100644 --- a/docs/stackit_mongodbflex_instance_describe.md +++ b/docs/stackit_mongodbflex_instance_describe.md @@ -31,10 +31,10 @@ stackit mongodbflex instance describe INSTANCE_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_mongodbflex_instance_list.md b/docs/stackit_mongodbflex_instance_list.md index 5abfe9cbc..57535fcaf 100644 --- a/docs/stackit_mongodbflex_instance_list.md +++ b/docs/stackit_mongodbflex_instance_list.md @@ -35,10 +35,10 @@ stackit mongodbflex instance list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_mongodbflex_instance_update.md b/docs/stackit_mongodbflex_instance_update.md index a9475fbeb..47c253766 100644 --- a/docs/stackit_mongodbflex_instance_update.md +++ b/docs/stackit_mongodbflex_instance_update.md @@ -32,7 +32,7 @@ stackit mongodbflex instance update INSTANCE_ID [flags] --ram int Amount of RAM (in GB) --storage-class string Storage class --storage-size int Storage size (in GB) - --type string Instance type, one of ["Replica" "Sharded" "Single"] + --type string Instance type, (one of: [Replica, Sharded, Single]) --version string Version ``` @@ -41,10 +41,10 @@ stackit mongodbflex instance update INSTANCE_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_mongodbflex_options.md b/docs/stackit_mongodbflex_options.md index d01544608..31ad5fa7f 100644 --- a/docs/stackit_mongodbflex_options.md +++ b/docs/stackit_mongodbflex_options.md @@ -39,10 +39,10 @@ stackit mongodbflex options [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_mongodbflex_user.md b/docs/stackit_mongodbflex_user.md index ce6528aa4..f1a53b480 100644 --- a/docs/stackit_mongodbflex_user.md +++ b/docs/stackit_mongodbflex_user.md @@ -21,10 +21,10 @@ stackit mongodbflex user [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_mongodbflex_user_create.md b/docs/stackit_mongodbflex_user_create.md index e8d4cdace..17a3648bb 100644 --- a/docs/stackit_mongodbflex_user_create.md +++ b/docs/stackit_mongodbflex_user_create.md @@ -29,7 +29,7 @@ stackit mongodbflex user create [flags] --database string The database inside the MongoDB instance that the user has access to. If it does not exist, it will be created once the user writes to it -h, --help Help for "stackit mongodbflex user create" --instance-id string ID of the instance - --role strings Roles of the user, possible values are ["read" "readWrite" "readAnyDatabase" "readWriteAnyDatabase" "stackitAdmin"]. The "readAnyDatabase", "readWriteAnyDatabase" and "stackitAdmin" roles will always be created in the admin database. (default [read]) + --role strings Roles of the user. The "readAnyDatabase", "readWriteAnyDatabase" and "stackitAdmin" roles will always be created in the admin database. (multiple of: [read, readWrite, readAnyDatabase, readWriteAnyDatabase, stackitAdmin]) (default [read]) --username string Username of the user. If not specified, a random username will be assigned ``` @@ -38,10 +38,10 @@ stackit mongodbflex user create [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_mongodbflex_user_delete.md b/docs/stackit_mongodbflex_user_delete.md index bf792ddea..08262bbf8 100644 --- a/docs/stackit_mongodbflex_user_delete.md +++ b/docs/stackit_mongodbflex_user_delete.md @@ -30,10 +30,10 @@ stackit mongodbflex user delete USER_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_mongodbflex_user_describe.md b/docs/stackit_mongodbflex_user_describe.md index 15642c9c2..6bca8c786 100644 --- a/docs/stackit_mongodbflex_user_describe.md +++ b/docs/stackit_mongodbflex_user_describe.md @@ -34,10 +34,10 @@ stackit mongodbflex user describe USER_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_mongodbflex_user_list.md b/docs/stackit_mongodbflex_user_list.md index 804abfe11..49327cb1e 100644 --- a/docs/stackit_mongodbflex_user_list.md +++ b/docs/stackit_mongodbflex_user_list.md @@ -36,10 +36,10 @@ stackit mongodbflex user list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_mongodbflex_user_reset-password.md b/docs/stackit_mongodbflex_user_reset-password.md index 183885b5f..b87591eba 100644 --- a/docs/stackit_mongodbflex_user_reset-password.md +++ b/docs/stackit_mongodbflex_user_reset-password.md @@ -30,10 +30,10 @@ stackit mongodbflex user reset-password USER_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_mongodbflex_user_update.md b/docs/stackit_mongodbflex_user_update.md index 02e0d42af..f97939851 100644 --- a/docs/stackit_mongodbflex_user_update.md +++ b/docs/stackit_mongodbflex_user_update.md @@ -23,7 +23,7 @@ stackit mongodbflex user update USER_ID [flags] --database string The database inside the MongoDB instance that the user has access to. If it does not exist, it will be created once the user writes to it -h, --help Help for "stackit mongodbflex user update" --instance-id string ID of the instance - --role strings Roles of the user, possible values are ["read" "readWrite" "readAnyDatabase" "readWriteAnyDatabase" "stackitAdmin"]. The "readAnyDatabase", "readWriteAnyDatabase" and "stackitAdmin" roles will always be created in the admin database. (default []) + --role strings Roles of the user. The "readAnyDatabase", "readWriteAnyDatabase" and "stackitAdmin" roles will always be created in the admin database. (multiple of: [read, readWrite, readAnyDatabase, readWriteAnyDatabase, stackitAdmin]) (default []) ``` ### Options inherited from parent commands @@ -31,10 +31,10 @@ stackit mongodbflex user update USER_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_network-area.md b/docs/stackit_network-area.md index e99e52ad1..19fa3091c 100644 --- a/docs/stackit_network-area.md +++ b/docs/stackit_network-area.md @@ -21,10 +21,10 @@ stackit network-area [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_network-area_create.md b/docs/stackit_network-area_create.md index e9a28231d..e9b29f2b8 100644 --- a/docs/stackit_network-area_create.md +++ b/docs/stackit_network-area_create.md @@ -34,10 +34,10 @@ stackit network-area create [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_network-area_delete.md b/docs/stackit_network-area_delete.md index f7814d583..d576cde46 100644 --- a/docs/stackit_network-area_delete.md +++ b/docs/stackit_network-area_delete.md @@ -31,10 +31,10 @@ stackit network-area delete AREA_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_network-area_describe.md b/docs/stackit_network-area_describe.md index a5656cfe7..e96d75699 100644 --- a/docs/stackit_network-area_describe.md +++ b/docs/stackit_network-area_describe.md @@ -36,10 +36,10 @@ stackit network-area describe AREA_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_network-area_list.md b/docs/stackit_network-area_list.md index 74fcaf9d7..24a7ee918 100644 --- a/docs/stackit_network-area_list.md +++ b/docs/stackit_network-area_list.md @@ -40,10 +40,10 @@ stackit network-area list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_network-area_network-range.md b/docs/stackit_network-area_network-range.md index 4e146f3d7..3f431fd9d 100644 --- a/docs/stackit_network-area_network-range.md +++ b/docs/stackit_network-area_network-range.md @@ -21,10 +21,10 @@ stackit network-area network-range [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_network-area_network-range_create.md b/docs/stackit_network-area_network-range_create.md index c51b7399a..a0b862957 100644 --- a/docs/stackit_network-area_network-range_create.md +++ b/docs/stackit_network-area_network-range_create.md @@ -31,10 +31,10 @@ stackit network-area network-range create [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_network-area_network-range_delete.md b/docs/stackit_network-area_network-range_delete.md index 22626b6bf..f2838a2a2 100644 --- a/docs/stackit_network-area_network-range_delete.md +++ b/docs/stackit_network-area_network-range_delete.md @@ -30,10 +30,10 @@ stackit network-area network-range delete NETWORK_RANGE_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_network-area_network-range_describe.md b/docs/stackit_network-area_network-range_describe.md index 5e1831f7f..112c407ba 100644 --- a/docs/stackit_network-area_network-range_describe.md +++ b/docs/stackit_network-area_network-range_describe.md @@ -30,10 +30,10 @@ stackit network-area network-range describe NETWORK_RANGE_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_network-area_network-range_list.md b/docs/stackit_network-area_network-range_list.md index f66857ce7..d76b22ec4 100644 --- a/docs/stackit_network-area_network-range_list.md +++ b/docs/stackit_network-area_network-range_list.md @@ -37,10 +37,10 @@ stackit network-area network-range list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_network-area_region.md b/docs/stackit_network-area_region.md index 07fd820eb..9db9465d7 100644 --- a/docs/stackit_network-area_region.md +++ b/docs/stackit_network-area_region.md @@ -21,10 +21,10 @@ stackit network-area region [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_network-area_region_create.md b/docs/stackit_network-area_region_create.md index 55632632f..c787f189e 100644 --- a/docs/stackit_network-area_region_create.md +++ b/docs/stackit_network-area_region_create.md @@ -46,10 +46,10 @@ stackit network-area region create [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_network-area_region_delete.md b/docs/stackit_network-area_region_delete.md index 6f2193e5e..9a8d787aa 100644 --- a/docs/stackit_network-area_region_delete.md +++ b/docs/stackit_network-area_region_delete.md @@ -34,10 +34,10 @@ stackit network-area region delete [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_network-area_region_describe.md b/docs/stackit_network-area_region_describe.md index e97ee813a..6f1361d38 100644 --- a/docs/stackit_network-area_region_describe.md +++ b/docs/stackit_network-area_region_describe.md @@ -34,10 +34,10 @@ stackit network-area region describe [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_network-area_region_list.md b/docs/stackit_network-area_region_list.md index 2b6eaf673..8c8ec725d 100644 --- a/docs/stackit_network-area_region_list.md +++ b/docs/stackit_network-area_region_list.md @@ -30,10 +30,10 @@ stackit network-area region list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_network-area_region_update.md b/docs/stackit_network-area_region_update.md index 400d85bc7..8e2429cc2 100644 --- a/docs/stackit_network-area_region_update.md +++ b/docs/stackit_network-area_region_update.md @@ -44,10 +44,10 @@ stackit network-area region update [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_network-area_route.md b/docs/stackit_network-area_route.md index a5fb3f19d..91d7964ae 100644 --- a/docs/stackit_network-area_route.md +++ b/docs/stackit_network-area_route.md @@ -21,10 +21,10 @@ stackit network-area route [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_network-area_route_create.md b/docs/stackit_network-area_route_create.md index ff697f896..a6bba2074 100644 --- a/docs/stackit_network-area_route_create.md +++ b/docs/stackit_network-area_route_create.md @@ -41,10 +41,10 @@ stackit network-area route create [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_network-area_route_delete.md b/docs/stackit_network-area_route_delete.md index fc95549b4..14332b576 100644 --- a/docs/stackit_network-area_route_delete.md +++ b/docs/stackit_network-area_route_delete.md @@ -30,10 +30,10 @@ stackit network-area route delete ROUTE_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_network-area_route_describe.md b/docs/stackit_network-area_route_describe.md index fbacf05bd..0440767ea 100644 --- a/docs/stackit_network-area_route_describe.md +++ b/docs/stackit_network-area_route_describe.md @@ -33,10 +33,10 @@ stackit network-area route describe ROUTE_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_network-area_route_list.md b/docs/stackit_network-area_route_list.md index ff0a6ab1e..72b1b6a98 100644 --- a/docs/stackit_network-area_route_list.md +++ b/docs/stackit_network-area_route_list.md @@ -37,10 +37,10 @@ stackit network-area route list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_network-area_route_update.md b/docs/stackit_network-area_route_update.md index 61e54d10f..b28d89d38 100644 --- a/docs/stackit_network-area_route_update.md +++ b/docs/stackit_network-area_route_update.md @@ -33,10 +33,10 @@ stackit network-area route update ROUTE_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_network-area_routing-table.md b/docs/stackit_network-area_routing-table.md index d1aefa50a..b39b4468e 100644 --- a/docs/stackit_network-area_routing-table.md +++ b/docs/stackit_network-area_routing-table.md @@ -24,10 +24,10 @@ stackit network-area routing-table [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_network-area_routing-table_create.md b/docs/stackit_network-area_routing-table_create.md index b926dcc7d..e4af0401d 100644 --- a/docs/stackit_network-area_routing-table_create.md +++ b/docs/stackit_network-area_routing-table_create.md @@ -44,10 +44,10 @@ stackit network-area routing-table create [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_network-area_routing-table_delete.md b/docs/stackit_network-area_routing-table_delete.md index 59a38395b..71225b8fd 100644 --- a/docs/stackit_network-area_routing-table_delete.md +++ b/docs/stackit_network-area_routing-table_delete.md @@ -30,10 +30,10 @@ stackit network-area routing-table delete ROUTING_TABLE_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_network-area_routing-table_describe.md b/docs/stackit_network-area_routing-table_describe.md index b608ce830..cce4804c4 100644 --- a/docs/stackit_network-area_routing-table_describe.md +++ b/docs/stackit_network-area_routing-table_describe.md @@ -30,10 +30,10 @@ stackit network-area routing-table describe ROUTING_TABLE_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_network-area_routing-table_list.md b/docs/stackit_network-area_routing-table_list.md index 5b7a277d4..63660ca06 100644 --- a/docs/stackit_network-area_routing-table_list.md +++ b/docs/stackit_network-area_routing-table_list.md @@ -38,10 +38,10 @@ stackit network-area routing-table list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_network-area_routing-table_route.md b/docs/stackit_network-area_routing-table_route.md index f23144acf..8424f8203 100644 --- a/docs/stackit_network-area_routing-table_route.md +++ b/docs/stackit_network-area_routing-table_route.md @@ -21,10 +21,10 @@ stackit network-area routing-table route [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_network-area_routing-table_route_create.md b/docs/stackit_network-area_routing-table_route_create.md index eb3c3ad52..80984448a 100644 --- a/docs/stackit_network-area_routing-table_route_create.md +++ b/docs/stackit_network-area_routing-table_route_create.md @@ -26,12 +26,12 @@ stackit network-area routing-table route create [flags] ### Options ``` - --destination-type string Destination type + --destination-type string Destination type (one of: [cidrv4, cidrv6]) --destination-value string Destination value -h, --help Help for "stackit network-area routing-table route create" --labels stringToString Key=value labels (default []) --network-area-id string Network-Area ID - --nexthop-type string Next hop type + --nexthop-type string Next hop type (one of: [ipv4, ipv6, internet, blackhole]) --nexthop-value string NextHop value --organization-id string Organization ID --routing-table-id string Routing-Table ID @@ -42,10 +42,10 @@ stackit network-area routing-table route create [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_network-area_routing-table_route_delete.md b/docs/stackit_network-area_routing-table_route_delete.md index 5f15e61d0..80f5dcbd0 100644 --- a/docs/stackit_network-area_routing-table_route_delete.md +++ b/docs/stackit_network-area_routing-table_route_delete.md @@ -31,10 +31,10 @@ stackit network-area routing-table route delete routing-table-id [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_network-area_routing-table_route_describe.md b/docs/stackit_network-area_routing-table_route_describe.md index 9b50da817..7eec6bd57 100644 --- a/docs/stackit_network-area_routing-table_route_describe.md +++ b/docs/stackit_network-area_routing-table_route_describe.md @@ -31,10 +31,10 @@ stackit network-area routing-table route describe ROUTE_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_network-area_routing-table_route_list.md b/docs/stackit_network-area_routing-table_route_list.md index 901b8d593..1cfde45e7 100644 --- a/docs/stackit_network-area_routing-table_route_list.md +++ b/docs/stackit_network-area_routing-table_route_list.md @@ -39,10 +39,10 @@ stackit network-area routing-table route list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_network-area_routing-table_route_update.md b/docs/stackit_network-area_routing-table_route_update.md index 22bdb11ad..aa6daec2b 100644 --- a/docs/stackit_network-area_routing-table_route_update.md +++ b/docs/stackit_network-area_routing-table_route_update.md @@ -32,10 +32,10 @@ stackit network-area routing-table route update ROUTE_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_network-area_routing-table_update.md b/docs/stackit_network-area_routing-table_update.md index 917565e38..b6803179a 100644 --- a/docs/stackit_network-area_routing-table_update.md +++ b/docs/stackit_network-area_routing-table_update.md @@ -47,10 +47,10 @@ stackit network-area routing-table update ROUTING_TABLE_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_network-area_update.md b/docs/stackit_network-area_update.md index 77665f0e8..b9d6cd546 100644 --- a/docs/stackit_network-area_update.md +++ b/docs/stackit_network-area_update.md @@ -31,10 +31,10 @@ stackit network-area update AREA_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_network-interface.md b/docs/stackit_network-interface.md index b7be67c0c..1b022b19e 100644 --- a/docs/stackit_network-interface.md +++ b/docs/stackit_network-interface.md @@ -21,10 +21,10 @@ stackit network-interface [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_network-interface_create.md b/docs/stackit_network-interface_create.md index 5ff3acd27..b42934899 100644 --- a/docs/stackit_network-interface_create.md +++ b/docs/stackit_network-interface_create.md @@ -39,10 +39,10 @@ stackit network-interface create [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_network-interface_delete.md b/docs/stackit_network-interface_delete.md index 624e0b83f..3d40859e7 100644 --- a/docs/stackit_network-interface_delete.md +++ b/docs/stackit_network-interface_delete.md @@ -29,10 +29,10 @@ stackit network-interface delete NIC_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_network-interface_describe.md b/docs/stackit_network-interface_describe.md index 159475be8..60aea3df6 100644 --- a/docs/stackit_network-interface_describe.md +++ b/docs/stackit_network-interface_describe.md @@ -35,10 +35,10 @@ stackit network-interface describe NIC_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_network-interface_list.md b/docs/stackit_network-interface_list.md index 50276fe12..acfdcb6fb 100644 --- a/docs/stackit_network-interface_list.md +++ b/docs/stackit_network-interface_list.md @@ -43,10 +43,10 @@ stackit network-interface list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_network-interface_update.md b/docs/stackit_network-interface_update.md index 0c3e2c322..54e9e2334 100644 --- a/docs/stackit_network-interface_update.md +++ b/docs/stackit_network-interface_update.md @@ -40,10 +40,10 @@ stackit network-interface update NIC_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_network.md b/docs/stackit_network.md index f196fe7b6..b443e615a 100644 --- a/docs/stackit_network.md +++ b/docs/stackit_network.md @@ -21,10 +21,10 @@ stackit network [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_network_create.md b/docs/stackit_network_create.md index 44934bee3..9d6ed3097 100644 --- a/docs/stackit_network_create.md +++ b/docs/stackit_network_create.md @@ -60,10 +60,10 @@ stackit network create [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_network_delete.md b/docs/stackit_network_delete.md index 5fb62e6e3..2765ce106 100644 --- a/docs/stackit_network_delete.md +++ b/docs/stackit_network_delete.md @@ -30,10 +30,10 @@ stackit network delete NETWORK_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_network_describe.md b/docs/stackit_network_describe.md index d7298e4e5..e432ea4e5 100644 --- a/docs/stackit_network_describe.md +++ b/docs/stackit_network_describe.md @@ -31,10 +31,10 @@ stackit network describe NETWORK_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_network_list.md b/docs/stackit_network_list.md index 1b4febd39..aedb0c8bc 100644 --- a/docs/stackit_network_list.md +++ b/docs/stackit_network_list.md @@ -39,10 +39,10 @@ stackit network list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_network_update.md b/docs/stackit_network_update.md index 7069b26d2..fbd5523de 100644 --- a/docs/stackit_network_update.md +++ b/docs/stackit_network_update.md @@ -49,10 +49,10 @@ stackit network update NETWORK_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_object-storage.md b/docs/stackit_object-storage.md index bae7c2496..bce1eae75 100644 --- a/docs/stackit_object-storage.md +++ b/docs/stackit_object-storage.md @@ -21,10 +21,10 @@ stackit object-storage [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_object-storage_bucket.md b/docs/stackit_object-storage_bucket.md index ac5d3b600..40fa6bf81 100644 --- a/docs/stackit_object-storage_bucket.md +++ b/docs/stackit_object-storage_bucket.md @@ -21,10 +21,10 @@ stackit object-storage bucket [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_object-storage_bucket_create.md b/docs/stackit_object-storage_bucket_create.md index 58f14a21a..e4a420de6 100644 --- a/docs/stackit_object-storage_bucket_create.md +++ b/docs/stackit_object-storage_bucket_create.md @@ -32,10 +32,10 @@ stackit object-storage bucket create BUCKET_NAME [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_object-storage_bucket_delete.md b/docs/stackit_object-storage_bucket_delete.md index d512e4625..74cf3436e 100644 --- a/docs/stackit_object-storage_bucket_delete.md +++ b/docs/stackit_object-storage_bucket_delete.md @@ -28,10 +28,10 @@ stackit object-storage bucket delete BUCKET_NAME [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_object-storage_bucket_describe.md b/docs/stackit_object-storage_bucket_describe.md index 256269aa9..adebdd92e 100644 --- a/docs/stackit_object-storage_bucket_describe.md +++ b/docs/stackit_object-storage_bucket_describe.md @@ -31,10 +31,10 @@ stackit object-storage bucket describe BUCKET_NAME [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_object-storage_bucket_list.md b/docs/stackit_object-storage_bucket_list.md index b77f0eecb..6473abb83 100644 --- a/docs/stackit_object-storage_bucket_list.md +++ b/docs/stackit_object-storage_bucket_list.md @@ -35,10 +35,10 @@ stackit object-storage bucket list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_object-storage_compliance-lock.md b/docs/stackit_object-storage_compliance-lock.md index 435807d29..e25cf4da0 100644 --- a/docs/stackit_object-storage_compliance-lock.md +++ b/docs/stackit_object-storage_compliance-lock.md @@ -21,10 +21,10 @@ stackit object-storage compliance-lock [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_object-storage_compliance-lock_describe.md b/docs/stackit_object-storage_compliance-lock_describe.md index 393b034da..c88bdfac8 100644 --- a/docs/stackit_object-storage_compliance-lock_describe.md +++ b/docs/stackit_object-storage_compliance-lock_describe.md @@ -28,10 +28,10 @@ stackit object-storage compliance-lock describe [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_object-storage_compliance-lock_lock.md b/docs/stackit_object-storage_compliance-lock_lock.md index 98a55265d..db2ae51bb 100644 --- a/docs/stackit_object-storage_compliance-lock_lock.md +++ b/docs/stackit_object-storage_compliance-lock_lock.md @@ -28,10 +28,10 @@ stackit object-storage compliance-lock lock [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_object-storage_compliance-lock_unlock.md b/docs/stackit_object-storage_compliance-lock_unlock.md index 5666c3a40..4d0d552a7 100644 --- a/docs/stackit_object-storage_compliance-lock_unlock.md +++ b/docs/stackit_object-storage_compliance-lock_unlock.md @@ -28,10 +28,10 @@ stackit object-storage compliance-lock unlock [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_object-storage_credentials-group.md b/docs/stackit_object-storage_credentials-group.md index d20daee64..7d8d5a18a 100644 --- a/docs/stackit_object-storage_credentials-group.md +++ b/docs/stackit_object-storage_credentials-group.md @@ -21,10 +21,10 @@ stackit object-storage credentials-group [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_object-storage_credentials-group_create.md b/docs/stackit_object-storage_credentials-group_create.md index 2dd99a88e..b32060e33 100644 --- a/docs/stackit_object-storage_credentials-group_create.md +++ b/docs/stackit_object-storage_credentials-group_create.md @@ -29,10 +29,10 @@ stackit object-storage credentials-group create [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_object-storage_credentials-group_delete.md b/docs/stackit_object-storage_credentials-group_delete.md index 4d97f4722..15d49240a 100644 --- a/docs/stackit_object-storage_credentials-group_delete.md +++ b/docs/stackit_object-storage_credentials-group_delete.md @@ -28,10 +28,10 @@ stackit object-storage credentials-group delete CREDENTIALS_GROUP_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_object-storage_credentials-group_list.md b/docs/stackit_object-storage_credentials-group_list.md index 2cb925069..28c09705b 100644 --- a/docs/stackit_object-storage_credentials-group_list.md +++ b/docs/stackit_object-storage_credentials-group_list.md @@ -35,10 +35,10 @@ stackit object-storage credentials-group list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_object-storage_credentials.md b/docs/stackit_object-storage_credentials.md index 2427b5f42..a1f77badf 100644 --- a/docs/stackit_object-storage_credentials.md +++ b/docs/stackit_object-storage_credentials.md @@ -21,10 +21,10 @@ stackit object-storage credentials [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_object-storage_credentials_create.md b/docs/stackit_object-storage_credentials_create.md index 95df0d984..c88b42f28 100644 --- a/docs/stackit_object-storage_credentials_create.md +++ b/docs/stackit_object-storage_credentials_create.md @@ -33,10 +33,10 @@ stackit object-storage credentials create [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_object-storage_credentials_delete.md b/docs/stackit_object-storage_credentials_delete.md index 91768a44e..d82cb99ee 100644 --- a/docs/stackit_object-storage_credentials_delete.md +++ b/docs/stackit_object-storage_credentials_delete.md @@ -29,10 +29,10 @@ stackit object-storage credentials delete CREDENTIALS_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_object-storage_credentials_list.md b/docs/stackit_object-storage_credentials_list.md index 08c2e94c2..f39d3a7b9 100644 --- a/docs/stackit_object-storage_credentials_list.md +++ b/docs/stackit_object-storage_credentials_list.md @@ -36,10 +36,10 @@ stackit object-storage credentials list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_object-storage_disable.md b/docs/stackit_object-storage_disable.md index c9aef3194..7f355efb2 100644 --- a/docs/stackit_object-storage_disable.md +++ b/docs/stackit_object-storage_disable.md @@ -28,10 +28,10 @@ stackit object-storage disable [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_object-storage_enable.md b/docs/stackit_object-storage_enable.md index 9de05bfb3..aa23e9d89 100644 --- a/docs/stackit_object-storage_enable.md +++ b/docs/stackit_object-storage_enable.md @@ -28,10 +28,10 @@ stackit object-storage enable [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_observability.md b/docs/stackit_observability.md index 393f10ff0..e8f0912de 100644 --- a/docs/stackit_observability.md +++ b/docs/stackit_observability.md @@ -21,10 +21,10 @@ stackit observability [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_observability_credentials.md b/docs/stackit_observability_credentials.md index 661db4f24..7b6e155a7 100644 --- a/docs/stackit_observability_credentials.md +++ b/docs/stackit_observability_credentials.md @@ -21,10 +21,10 @@ stackit observability credentials [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_observability_credentials_create.md b/docs/stackit_observability_credentials_create.md index e850b8418..062a85746 100644 --- a/docs/stackit_observability_credentials_create.md +++ b/docs/stackit_observability_credentials_create.md @@ -30,10 +30,10 @@ stackit observability credentials create [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_observability_credentials_delete.md b/docs/stackit_observability_credentials_delete.md index 98b927431..062062417 100644 --- a/docs/stackit_observability_credentials_delete.md +++ b/docs/stackit_observability_credentials_delete.md @@ -29,10 +29,10 @@ stackit observability credentials delete USERNAME [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_observability_credentials_list.md b/docs/stackit_observability_credentials_list.md index 905f6658d..45fbff36f 100644 --- a/docs/stackit_observability_credentials_list.md +++ b/docs/stackit_observability_credentials_list.md @@ -36,10 +36,10 @@ stackit observability credentials list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_observability_grafana.md b/docs/stackit_observability_grafana.md index 57f7a6440..67371e66f 100644 --- a/docs/stackit_observability_grafana.md +++ b/docs/stackit_observability_grafana.md @@ -21,10 +21,10 @@ stackit observability grafana [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_observability_grafana_describe.md b/docs/stackit_observability_grafana_describe.md index e44800614..6cbb5e2c4 100644 --- a/docs/stackit_observability_grafana_describe.md +++ b/docs/stackit_observability_grafana_describe.md @@ -32,10 +32,10 @@ stackit observability grafana describe INSTANCE_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_observability_grafana_public-read-access.md b/docs/stackit_observability_grafana_public-read-access.md index 39db9ef60..56d9fbc8f 100644 --- a/docs/stackit_observability_grafana_public-read-access.md +++ b/docs/stackit_observability_grafana_public-read-access.md @@ -22,10 +22,10 @@ stackit observability grafana public-read-access [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_observability_grafana_public-read-access_disable.md b/docs/stackit_observability_grafana_public-read-access_disable.md index 02566e9f8..d62db72ac 100644 --- a/docs/stackit_observability_grafana_public-read-access_disable.md +++ b/docs/stackit_observability_grafana_public-read-access_disable.md @@ -29,10 +29,10 @@ stackit observability grafana public-read-access disable INSTANCE_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_observability_grafana_public-read-access_enable.md b/docs/stackit_observability_grafana_public-read-access_enable.md index 7b71bbb4e..82883deda 100644 --- a/docs/stackit_observability_grafana_public-read-access_enable.md +++ b/docs/stackit_observability_grafana_public-read-access_enable.md @@ -29,10 +29,10 @@ stackit observability grafana public-read-access enable INSTANCE_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_observability_grafana_single-sign-on.md b/docs/stackit_observability_grafana_single-sign-on.md index dfba3ff2e..bd9273bd9 100644 --- a/docs/stackit_observability_grafana_single-sign-on.md +++ b/docs/stackit_observability_grafana_single-sign-on.md @@ -22,10 +22,10 @@ stackit observability grafana single-sign-on [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_observability_grafana_single-sign-on_disable.md b/docs/stackit_observability_grafana_single-sign-on_disable.md index e4907acfa..39ded4216 100644 --- a/docs/stackit_observability_grafana_single-sign-on_disable.md +++ b/docs/stackit_observability_grafana_single-sign-on_disable.md @@ -29,10 +29,10 @@ stackit observability grafana single-sign-on disable INSTANCE_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_observability_grafana_single-sign-on_enable.md b/docs/stackit_observability_grafana_single-sign-on_enable.md index f083b1536..96c936aa1 100644 --- a/docs/stackit_observability_grafana_single-sign-on_enable.md +++ b/docs/stackit_observability_grafana_single-sign-on_enable.md @@ -29,10 +29,10 @@ stackit observability grafana single-sign-on enable INSTANCE_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_observability_instance.md b/docs/stackit_observability_instance.md index 4b7350a5f..4b000ecb9 100644 --- a/docs/stackit_observability_instance.md +++ b/docs/stackit_observability_instance.md @@ -21,10 +21,10 @@ stackit observability instance [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_observability_instance_create.md b/docs/stackit_observability_instance_create.md index 994fda4ba..2b99ae565 100644 --- a/docs/stackit_observability_instance_create.md +++ b/docs/stackit_observability_instance_create.md @@ -34,10 +34,10 @@ stackit observability instance create [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_observability_instance_delete.md b/docs/stackit_observability_instance_delete.md index 30005abe4..d8b40f922 100644 --- a/docs/stackit_observability_instance_delete.md +++ b/docs/stackit_observability_instance_delete.md @@ -28,10 +28,10 @@ stackit observability instance delete INSTANCE_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_observability_instance_describe.md b/docs/stackit_observability_instance_describe.md index d8f50173c..6a67f87d7 100644 --- a/docs/stackit_observability_instance_describe.md +++ b/docs/stackit_observability_instance_describe.md @@ -31,10 +31,10 @@ stackit observability instance describe INSTANCE_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_observability_instance_list.md b/docs/stackit_observability_instance_list.md index 18062dfa0..cce0a5ee8 100644 --- a/docs/stackit_observability_instance_list.md +++ b/docs/stackit_observability_instance_list.md @@ -35,10 +35,10 @@ stackit observability instance list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_observability_instance_update.md b/docs/stackit_observability_instance_update.md index fdbcc88f4..902334b8c 100644 --- a/docs/stackit_observability_instance_update.md +++ b/docs/stackit_observability_instance_update.md @@ -37,10 +37,10 @@ stackit observability instance update INSTANCE_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_observability_plans.md b/docs/stackit_observability_plans.md index c0fb3846d..982ff6728 100644 --- a/docs/stackit_observability_plans.md +++ b/docs/stackit_observability_plans.md @@ -35,10 +35,10 @@ stackit observability plans [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_observability_scrape-config.md b/docs/stackit_observability_scrape-config.md index cecb2058b..75f70c337 100644 --- a/docs/stackit_observability_scrape-config.md +++ b/docs/stackit_observability_scrape-config.md @@ -21,10 +21,10 @@ stackit observability scrape-config [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_observability_scrape-config_create.md b/docs/stackit_observability_scrape-config_create.md index f8db966bb..982dafa6e 100644 --- a/docs/stackit_observability_scrape-config_create.md +++ b/docs/stackit_observability_scrape-config_create.md @@ -44,10 +44,10 @@ stackit observability scrape-config create [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_observability_scrape-config_delete.md b/docs/stackit_observability_scrape-config_delete.md index 1ea9678ee..22086f974 100644 --- a/docs/stackit_observability_scrape-config_delete.md +++ b/docs/stackit_observability_scrape-config_delete.md @@ -29,10 +29,10 @@ stackit observability scrape-config delete JOB_NAME [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_observability_scrape-config_describe.md b/docs/stackit_observability_scrape-config_describe.md index de6ad62cd..00c6bc335 100644 --- a/docs/stackit_observability_scrape-config_describe.md +++ b/docs/stackit_observability_scrape-config_describe.md @@ -32,10 +32,10 @@ stackit observability scrape-config describe JOB_NAME [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_observability_scrape-config_generate-payload.md b/docs/stackit_observability_scrape-config_generate-payload.md index 2cc4d0ad0..56a255be4 100644 --- a/docs/stackit_observability_scrape-config_generate-payload.md +++ b/docs/stackit_observability_scrape-config_generate-payload.md @@ -47,10 +47,10 @@ stackit observability scrape-config generate-payload [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_observability_scrape-config_list.md b/docs/stackit_observability_scrape-config_list.md index 0db93b027..2f06b3a90 100644 --- a/docs/stackit_observability_scrape-config_list.md +++ b/docs/stackit_observability_scrape-config_list.md @@ -36,10 +36,10 @@ stackit observability scrape-config list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_observability_scrape-config_update.md b/docs/stackit_observability_scrape-config_update.md index a92e5cfb5..674fb7f7a 100644 --- a/docs/stackit_observability_scrape-config_update.md +++ b/docs/stackit_observability_scrape-config_update.md @@ -40,10 +40,10 @@ stackit observability scrape-config update JOB_NAME [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_opensearch.md b/docs/stackit_opensearch.md index c83f878ba..cb38c4ccd 100644 --- a/docs/stackit_opensearch.md +++ b/docs/stackit_opensearch.md @@ -21,10 +21,10 @@ stackit opensearch [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_opensearch_credentials.md b/docs/stackit_opensearch_credentials.md index 2af0661e5..cce6ea45c 100644 --- a/docs/stackit_opensearch_credentials.md +++ b/docs/stackit_opensearch_credentials.md @@ -21,10 +21,10 @@ stackit opensearch credentials [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_opensearch_credentials_create.md b/docs/stackit_opensearch_credentials_create.md index dce634d44..cfe32b2ac 100644 --- a/docs/stackit_opensearch_credentials_create.md +++ b/docs/stackit_opensearch_credentials_create.md @@ -33,10 +33,10 @@ stackit opensearch credentials create [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_opensearch_credentials_delete.md b/docs/stackit_opensearch_credentials_delete.md index 34af83bbd..ebd5e996b 100644 --- a/docs/stackit_opensearch_credentials_delete.md +++ b/docs/stackit_opensearch_credentials_delete.md @@ -29,10 +29,10 @@ stackit opensearch credentials delete CREDENTIALS_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_opensearch_credentials_describe.md b/docs/stackit_opensearch_credentials_describe.md index 5f7c93e61..a55f6ba57 100644 --- a/docs/stackit_opensearch_credentials_describe.md +++ b/docs/stackit_opensearch_credentials_describe.md @@ -32,10 +32,10 @@ stackit opensearch credentials describe CREDENTIALS_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_opensearch_credentials_list.md b/docs/stackit_opensearch_credentials_list.md index 6cc855daa..7d67d4bc6 100644 --- a/docs/stackit_opensearch_credentials_list.md +++ b/docs/stackit_opensearch_credentials_list.md @@ -36,10 +36,10 @@ stackit opensearch credentials list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_opensearch_instance.md b/docs/stackit_opensearch_instance.md index 2b2df6283..4e42492e0 100644 --- a/docs/stackit_opensearch_instance.md +++ b/docs/stackit_opensearch_instance.md @@ -21,10 +21,10 @@ stackit opensearch instance [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_opensearch_instance_create.md b/docs/stackit_opensearch_instance_create.md index 77b5aada1..ba979af69 100644 --- a/docs/stackit_opensearch_instance_create.md +++ b/docs/stackit_opensearch_instance_create.md @@ -46,10 +46,10 @@ stackit opensearch instance create [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_opensearch_instance_delete.md b/docs/stackit_opensearch_instance_delete.md index 2783bc403..c40f7f12e 100644 --- a/docs/stackit_opensearch_instance_delete.md +++ b/docs/stackit_opensearch_instance_delete.md @@ -28,10 +28,10 @@ stackit opensearch instance delete INSTANCE_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_opensearch_instance_describe.md b/docs/stackit_opensearch_instance_describe.md index 8246df4f3..f0b6e5a48 100644 --- a/docs/stackit_opensearch_instance_describe.md +++ b/docs/stackit_opensearch_instance_describe.md @@ -31,10 +31,10 @@ stackit opensearch instance describe INSTANCE_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_opensearch_instance_list.md b/docs/stackit_opensearch_instance_list.md index 36904c646..1b9f644cc 100644 --- a/docs/stackit_opensearch_instance_list.md +++ b/docs/stackit_opensearch_instance_list.md @@ -35,10 +35,10 @@ stackit opensearch instance list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_opensearch_instance_update.md b/docs/stackit_opensearch_instance_update.md index 8e174c120..33b2b817b 100644 --- a/docs/stackit_opensearch_instance_update.md +++ b/docs/stackit_opensearch_instance_update.md @@ -42,10 +42,10 @@ stackit opensearch instance update INSTANCE_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_opensearch_plans.md b/docs/stackit_opensearch_plans.md index 5617d7e2b..e9c521d45 100644 --- a/docs/stackit_opensearch_plans.md +++ b/docs/stackit_opensearch_plans.md @@ -35,10 +35,10 @@ stackit opensearch plans [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_organization.md b/docs/stackit_organization.md index ad124b975..9d2ad0965 100644 --- a/docs/stackit_organization.md +++ b/docs/stackit_organization.md @@ -22,10 +22,10 @@ stackit organization [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_organization_describe.md b/docs/stackit_organization_describe.md index 795cf38e5..e927d03a7 100644 --- a/docs/stackit_organization_describe.md +++ b/docs/stackit_organization_describe.md @@ -31,10 +31,10 @@ stackit organization describe [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_organization_list.md b/docs/stackit_organization_list.md index a258807ba..b04e969f4 100644 --- a/docs/stackit_organization_list.md +++ b/docs/stackit_organization_list.md @@ -32,10 +32,10 @@ stackit organization list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_organization_member.md b/docs/stackit_organization_member.md index 9a0c0233d..9a0a12a4b 100644 --- a/docs/stackit_organization_member.md +++ b/docs/stackit_organization_member.md @@ -21,10 +21,10 @@ stackit organization member [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_organization_member_add.md b/docs/stackit_organization_member_add.md index c3946d22c..cc3e9f97b 100644 --- a/docs/stackit_organization_member_add.md +++ b/docs/stackit_organization_member_add.md @@ -34,10 +34,10 @@ stackit organization member add SUBJECT [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_organization_member_list.md b/docs/stackit_organization_member_list.md index feb052304..209f402e7 100644 --- a/docs/stackit_organization_member_list.md +++ b/docs/stackit_organization_member_list.md @@ -29,7 +29,7 @@ stackit organization member list [flags] -h, --help Help for "stackit organization member list" --limit int Maximum number of entries to list --organization-id string The organization ID - --sort-by string Sort entries by a specific field, one of ["subject" "role"] (default "subject") + --sort-by string Sort entries by a specific field, (one of: [subject, role]) (default "subject") --subject string Filter by subject (Identifier of user, service account or client. Usually email address in case of users or name in case of clients) ``` @@ -38,10 +38,10 @@ stackit organization member list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_organization_member_remove.md b/docs/stackit_organization_member_remove.md index f1a876d67..4627dfbce 100644 --- a/docs/stackit_organization_member_remove.md +++ b/docs/stackit_organization_member_remove.md @@ -36,10 +36,10 @@ stackit organization member remove SUBJECT [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_organization_role.md b/docs/stackit_organization_role.md index 6be031740..e95171361 100644 --- a/docs/stackit_organization_role.md +++ b/docs/stackit_organization_role.md @@ -21,10 +21,10 @@ stackit organization role [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_organization_role_list.md b/docs/stackit_organization_role_list.md index 265b9967e..13250aa93 100644 --- a/docs/stackit_organization_role_list.md +++ b/docs/stackit_organization_role_list.md @@ -36,10 +36,10 @@ stackit organization role list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_postgresflex.md b/docs/stackit_postgresflex.md index 125604dea..049c614ca 100644 --- a/docs/stackit_postgresflex.md +++ b/docs/stackit_postgresflex.md @@ -21,10 +21,10 @@ stackit postgresflex [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_postgresflex_backup.md b/docs/stackit_postgresflex_backup.md index 2fcac02b7..667a0d3ac 100644 --- a/docs/stackit_postgresflex_backup.md +++ b/docs/stackit_postgresflex_backup.md @@ -21,10 +21,10 @@ stackit postgresflex backup [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_postgresflex_backup_describe.md b/docs/stackit_postgresflex_backup_describe.md index bc506d775..41b20c98f 100644 --- a/docs/stackit_postgresflex_backup_describe.md +++ b/docs/stackit_postgresflex_backup_describe.md @@ -32,10 +32,10 @@ stackit postgresflex backup describe BACKUP_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_postgresflex_backup_list.md b/docs/stackit_postgresflex_backup_list.md index fcdc7a536..6c7c61b8a 100644 --- a/docs/stackit_postgresflex_backup_list.md +++ b/docs/stackit_postgresflex_backup_list.md @@ -36,10 +36,10 @@ stackit postgresflex backup list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_postgresflex_backup_update-schedule.md b/docs/stackit_postgresflex_backup_update-schedule.md index 50a369194..fa912af61 100644 --- a/docs/stackit_postgresflex_backup_update-schedule.md +++ b/docs/stackit_postgresflex_backup_update-schedule.md @@ -30,10 +30,10 @@ stackit postgresflex backup update-schedule [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_postgresflex_instance.md b/docs/stackit_postgresflex_instance.md index bfd19a6c9..4acb0d07b 100644 --- a/docs/stackit_postgresflex_instance.md +++ b/docs/stackit_postgresflex_instance.md @@ -21,10 +21,10 @@ stackit postgresflex instance [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_postgresflex_instance_clone.md b/docs/stackit_postgresflex_instance_clone.md index ce0203986..a435dd61e 100644 --- a/docs/stackit_postgresflex_instance_clone.md +++ b/docs/stackit_postgresflex_instance_clone.md @@ -37,10 +37,10 @@ stackit postgresflex instance clone INSTANCE_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_postgresflex_instance_create.md b/docs/stackit_postgresflex_instance_create.md index b4a333ba3..65150d045 100644 --- a/docs/stackit_postgresflex_instance_create.md +++ b/docs/stackit_postgresflex_instance_create.md @@ -35,7 +35,7 @@ stackit postgresflex instance create [flags] --ram int Amount of RAM (in GB) --storage-class string Storage class (default "premium-perf2-stackit") --storage-size int Storage size (in GB) (default 10) - --type string Instance type, one of ["Replica" "Single"] (default "Replica") + --type string Instance type, (one of: [Replica, Single]) (default "Replica") --version string PostgreSQL version. Defaults to the latest version available ``` @@ -44,10 +44,10 @@ stackit postgresflex instance create [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_postgresflex_instance_delete.md b/docs/stackit_postgresflex_instance_delete.md index 17992e627..c652d3745 100644 --- a/docs/stackit_postgresflex_instance_delete.md +++ b/docs/stackit_postgresflex_instance_delete.md @@ -34,10 +34,10 @@ stackit postgresflex instance delete INSTANCE_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_postgresflex_instance_describe.md b/docs/stackit_postgresflex_instance_describe.md index 629ffbc9b..7b50cb524 100644 --- a/docs/stackit_postgresflex_instance_describe.md +++ b/docs/stackit_postgresflex_instance_describe.md @@ -31,10 +31,10 @@ stackit postgresflex instance describe INSTANCE_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_postgresflex_instance_list.md b/docs/stackit_postgresflex_instance_list.md index 9d452376b..98c80590b 100644 --- a/docs/stackit_postgresflex_instance_list.md +++ b/docs/stackit_postgresflex_instance_list.md @@ -35,10 +35,10 @@ stackit postgresflex instance list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_postgresflex_instance_update.md b/docs/stackit_postgresflex_instance_update.md index 844e7d22a..511ccbc9c 100644 --- a/docs/stackit_postgresflex_instance_update.md +++ b/docs/stackit_postgresflex_instance_update.md @@ -32,7 +32,7 @@ stackit postgresflex instance update INSTANCE_ID [flags] --ram int Amount of RAM (in GB) --storage-class string Storage class --storage-size int Storage size (in GB) - --type string Instance type, one of ["Replica" "Single"] + --type string Instance type, (one of: [Replica, Single]) --version string Version ``` @@ -41,10 +41,10 @@ stackit postgresflex instance update INSTANCE_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_postgresflex_options.md b/docs/stackit_postgresflex_options.md index 7fa8ee2bd..d6dc73d98 100644 --- a/docs/stackit_postgresflex_options.md +++ b/docs/stackit_postgresflex_options.md @@ -39,10 +39,10 @@ stackit postgresflex options [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_postgresflex_user.md b/docs/stackit_postgresflex_user.md index b1793c663..af06124d4 100644 --- a/docs/stackit_postgresflex_user.md +++ b/docs/stackit_postgresflex_user.md @@ -21,10 +21,10 @@ stackit postgresflex user [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_postgresflex_user_create.md b/docs/stackit_postgresflex_user_create.md index fb66d84c3..918588b81 100644 --- a/docs/stackit_postgresflex_user_create.md +++ b/docs/stackit_postgresflex_user_create.md @@ -28,7 +28,7 @@ stackit postgresflex user create [flags] ``` -h, --help Help for "stackit postgresflex user create" --instance-id string ID of the instance - --role strings Roles of the user, possible values are ["login" "createdb"] (default [login]) + --role strings Roles of the user, (multiple of: [login, createdb]) (default [login]) --username string Username of the user ``` @@ -37,10 +37,10 @@ stackit postgresflex user create [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_postgresflex_user_delete.md b/docs/stackit_postgresflex_user_delete.md index 2bdd099d7..7c52deca2 100644 --- a/docs/stackit_postgresflex_user_delete.md +++ b/docs/stackit_postgresflex_user_delete.md @@ -31,10 +31,10 @@ stackit postgresflex user delete USER_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_postgresflex_user_describe.md b/docs/stackit_postgresflex_user_describe.md index 365b6764b..fc50454cf 100644 --- a/docs/stackit_postgresflex_user_describe.md +++ b/docs/stackit_postgresflex_user_describe.md @@ -34,10 +34,10 @@ stackit postgresflex user describe USER_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_postgresflex_user_list.md b/docs/stackit_postgresflex_user_list.md index 986fc8567..c2e817675 100644 --- a/docs/stackit_postgresflex_user_list.md +++ b/docs/stackit_postgresflex_user_list.md @@ -36,10 +36,10 @@ stackit postgresflex user list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_postgresflex_user_reset-password.md b/docs/stackit_postgresflex_user_reset-password.md index 42216c5e8..d99aeb9e7 100644 --- a/docs/stackit_postgresflex_user_reset-password.md +++ b/docs/stackit_postgresflex_user_reset-password.md @@ -30,10 +30,10 @@ stackit postgresflex user reset-password USER_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_postgresflex_user_update.md b/docs/stackit_postgresflex_user_update.md index d76b18447..643f2591c 100644 --- a/docs/stackit_postgresflex_user_update.md +++ b/docs/stackit_postgresflex_user_update.md @@ -22,7 +22,7 @@ stackit postgresflex user update USER_ID [flags] ``` -h, --help Help for "stackit postgresflex user update" --instance-id string ID of the instance - --role strings Roles of the user, possible values are ["login" "createdb"] (default []) + --role strings Roles of the user, (multiple of: [login, createdb]) (default []) ``` ### Options inherited from parent commands @@ -30,10 +30,10 @@ stackit postgresflex user update USER_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_project.md b/docs/stackit_project.md index cd2eb8f46..b1fafcb63 100644 --- a/docs/stackit_project.md +++ b/docs/stackit_project.md @@ -22,10 +22,10 @@ stackit project [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_project_create.md b/docs/stackit_project_create.md index 9cc565f2b..0a7f95f6f 100644 --- a/docs/stackit_project_create.md +++ b/docs/stackit_project_create.md @@ -43,10 +43,10 @@ stackit project create [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_project_delete.md b/docs/stackit_project_delete.md index b6eb31164..5292a0ada 100644 --- a/docs/stackit_project_delete.md +++ b/docs/stackit_project_delete.md @@ -31,10 +31,10 @@ stackit project delete [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_project_describe.md b/docs/stackit_project_describe.md index 6afced7fc..fded420d1 100644 --- a/docs/stackit_project_describe.md +++ b/docs/stackit_project_describe.md @@ -35,10 +35,10 @@ stackit project describe [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_project_list.md b/docs/stackit_project_list.md index f4b22b007..202a3008e 100644 --- a/docs/stackit_project_list.md +++ b/docs/stackit_project_list.md @@ -43,10 +43,10 @@ stackit project list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_project_member.md b/docs/stackit_project_member.md index 445143fe2..4e4f4bef4 100644 --- a/docs/stackit_project_member.md +++ b/docs/stackit_project_member.md @@ -21,10 +21,10 @@ stackit project member [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_project_member_add.md b/docs/stackit_project_member_add.md index d3fc54513..f39c0a932 100644 --- a/docs/stackit_project_member_add.md +++ b/docs/stackit_project_member_add.md @@ -33,10 +33,10 @@ stackit project member add SUBJECT [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_project_member_list.md b/docs/stackit_project_member_list.md index 18d7874d8..aeb8efa89 100644 --- a/docs/stackit_project_member_list.md +++ b/docs/stackit_project_member_list.md @@ -28,7 +28,7 @@ stackit project member list [flags] ``` -h, --help Help for "stackit project member list" --limit int Maximum number of entries to list - --sort-by string Sort entries by a specific field, one of ["subject" "role"] (default "subject") + --sort-by string Sort entries by a specific field, (one of: [subject, role]) (default "subject") --subject string Filter by subject (the identifier of a user, service account or client). This is usually the email address (for users) or name (for clients) ``` @@ -37,10 +37,10 @@ stackit project member list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_project_member_remove.md b/docs/stackit_project_member_remove.md index 908e44523..137a895d1 100644 --- a/docs/stackit_project_member_remove.md +++ b/docs/stackit_project_member_remove.md @@ -35,10 +35,10 @@ stackit project member remove SUBJECT [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_project_role.md b/docs/stackit_project_role.md index d02d2512d..9d69128f0 100644 --- a/docs/stackit_project_role.md +++ b/docs/stackit_project_role.md @@ -21,10 +21,10 @@ stackit project role [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_project_role_list.md b/docs/stackit_project_role_list.md index 90c54d0b1..cae7f48cf 100644 --- a/docs/stackit_project_role_list.md +++ b/docs/stackit_project_role_list.md @@ -35,10 +35,10 @@ stackit project role list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_project_update.md b/docs/stackit_project_update.md index 9c64e8f6a..69441ac12 100644 --- a/docs/stackit_project_update.md +++ b/docs/stackit_project_update.md @@ -37,10 +37,10 @@ stackit project update [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_public-ip.md b/docs/stackit_public-ip.md index d5dcafd53..569cf7f72 100644 --- a/docs/stackit_public-ip.md +++ b/docs/stackit_public-ip.md @@ -21,10 +21,10 @@ stackit public-ip [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_public-ip_associate.md b/docs/stackit_public-ip_associate.md index 484eabaf8..6d1f24a49 100644 --- a/docs/stackit_public-ip_associate.md +++ b/docs/stackit_public-ip_associate.md @@ -29,10 +29,10 @@ stackit public-ip associate PUBLIC_IP_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_public-ip_create.md b/docs/stackit_public-ip_create.md index 9ea017de9..fa0a5d592 100644 --- a/docs/stackit_public-ip_create.md +++ b/docs/stackit_public-ip_create.md @@ -36,10 +36,10 @@ stackit public-ip create [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_public-ip_delete.md b/docs/stackit_public-ip_delete.md index d5d7c46e2..161d07fca 100644 --- a/docs/stackit_public-ip_delete.md +++ b/docs/stackit_public-ip_delete.md @@ -30,10 +30,10 @@ stackit public-ip delete PUBLIC_IP_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_public-ip_describe.md b/docs/stackit_public-ip_describe.md index 811d7c4d7..3da3bb8ac 100644 --- a/docs/stackit_public-ip_describe.md +++ b/docs/stackit_public-ip_describe.md @@ -31,10 +31,10 @@ stackit public-ip describe PUBLIC_IP_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_public-ip_disassociate.md b/docs/stackit_public-ip_disassociate.md index 992ca2044..73733e35f 100644 --- a/docs/stackit_public-ip_disassociate.md +++ b/docs/stackit_public-ip_disassociate.md @@ -28,10 +28,10 @@ stackit public-ip disassociate PUBLIC_IP_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_public-ip_list.md b/docs/stackit_public-ip_list.md index 513394fa9..b4273ef94 100644 --- a/docs/stackit_public-ip_list.md +++ b/docs/stackit_public-ip_list.md @@ -39,10 +39,10 @@ stackit public-ip list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_public-ip_ranges.md b/docs/stackit_public-ip_ranges.md index 025ddba9b..70a7971e3 100644 --- a/docs/stackit_public-ip_ranges.md +++ b/docs/stackit_public-ip_ranges.md @@ -21,10 +21,10 @@ stackit public-ip ranges [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_public-ip_ranges_list.md b/docs/stackit_public-ip_ranges_list.md index c152b9851..8085da895 100644 --- a/docs/stackit_public-ip_ranges_list.md +++ b/docs/stackit_public-ip_ranges_list.md @@ -35,10 +35,10 @@ stackit public-ip ranges list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_public-ip_update.md b/docs/stackit_public-ip_update.md index 96a625987..8160b1a7e 100644 --- a/docs/stackit_public-ip_update.md +++ b/docs/stackit_public-ip_update.md @@ -32,10 +32,10 @@ stackit public-ip update PUBLIC_IP_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_quota.md b/docs/stackit_quota.md index 074b95cbc..f0c5abc3a 100644 --- a/docs/stackit_quota.md +++ b/docs/stackit_quota.md @@ -21,10 +21,10 @@ stackit quota [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_quota_list.md b/docs/stackit_quota_list.md index f68113391..5fc69d003 100644 --- a/docs/stackit_quota_list.md +++ b/docs/stackit_quota_list.md @@ -28,10 +28,10 @@ stackit quota list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_rabbitmq.md b/docs/stackit_rabbitmq.md index 2e6779ccc..f9a9e114c 100644 --- a/docs/stackit_rabbitmq.md +++ b/docs/stackit_rabbitmq.md @@ -21,10 +21,10 @@ stackit rabbitmq [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_rabbitmq_credentials.md b/docs/stackit_rabbitmq_credentials.md index debec8700..04020705c 100644 --- a/docs/stackit_rabbitmq_credentials.md +++ b/docs/stackit_rabbitmq_credentials.md @@ -21,10 +21,10 @@ stackit rabbitmq credentials [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_rabbitmq_credentials_create.md b/docs/stackit_rabbitmq_credentials_create.md index 98f1c8e4c..73f15ff9d 100644 --- a/docs/stackit_rabbitmq_credentials_create.md +++ b/docs/stackit_rabbitmq_credentials_create.md @@ -33,10 +33,10 @@ stackit rabbitmq credentials create [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_rabbitmq_credentials_delete.md b/docs/stackit_rabbitmq_credentials_delete.md index 9e9cae18e..1e6065af2 100644 --- a/docs/stackit_rabbitmq_credentials_delete.md +++ b/docs/stackit_rabbitmq_credentials_delete.md @@ -29,10 +29,10 @@ stackit rabbitmq credentials delete CREDENTIALS_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_rabbitmq_credentials_describe.md b/docs/stackit_rabbitmq_credentials_describe.md index bd1f9fad3..067255b88 100644 --- a/docs/stackit_rabbitmq_credentials_describe.md +++ b/docs/stackit_rabbitmq_credentials_describe.md @@ -32,10 +32,10 @@ stackit rabbitmq credentials describe CREDENTIALS_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_rabbitmq_credentials_list.md b/docs/stackit_rabbitmq_credentials_list.md index 8fe0b14f6..4ca3aa9e2 100644 --- a/docs/stackit_rabbitmq_credentials_list.md +++ b/docs/stackit_rabbitmq_credentials_list.md @@ -36,10 +36,10 @@ stackit rabbitmq credentials list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_rabbitmq_instance.md b/docs/stackit_rabbitmq_instance.md index 0c6dd7af3..c95d19a29 100644 --- a/docs/stackit_rabbitmq_instance.md +++ b/docs/stackit_rabbitmq_instance.md @@ -21,10 +21,10 @@ stackit rabbitmq instance [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_rabbitmq_instance_create.md b/docs/stackit_rabbitmq_instance_create.md index 8b00f0fcc..cff51b9e0 100644 --- a/docs/stackit_rabbitmq_instance_create.md +++ b/docs/stackit_rabbitmq_instance_create.md @@ -46,10 +46,10 @@ stackit rabbitmq instance create [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_rabbitmq_instance_delete.md b/docs/stackit_rabbitmq_instance_delete.md index 4a078fc5e..9ab5801f3 100644 --- a/docs/stackit_rabbitmq_instance_delete.md +++ b/docs/stackit_rabbitmq_instance_delete.md @@ -28,10 +28,10 @@ stackit rabbitmq instance delete INSTANCE_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_rabbitmq_instance_describe.md b/docs/stackit_rabbitmq_instance_describe.md index e2cb8cb74..bc17a046b 100644 --- a/docs/stackit_rabbitmq_instance_describe.md +++ b/docs/stackit_rabbitmq_instance_describe.md @@ -31,10 +31,10 @@ stackit rabbitmq instance describe INSTANCE_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_rabbitmq_instance_list.md b/docs/stackit_rabbitmq_instance_list.md index 196a8f275..d834200cc 100644 --- a/docs/stackit_rabbitmq_instance_list.md +++ b/docs/stackit_rabbitmq_instance_list.md @@ -35,10 +35,10 @@ stackit rabbitmq instance list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_rabbitmq_instance_update.md b/docs/stackit_rabbitmq_instance_update.md index 985781786..1635bbc4a 100644 --- a/docs/stackit_rabbitmq_instance_update.md +++ b/docs/stackit_rabbitmq_instance_update.md @@ -42,10 +42,10 @@ stackit rabbitmq instance update INSTANCE_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_rabbitmq_plans.md b/docs/stackit_rabbitmq_plans.md index fe33723a0..565b56f89 100644 --- a/docs/stackit_rabbitmq_plans.md +++ b/docs/stackit_rabbitmq_plans.md @@ -35,10 +35,10 @@ stackit rabbitmq plans [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_redis.md b/docs/stackit_redis.md index b371d2389..1afc75205 100644 --- a/docs/stackit_redis.md +++ b/docs/stackit_redis.md @@ -21,10 +21,10 @@ stackit redis [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_redis_credentials.md b/docs/stackit_redis_credentials.md index 323147b4b..5002442de 100644 --- a/docs/stackit_redis_credentials.md +++ b/docs/stackit_redis_credentials.md @@ -21,10 +21,10 @@ stackit redis credentials [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_redis_credentials_create.md b/docs/stackit_redis_credentials_create.md index 444f9ee1e..949cb2163 100644 --- a/docs/stackit_redis_credentials_create.md +++ b/docs/stackit_redis_credentials_create.md @@ -33,10 +33,10 @@ stackit redis credentials create [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_redis_credentials_delete.md b/docs/stackit_redis_credentials_delete.md index 2ff4795cf..702f80e1c 100644 --- a/docs/stackit_redis_credentials_delete.md +++ b/docs/stackit_redis_credentials_delete.md @@ -29,10 +29,10 @@ stackit redis credentials delete CREDENTIALS_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_redis_credentials_describe.md b/docs/stackit_redis_credentials_describe.md index 8c3937344..06a8a7cef 100644 --- a/docs/stackit_redis_credentials_describe.md +++ b/docs/stackit_redis_credentials_describe.md @@ -32,10 +32,10 @@ stackit redis credentials describe CREDENTIALS_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_redis_credentials_list.md b/docs/stackit_redis_credentials_list.md index 14c162c0b..4eefcd466 100644 --- a/docs/stackit_redis_credentials_list.md +++ b/docs/stackit_redis_credentials_list.md @@ -36,10 +36,10 @@ stackit redis credentials list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_redis_instance.md b/docs/stackit_redis_instance.md index 009415f9b..03c044a49 100644 --- a/docs/stackit_redis_instance.md +++ b/docs/stackit_redis_instance.md @@ -21,10 +21,10 @@ stackit redis instance [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_redis_instance_create.md b/docs/stackit_redis_instance_create.md index 004741d48..a17e2b72b 100644 --- a/docs/stackit_redis_instance_create.md +++ b/docs/stackit_redis_instance_create.md @@ -45,10 +45,10 @@ stackit redis instance create [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_redis_instance_delete.md b/docs/stackit_redis_instance_delete.md index 2508659ee..02383d8b8 100644 --- a/docs/stackit_redis_instance_delete.md +++ b/docs/stackit_redis_instance_delete.md @@ -28,10 +28,10 @@ stackit redis instance delete INSTANCE_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_redis_instance_describe.md b/docs/stackit_redis_instance_describe.md index 4f7632ca3..426c10631 100644 --- a/docs/stackit_redis_instance_describe.md +++ b/docs/stackit_redis_instance_describe.md @@ -31,10 +31,10 @@ stackit redis instance describe INSTANCE_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_redis_instance_list.md b/docs/stackit_redis_instance_list.md index 3c97031ac..aeb5a0963 100644 --- a/docs/stackit_redis_instance_list.md +++ b/docs/stackit_redis_instance_list.md @@ -35,10 +35,10 @@ stackit redis instance list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_redis_instance_update.md b/docs/stackit_redis_instance_update.md index 801622ed7..bf84834fa 100644 --- a/docs/stackit_redis_instance_update.md +++ b/docs/stackit_redis_instance_update.md @@ -41,10 +41,10 @@ stackit redis instance update INSTANCE_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_redis_plans.md b/docs/stackit_redis_plans.md index 2dc40245a..1a88287b3 100644 --- a/docs/stackit_redis_plans.md +++ b/docs/stackit_redis_plans.md @@ -35,10 +35,10 @@ stackit redis plans [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_secrets-manager.md b/docs/stackit_secrets-manager.md index 84bb95a52..d72dfad24 100644 --- a/docs/stackit_secrets-manager.md +++ b/docs/stackit_secrets-manager.md @@ -21,10 +21,10 @@ stackit secrets-manager [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_secrets-manager_instance.md b/docs/stackit_secrets-manager_instance.md index db579c80c..6a491b36b 100644 --- a/docs/stackit_secrets-manager_instance.md +++ b/docs/stackit_secrets-manager_instance.md @@ -21,10 +21,10 @@ stackit secrets-manager instance [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_secrets-manager_instance_create.md b/docs/stackit_secrets-manager_instance_create.md index 65108008a..7de5fd5f0 100644 --- a/docs/stackit_secrets-manager_instance_create.md +++ b/docs/stackit_secrets-manager_instance_create.md @@ -40,10 +40,10 @@ stackit secrets-manager instance create [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_secrets-manager_instance_delete.md b/docs/stackit_secrets-manager_instance_delete.md index 0a8b18c6b..7b8aa1155 100644 --- a/docs/stackit_secrets-manager_instance_delete.md +++ b/docs/stackit_secrets-manager_instance_delete.md @@ -28,10 +28,10 @@ stackit secrets-manager instance delete INSTANCE_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_secrets-manager_instance_describe.md b/docs/stackit_secrets-manager_instance_describe.md index d2695dc76..5b499b2fc 100644 --- a/docs/stackit_secrets-manager_instance_describe.md +++ b/docs/stackit_secrets-manager_instance_describe.md @@ -31,10 +31,10 @@ stackit secrets-manager instance describe INSTANCE_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_secrets-manager_instance_list.md b/docs/stackit_secrets-manager_instance_list.md index 742dd9000..74f957b50 100644 --- a/docs/stackit_secrets-manager_instance_list.md +++ b/docs/stackit_secrets-manager_instance_list.md @@ -35,10 +35,10 @@ stackit secrets-manager instance list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_secrets-manager_instance_update.md b/docs/stackit_secrets-manager_instance_update.md index c000c7cad..a0fb1a29a 100644 --- a/docs/stackit_secrets-manager_instance_update.md +++ b/docs/stackit_secrets-manager_instance_update.md @@ -43,10 +43,10 @@ stackit secrets-manager instance update INSTANCE_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_secrets-manager_user.md b/docs/stackit_secrets-manager_user.md index b6ba33cae..2e69e0c9c 100644 --- a/docs/stackit_secrets-manager_user.md +++ b/docs/stackit_secrets-manager_user.md @@ -21,10 +21,10 @@ stackit secrets-manager user [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_secrets-manager_user_create.md b/docs/stackit_secrets-manager_user_create.md index 34f83c324..629811420 100644 --- a/docs/stackit_secrets-manager_user_create.md +++ b/docs/stackit_secrets-manager_user_create.md @@ -36,10 +36,10 @@ stackit secrets-manager user create [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_secrets-manager_user_delete.md b/docs/stackit_secrets-manager_user_delete.md index eb2a28000..a4ab60a94 100644 --- a/docs/stackit_secrets-manager_user_delete.md +++ b/docs/stackit_secrets-manager_user_delete.md @@ -30,10 +30,10 @@ stackit secrets-manager user delete USER_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_secrets-manager_user_describe.md b/docs/stackit_secrets-manager_user_describe.md index 56ca9f25b..a67669a87 100644 --- a/docs/stackit_secrets-manager_user_describe.md +++ b/docs/stackit_secrets-manager_user_describe.md @@ -32,10 +32,10 @@ stackit secrets-manager user describe USER_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_secrets-manager_user_list.md b/docs/stackit_secrets-manager_user_list.md index b610591be..4f1f3ad99 100644 --- a/docs/stackit_secrets-manager_user_list.md +++ b/docs/stackit_secrets-manager_user_list.md @@ -36,10 +36,10 @@ stackit secrets-manager user list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_secrets-manager_user_update.md b/docs/stackit_secrets-manager_user_update.md index c181eb96e..d001b9657 100644 --- a/docs/stackit_secrets-manager_user_update.md +++ b/docs/stackit_secrets-manager_user_update.md @@ -34,10 +34,10 @@ stackit secrets-manager user update USER_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_security-group.md b/docs/stackit_security-group.md index 949333c96..42b36afed 100644 --- a/docs/stackit_security-group.md +++ b/docs/stackit_security-group.md @@ -21,10 +21,10 @@ stackit security-group [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_security-group_create.md b/docs/stackit_security-group_create.md index c63370118..969814d73 100644 --- a/docs/stackit_security-group_create.md +++ b/docs/stackit_security-group_create.md @@ -35,10 +35,10 @@ stackit security-group create [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_security-group_delete.md b/docs/stackit_security-group_delete.md index 6402e0bd2..1eb103da3 100644 --- a/docs/stackit_security-group_delete.md +++ b/docs/stackit_security-group_delete.md @@ -28,10 +28,10 @@ stackit security-group delete GROUP_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_security-group_describe.md b/docs/stackit_security-group_describe.md index 2a29d26fc..6e30a3add 100644 --- a/docs/stackit_security-group_describe.md +++ b/docs/stackit_security-group_describe.md @@ -28,10 +28,10 @@ stackit security-group describe GROUP_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_security-group_list.md b/docs/stackit_security-group_list.md index 20f86bf88..2f33177c2 100644 --- a/docs/stackit_security-group_list.md +++ b/docs/stackit_security-group_list.md @@ -39,10 +39,10 @@ stackit security-group list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_security-group_rule.md b/docs/stackit_security-group_rule.md index 558abe544..7c8d32396 100644 --- a/docs/stackit_security-group_rule.md +++ b/docs/stackit_security-group_rule.md @@ -21,10 +21,10 @@ stackit security-group rule [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_security-group_rule_create.md b/docs/stackit_security-group_rule_create.md index 0ad7a823b..90ecbdfdf 100644 --- a/docs/stackit_security-group_rule_create.md +++ b/docs/stackit_security-group_rule_create.md @@ -49,10 +49,10 @@ stackit security-group rule create [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_security-group_rule_delete.md b/docs/stackit_security-group_rule_delete.md index 003912835..d130759e9 100644 --- a/docs/stackit_security-group_rule_delete.md +++ b/docs/stackit_security-group_rule_delete.md @@ -31,10 +31,10 @@ stackit security-group rule delete SECURITY_GROUP_RULE_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_security-group_rule_describe.md b/docs/stackit_security-group_rule_describe.md index 66579d57e..0b016815a 100644 --- a/docs/stackit_security-group_rule_describe.md +++ b/docs/stackit_security-group_rule_describe.md @@ -32,10 +32,10 @@ stackit security-group rule describe SECURITY_GROUP_RULE_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_security-group_rule_list.md b/docs/stackit_security-group_rule_list.md index c1aff833b..93701b157 100644 --- a/docs/stackit_security-group_rule_list.md +++ b/docs/stackit_security-group_rule_list.md @@ -36,10 +36,10 @@ stackit security-group rule list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_security-group_update.md b/docs/stackit_security-group_update.md index 4dd30f03b..0240a1550 100644 --- a/docs/stackit_security-group_update.md +++ b/docs/stackit_security-group_update.md @@ -34,10 +34,10 @@ stackit security-group update GROUP_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_server.md b/docs/stackit_server.md index 267a8df3b..555ef00ac 100644 --- a/docs/stackit_server.md +++ b/docs/stackit_server.md @@ -21,10 +21,10 @@ stackit server [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_server_backup.md b/docs/stackit_server_backup.md index 40ec81ed9..7ad7ea4a1 100644 --- a/docs/stackit_server_backup.md +++ b/docs/stackit_server_backup.md @@ -21,10 +21,10 @@ stackit server backup [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_server_backup_create.md b/docs/stackit_server_backup_create.md index 0d77984fb..956ac525e 100644 --- a/docs/stackit_server_backup_create.md +++ b/docs/stackit_server_backup_create.md @@ -35,10 +35,10 @@ stackit server backup create [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_server_backup_delete.md b/docs/stackit_server_backup_delete.md index 96e1fca84..214ddbfc4 100644 --- a/docs/stackit_server_backup_delete.md +++ b/docs/stackit_server_backup_delete.md @@ -29,10 +29,10 @@ stackit server backup delete BACKUP_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_server_backup_describe.md b/docs/stackit_server_backup_describe.md index 008fc02ee..50887ab7f 100644 --- a/docs/stackit_server_backup_describe.md +++ b/docs/stackit_server_backup_describe.md @@ -32,10 +32,10 @@ stackit server backup describe BACKUP_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_server_backup_disable.md b/docs/stackit_server_backup_disable.md index 3a5d623d1..89f6389f8 100644 --- a/docs/stackit_server_backup_disable.md +++ b/docs/stackit_server_backup_disable.md @@ -29,10 +29,10 @@ stackit server backup disable [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_server_backup_enable.md b/docs/stackit_server_backup_enable.md index e0268a57f..5813bf387 100644 --- a/docs/stackit_server_backup_enable.md +++ b/docs/stackit_server_backup_enable.md @@ -29,10 +29,10 @@ stackit server backup enable [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_server_backup_list.md b/docs/stackit_server_backup_list.md index 702d4917b..c2e66bd9b 100644 --- a/docs/stackit_server_backup_list.md +++ b/docs/stackit_server_backup_list.md @@ -33,10 +33,10 @@ stackit server backup list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_server_backup_restore.md b/docs/stackit_server_backup_restore.md index 1b33b16f6..f1339eed1 100644 --- a/docs/stackit_server_backup_restore.md +++ b/docs/stackit_server_backup_restore.md @@ -34,10 +34,10 @@ stackit server backup restore BACKUP_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_server_backup_schedule.md b/docs/stackit_server_backup_schedule.md index 710c97b18..00c4ee68a 100644 --- a/docs/stackit_server_backup_schedule.md +++ b/docs/stackit_server_backup_schedule.md @@ -21,10 +21,10 @@ stackit server backup schedule [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_server_backup_schedule_create.md b/docs/stackit_server_backup_schedule_create.md index 8b0460852..bdc31cb3e 100644 --- a/docs/stackit_server_backup_schedule_create.md +++ b/docs/stackit_server_backup_schedule_create.md @@ -38,10 +38,10 @@ stackit server backup schedule create [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_server_backup_schedule_delete.md b/docs/stackit_server_backup_schedule_delete.md index e4fbf501f..e1dc97b6e 100644 --- a/docs/stackit_server_backup_schedule_delete.md +++ b/docs/stackit_server_backup_schedule_delete.md @@ -29,10 +29,10 @@ stackit server backup schedule delete SCHEDULE_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_server_backup_schedule_describe.md b/docs/stackit_server_backup_schedule_describe.md index e90933b67..d40e7bd0a 100644 --- a/docs/stackit_server_backup_schedule_describe.md +++ b/docs/stackit_server_backup_schedule_describe.md @@ -32,10 +32,10 @@ stackit server backup schedule describe BACKUP_SCHEDULE_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_server_backup_schedule_list.md b/docs/stackit_server_backup_schedule_list.md index e5c69b1ad..71ea6cf98 100644 --- a/docs/stackit_server_backup_schedule_list.md +++ b/docs/stackit_server_backup_schedule_list.md @@ -33,10 +33,10 @@ stackit server backup schedule list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_server_backup_schedule_update.md b/docs/stackit_server_backup_schedule_update.md index 522c6e7a7..dbb735961 100644 --- a/docs/stackit_server_backup_schedule_update.md +++ b/docs/stackit_server_backup_schedule_update.md @@ -38,10 +38,10 @@ stackit server backup schedule update SCHEDULE_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_server_backup_volume-backup.md b/docs/stackit_server_backup_volume-backup.md index ba8068b93..7574f3999 100644 --- a/docs/stackit_server_backup_volume-backup.md +++ b/docs/stackit_server_backup_volume-backup.md @@ -21,10 +21,10 @@ stackit server backup volume-backup [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_server_backup_volume-backup_delete.md b/docs/stackit_server_backup_volume-backup_delete.md index 9cbbdc727..2dcaa2df7 100644 --- a/docs/stackit_server_backup_volume-backup_delete.md +++ b/docs/stackit_server_backup_volume-backup_delete.md @@ -30,10 +30,10 @@ stackit server backup volume-backup delete VOLUME_BACKUP_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_server_backup_volume-backup_restore.md b/docs/stackit_server_backup_volume-backup_restore.md index 622d45f6f..e9d30413f 100644 --- a/docs/stackit_server_backup_volume-backup_restore.md +++ b/docs/stackit_server_backup_volume-backup_restore.md @@ -31,10 +31,10 @@ stackit server backup volume-backup restore VOLUME_BACKUP_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_server_command.md b/docs/stackit_server_command.md index c0640ba60..59b474d0e 100644 --- a/docs/stackit_server_command.md +++ b/docs/stackit_server_command.md @@ -21,10 +21,10 @@ stackit server command [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_server_command_create.md b/docs/stackit_server_command_create.md index 224e7742f..3bb634a67 100644 --- a/docs/stackit_server_command_create.md +++ b/docs/stackit_server_command_create.md @@ -34,10 +34,10 @@ stackit server command create [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_server_command_describe.md b/docs/stackit_server_command_describe.md index 61af4782c..4ea803d98 100644 --- a/docs/stackit_server_command_describe.md +++ b/docs/stackit_server_command_describe.md @@ -32,10 +32,10 @@ stackit server command describe COMMAND_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_server_command_list.md b/docs/stackit_server_command_list.md index 6467de601..f5c0b2aff 100644 --- a/docs/stackit_server_command_list.md +++ b/docs/stackit_server_command_list.md @@ -33,10 +33,10 @@ stackit server command list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_server_command_template.md b/docs/stackit_server_command_template.md index 92a904fea..17a293693 100644 --- a/docs/stackit_server_command_template.md +++ b/docs/stackit_server_command_template.md @@ -21,10 +21,10 @@ stackit server command template [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_server_command_template_describe.md b/docs/stackit_server_command_template_describe.md index 86a035a2b..871b979ce 100644 --- a/docs/stackit_server_command_template_describe.md +++ b/docs/stackit_server_command_template_describe.md @@ -32,10 +32,10 @@ stackit server command template describe COMMAND_TEMPLATE_NAME [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_server_command_template_list.md b/docs/stackit_server_command_template_list.md index 36457e6f1..5bc14adf5 100644 --- a/docs/stackit_server_command_template_list.md +++ b/docs/stackit_server_command_template_list.md @@ -32,10 +32,10 @@ stackit server command template list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_server_console.md b/docs/stackit_server_console.md index a8f6300a6..6b1626f30 100644 --- a/docs/stackit_server_console.md +++ b/docs/stackit_server_console.md @@ -31,10 +31,10 @@ stackit server console SERVER_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_server_create.md b/docs/stackit_server_create.md index f3d1557ea..c459a4c63 100644 --- a/docs/stackit_server_create.md +++ b/docs/stackit_server_create.md @@ -39,7 +39,7 @@ stackit server create [flags] ``` --affinity-group string The affinity group the server is assigned to - --agent-provisioning-policy string Whether to provision an agent on server creation, one of ["ALWAYS" "NEVER" "INHERIT"] (default "INHERIT") + --agent-provisioning-policy string Whether to provision an agent on server creation, (one of: [ALWAYS, NEVER, INHERIT]) (default "INHERIT") --availability-zone string The availability zone of the server --boot-volume-delete-on-termination Delete the volume during the termination of the server. Defaults to false --boot-volume-performance-class string Boot volume performance class @@ -64,10 +64,10 @@ stackit server create [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_server_deallocate.md b/docs/stackit_server_deallocate.md index aa4921589..25aa67db9 100644 --- a/docs/stackit_server_deallocate.md +++ b/docs/stackit_server_deallocate.md @@ -28,10 +28,10 @@ stackit server deallocate SERVER_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_server_delete.md b/docs/stackit_server_delete.md index 32cf0bfe5..3a3a32155 100644 --- a/docs/stackit_server_delete.md +++ b/docs/stackit_server_delete.md @@ -30,10 +30,10 @@ stackit server delete SERVER_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_server_describe.md b/docs/stackit_server_describe.md index c6507dfbe..2ae8882bd 100644 --- a/docs/stackit_server_describe.md +++ b/docs/stackit_server_describe.md @@ -31,10 +31,10 @@ stackit server describe SERVER_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_server_list.md b/docs/stackit_server_list.md index 064850236..703b7e5bc 100644 --- a/docs/stackit_server_list.md +++ b/docs/stackit_server_list.md @@ -39,10 +39,10 @@ stackit server list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_server_log.md b/docs/stackit_server_log.md index c1e1e7975..7cde020a4 100644 --- a/docs/stackit_server_log.md +++ b/docs/stackit_server_log.md @@ -35,10 +35,10 @@ stackit server log SERVER_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_server_machine-type.md b/docs/stackit_server_machine-type.md index 4a7058bd8..04d80923f 100644 --- a/docs/stackit_server_machine-type.md +++ b/docs/stackit_server_machine-type.md @@ -21,10 +21,10 @@ stackit server machine-type [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_server_machine-type_describe.md b/docs/stackit_server_machine-type_describe.md index c79ec2a84..a35a9b8fe 100644 --- a/docs/stackit_server_machine-type_describe.md +++ b/docs/stackit_server_machine-type_describe.md @@ -31,10 +31,10 @@ stackit server machine-type describe MACHINE_TYPE [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_server_machine-type_list.md b/docs/stackit_server_machine-type_list.md index 127563908..405f8c365 100644 --- a/docs/stackit_server_machine-type_list.md +++ b/docs/stackit_server_machine-type_list.md @@ -42,10 +42,10 @@ stackit server machine-type list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_server_network-interface.md b/docs/stackit_server_network-interface.md index c198fb69f..742f7cb0f 100644 --- a/docs/stackit_server_network-interface.md +++ b/docs/stackit_server_network-interface.md @@ -21,10 +21,10 @@ stackit server network-interface [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_server_network-interface_attach.md b/docs/stackit_server_network-interface_attach.md index f20e49cb5..3ad6fa2bd 100644 --- a/docs/stackit_server_network-interface_attach.md +++ b/docs/stackit_server_network-interface_attach.md @@ -35,10 +35,10 @@ stackit server network-interface attach [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_server_network-interface_detach.md b/docs/stackit_server_network-interface_detach.md index 19369455a..fa5c2fbf8 100644 --- a/docs/stackit_server_network-interface_detach.md +++ b/docs/stackit_server_network-interface_detach.md @@ -35,10 +35,10 @@ stackit server network-interface detach [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_server_network-interface_list.md b/docs/stackit_server_network-interface_list.md index 42ed2e5b5..c458511bd 100644 --- a/docs/stackit_server_network-interface_list.md +++ b/docs/stackit_server_network-interface_list.md @@ -36,10 +36,10 @@ stackit server network-interface list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_server_os-update.md b/docs/stackit_server_os-update.md index baf0ad8cc..581190fc8 100644 --- a/docs/stackit_server_os-update.md +++ b/docs/stackit_server_os-update.md @@ -21,10 +21,10 @@ stackit server os-update [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_server_os-update_create.md b/docs/stackit_server_os-update_create.md index 4d110f8bc..d7661419a 100644 --- a/docs/stackit_server_os-update_create.md +++ b/docs/stackit_server_os-update_create.md @@ -33,10 +33,10 @@ stackit server os-update create [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_server_os-update_describe.md b/docs/stackit_server_os-update_describe.md index 8302a131f..847aeb41a 100644 --- a/docs/stackit_server_os-update_describe.md +++ b/docs/stackit_server_os-update_describe.md @@ -32,10 +32,10 @@ stackit server os-update describe UPDATE_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_server_os-update_disable.md b/docs/stackit_server_os-update_disable.md index 5be186b0b..be2dee1f5 100644 --- a/docs/stackit_server_os-update_disable.md +++ b/docs/stackit_server_os-update_disable.md @@ -29,10 +29,10 @@ stackit server os-update disable [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_server_os-update_enable.md b/docs/stackit_server_os-update_enable.md index fdcc98abe..a702fe39b 100644 --- a/docs/stackit_server_os-update_enable.md +++ b/docs/stackit_server_os-update_enable.md @@ -29,10 +29,10 @@ stackit server os-update enable [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_server_os-update_list.md b/docs/stackit_server_os-update_list.md index 97ff3bad7..fa2007ac6 100644 --- a/docs/stackit_server_os-update_list.md +++ b/docs/stackit_server_os-update_list.md @@ -33,10 +33,10 @@ stackit server os-update list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_server_os-update_schedule.md b/docs/stackit_server_os-update_schedule.md index 1cc934797..4a174f00f 100644 --- a/docs/stackit_server_os-update_schedule.md +++ b/docs/stackit_server_os-update_schedule.md @@ -21,10 +21,10 @@ stackit server os-update schedule [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_server_os-update_schedule_create.md b/docs/stackit_server_os-update_schedule_create.md index 75862ef17..fed9333d2 100644 --- a/docs/stackit_server_os-update_schedule_create.md +++ b/docs/stackit_server_os-update_schedule_create.md @@ -36,10 +36,10 @@ stackit server os-update schedule create [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_server_os-update_schedule_delete.md b/docs/stackit_server_os-update_schedule_delete.md index c61c8b7ce..a320b1b73 100644 --- a/docs/stackit_server_os-update_schedule_delete.md +++ b/docs/stackit_server_os-update_schedule_delete.md @@ -29,10 +29,10 @@ stackit server os-update schedule delete SCHEDULE_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_server_os-update_schedule_describe.md b/docs/stackit_server_os-update_schedule_describe.md index f93d219ac..c705d3da2 100644 --- a/docs/stackit_server_os-update_schedule_describe.md +++ b/docs/stackit_server_os-update_schedule_describe.md @@ -32,10 +32,10 @@ stackit server os-update schedule describe SCHEDULE_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_server_os-update_schedule_list.md b/docs/stackit_server_os-update_schedule_list.md index 3cf2d1580..e1acca16c 100644 --- a/docs/stackit_server_os-update_schedule_list.md +++ b/docs/stackit_server_os-update_schedule_list.md @@ -33,10 +33,10 @@ stackit server os-update schedule list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_server_os-update_schedule_update.md b/docs/stackit_server_os-update_schedule_update.md index 8a29cd366..1515127ac 100644 --- a/docs/stackit_server_os-update_schedule_update.md +++ b/docs/stackit_server_os-update_schedule_update.md @@ -33,10 +33,10 @@ stackit server os-update schedule update SCHEDULE_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_server_public-ip.md b/docs/stackit_server_public-ip.md index 6ad5bfc99..98f26b955 100644 --- a/docs/stackit_server_public-ip.md +++ b/docs/stackit_server_public-ip.md @@ -21,10 +21,10 @@ stackit server public-ip [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_server_public-ip_attach.md b/docs/stackit_server_public-ip_attach.md index a3cc5172f..e7299a2a5 100644 --- a/docs/stackit_server_public-ip_attach.md +++ b/docs/stackit_server_public-ip_attach.md @@ -29,10 +29,10 @@ stackit server public-ip attach PUBLIC_IP_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_server_public-ip_detach.md b/docs/stackit_server_public-ip_detach.md index 4881e3c2d..ac30baea9 100644 --- a/docs/stackit_server_public-ip_detach.md +++ b/docs/stackit_server_public-ip_detach.md @@ -29,10 +29,10 @@ stackit server public-ip detach PUBLIC_IP_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_server_reboot.md b/docs/stackit_server_reboot.md index 8075a67ba..1353ae9d0 100644 --- a/docs/stackit_server_reboot.md +++ b/docs/stackit_server_reboot.md @@ -32,10 +32,10 @@ stackit server reboot SERVER_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_server_rescue.md b/docs/stackit_server_rescue.md index 4aaa5104b..a42ad285e 100644 --- a/docs/stackit_server_rescue.md +++ b/docs/stackit_server_rescue.md @@ -29,10 +29,10 @@ stackit server rescue SERVER_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_server_resize.md b/docs/stackit_server_resize.md index bbcb239f5..3c70bcb7e 100644 --- a/docs/stackit_server_resize.md +++ b/docs/stackit_server_resize.md @@ -29,10 +29,10 @@ stackit server resize SERVER_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_server_security-group.md b/docs/stackit_server_security-group.md index b44ce57e4..4371f853d 100644 --- a/docs/stackit_server_security-group.md +++ b/docs/stackit_server_security-group.md @@ -21,10 +21,10 @@ stackit server security-group [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_server_security-group_attach.md b/docs/stackit_server_security-group_attach.md index c42466381..8f60a4c1e 100644 --- a/docs/stackit_server_security-group_attach.md +++ b/docs/stackit_server_security-group_attach.md @@ -30,10 +30,10 @@ stackit server security-group attach [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_server_security-group_detach.md b/docs/stackit_server_security-group_detach.md index 493eee69f..c0719430d 100644 --- a/docs/stackit_server_security-group_detach.md +++ b/docs/stackit_server_security-group_detach.md @@ -30,10 +30,10 @@ stackit server security-group detach [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_server_service-account.md b/docs/stackit_server_service-account.md index 5af599a53..375145c72 100644 --- a/docs/stackit_server_service-account.md +++ b/docs/stackit_server_service-account.md @@ -21,10 +21,10 @@ stackit server service-account [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_server_service-account_attach.md b/docs/stackit_server_service-account_attach.md index 2cd7be4c7..26df44ffd 100644 --- a/docs/stackit_server_service-account_attach.md +++ b/docs/stackit_server_service-account_attach.md @@ -30,10 +30,10 @@ stackit server service-account attach [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_server_service-account_detach.md b/docs/stackit_server_service-account_detach.md index 6155054fb..b409d406b 100644 --- a/docs/stackit_server_service-account_detach.md +++ b/docs/stackit_server_service-account_detach.md @@ -30,10 +30,10 @@ stackit server service-account detach [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_server_service-account_list.md b/docs/stackit_server_service-account_list.md index 78349aee3..53a629223 100644 --- a/docs/stackit_server_service-account_list.md +++ b/docs/stackit_server_service-account_list.md @@ -36,10 +36,10 @@ stackit server service-account list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_server_start.md b/docs/stackit_server_start.md index 1fa89116d..21ef308a5 100644 --- a/docs/stackit_server_start.md +++ b/docs/stackit_server_start.md @@ -28,10 +28,10 @@ stackit server start SERVER_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_server_stop.md b/docs/stackit_server_stop.md index 41403e1f7..44e501a67 100644 --- a/docs/stackit_server_stop.md +++ b/docs/stackit_server_stop.md @@ -28,10 +28,10 @@ stackit server stop SERVER_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_server_unrescue.md b/docs/stackit_server_unrescue.md index 5dc30bab3..0c111d8ac 100644 --- a/docs/stackit_server_unrescue.md +++ b/docs/stackit_server_unrescue.md @@ -28,10 +28,10 @@ stackit server unrescue SERVER_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_server_update.md b/docs/stackit_server_update.md index 3aac20259..c47e8810a 100644 --- a/docs/stackit_server_update.md +++ b/docs/stackit_server_update.md @@ -33,10 +33,10 @@ stackit server update SERVER_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_server_volume.md b/docs/stackit_server_volume.md index 74e426604..da58fe5e7 100644 --- a/docs/stackit_server_volume.md +++ b/docs/stackit_server_volume.md @@ -21,10 +21,10 @@ stackit server volume [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_server_volume_attach.md b/docs/stackit_server_volume_attach.md index b7014c6a1..15de47087 100644 --- a/docs/stackit_server_volume_attach.md +++ b/docs/stackit_server_volume_attach.md @@ -33,10 +33,10 @@ stackit server volume attach VOLUME_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_server_volume_describe.md b/docs/stackit_server_volume_describe.md index be85d6afc..8a399fbe8 100644 --- a/docs/stackit_server_volume_describe.md +++ b/docs/stackit_server_volume_describe.md @@ -35,10 +35,10 @@ stackit server volume describe VOLUME_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_server_volume_detach.md b/docs/stackit_server_volume_detach.md index 3758a7b35..0106a4a1b 100644 --- a/docs/stackit_server_volume_detach.md +++ b/docs/stackit_server_volume_detach.md @@ -29,10 +29,10 @@ stackit server volume detach VOLUME_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_server_volume_list.md b/docs/stackit_server_volume_list.md index 97560e090..06be69594 100644 --- a/docs/stackit_server_volume_list.md +++ b/docs/stackit_server_volume_list.md @@ -32,10 +32,10 @@ stackit server volume list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_server_volume_update.md b/docs/stackit_server_volume_update.md index 70290e948..aabe54f13 100644 --- a/docs/stackit_server_volume_update.md +++ b/docs/stackit_server_volume_update.md @@ -30,10 +30,10 @@ stackit server volume update VOLUME_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_service-account.md b/docs/stackit_service-account.md index fbd524334..2d5d4d37d 100644 --- a/docs/stackit_service-account.md +++ b/docs/stackit_service-account.md @@ -21,10 +21,10 @@ stackit service-account [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_service-account_create.md b/docs/stackit_service-account_create.md index cb1617fc7..d28c26f6d 100644 --- a/docs/stackit_service-account_create.md +++ b/docs/stackit_service-account_create.md @@ -29,10 +29,10 @@ stackit service-account create [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_service-account_delete.md b/docs/stackit_service-account_delete.md index 3e011d03f..e466da9ef 100644 --- a/docs/stackit_service-account_delete.md +++ b/docs/stackit_service-account_delete.md @@ -28,10 +28,10 @@ stackit service-account delete EMAIL [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_service-account_get-jwks.md b/docs/stackit_service-account_get-jwks.md index 2c34e76fb..9cd0a2519 100644 --- a/docs/stackit_service-account_get-jwks.md +++ b/docs/stackit_service-account_get-jwks.md @@ -28,10 +28,10 @@ stackit service-account get-jwks EMAIL [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_service-account_key.md b/docs/stackit_service-account_key.md index bb4306f77..bbda852da 100644 --- a/docs/stackit_service-account_key.md +++ b/docs/stackit_service-account_key.md @@ -21,10 +21,10 @@ stackit service-account key [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_service-account_key_create.md b/docs/stackit_service-account_key_create.md index 0ebcf7d02..108638ccb 100644 --- a/docs/stackit_service-account_key_create.md +++ b/docs/stackit_service-account_key_create.md @@ -39,10 +39,10 @@ stackit service-account key create [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_service-account_key_delete.md b/docs/stackit_service-account_key_delete.md index b039f82f4..7d4b60b8e 100644 --- a/docs/stackit_service-account_key_delete.md +++ b/docs/stackit_service-account_key_delete.md @@ -29,10 +29,10 @@ stackit service-account key delete KEY_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_service-account_key_describe.md b/docs/stackit_service-account_key_describe.md index 2ff0ac156..32212c019 100644 --- a/docs/stackit_service-account_key_describe.md +++ b/docs/stackit_service-account_key_describe.md @@ -29,10 +29,10 @@ stackit service-account key describe KEY_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_service-account_key_list.md b/docs/stackit_service-account_key_list.md index 8ad4ad291..6d65b39f5 100644 --- a/docs/stackit_service-account_key_list.md +++ b/docs/stackit_service-account_key_list.md @@ -36,10 +36,10 @@ stackit service-account key list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_service-account_key_update.md b/docs/stackit_service-account_key_update.md index f16648405..c2eb660c3 100644 --- a/docs/stackit_service-account_key_update.md +++ b/docs/stackit_service-account_key_update.md @@ -39,10 +39,10 @@ stackit service-account key update KEY_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_service-account_list.md b/docs/stackit_service-account_list.md index 6e00f821c..421074710 100644 --- a/docs/stackit_service-account_list.md +++ b/docs/stackit_service-account_list.md @@ -29,10 +29,10 @@ stackit service-account list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_service-account_token.md b/docs/stackit_service-account_token.md index d417d9095..fcf521ca1 100644 --- a/docs/stackit_service-account_token.md +++ b/docs/stackit_service-account_token.md @@ -21,10 +21,10 @@ stackit service-account token [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_service-account_token_create.md b/docs/stackit_service-account_token_create.md index bcdc6fc41..e4e299392 100644 --- a/docs/stackit_service-account_token_create.md +++ b/docs/stackit_service-account_token_create.md @@ -35,10 +35,10 @@ stackit service-account token create [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_service-account_token_list.md b/docs/stackit_service-account_token_list.md index 800689e4c..46cbb4c18 100644 --- a/docs/stackit_service-account_token_list.md +++ b/docs/stackit_service-account_token_list.md @@ -38,10 +38,10 @@ stackit service-account token list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_service-account_token_revoke.md b/docs/stackit_service-account_token_revoke.md index d295e8168..a226c1c53 100644 --- a/docs/stackit_service-account_token_revoke.md +++ b/docs/stackit_service-account_token_revoke.md @@ -31,10 +31,10 @@ stackit service-account token revoke TOKEN_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_ske.md b/docs/stackit_ske.md index b6a307937..dfcc13116 100644 --- a/docs/stackit_ske.md +++ b/docs/stackit_ske.md @@ -21,10 +21,10 @@ stackit ske [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_ske_cluster.md b/docs/stackit_ske_cluster.md index a575e5495..6ecab2783 100644 --- a/docs/stackit_ske_cluster.md +++ b/docs/stackit_ske_cluster.md @@ -21,10 +21,10 @@ stackit ske cluster [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_ske_cluster_create.md b/docs/stackit_ske_cluster_create.md index 3c94a7bdd..8dc73c36d 100644 --- a/docs/stackit_ske_cluster_create.md +++ b/docs/stackit_ske_cluster_create.md @@ -42,10 +42,10 @@ stackit ske cluster create CLUSTER_NAME [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_ske_cluster_delete.md b/docs/stackit_ske_cluster_delete.md index c1c0407a7..0c27d8a88 100644 --- a/docs/stackit_ske_cluster_delete.md +++ b/docs/stackit_ske_cluster_delete.md @@ -28,10 +28,10 @@ stackit ske cluster delete CLUSTER_NAME [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_ske_cluster_describe.md b/docs/stackit_ske_cluster_describe.md index 91b3949fc..d934e0078 100644 --- a/docs/stackit_ske_cluster_describe.md +++ b/docs/stackit_ske_cluster_describe.md @@ -31,10 +31,10 @@ stackit ske cluster describe CLUSTER_NAME [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_ske_cluster_generate-payload.md b/docs/stackit_ske_cluster_generate-payload.md index d5592293f..db49e0480 100644 --- a/docs/stackit_ske_cluster_generate-payload.md +++ b/docs/stackit_ske_cluster_generate-payload.md @@ -41,10 +41,10 @@ stackit ske cluster generate-payload [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_ske_cluster_hibernate.md b/docs/stackit_ske_cluster_hibernate.md index 20baddd1b..e626e944e 100644 --- a/docs/stackit_ske_cluster_hibernate.md +++ b/docs/stackit_ske_cluster_hibernate.md @@ -28,10 +28,10 @@ stackit ske cluster hibernate CLUSTER_NAME [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_ske_cluster_list.md b/docs/stackit_ske_cluster_list.md index a757d19b3..6579158fd 100644 --- a/docs/stackit_ske_cluster_list.md +++ b/docs/stackit_ske_cluster_list.md @@ -35,10 +35,10 @@ stackit ske cluster list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_ske_cluster_maintenance.md b/docs/stackit_ske_cluster_maintenance.md index 0a6c6540c..2bc324d1d 100644 --- a/docs/stackit_ske_cluster_maintenance.md +++ b/docs/stackit_ske_cluster_maintenance.md @@ -28,10 +28,10 @@ stackit ske cluster maintenance CLUSTER_NAME [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_ske_cluster_reconcile.md b/docs/stackit_ske_cluster_reconcile.md index 64887316d..df5fc87f3 100644 --- a/docs/stackit_ske_cluster_reconcile.md +++ b/docs/stackit_ske_cluster_reconcile.md @@ -28,10 +28,10 @@ stackit ske cluster reconcile CLUSTER_NAME [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_ske_cluster_update.md b/docs/stackit_ske_cluster_update.md index 24fa95748..28289423a 100644 --- a/docs/stackit_ske_cluster_update.md +++ b/docs/stackit_ske_cluster_update.md @@ -39,10 +39,10 @@ stackit ske cluster update CLUSTER_NAME [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_ske_cluster_wakeup.md b/docs/stackit_ske_cluster_wakeup.md index 7b07e9965..f639657f0 100644 --- a/docs/stackit_ske_cluster_wakeup.md +++ b/docs/stackit_ske_cluster_wakeup.md @@ -28,10 +28,10 @@ stackit ske cluster wakeup CLUSTER_NAME [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_ske_credentials.md b/docs/stackit_ske_credentials.md index 252b629e0..d5de8a89e 100644 --- a/docs/stackit_ske_credentials.md +++ b/docs/stackit_ske_credentials.md @@ -21,10 +21,10 @@ stackit ske credentials [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_ske_credentials_complete-rotation.md b/docs/stackit_ske_credentials_complete-rotation.md index 7df00136f..29db45813 100644 --- a/docs/stackit_ske_credentials_complete-rotation.md +++ b/docs/stackit_ske_credentials_complete-rotation.md @@ -43,10 +43,10 @@ stackit ske credentials complete-rotation CLUSTER_NAME [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_ske_credentials_start-rotation.md b/docs/stackit_ske_credentials_start-rotation.md index 05200a386..a99123344 100644 --- a/docs/stackit_ske_credentials_start-rotation.md +++ b/docs/stackit_ske_credentials_start-rotation.md @@ -47,10 +47,10 @@ stackit ske credentials start-rotation CLUSTER_NAME [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_ske_describe.md b/docs/stackit_ske_describe.md index 1cd29f31d..1764bd6ba 100644 --- a/docs/stackit_ske_describe.md +++ b/docs/stackit_ske_describe.md @@ -28,10 +28,10 @@ stackit ske describe [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_ske_disable.md b/docs/stackit_ske_disable.md index c86d2b10c..f72e3a12d 100644 --- a/docs/stackit_ske_disable.md +++ b/docs/stackit_ske_disable.md @@ -28,10 +28,10 @@ stackit ske disable [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_ske_enable.md b/docs/stackit_ske_enable.md index ccc25bebb..2bef68fee 100644 --- a/docs/stackit_ske_enable.md +++ b/docs/stackit_ske_enable.md @@ -28,10 +28,10 @@ stackit ske enable [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_ske_kubeconfig.md b/docs/stackit_ske_kubeconfig.md index 83634e149..84056db65 100644 --- a/docs/stackit_ske_kubeconfig.md +++ b/docs/stackit_ske_kubeconfig.md @@ -21,10 +21,10 @@ stackit ske kubeconfig [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_ske_kubeconfig_create.md b/docs/stackit_ske_kubeconfig_create.md index 5717a31f8..e93d7c3cc 100644 --- a/docs/stackit_ske_kubeconfig_create.md +++ b/docs/stackit_ske_kubeconfig_create.md @@ -48,7 +48,7 @@ stackit ske kubeconfig create CLUSTER_NAME [flags] ### Options ``` - --disable-writing Disable the writing of kubeconfig. Set the output format to json or yaml using the --output-format flag to display the kubeconfig. + --disable-writing Disable the writing of kubeconfig. Set the output format to json or yaml using the -- flag to display the kubeconfig. -e, --expiration string Expiration time for the kubeconfig in seconds(s), minutes(m), hours(h), days(d) or months(M). Example: 30d. By default, expiration time is 1h --filepath string Path to create the kubeconfig file. Will fall back to KUBECONFIG env variable if not set. In case both aren't set, the kubeconfig is created as file named 'config' in the .kube folder in the user's home directory. -h, --help Help for "stackit ske kubeconfig create" @@ -62,10 +62,10 @@ stackit ske kubeconfig create CLUSTER_NAME [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_ske_kubeconfig_login.md b/docs/stackit_ske_kubeconfig_login.md index 2b9956717..0df7567e5 100644 --- a/docs/stackit_ske_kubeconfig_login.md +++ b/docs/stackit_ske_kubeconfig_login.md @@ -38,10 +38,10 @@ stackit ske kubeconfig login [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_ske_options.md b/docs/stackit_ske_options.md index 2590f989c..8dbcddd46 100644 --- a/docs/stackit_ske_options.md +++ b/docs/stackit_ske_options.md @@ -23,10 +23,10 @@ stackit ske options [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_ske_options_availability-zones.md b/docs/stackit_ske_options_availability-zones.md index 4bf77c67f..77ecaf24e 100644 --- a/docs/stackit_ske_options_availability-zones.md +++ b/docs/stackit_ske_options_availability-zones.md @@ -28,10 +28,10 @@ stackit ske options availability-zones [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_ske_options_kubernetes-versions.md b/docs/stackit_ske_options_kubernetes-versions.md index a2dd50edd..3d0b25d58 100644 --- a/docs/stackit_ske_options_kubernetes-versions.md +++ b/docs/stackit_ske_options_kubernetes-versions.md @@ -32,10 +32,10 @@ stackit ske options kubernetes-versions [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_ske_options_machine-images.md b/docs/stackit_ske_options_machine-images.md index f6deb67db..646c4fc31 100644 --- a/docs/stackit_ske_options_machine-images.md +++ b/docs/stackit_ske_options_machine-images.md @@ -28,10 +28,10 @@ stackit ske options machine-images [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_ske_options_machine-types.md b/docs/stackit_ske_options_machine-types.md index 333384fc3..d5601ed3e 100644 --- a/docs/stackit_ske_options_machine-types.md +++ b/docs/stackit_ske_options_machine-types.md @@ -28,10 +28,10 @@ stackit ske options machine-types [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_ske_options_volume-types.md b/docs/stackit_ske_options_volume-types.md index aeea921dc..54f032aa8 100644 --- a/docs/stackit_ske_options_volume-types.md +++ b/docs/stackit_ske_options_volume-types.md @@ -28,10 +28,10 @@ stackit ske options volume-types [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_volume.md b/docs/stackit_volume.md index 3412504c2..67664d6ba 100644 --- a/docs/stackit_volume.md +++ b/docs/stackit_volume.md @@ -21,10 +21,10 @@ stackit volume [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_volume_backup.md b/docs/stackit_volume_backup.md index f6390f385..23d579a9c 100644 --- a/docs/stackit_volume_backup.md +++ b/docs/stackit_volume_backup.md @@ -21,10 +21,10 @@ stackit volume backup [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_volume_backup_create.md b/docs/stackit_volume_backup_create.md index 5a322f34a..22fcd307f 100644 --- a/docs/stackit_volume_backup_create.md +++ b/docs/stackit_volume_backup_create.md @@ -30,7 +30,7 @@ stackit volume backup create [flags] --labels stringToString Key-value string pairs as labels (default []) --name string Name of the backup --source-id string ID of the source from which a backup should be created - --source-type string Source type of the backup, one of ["volume" "snapshot"] + --source-type string Source type of the backup, (one of: [volume, snapshot]) ``` ### Options inherited from parent commands @@ -38,10 +38,10 @@ stackit volume backup create [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_volume_backup_delete.md b/docs/stackit_volume_backup_delete.md index 5300f7854..e0d43a4ce 100644 --- a/docs/stackit_volume_backup_delete.md +++ b/docs/stackit_volume_backup_delete.md @@ -28,10 +28,10 @@ stackit volume backup delete BACKUP_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_volume_backup_describe.md b/docs/stackit_volume_backup_describe.md index dbff5e4dc..dd4b3e1d6 100644 --- a/docs/stackit_volume_backup_describe.md +++ b/docs/stackit_volume_backup_describe.md @@ -31,10 +31,10 @@ stackit volume backup describe BACKUP_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_volume_backup_list.md b/docs/stackit_volume_backup_list.md index 91f3ca99a..5c06dec33 100644 --- a/docs/stackit_volume_backup_list.md +++ b/docs/stackit_volume_backup_list.md @@ -39,10 +39,10 @@ stackit volume backup list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_volume_backup_restore.md b/docs/stackit_volume_backup_restore.md index 80dc563db..95e68d9b7 100644 --- a/docs/stackit_volume_backup_restore.md +++ b/docs/stackit_volume_backup_restore.md @@ -28,10 +28,10 @@ stackit volume backup restore BACKUP_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_volume_backup_update.md b/docs/stackit_volume_backup_update.md index 02f86f4e8..0c08c6b32 100644 --- a/docs/stackit_volume_backup_update.md +++ b/docs/stackit_volume_backup_update.md @@ -33,10 +33,10 @@ stackit volume backup update BACKUP_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_volume_create.md b/docs/stackit_volume_create.md index dedf3c595..d10e8e992 100644 --- a/docs/stackit_volume_create.md +++ b/docs/stackit_volume_create.md @@ -45,10 +45,10 @@ stackit volume create [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_volume_delete.md b/docs/stackit_volume_delete.md index 165804aa6..8f7eaadd5 100644 --- a/docs/stackit_volume_delete.md +++ b/docs/stackit_volume_delete.md @@ -30,10 +30,10 @@ stackit volume delete VOLUME_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_volume_describe.md b/docs/stackit_volume_describe.md index a098db3a7..f8df34be6 100644 --- a/docs/stackit_volume_describe.md +++ b/docs/stackit_volume_describe.md @@ -31,10 +31,10 @@ stackit volume describe VOLUME_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_volume_list.md b/docs/stackit_volume_list.md index 2e59fd0d7..8e9ea498c 100644 --- a/docs/stackit_volume_list.md +++ b/docs/stackit_volume_list.md @@ -39,10 +39,10 @@ stackit volume list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_volume_performance-class.md b/docs/stackit_volume_performance-class.md index f584910ab..d3c08f0b3 100644 --- a/docs/stackit_volume_performance-class.md +++ b/docs/stackit_volume_performance-class.md @@ -21,10 +21,10 @@ stackit volume performance-class [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_volume_performance-class_describe.md b/docs/stackit_volume_performance-class_describe.md index a7c53a69c..8b7af4b28 100644 --- a/docs/stackit_volume_performance-class_describe.md +++ b/docs/stackit_volume_performance-class_describe.md @@ -31,10 +31,10 @@ stackit volume performance-class describe VOLUME_PERFORMANCE_CLASS [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_volume_performance-class_list.md b/docs/stackit_volume_performance-class_list.md index e01cd3df4..4422a4c84 100644 --- a/docs/stackit_volume_performance-class_list.md +++ b/docs/stackit_volume_performance-class_list.md @@ -39,10 +39,10 @@ stackit volume performance-class list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_volume_resize.md b/docs/stackit_volume_resize.md index 04286ff44..b32203f4c 100644 --- a/docs/stackit_volume_resize.md +++ b/docs/stackit_volume_resize.md @@ -29,10 +29,10 @@ stackit volume resize VOLUME_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_volume_snapshot.md b/docs/stackit_volume_snapshot.md index 61f6f428e..8728cb9f2 100644 --- a/docs/stackit_volume_snapshot.md +++ b/docs/stackit_volume_snapshot.md @@ -21,10 +21,10 @@ stackit volume snapshot [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_volume_snapshot_create.md b/docs/stackit_volume_snapshot_create.md index 4ed86ad39..9ff3e553f 100644 --- a/docs/stackit_volume_snapshot_create.md +++ b/docs/stackit_volume_snapshot_create.md @@ -37,10 +37,10 @@ stackit volume snapshot create [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_volume_snapshot_delete.md b/docs/stackit_volume_snapshot_delete.md index df9a37828..d9c5a8be5 100644 --- a/docs/stackit_volume_snapshot_delete.md +++ b/docs/stackit_volume_snapshot_delete.md @@ -28,10 +28,10 @@ stackit volume snapshot delete SNAPSHOT_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_volume_snapshot_describe.md b/docs/stackit_volume_snapshot_describe.md index 5f7f256b7..5b030540d 100644 --- a/docs/stackit_volume_snapshot_describe.md +++ b/docs/stackit_volume_snapshot_describe.md @@ -31,10 +31,10 @@ stackit volume snapshot describe SNAPSHOT_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_volume_snapshot_list.md b/docs/stackit_volume_snapshot_list.md index f4fe9dd3a..03a5cd46e 100644 --- a/docs/stackit_volume_snapshot_list.md +++ b/docs/stackit_volume_snapshot_list.md @@ -36,10 +36,10 @@ stackit volume snapshot list [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_volume_snapshot_update.md b/docs/stackit_volume_snapshot_update.md index 2b74b5ae8..9df1cbada 100644 --- a/docs/stackit_volume_snapshot_update.md +++ b/docs/stackit_volume_snapshot_update.md @@ -33,10 +33,10 @@ stackit volume snapshot update SNAPSHOT_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/docs/stackit_volume_update.md b/docs/stackit_volume_update.md index 1f28e3b1e..0d09cedb7 100644 --- a/docs/stackit_volume_update.md +++ b/docs/stackit_volume_update.md @@ -37,10 +37,10 @@ stackit volume update VOLUME_ID [flags] ``` -y, --assume-yes If set, skips all confirmation prompts --async If set, runs the command asynchronously - -o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"] + -o, --output-format string Output format, (one of: [json, pretty, none, yaml]) -p, --project-id string Project ID --region string Target region for region-specific requests - --verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info") + --verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info") ``` ### SEE ALSO diff --git a/internal/cmd/beta/alb/template/template.go b/internal/cmd/beta/alb/template/template.go index 74243b531..ad607875c 100644 --- a/internal/cmd/beta/alb/template/template.go +++ b/internal/cmd/beta/alb/template/template.go @@ -20,9 +20,23 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/utils" ) -const ( - formatFlag = "format" - typeFlag = "type" +var ( + formatFlag = flags.StringEnumFlag( + "format", + []string{"json", "yaml"}, + "Defines the output format", + flags.StringEnumIgnoreCase[string](), + flags.StringEnumShortHand[string]("f"), + flags.StringEnumDefaultValue("json"), + ) + typeFlag = flags.StringEnumFlag( + "type", + []string{"alb", "pool"}, + "Defines the output type", + flags.StringEnumIgnoreCase[string](), + flags.StringEnumShortHand[string]("t"), + flags.StringEnumDefaultValue("alb"), + ) ) type inputModel struct { @@ -97,8 +111,8 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } func configureFlags(cmd *cobra.Command) { - cmd.Flags().VarP(flags.EnumFlag(true, "json", "json", "yaml"), formatFlag, "f", "Defines the output format ('yaml' or 'json'), default is 'json'") - cmd.Flags().VarP(flags.EnumFlag(true, "alb", "alb", "pool"), typeFlag, "t", "Defines the output type ('alb' or 'pool'), default is 'alb'") + formatFlag.Register(cmd.Flags()) + typeFlag.Register(cmd.Flags()) } func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, error) { @@ -109,8 +123,8 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, model := inputModel{ GlobalFlagModel: globalFlags, - Format: flags.FlagToStringPointer(p, cmd, formatFlag), - Type: flags.FlagToStringPointer(p, cmd, typeFlag), + Format: formatFlag.Ptr(), + Type: typeFlag.Ptr(), } p.DebugInputModel(model) diff --git a/internal/cmd/beta/alb/template/template_test.go b/internal/cmd/beta/alb/template/template_test.go index 7f73d3f7d..7f22c3b1c 100644 --- a/internal/cmd/beta/alb/template/template_test.go +++ b/internal/cmd/beta/alb/template/template_test.go @@ -29,6 +29,8 @@ func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]st func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { model := &inputModel{ GlobalFlagModel: &globalflags.GlobalFlagModel{ProjectId: testProjectId, Region: testRegion, Verbosity: globalflags.VerbosityDefault}, + Format: utils.Ptr("json"), + Type: utils.Ptr("alb"), } for _, mod := range mods { mod(model) @@ -79,8 +81,8 @@ func TestParseInput(t *testing.T) { { description: "alb with yaml", flagValues: fixtureFlagValues(func(flagValues map[string]string) { - flagValues[formatFlag] = "yaml" - flagValues[typeFlag] = "alb" + flagValues[formatFlag.Name()] = "yaml" + flagValues[typeFlag.Name()] = "alb" }), isValid: true, expectedModel: fixtureInputModel(func(model *inputModel) { @@ -90,8 +92,8 @@ func TestParseInput(t *testing.T) { }, { description: "alb with yaml", flagValues: fixtureFlagValues(func(flagValues map[string]string) { - flagValues[formatFlag] = "yaml" - flagValues[typeFlag] = "alb" + flagValues[formatFlag.Name()] = "yaml" + flagValues[typeFlag.Name()] = "alb" }), isValid: true, expectedModel: fixtureInputModel(func(model *inputModel) { @@ -101,8 +103,8 @@ func TestParseInput(t *testing.T) { }, { description: "alb with json", flagValues: fixtureFlagValues(func(flagValues map[string]string) { - flagValues[formatFlag] = "json" - flagValues[typeFlag] = "alb" + flagValues[formatFlag.Name()] = "json" + flagValues[typeFlag.Name()] = "alb" }), isValid: true, expectedModel: fixtureInputModel(func(model *inputModel) { @@ -112,8 +114,8 @@ func TestParseInput(t *testing.T) { }, { description: "pool with yaml", flagValues: fixtureFlagValues(func(flagValues map[string]string) { - flagValues[formatFlag] = "yaml" - flagValues[typeFlag] = "pool" + flagValues[formatFlag.Name()] = "yaml" + flagValues[typeFlag.Name()] = "pool" }), isValid: true, expectedModel: fixtureInputModel(func(model *inputModel) { @@ -124,8 +126,8 @@ func TestParseInput(t *testing.T) { { description: "pool with json", flagValues: fixtureFlagValues(func(flagValues map[string]string) { - flagValues[formatFlag] = "json" - flagValues[typeFlag] = "pool" + flagValues[formatFlag.Name()] = "json" + flagValues[typeFlag.Name()] = "pool" }), isValid: true, expectedModel: fixtureInputModel(func(model *inputModel) { diff --git a/internal/cmd/beta/cdn/distribution/create/create.go b/internal/cmd/beta/cdn/distribution/create/create.go index 6c8821c13..457009b27 100644 --- a/internal/cmd/beta/cdn/distribution/create/create.go +++ b/internal/cmd/beta/cdn/distribution/create/create.go @@ -5,7 +5,6 @@ import ( "fmt" "github.com/spf13/cobra" - sdkUtils "github.com/stackitcloud/stackit-sdk-go/core/utils" cdn "github.com/stackitcloud/stackit-sdk-go/services/cdn/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/args" @@ -22,7 +21,6 @@ import ( ) const ( - flagRegion = "regions" flagHTTP = "http" flagHTTPOriginURL = "http-origin-url" flagHTTPGeofencing = "http-geofencing" @@ -43,6 +41,12 @@ const ( flagOptimizer = "optimizer" ) +var flagRegion = flags.StringEnumSliceFlag( + "regions", + cdn.AllowedRegionEnumValues, + "Regions in which content should be cached, multiple values accepted,", +) + type httpInputModel struct { OriginURL string Geofencing *map[string][]string @@ -154,7 +158,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } func configureFlags(cmd *cobra.Command, params *types.CmdParams) { - cmd.Flags().Var(flags.EnumSliceFlag(false, []string{}, sdkUtils.EnumSliceToStringSlice(cdn.AllowedRegionEnumValues)...), flagRegion, fmt.Sprintf("Regions in which content should be cached, multiple of: %q", utils.FormatPossibleValues(sdkUtils.EnumSliceToStringSlice(cdn.AllowedRegionEnumValues)...))) + flagRegion.Register(cmd) cmd.Flags().Bool(flagHTTP, false, "Use HTTP backend") cmd.Flags().String(flagHTTPOriginURL, "", "Origin URL for HTTP backend") cmd.Flags().StringSlice(flagHTTPOriginRequestHeaders, []string{}, "Origin request headers for HTTP backend in the format 'HeaderName: HeaderValue', repeatable. WARNING: do not store sensitive values in the headers!") @@ -177,7 +181,7 @@ func configureFlags(cmd *cobra.Command, params *types.CmdParams) { cmd.Flags().Bool(flagOptimizer, false, "Enable optimizer for the CDN distribution (paid feature).") cmd.MarkFlagsMutuallyExclusive(flagHTTP, flagBucket) cmd.MarkFlagsOneRequired(flagHTTP, flagBucket) - err := flags.MarkFlagsRequired(cmd, flagRegion) + err := flags.MarkFlagsRequired(cmd, flagRegion.Name()) cobra.CheckErr(err) } @@ -187,12 +191,6 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, return nil, &errors.ProjectIdError{} } - regionStrings := flags.FlagToStringSliceValue(p, cmd, flagRegion) - regions := make([]cdn.Region, 0, len(regionStrings)) - for _, regionStr := range regionStrings { - regions = append(regions, cdn.Region(regionStr)) - } - var http *httpInputModel if flags.FlagToBoolValue(p, cmd, flagHTTP) { originURL := flags.FlagToStringValue(p, cmd, flagHTTPOriginURL) @@ -249,7 +247,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, model := inputModel{ GlobalFlagModel: globalFlags, - Regions: regions, + Regions: flagRegion.Get(), HTTP: http, Bucket: bucket, BlockedCountries: blockedCountries, diff --git a/internal/cmd/beta/cdn/distribution/create/create_test.go b/internal/cmd/beta/cdn/distribution/create/create_test.go index 5a38cf2e6..966f74570 100644 --- a/internal/cmd/beta/cdn/distribution/create/create_test.go +++ b/internal/cmd/beta/cdn/distribution/create/create_test.go @@ -31,7 +31,7 @@ const testRegions = cdn.REGION_EU func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string { flagValues := map[string]string{ globalflags.ProjectIdFlag: testProjectId, - flagRegion: string(testRegions), + flagRegion.Name(): string(testRegions), } flagsHTTPBackend()(flagValues) for _, mod := range mods { @@ -69,11 +69,11 @@ func flagsLoki() func(flagValues map[string]string) { func flagRegions(regions ...cdn.Region) func(flagValues map[string]string) { return func(flagValues map[string]string) { if len(regions) == 0 { - delete(flagValues, flagRegion) + delete(flagValues, flagRegion.Name()) return } stringRegions := sdkUtils.EnumSliceToStringSlice(regions) - flagValues[flagRegion] = strings.Join(stringRegions, ",") + flagValues[flagRegion.Name()] = strings.Join(stringRegions, ",") } } diff --git a/internal/cmd/beta/cdn/distribution/list/list.go b/internal/cmd/beta/cdn/distribution/list/list.go index 60a7d30a1..1a47a908f 100644 --- a/internal/cmd/beta/cdn/distribution/list/list.go +++ b/internal/cmd/beta/cdn/distribution/list/list.go @@ -28,11 +28,17 @@ type inputModel struct { } const ( - sortByFlag = "sort-by" limitFlag = "" maxPageSize = int32(100) ) +var sortByFlag = flags.StringEnumFlag( + "sort-by", + []string{"id", "createdAt", "updatedAt", "originUrl", "status", "originUrlRelated"}, + "Sort entries by a specific field,", + flags.StringEnumDefaultValue("createdAt"), +) + func NewCmd(params *types.CmdParams) *cobra.Command { cmd := &cobra.Command{ Use: "list", @@ -75,11 +81,9 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return cmd } -var sortByFlagOptions = []string{"id", "createdAt", "updatedAt", "originUrl", "status", "originUrlRelated"} - func configureFlags(cmd *cobra.Command) { // same default as apiClient - cmd.Flags().Var(flags.EnumFlag(false, "createdAt", sortByFlagOptions...), sortByFlag, fmt.Sprintf("Sort entries by a specific field, one of %q", sortByFlagOptions)) + sortByFlag.Register(cmd.Flags()) cmd.Flags().Int64(limitFlag, 0, "Limit the output to the first n elements") } @@ -99,7 +103,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, model := inputModel{ GlobalFlagModel: globalFlags, - SortBy: flags.FlagWithDefaultToStringValue(p, cmd, sortByFlag), + SortBy: sortByFlag.Get(), } p.DebugInputModel(model) diff --git a/internal/cmd/beta/cdn/distribution/list/list_test.go b/internal/cmd/beta/cdn/distribution/list/list_test.go index e41e1d300..26c21f017 100644 --- a/internal/cmd/beta/cdn/distribution/list/list_test.go +++ b/internal/cmd/beta/cdn/distribution/list/list_test.go @@ -93,7 +93,7 @@ func TestParseInput(t *testing.T) { { description: "sort by id", flagValues: fixtureFlagValues(func(flagValues map[string]string) { - flagValues[sortByFlag] = "id" + flagValues[sortByFlag.Name()] = "id" }), isValid: true, expected: fixtureInputModel(func(model *inputModel) { @@ -103,7 +103,7 @@ func TestParseInput(t *testing.T) { { description: "sort by origin-url", flagValues: fixtureFlagValues(func(flagValues map[string]string) { - flagValues[sortByFlag] = "originUrl" + flagValues[sortByFlag.Name()] = "originUrl" }), isValid: true, expected: fixtureInputModel(func(model *inputModel) { @@ -113,7 +113,7 @@ func TestParseInput(t *testing.T) { { description: "sort by status", flagValues: fixtureFlagValues(func(flagValues map[string]string) { - flagValues[sortByFlag] = "status" + flagValues[sortByFlag.Name()] = "status" }), isValid: true, expected: fixtureInputModel(func(model *inputModel) { @@ -123,7 +123,7 @@ func TestParseInput(t *testing.T) { { description: "sort by created", flagValues: fixtureFlagValues(func(flagValues map[string]string) { - flagValues[sortByFlag] = "createdAt" + flagValues[sortByFlag.Name()] = "createdAt" }), isValid: true, expected: fixtureInputModel(func(model *inputModel) { @@ -133,7 +133,7 @@ func TestParseInput(t *testing.T) { { description: "sort by updated", flagValues: fixtureFlagValues(func(flagValues map[string]string) { - flagValues[sortByFlag] = "updatedAt" + flagValues[sortByFlag.Name()] = "updatedAt" }), isValid: true, expected: fixtureInputModel(func(model *inputModel) { @@ -143,7 +143,7 @@ func TestParseInput(t *testing.T) { { description: "sort by originUrlRelated", flagValues: fixtureFlagValues(func(flagValues map[string]string) { - flagValues[sortByFlag] = "originUrlRelated" + flagValues[sortByFlag.Name()] = "originUrlRelated" }), isValid: true, expected: fixtureInputModel(func(model *inputModel) { @@ -153,7 +153,7 @@ func TestParseInput(t *testing.T) { { description: "invalid sort by", flagValues: fixtureFlagValues(func(flagValues map[string]string) { - flagValues[sortByFlag] = "invalid" + flagValues[sortByFlag.Name()] = "invalid" }), isValid: false, }, @@ -161,7 +161,7 @@ func TestParseInput(t *testing.T) { description: "missing sort by uses default", flagValues: fixtureFlagValues( func(flagValues map[string]string) { - delete(flagValues, sortByFlag) + delete(flagValues, sortByFlag.Name()) }, ), isValid: true, @@ -244,7 +244,7 @@ func fixtureDistributions(count int) []cdn.Distribution { distributions[i] = cdn.Distribution{ Id: id, ProjectId: testProjectId, - Status: string(testStatus), + Status: testStatus, Config: cdn.Config{ Backend: cdn.HttpBackendAsConfigBackend(&cdn.HttpBackend{ Type: "http", diff --git a/internal/cmd/beta/cdn/distribution/update/update.go b/internal/cmd/beta/cdn/distribution/update/update.go index ab5798db5..b4418dc50 100644 --- a/internal/cmd/beta/cdn/distribution/update/update.go +++ b/internal/cmd/beta/cdn/distribution/update/update.go @@ -5,7 +5,6 @@ import ( "fmt" "github.com/spf13/cobra" - sdkUtils "github.com/stackitcloud/stackit-sdk-go/core/utils" cdn "github.com/stackitcloud/stackit-sdk-go/services/cdn/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/args" @@ -23,7 +22,6 @@ import ( const ( argDistributionID = "DISTRIBUTION_ID" - flagRegions = "regions" flagHTTP = "http" flagHTTPOriginURL = "http-origin-url" flagHTTPGeofencing = "http-geofencing" @@ -44,6 +42,12 @@ const ( flagOptimizer = "optimizer" ) +var flagRegions = flags.StringEnumSliceFlag( + "regions", + cdn.AllowedRegionEnumValues, + "Regions in which content should be cached,", +) + type bucketInputModel struct { URL string AccessKeyID string @@ -127,7 +131,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } func configureFlags(cmd *cobra.Command, params *types.CmdParams) { - cmd.Flags().Var(flags.EnumSliceFlag(false, []string{}, sdkUtils.EnumSliceToStringSlice(cdn.AllowedRegionEnumValues)...), flagRegions, fmt.Sprintf("Regions in which content should be cached, multiple of: %q", utils.FormatPossibleValues(sdkUtils.EnumSliceToStringSlice(cdn.AllowedRegionEnumValues)...))) + flagRegions.Register(cmd) cmd.Flags().Bool(flagHTTP, false, "Use HTTP backend") cmd.Flags().String(flagHTTPOriginURL, "", "Origin URL for HTTP backend") cmd.Flags().StringSlice(flagHTTPOriginRequestHeaders, []string{}, "Origin request headers for HTTP backend in the format 'HeaderName: HeaderValue', repeatable. WARNING: do not store sensitive values in the headers!") @@ -158,11 +162,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } distributionID := inputArgs[0] - regionStrings := flags.FlagToStringSliceValue(p, cmd, flagRegions) - regions := make([]cdn.Region, 0, len(regionStrings)) - for _, regionStr := range regionStrings { - regions = append(regions, cdn.Region(regionStr)) - } + regions := flagRegions.Get() var http *httpInputModel if flags.FlagToBoolValue(p, cmd, flagHTTP) { diff --git a/internal/cmd/beta/cdn/distribution/update/update_test.go b/internal/cmd/beta/cdn/distribution/update/update_test.go index 2dea1219c..829d6522f 100644 --- a/internal/cmd/beta/cdn/distribution/update/update_test.go +++ b/internal/cmd/beta/cdn/distribution/update/update_test.go @@ -45,7 +45,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { ProjectId: testProjectId, }, DistributionID: testDistributionID, - Regions: []cdn.Region{}, + Regions: nil, } for _, mod := range mods { mod(model) @@ -125,7 +125,7 @@ func TestParseInput(t *testing.T) { argValues: []string{testDistributionID}, flagValues: fixtureFlagValues( func(flagValues map[string]string) { - flagValues[flagRegions] = "EU,US" + flagValues[flagRegions.Name()] = "EU,US" flagValues[flagBlockedCountries] = "DE,AT,CH" flagValues[flagBlockedIPs] = "127.0.0.1,10.0.0.8" flagValues[flagDefaultCacheDuration] = "P1DT12H" diff --git a/internal/cmd/beta/edge/kubeconfig/create/create.go b/internal/cmd/beta/edge/kubeconfig/create/create.go index dd38b8322..7f7ee4d06 100755 --- a/internal/cmd/beta/edge/kubeconfig/create/create.go +++ b/internal/cmd/beta/edge/kubeconfig/create/create.go @@ -219,12 +219,12 @@ func parseInput(p *print.Printer, cmd *cobra.Command) (*inputModel, error) { if globalFlags.OutputFormat == "" || globalFlags.OutputFormat == print.NoneOutputFormat { return nil, &cliErr.FlagValidationError{ Flag: commonKubeconfig.DisableWritingFlag, - Details: fmt.Sprintf("must be used with --%s", globalflags.OutputFormatFlag), + Details: fmt.Sprintf("must be used with --%s", globalflags.OutputFormatFlag.Name()), } } if globalFlags.OutputFormat != print.JSONOutputFormat && globalFlags.OutputFormat != print.YAMLOutputFormat { return nil, &cliErr.FlagValidationError{ - Flag: globalflags.OutputFormatFlag, + Flag: globalflags.OutputFormatFlag.Name(), Details: fmt.Sprintf("valid output formats for this command are: %s", fmt.Sprintf("%s, %s", print.JSONOutputFormat, print.YAMLOutputFormat)), } } diff --git a/internal/cmd/beta/edge/kubeconfig/create/create_test.go b/internal/cmd/beta/edge/kubeconfig/create/create_test.go index 9ed5f2d96..051e470f8 100755 --- a/internal/cmd/beta/edge/kubeconfig/create/create_test.go +++ b/internal/cmd/beta/edge/kubeconfig/create/create_test.go @@ -381,7 +381,7 @@ func TestParseInput(t *testing.T) { args: args{ flags: fixtureFlagValues(func(flagValues map[string]string) { flagValues[commonKubeconfig.DisableWritingFlag] = "true" - flagValues[globalflags.OutputFormatFlag] = print.PrettyOutputFormat + flagValues[globalflags.OutputFormatFlag.Name()] = print.PrettyOutputFormat }), }, }, @@ -403,7 +403,7 @@ func TestParseInput(t *testing.T) { args: args{ flags: fixtureFlagValues(func(flagValues map[string]string) { flagValues[commonKubeconfig.DisableWritingFlag] = "true" - flagValues[globalflags.OutputFormatFlag] = print.YAMLOutputFormat + flagValues[globalflags.OutputFormatFlag.Name()] = print.YAMLOutputFormat }), cmpOpts: []testUtils.ValueComparisonOption{ testUtils.WithAllowUnexported(inputModel{}), diff --git a/internal/cmd/beta/edge/token/create/create.go b/internal/cmd/beta/edge/token/create/create.go index cec854bcc..cbe7ab900 100755 --- a/internal/cmd/beta/edge/token/create/create.go +++ b/internal/cmd/beta/edge/token/create/create.go @@ -190,7 +190,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command) (*inputModel, error) { // Make sure to only output if the format is not none if globalFlags.OutputFormat == print.NoneOutputFormat { return nil, &cliErr.FlagValidationError{ - Flag: globalflags.OutputFormatFlag, + Flag: globalflags.OutputFormatFlag.Name(), Details: fmt.Sprintf("valid formats for this command are: %s", fmt.Sprintf("%s, %s, %s", print.PrettyOutputFormat, print.JSONOutputFormat, print.YAMLOutputFormat)), } } diff --git a/internal/cmd/beta/sfs/snapshot-policy/list/list.go b/internal/cmd/beta/sfs/snapshot-policy/list/list.go index b73137200..d343216f2 100644 --- a/internal/cmd/beta/sfs/snapshot-policy/list/list.go +++ b/internal/cmd/beta/sfs/snapshot-policy/list/list.go @@ -22,8 +22,15 @@ import ( ) const ( - limitFlag = "limit" - immutableFlag = "immutable" + limitFlag = "limit" +) + +var immutableFlag = flags.StringEnumFlag( + "immutable", + []string{"all", "immutable-only", "mutable-only"}, + "Immutable snapshot policy,", + flags.StringEnumDefaultValue("all"), + flags.StringEnumIgnoreCase[string](), ) type inputModel struct { @@ -99,8 +106,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } func configureFlags(cmd *cobra.Command) { - immutableOptions := []string{"all", "immutable-only", "mutable-only"} - cmd.Flags().Var(flags.EnumFlag(true, "all", immutableOptions...), immutableFlag, fmt.Sprintf("Immutable snapshot policy, one of %q", immutableOptions)) + immutableFlag.Register(cmd.Flags()) cmd.Flags().Int64(limitFlag, 0, "Maximum number of entries to list") } @@ -121,7 +127,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, model := inputModel{ GlobalFlagModel: globalFlags, Limit: limit, - Immutable: flags.FlagToStringPointer(p, cmd, immutableFlag), + Immutable: immutableFlag.Ptr(), } p.DebugInputModel(model) diff --git a/internal/cmd/beta/sfs/snapshot-policy/list/list_test.go b/internal/cmd/beta/sfs/snapshot-policy/list/list_test.go index 04c73c920..6106bc1c6 100644 --- a/internal/cmd/beta/sfs/snapshot-policy/list/list_test.go +++ b/internal/cmd/beta/sfs/snapshot-policy/list/list_test.go @@ -46,7 +46,8 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { Verbosity: globalflags.VerbosityDefault, Region: testRegion, }, - Limit: utils.Ptr(int64(10)), + Immutable: utils.Ptr("all"), + Limit: utils.Ptr(int64(10)), } for _, mod := range mods { mod(model) @@ -105,7 +106,7 @@ func TestParseInput(t *testing.T) { { description: "immutable snapshot policies", flagValues: fixtureFlagValues(func(flagValues map[string]string) { - flagValues[immutableFlag] = "immutable-only" + flagValues[immutableFlag.Name()] = "immutable-only" }), isValid: true, expectedModel: fixtureInputModel(func(model *inputModel) { @@ -115,7 +116,7 @@ func TestParseInput(t *testing.T) { { description: "mutable snapshot policies", flagValues: fixtureFlagValues(func(flagValues map[string]string) { - flagValues[immutableFlag] = "mutable-only" + flagValues[immutableFlag.Name()] = "mutable-only" }), isValid: true, expectedModel: fixtureInputModel(func(model *inputModel) { @@ -125,23 +126,13 @@ func TestParseInput(t *testing.T) { { description: "all snapshot policies", flagValues: fixtureFlagValues(func(flagValues map[string]string) { - flagValues[immutableFlag] = "all" + flagValues[immutableFlag.Name()] = "all" }), isValid: true, expectedModel: fixtureInputModel(func(model *inputModel) { model.Immutable = utils.Ptr("all") }), }, - { - description: "all snapshot policies - without immutable flag", - flagValues: fixtureFlagValues(func(flagValues map[string]string) { - delete(flagValues, immutableFlag) - }), - isValid: true, - expectedModel: fixtureInputModel(func(model *inputModel) { - model.Immutable = nil - }), - }, } for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { diff --git a/internal/cmd/beta/vpn/connection/create/create.go b/internal/cmd/beta/vpn/connection/create/create.go index d9f1b227f..248c97b30 100644 --- a/internal/cmd/beta/vpn/connection/create/create.go +++ b/internal/cmd/beta/vpn/connection/create/create.go @@ -237,8 +237,8 @@ func configureFlags(cmd *cobra.Command) { tunnel1Phase2EncryptionAlgorithmsFlag.Register(cmd) tunnel1Phase2IntegrityAlgorithmsFlag.Register(cmd) cmd.Flags().Int64(tunnel1Phase2RekeyTimeFlag, 0, "Tunnel 1 Phase 2 Rekey Time.\nTime to schedule a Child SA re-keying (in seconds).") - tunnel1Phase2DpdActionFlag.Register(cmd) - tunnel1Phase2StartActionFlag.Register(cmd) + tunnel1Phase2DpdActionFlag.Register(cmd.Flags()) + tunnel1Phase2StartActionFlag.Register(cmd.Flags()) cmd.Flags().String(tunnel1PreSharedKeyFlag, "", "Required: Tunnel 1 Pre Shared Key.\nA Pre-Shared Key for authentication. Required in create-requests, optional in update-requests and omitted in every response.") cmd.Flags().String(tunnel1RemoteAddressFlag, "", "Tunnel 1 Remote Address") @@ -253,8 +253,8 @@ func configureFlags(cmd *cobra.Command) { tunnel2Phase2EncryptionAlgorithmsFlag.Register(cmd) tunnel2Phase2IntegrityAlgorithmsFlag.Register(cmd) cmd.Flags().Int64(tunnel2Phase2RekeyTimeFlag, 0, "Tunnel 2 Phase 2 Rekey Time.\nTime to schedule a Child SA re-keying (in seconds).") - tunnel2Phase2DpdActionFlag.Register(cmd) - tunnel2Phase2StartActionFlag.Register(cmd) + tunnel2Phase2DpdActionFlag.Register(cmd.Flags()) + tunnel2Phase2StartActionFlag.Register(cmd.Flags()) cmd.Flags().String(tunnel2PreSharedKeyFlag, "", "Required: Tunnel 2 Pre Shared Key.\nA Pre-Shared Key for authentication. Required in create-requests, optional in update-requests and omitted in every response.") cmd.Flags().String(tunnel2RemoteAddressFlag, "", "Tunnel 2 Remote Address") diff --git a/internal/cmd/config/profile/create/create_test.go b/internal/cmd/config/profile/create/create_test.go index eaebaac64..8d214e8d4 100644 --- a/internal/cmd/config/profile/create/create_test.go +++ b/internal/cmd/config/profile/create/create_test.go @@ -63,7 +63,7 @@ func TestParseInput(t *testing.T) { description: "some global flag", argValues: fixtureArgValues(), flagValues: map[string]string{ - globalflags.VerbosityFlag: globalflags.DebugVerbosity, + globalflags.VerbosityFlag.Name(): globalflags.DebugVerbosity, }, isValid: true, expectedModel: fixtureInputModel(func(model *inputModel) { diff --git a/internal/cmd/config/profile/delete/delete_test.go b/internal/cmd/config/profile/delete/delete_test.go index 919ddb078..cb98a23c0 100644 --- a/internal/cmd/config/profile/delete/delete_test.go +++ b/internal/cmd/config/profile/delete/delete_test.go @@ -68,7 +68,7 @@ func TestParseInput(t *testing.T) { description: "some global flag", argValues: fixtureArgValues(), flagValues: map[string]string{ - globalflags.VerbosityFlag: globalflags.DebugVerbosity, + globalflags.VerbosityFlag.Name(): globalflags.DebugVerbosity, }, isValid: true, expectedModel: fixtureInputModel(func(model *inputModel) { diff --git a/internal/cmd/config/profile/set/set_test.go b/internal/cmd/config/profile/set/set_test.go index 13d23e1be..e718ab0eb 100644 --- a/internal/cmd/config/profile/set/set_test.go +++ b/internal/cmd/config/profile/set/set_test.go @@ -61,7 +61,7 @@ func TestParseInput(t *testing.T) { description: "some global flag", argValues: fixtureArgValues(), flagValues: map[string]string{ - globalflags.VerbosityFlag: globalflags.DebugVerbosity, + globalflags.VerbosityFlag.Name(): globalflags.DebugVerbosity, }, isValid: true, expectedModel: fixtureInputModel(func(model *inputModel) { diff --git a/internal/cmd/config/unset/unset.go b/internal/cmd/config/unset/unset.go index ad57f8113..580292b2e 100644 --- a/internal/cmd/config/unset/unset.go +++ b/internal/cmd/config/unset/unset.go @@ -17,12 +17,10 @@ import ( ) const ( - asyncFlag = globalflags.AsyncFlag - outputFormatFlag = globalflags.OutputFormatFlag - projectIdFlag = globalflags.ProjectIdFlag - regionFlag = globalflags.RegionFlag - verbosityFlag = globalflags.VerbosityFlag - assumeYesFlag = globalflags.AssumeYesFlag + asyncFlag = globalflags.AsyncFlag + projectIdFlag = globalflags.ProjectIdFlag + regionFlag = globalflags.RegionFlag + assumeYesFlag = globalflags.AssumeYesFlag sessionTimeLimitFlag = "session-time-limit" identityProviderCustomWellKnownConfigurationFlag = "identity-provider-custom-well-known-configuration" @@ -60,6 +58,11 @@ const ( cdnCustomEndpointFlag = "cdn-custom-endpoint" ) +var ( + outputFormatFlag = globalflags.OutputFormatFlag.Name() + verbosityFlag = globalflags.VerbosityFlag.Name() +) + type inputModel struct { Async bool OutputFormat bool diff --git a/internal/cmd/curl/curl.go b/internal/cmd/curl/curl.go index 341654dfd..3529872bc 100644 --- a/internal/cmd/curl/curl.go +++ b/internal/cmd/curl/curl.go @@ -25,7 +25,6 @@ import ( ) const ( - requestMethodFlag = "request" headerFlag = "header" dataFlag = "data" includeResponseHeadersFlag = "include" @@ -37,6 +36,25 @@ const ( urlArg = "URL" ) +var requestMethodFlag = flags.StringEnumFlag( + "request", + []string{ + http.MethodGet, + http.MethodHead, + http.MethodPost, + http.MethodPut, + http.MethodPatch, + http.MethodDelete, + http.MethodConnect, + http.MethodOptions, + http.MethodTrace, + }, + "HTTP method, defaults to GET", + flags.StringEnumIgnoreCase[string](), + flags.StringEnumDefaultValue(http.MethodGet), + flags.StringEnumShortHand[string]("X"), +) + type inputModel struct { URL string RequestMethod string @@ -117,20 +135,8 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } func configureFlags(cmd *cobra.Command) { - requestMethodOptions := []string{ - http.MethodGet, - http.MethodHead, - http.MethodPost, - http.MethodPut, - http.MethodPatch, - http.MethodDelete, - http.MethodConnect, - http.MethodOptions, - http.MethodTrace, - } + requestMethodFlag.Register(cmd.Flags()) headerFlagUsage := `Custom headers to include in the request, can be specified multiple times. If the "Authorization" header is set, it will override the authentication provided by the CLI` - - cmd.Flags().VarP(flags.EnumFlag(true, "", requestMethodOptions...), requestMethodFlag, "X", "HTTP method, defaults to GET") cmd.Flags().StringSliceP(headerFlag, "H", []string{}, headerFlagUsage) cmd.Flags().Var(flags.ReadFromFileFlag(), dataFlag, `Content to include in the request body. Can be a string or a file path prefixed with "@"`) cmd.Flags().Bool(includeResponseHeadersFlag, false, "If set, response headers are added to the output") @@ -140,10 +146,7 @@ func configureFlags(cmd *cobra.Command) { func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inputModel, error) { urlString := inputArgs[0] - requestMethod := flags.FlagToStringValue(p, cmd, requestMethodFlag) - if requestMethod == "" { - requestMethod = http.MethodGet - } + requestMethod := requestMethodFlag.Get() model := inputModel{ URL: urlString, diff --git a/internal/cmd/curl/curl_test.go b/internal/cmd/curl/curl_test.go index 6f0a9b74b..405f8cafc 100644 --- a/internal/cmd/curl/curl_test.go +++ b/internal/cmd/curl/curl_test.go @@ -36,7 +36,7 @@ func fixtureArgValues(mods ...func(argValues []string)) []string { func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string { flagValues := map[string]string{ - requestMethodFlag: "post", + requestMethodFlag.Name(): "post", headerFlag: "Test-header-1: Test value 1", dataFlag: "data", includeResponseHeadersFlag: "true", @@ -143,7 +143,7 @@ func TestParseInput(t *testing.T) { description: "invalid method 1", argValues: fixtureArgValues(), flagValues: fixtureFlagValues(func(flagValues map[string]string) { - flagValues[requestMethodFlag] = "" + flagValues[requestMethodFlag.Name()] = "" }), isValid: false, }, @@ -151,7 +151,7 @@ func TestParseInput(t *testing.T) { description: "invalid method 2", argValues: fixtureArgValues(), flagValues: fixtureFlagValues(func(flagValues map[string]string) { - flagValues[requestMethodFlag] = "foo" + flagValues[requestMethodFlag.Name()] = "foo" }), isValid: false, }, @@ -159,7 +159,7 @@ func TestParseInput(t *testing.T) { description: "invalid method 3", argValues: fixtureArgValues(), flagValues: fixtureFlagValues(func(flagValues map[string]string) { - flagValues[requestMethodFlag] = " GET" + flagValues[requestMethodFlag.Name()] = " GET" }), isValid: false, }, @@ -167,7 +167,7 @@ func TestParseInput(t *testing.T) { description: "valid method 1", argValues: fixtureArgValues(), flagValues: fixtureFlagValues(func(flagValues map[string]string) { - flagValues[requestMethodFlag] = "put" + flagValues[requestMethodFlag.Name()] = "put" }), isValid: true, expectedModel: fixtureInputModel(func(model *inputModel) { @@ -178,7 +178,7 @@ func TestParseInput(t *testing.T) { description: "valid method 2", argValues: fixtureArgValues(), flagValues: fixtureFlagValues(func(flagValues map[string]string) { - flagValues[requestMethodFlag] = "pAtCh" + flagValues[requestMethodFlag.Name()] = "pAtCh" }), isValid: true, expectedModel: fixtureInputModel(func(model *inputModel) { @@ -217,6 +217,7 @@ func TestParseInput(t *testing.T) { for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { + requestMethodFlag.Reset() params := testparams.NewTestParams() cmd := NewCmd(params.CmdParams) err := globalflags.Configure(cmd.Flags()) diff --git a/internal/cmd/dns/record-set/create/create.go b/internal/cmd/dns/record-set/create/create.go index d3a86eb4e..7221945c3 100644 --- a/internal/cmd/dns/record-set/create/create.go +++ b/internal/cmd/dns/record-set/create/create.go @@ -4,11 +4,8 @@ import ( "context" "fmt" - sdkUtils "github.com/stackitcloud/stackit-sdk-go/core/utils" "github.com/stackitcloud/stackit-sdk-go/services/dns/v1api/wait" - "github.com/stackitcloud/stackit-cli/internal/pkg/utils" - "github.com/stackitcloud/stackit-cli/internal/pkg/types" "github.com/spf13/cobra" @@ -31,12 +28,18 @@ const ( nameFlag = "name" recordFlag = "record" ttlFlag = "ttl" - typeFlag = "type" defaultType = dns.CREATERECORDSETPAYLOADTYPE_A txtType = dns.CREATERECORDSETPAYLOADTYPE_TXT ) +var typeFlag = flags.StringEnumFlag( + "type", + dns.AllowedCreateRecordSetPayloadTypeEnumValues, + "Record type,", + flags.StringEnumDefaultValue(defaultType), +) + type inputModel struct { *globalflags.GlobalFlagModel ZoneId string @@ -115,7 +118,7 @@ func configureFlags(cmd *cobra.Command) { cmd.Flags().String(nameFlag, "", "Name of the record, should be compliant with RFC1035, Section 2.3.4") cmd.Flags().Int32(ttlFlag, 0, "Time to live, if not provided defaults to the zone's default TTL") cmd.Flags().StringSlice(recordFlag, []string{}, "Records belonging to the record set") - cmd.Flags().Var(flags.EnumFlag(false, string(defaultType), sdkUtils.EnumSliceToStringSlice(dns.AllowedCreateRecordSetPayloadTypeEnumValues)...), typeFlag, fmt.Sprintf("Record type, one of %q", utils.FormatPossibleValues(sdkUtils.EnumSliceToStringSlice(dns.AllowedCreateRecordSetPayloadTypeEnumValues)...))) + typeFlag.Register(cmd.Flags()) err := flags.MarkFlagsRequired(cmd, zoneIdFlag, nameFlag, recordFlag) cobra.CheckErr(err) @@ -127,8 +130,6 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, return nil, &errors.ProjectIdError{} } - recordType := flags.FlagWithDefaultToStringValue(p, cmd, typeFlag) - model := inputModel{ GlobalFlagModel: globalFlags, ZoneId: flags.FlagToStringValue(p, cmd, zoneIdFlag), @@ -136,7 +137,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, Name: flags.FlagToStringPointer(p, cmd, nameFlag), Records: flags.FlagToStringSliceValue(p, cmd, recordFlag), TTL: flags.FlagToInt32Pointer(p, cmd, ttlFlag), - Type: dns.CreateRecordSetPayloadType(recordType), + Type: typeFlag.Get(), } if model.Type == txtType { diff --git a/internal/cmd/dns/record-set/create/create_test.go b/internal/cmd/dns/record-set/create/create_test.go index 03c8a637c..1f19400f5 100644 --- a/internal/cmd/dns/record-set/create/create_test.go +++ b/internal/cmd/dns/record-set/create/create_test.go @@ -25,9 +25,9 @@ var testProjectId = uuid.NewString() var testZoneId = uuid.NewString() var recordTxtOver255Char = []string{ - "foobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoo", - "foobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoo", - "foobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobar", + strings.Repeat("a", 255), + strings.Repeat("a", 255), + strings.Repeat("a", 60), } func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string { @@ -38,7 +38,7 @@ func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]st nameFlag: "example.com", recordFlag: "1.1.1.1", ttlFlag: "3600", - typeFlag: "SOA", // Non-default value + typeFlag.Name(): "SOA", // Non-default value } for _, mod := range mods { mod(flagValues) @@ -205,7 +205,7 @@ func TestParseInput(t *testing.T) { { description: "type missing", flagValues: fixtureFlagValues(func(flagValues map[string]string) { - delete(flagValues, typeFlag) + delete(flagValues, typeFlag.Name()) }), isValid: true, expectedModel: fixtureInputModel(func(model *inputModel) { @@ -215,14 +215,14 @@ func TestParseInput(t *testing.T) { { description: "type invalid 1", flagValues: fixtureFlagValues(func(flagValues map[string]string) { - flagValues[typeFlag] = "" + flagValues[typeFlag.Name()] = "" }), isValid: false, }, { description: "type invalid 2", flagValues: fixtureFlagValues(func(flagValues map[string]string) { - flagValues[typeFlag] = "a" + flagValues[typeFlag.Name()] = "a" }), isValid: false, }, @@ -247,7 +247,7 @@ func TestParseInput(t *testing.T) { { description: "TXT record with > 255 characters", flagValues: fixtureFlagValues(func(flagValues map[string]string) { - flagValues[typeFlag] = string(txtType) + flagValues[typeFlag.Name()] = string(txtType) flagValues[recordFlag] = strings.Join(recordTxtOver255Char, "") }), isValid: true, diff --git a/internal/cmd/dns/record-set/list/list.go b/internal/cmd/dns/record-set/list/list.go index 64f984a8a..cb3c0ffc2 100644 --- a/internal/cmd/dns/record-set/list/list.go +++ b/internal/cmd/dns/record-set/list/list.go @@ -23,20 +23,26 @@ import ( ) const ( - activeFlag = "active" - inactiveFlag = "inactive" - zoneIdFlag = "zone-id" - deletedFlag = "deleted" - nameLikeFlag = "name-like" - orderByNameFlag = "order-by-name" - limitFlag = "limit" - pageSizeFlag = "page-size" + activeFlag = "active" + inactiveFlag = "inactive" + zoneIdFlag = "zone-id" + deletedFlag = "deleted" + nameLikeFlag = "name-like" + limitFlag = "limit" + pageSizeFlag = "page-size" defaultPage = 1 pageSizeDefault = 100 deleteSucceededState = "DELETE_SUCCEEDED" ) +var orderByNameFlag = flags.StringEnumFlag( + "order-by-name", + []string{"asc", "desc"}, + "Order by name,", + flags.StringEnumIgnoreCase[string](), +) + type inputModel struct { *globalflags.GlobalFlagModel @@ -107,14 +113,12 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } func configureFlags(cmd *cobra.Command) { - orderByNameFlagOptions := []string{"asc", "desc"} - cmd.Flags().Var(flags.UUIDFlag(), zoneIdFlag, "Zone ID") cmd.Flags().Bool(activeFlag, false, "Filter for active record sets") cmd.Flags().Bool(inactiveFlag, false, "Filter for inactive record sets. Deleted record sets are always inactive and will be included when this flag is set") cmd.Flags().Bool(deletedFlag, false, "Filter for deleted record sets") cmd.Flags().String(nameLikeFlag, "", "Filter by name") - cmd.Flags().Var(flags.EnumFlag(true, "", orderByNameFlagOptions...), orderByNameFlag, fmt.Sprintf("Order by name, one of %q", orderByNameFlagOptions)) + orderByNameFlag.Register(cmd.Flags()) cmd.Flags().Int64(limitFlag, 0, "Maximum number of entries to list") cmd.Flags().Int64(pageSizeFlag, pageSizeDefault, "Number of items fetched in each API call. Does not affect the number of items in the command output") @@ -157,7 +161,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, Inactive: inactive, Deleted: flags.FlagToBoolValue(p, cmd, deletedFlag), NameLike: flags.FlagToStringPointer(p, cmd, nameLikeFlag), - OrderByName: flags.FlagToStringPointer(p, cmd, orderByNameFlag), + OrderByName: orderByNameFlag.Ptr(), Limit: flags.FlagToInt64Pointer(p, cmd, limitFlag), PageSize: pageSize, } diff --git a/internal/cmd/dns/record-set/list/list_test.go b/internal/cmd/dns/record-set/list/list_test.go index 08bad82db..d3a806c56 100644 --- a/internal/cmd/dns/record-set/list/list_test.go +++ b/internal/cmd/dns/record-set/list/list_test.go @@ -32,7 +32,7 @@ func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]st globalflags.ProjectIdFlag: testProjectId, zoneIdFlag: testZoneId, nameLikeFlag: "some-pattern", - orderByNameFlag: "asc", + orderByNameFlag.Name(): "asc", } for _, mod := range mods { mod(flagValues) @@ -175,7 +175,7 @@ func TestParseInput(t *testing.T) { { description: "order by name desc", flagValues: fixtureFlagValues(func(flagValues map[string]string) { - flagValues[orderByNameFlag] = "desc" + flagValues[orderByNameFlag.Name()] = "desc" }), isValid: true, expectedModel: fixtureInputModel(func(model *inputModel) { @@ -185,14 +185,14 @@ func TestParseInput(t *testing.T) { { description: "order by name invalid 1", flagValues: fixtureFlagValues(func(flagValues map[string]string) { - flagValues[orderByNameFlag] = "" + flagValues[orderByNameFlag.Name()] = "" }), isValid: false, }, { description: "order by name invalid 2", flagValues: fixtureFlagValues(func(flagValues map[string]string) { - flagValues[orderByNameFlag] = "invalid" + flagValues[orderByNameFlag.Name()] = "invalid" }), isValid: false, }, diff --git a/internal/cmd/dns/zone/create/create.go b/internal/cmd/dns/zone/create/create.go index 0770b4e82..0951edda6 100644 --- a/internal/cmd/dns/zone/create/create.go +++ b/internal/cmd/dns/zone/create/create.go @@ -4,11 +4,6 @@ import ( "context" "fmt" - sdkUtils "github.com/stackitcloud/stackit-sdk-go/core/utils" - - "github.com/stackitcloud/stackit-cli/internal/pkg/types" - "github.com/stackitcloud/stackit-cli/internal/pkg/utils" - "github.com/stackitcloud/stackit-cli/internal/pkg/args" "github.com/stackitcloud/stackit-cli/internal/pkg/errors" "github.com/stackitcloud/stackit-cli/internal/pkg/examples" @@ -18,6 +13,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/projectname" "github.com/stackitcloud/stackit-cli/internal/pkg/services/dns/client" "github.com/stackitcloud/stackit-cli/internal/pkg/spinner" + "github.com/stackitcloud/stackit-cli/internal/pkg/types" "github.com/spf13/cobra" dns "github.com/stackitcloud/stackit-sdk-go/services/dns/v1api" @@ -30,7 +26,6 @@ const ( defaultTTLFlag = "default-ttl" primaryFlag = "primary" aclFlag = "acl" - typeFlag = "type" retryTimeFlag = "retry-time" refreshTimeFlag = "refresh-time" negativeCacheFlag = "negative-cache" @@ -40,6 +35,13 @@ const ( contactEmailFlag = "contact-email" ) +var typeFlag = flags.StringEnumFlag( + "type", + append(dns.AllowedCreateZonePayloadTypeEnumValues, ""), + "Zone type,", + flags.StringEnumDefaultValue(dns.CreateZonePayloadType("")), +) + type inputModel struct { *globalflags.GlobalFlagModel Name string @@ -128,7 +130,7 @@ func configureFlags(cmd *cobra.Command) { cmd.Flags().Int32(defaultTTLFlag, 1000, "Default time to live") cmd.Flags().StringSlice(primaryFlag, []string{}, "Primary name server for secondary zone") cmd.Flags().String(aclFlag, "", "Access control list") - cmd.Flags().Var(flags.EnumFlag(false, "", append(sdkUtils.EnumSliceToStringSlice(dns.AllowedCreateZonePayloadTypeEnumValues), "")...), typeFlag, fmt.Sprintf("Zone type, one of: %q", utils.FormatPossibleValues(sdkUtils.EnumSliceToStringSlice(dns.AllowedCreateZonePayloadTypeEnumValues)...))) + typeFlag.Register(cmd.Flags()) cmd.Flags().Int32(retryTimeFlag, 0, "Retry time") cmd.Flags().Int32(refreshTimeFlag, 0, "Refresh time") cmd.Flags().Int32(negativeCacheFlag, 0, "Negative cache") @@ -148,8 +150,8 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, } var zoneType *dns.CreateZonePayloadType - if zoneTypeString := flags.FlagToStringPointer(p, cmd, typeFlag); zoneTypeString != nil && *zoneTypeString != "" { - zoneType = dns.CreateZonePayloadType(*zoneTypeString).Ptr() + if typeFlagValue := typeFlag.Ptr(); typeFlagValue != nil && *typeFlagValue != "" { + zoneType = typeFlagValue } model := inputModel{ diff --git a/internal/cmd/dns/zone/create/create_test.go b/internal/cmd/dns/zone/create/create_test.go index 84ecf724d..aee805cac 100644 --- a/internal/cmd/dns/zone/create/create_test.go +++ b/internal/cmd/dns/zone/create/create_test.go @@ -28,7 +28,7 @@ func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]st dnsNameFlag: "example.com", defaultTTLFlag: "3600", aclFlag: "0.0.0.0/0", - typeFlag: string(dns.CREATEZONEPAYLOADTYPE_PRIMARY), + typeFlag.Name(): string(dns.CREATEZONEPAYLOADTYPE_PRIMARY), primaryFlag: "1.1.1.1", retryTimeFlag: "600", refreshTimeFlag: "3600", @@ -138,7 +138,7 @@ func TestParseInput(t *testing.T) { dnsNameFlag: "", defaultTTLFlag: "0", aclFlag: "", - typeFlag: "", + typeFlag.Name(): "", retryTimeFlag: "0", refreshTimeFlag: "0", negativeCacheFlag: "0", diff --git a/internal/cmd/dns/zone/list/list.go b/internal/cmd/dns/zone/list/list.go index 05ba02073..80f6aa823 100644 --- a/internal/cmd/dns/zone/list/list.go +++ b/internal/cmd/dns/zone/list/list.go @@ -27,7 +27,6 @@ const ( activeFlag = "active" inactiveFlag = "inactive" nameLikeFlag = "name-like" - orderByNameFlag = "order-by-name" includeDeletedFlag = "include-deleted" limitFlag = "limit" pageSizeFlag = "page-size" @@ -37,6 +36,13 @@ const ( deleteSucceededState = "DELETE_SUCCEEDED" ) +var orderByNameFlag = flags.StringEnumFlag( + "order-by-name", + []string{"asc", "desc"}, + "Order by name,", + flags.StringEnumIgnoreCase[string](), +) + type inputModel struct { *globalflags.GlobalFlagModel @@ -102,12 +108,10 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } func configureFlags(cmd *cobra.Command) { - orderByNameFlagOptions := []string{"asc", "desc"} - cmd.Flags().Bool(activeFlag, false, "Filter for active zones") cmd.Flags().Bool(inactiveFlag, false, "Filter for inactive zones") cmd.Flags().String(nameLikeFlag, "", "Filter by name") - cmd.Flags().Var(flags.EnumFlag(true, "", orderByNameFlagOptions...), orderByNameFlag, fmt.Sprintf("Order by name, one of %q", orderByNameFlagOptions)) + orderByNameFlag.Register(cmd.Flags()) cmd.Flags().Bool(includeDeletedFlag, false, "Includes successfully deleted zones (if unset, these are filtered out)") cmd.Flags().Int64(limitFlag, 0, "Maximum number of entries to list") cmd.Flags().Int64(pageSizeFlag, pageSizeDefault, "Number of items fetched in each API call. Does not affect the number of items in the command output") @@ -147,7 +151,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, Inactive: inactive, IncludeDeleted: flags.FlagToBoolValue(p, cmd, includeDeletedFlag), NameLike: flags.FlagToStringPointer(p, cmd, nameLikeFlag), - OrderByName: flags.FlagToStringPointer(p, cmd, orderByNameFlag), + OrderByName: orderByNameFlag.Ptr(), Limit: limit, PageSize: pageSize, } diff --git a/internal/cmd/dns/zone/list/list_test.go b/internal/cmd/dns/zone/list/list_test.go index d2413643e..a7ac752c9 100644 --- a/internal/cmd/dns/zone/list/list_test.go +++ b/internal/cmd/dns/zone/list/list_test.go @@ -30,7 +30,7 @@ func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]st flagValues := map[string]string{ globalflags.ProjectIdFlag: testProjectId, nameLikeFlag: "some-pattern", - orderByNameFlag: "asc", + orderByNameFlag.Name(): "asc", } for _, mod := range mods { mod(flagValues) @@ -170,7 +170,7 @@ func TestParseInput(t *testing.T) { { description: "order by name desc", flagValues: fixtureFlagValues(func(flagValues map[string]string) { - flagValues[orderByNameFlag] = "desc" + flagValues[orderByNameFlag.Name()] = "desc" }), isValid: true, expectedModel: fixtureInputModel(func(model *inputModel) { @@ -180,14 +180,14 @@ func TestParseInput(t *testing.T) { { description: "order by name invalid 1", flagValues: fixtureFlagValues(func(flagValues map[string]string) { - flagValues[orderByNameFlag] = "" + flagValues[orderByNameFlag.Name()] = "" }), isValid: false, }, { description: "order by name invalid 2", flagValues: fixtureFlagValues(func(flagValues map[string]string) { - flagValues[orderByNameFlag] = "invalid" + flagValues[orderByNameFlag.Name()] = "invalid" }), isValid: false, }, diff --git a/internal/cmd/kms/key/create/create.go b/internal/cmd/kms/key/create/create.go index 0b78618e0..a829f45ed 100644 --- a/internal/cmd/kms/key/create/create.go +++ b/internal/cmd/kms/key/create/create.go @@ -184,9 +184,9 @@ func outputResult(p *print.Printer, model *inputModel, resp *kms.Key) error { } func configureFlags(cmd *cobra.Command) { - algorithmFlag.Register(cmd) - purposeFlag.Register(cmd) - protectionFlag.Register(cmd) + algorithmFlag.Register(cmd.Flags()) + purposeFlag.Register(cmd.Flags()) + protectionFlag.Register(cmd.Flags()) // All further non Enum Flags cmd.Flags().Var(flags.UUIDFlag(), keyRingIdFlag, "ID of the KMS key ring") diff --git a/internal/cmd/kms/wrappingkey/create/create.go b/internal/cmd/kms/wrappingkey/create/create.go index e2c3ddba1..8d8295329 100644 --- a/internal/cmd/kms/wrappingkey/create/create.go +++ b/internal/cmd/kms/wrappingkey/create/create.go @@ -169,9 +169,9 @@ func outputResult(p *print.Printer, model *inputModel, resp *kms.WrappingKey) er } func configureFlags(cmd *cobra.Command) { - algorithmFlag.Register(cmd) - purposeFlag.Register(cmd) - protectionFlag.Register(cmd) + algorithmFlag.Register(cmd.Flags()) + purposeFlag.Register(cmd.Flags()) + protectionFlag.Register(cmd.Flags()) // All further non Enum Flags cmd.Flags().Var(flags.UUIDFlag(), keyRingIdFlag, "ID of the KMS key ring") diff --git a/internal/cmd/mongodbflex/instance/create/create.go b/internal/cmd/mongodbflex/instance/create/create.go index 26e65e9a0..dbb8455f4 100644 --- a/internal/cmd/mongodbflex/instance/create/create.go +++ b/internal/cmd/mongodbflex/instance/create/create.go @@ -34,7 +34,6 @@ const ( storageClassFlag = "storage-class" storageSizeFlag = "storage-size" versionFlag = "version" - typeFlag = "type" defaultBackupSchedule = "0 0/6 * * *" defaultStorageClass = "premium-perf2-mongodb" @@ -42,6 +41,13 @@ const ( defaultType = "Replica" ) +var typeFlag = flags.StringEnumFlag( + "type", + mongodbflexUtils.AvailableInstanceTypes(), + "Instance type,", + flags.StringEnumDefaultValue(defaultType), +) + type inputModel struct { *globalflags.GlobalFlagModel @@ -139,8 +145,6 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } func configureFlags(cmd *cobra.Command) { - typeFlagOptions := mongodbflexUtils.AvailableInstanceTypes() - cmd.Flags().StringP(instanceNameFlag, "n", "", "Instance name") cmd.Flags().Var(flags.CIDRSliceFlag(), aclFlag, "The access control list (ACL). Must contain at least one valid subnet, for instance '0.0.0.0/0' for open access (discouraged), '1.2.3.0/24 for a public IP range of an organization, '1.2.3.4/32' for a single IP range, etc.") cmd.Flags().String(backupScheduleFlag, defaultBackupSchedule, "Backup schedule") @@ -150,7 +154,7 @@ func configureFlags(cmd *cobra.Command) { cmd.Flags().String(storageClassFlag, defaultStorageClass, "Storage class") cmd.Flags().Int64(storageSizeFlag, defaultStorageSize, "Storage size (in GB)") cmd.Flags().String(versionFlag, "", "MongoDB version. Defaults to the latest version available") - cmd.Flags().Var(flags.EnumFlag(false, defaultType, typeFlagOptions...), typeFlag, fmt.Sprintf("Instance type, one of %q", typeFlagOptions)) + typeFlag.Register(cmd.Flags()) err := flags.MarkFlagsRequired(cmd, instanceNameFlag, aclFlag) cobra.CheckErr(err) @@ -190,7 +194,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, StorageClass: utils.Ptr(flags.FlagWithDefaultToStringValue(p, cmd, storageClassFlag)), StorageSize: &storageSize, Version: flags.FlagToStringPointer(p, cmd, versionFlag), - Type: utils.Ptr(flags.FlagWithDefaultToStringValue(p, cmd, typeFlag)), + Type: typeFlag.Ptr(), } p.DebugInputModel(model) diff --git a/internal/cmd/mongodbflex/instance/create/create_test.go b/internal/cmd/mongodbflex/instance/create/create_test.go index 6812cfff3..1b5961008 100644 --- a/internal/cmd/mongodbflex/instance/create/create_test.go +++ b/internal/cmd/mongodbflex/instance/create/create_test.go @@ -64,7 +64,7 @@ func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]st storageClassFlag: "premium-perf4-mongodb", // Non-default storageSizeFlag: "10", versionFlag: "6.0", - typeFlag: "Replica", + typeFlag.Name(): "Replica", } for _, mod := range mods { mod(flagValues) @@ -144,7 +144,7 @@ func TestParseInput(t *testing.T) { description: "with defaults", flagValues: fixtureFlagValues(func(flagValues map[string]string) { delete(flagValues, backupScheduleFlag) - delete(flagValues, typeFlag) + delete(flagValues, typeFlag.Name()) }), isValid: true, expectedModel: fixtureInputModel(), diff --git a/internal/cmd/mongodbflex/instance/update/update.go b/internal/cmd/mongodbflex/instance/update/update.go index e340f95d2..f255ecb52 100644 --- a/internal/cmd/mongodbflex/instance/update/update.go +++ b/internal/cmd/mongodbflex/instance/update/update.go @@ -35,7 +35,12 @@ const ( storageClassFlag = "storage-class" storageSizeFlag = "storage-size" versionFlag = "version" - typeFlag = "type" +) + +var typeFlag = flags.StringEnumFlag( + "type", + mongodbflexUtils.AvailableInstanceTypes(), + "Instance type,", ) type inputModel struct { @@ -124,8 +129,6 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } func configureFlags(cmd *cobra.Command) { - typeFlagOptions := mongodbflexUtils.AvailableInstanceTypes() - cmd.Flags().StringP(instanceNameFlag, "n", "", "Instance name") cmd.Flags().Var(flags.CIDRSliceFlag(), aclFlag, "Lists of IP networks in CIDR notation which are allowed to access this instance") cmd.Flags().String(backupScheduleFlag, "", "Backup schedule") @@ -135,7 +138,7 @@ func configureFlags(cmd *cobra.Command) { cmd.Flags().String(storageClassFlag, "", "Storage class") cmd.Flags().Int64(storageSizeFlag, 0, "Storage size (in GB)") cmd.Flags().String(versionFlag, "", "Version") - cmd.Flags().Var(flags.EnumFlag(false, "", typeFlagOptions...), typeFlag, fmt.Sprintf("Instance type, one of %q", typeFlagOptions)) + typeFlag.Register(cmd.Flags()) } func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inputModel, error) { @@ -155,7 +158,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu storageClass := flags.FlagToStringPointer(p, cmd, storageClassFlag) storageSize := flags.FlagToInt64Pointer(p, cmd, storageSizeFlag) version := flags.FlagToStringPointer(p, cmd, versionFlag) - instanceType := flags.FlagToStringPointer(p, cmd, typeFlag) + instanceType := typeFlag.Ptr() if instanceName == nil && flavorId == nil && cpu == nil && ram == nil && acl == nil && backupSchedule == nil && storageClass == nil && storageSize == nil && version == nil && instanceType == nil { diff --git a/internal/cmd/mongodbflex/instance/update/update_test.go b/internal/cmd/mongodbflex/instance/update/update_test.go index 9841b3e36..0a12cf79d 100644 --- a/internal/cmd/mongodbflex/instance/update/update_test.go +++ b/internal/cmd/mongodbflex/instance/update/update_test.go @@ -94,7 +94,7 @@ func fixtureStandardFlagValues(mods ...func(flagValues map[string]string)) map[s storageClassFlag: "class", storageSizeFlag: "10", versionFlag: "5.0", - typeFlag: "Single", + typeFlag.Name(): "Single", } for _, mod := range mods { mod(flagValues) @@ -285,6 +285,7 @@ func TestParseInput(t *testing.T) { for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { + typeFlag.Reset() params := testparams.NewTestParams() cmd := NewCmd(params.CmdParams) err := globalflags.Configure(cmd.Flags()) diff --git a/internal/cmd/mongodbflex/user/create/create.go b/internal/cmd/mongodbflex/user/create/create.go index c25309c64..886027376 100644 --- a/internal/cmd/mongodbflex/user/create/create.go +++ b/internal/cmd/mongodbflex/user/create/create.go @@ -24,11 +24,16 @@ const ( instanceIdFlag = "instance-id" usernameFlag = "username" databaseFlag = "database" - roleFlag = "role" ) var ( rolesDefault = []string{"read"} + roleFlag = flags.StringEnumSliceFlag( + "role", + []string{"read", "readWrite", "readAnyDatabase", "readWriteAnyDatabase", "stackitAdmin"}, + "Roles of the user. The \"readAnyDatabase\", \"readWriteAnyDatabase\" and \"stackitAdmin\" roles will always be created in the admin database.", + flags.DefaultValues("read"), + ) ) type inputModel struct { @@ -101,12 +106,10 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } func configureFlags(cmd *cobra.Command) { - roleOptions := []string{"read", "readWrite", "readAnyDatabase", "readWriteAnyDatabase", "stackitAdmin"} - cmd.Flags().Var(flags.UUIDFlag(), instanceIdFlag, "ID of the instance") cmd.Flags().String(usernameFlag, "", "Username of the user. If not specified, a random username will be assigned") cmd.Flags().String(databaseFlag, "", "The database inside the MongoDB instance that the user has access to. If it does not exist, it will be created once the user writes to it") - cmd.Flags().Var(flags.EnumSliceFlag(false, rolesDefault, roleOptions...), roleFlag, fmt.Sprintf("Roles of the user, possible values are %q. The \"readAnyDatabase\", \"readWriteAnyDatabase\" and \"stackitAdmin\" roles will always be created in the admin database.", roleOptions)) + roleFlag.Register(cmd) err := flags.MarkFlagsRequired(cmd, instanceIdFlag, databaseFlag) cobra.CheckErr(err) @@ -123,7 +126,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, InstanceId: flags.FlagToStringValue(p, cmd, instanceIdFlag), Username: flags.FlagToStringPointer(p, cmd, usernameFlag), Database: flags.FlagToStringPointer(p, cmd, databaseFlag), - Roles: flags.FlagWithDefaultToStringSlicePointer(p, cmd, roleFlag), + Roles: roleFlag.Ptr(), } p.DebugInputModel(model) diff --git a/internal/cmd/mongodbflex/user/create/create_test.go b/internal/cmd/mongodbflex/user/create/create_test.go index c13ba7a50..b290fb3a4 100644 --- a/internal/cmd/mongodbflex/user/create/create_test.go +++ b/internal/cmd/mongodbflex/user/create/create_test.go @@ -33,7 +33,6 @@ func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]st instanceIdFlag: testInstanceId, usernameFlag: "johndoe", databaseFlag: "default", - roleFlag: "read", } for _, mod := range mods { mod(flagValues) @@ -148,7 +147,7 @@ func TestParseInput(t *testing.T) { { description: "roles missing", flagValues: fixtureFlagValues(func(flagValues map[string]string) { - delete(flagValues, roleFlag) + delete(flagValues, roleFlag.Name()) }), isValid: true, expectedModel: fixtureInputModel(func(model *inputModel) { @@ -158,7 +157,7 @@ func TestParseInput(t *testing.T) { { description: "invalid role", flagValues: fixtureFlagValues(func(flagValues map[string]string) { - flagValues[roleFlag] = "invalid-role" + flagValues[roleFlag.Name()] = "invalid-role" }), isValid: false, }, diff --git a/internal/cmd/mongodbflex/user/update/update.go b/internal/cmd/mongodbflex/user/update/update.go index 200873a77..bd107bafa 100644 --- a/internal/cmd/mongodbflex/user/update/update.go +++ b/internal/cmd/mongodbflex/user/update/update.go @@ -25,7 +25,12 @@ const ( instanceIdFlag = "instance-id" databaseFlag = "database" - roleFlag = "role" +) + +var roleFlag = flags.StringEnumSliceFlag( + "role", + []string{"read", "readWrite", "readAnyDatabase", "readWriteAnyDatabase", "stackitAdmin"}, + "Roles of the user. The \"readAnyDatabase\", \"readWriteAnyDatabase\" and \"stackitAdmin\" roles will always be created in the admin database.", ) type inputModel struct { @@ -96,11 +101,9 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } func configureFlags(cmd *cobra.Command) { - roleOptions := []string{"read", "readWrite", "readAnyDatabase", "readWriteAnyDatabase", "stackitAdmin"} - cmd.Flags().Var(flags.UUIDFlag(), instanceIdFlag, "ID of the instance") cmd.Flags().String(databaseFlag, "", "The database inside the MongoDB instance that the user has access to. If it does not exist, it will be created once the user writes to it") - cmd.Flags().Var(flags.EnumSliceFlag(false, nil, roleOptions...), roleFlag, fmt.Sprintf("Roles of the user, possible values are %q. The \"readAnyDatabase\", \"readWriteAnyDatabase\" and \"stackitAdmin\" roles will always be created in the admin database.", roleOptions)) + roleFlag.Register(cmd) err := flags.MarkFlagsRequired(cmd, instanceIdFlag) cobra.CheckErr(err) @@ -115,7 +118,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } database := flags.FlagToStringPointer(p, cmd, databaseFlag) - roles := flags.FlagToStringSlicePointer(p, cmd, roleFlag) + roles := roleFlag.Ptr() if database == nil && roles == nil { return nil, &errors.EmptyUpdateError{} diff --git a/internal/cmd/mongodbflex/user/update/update_test.go b/internal/cmd/mongodbflex/user/update/update_test.go index 0d110a06c..dc8451036 100644 --- a/internal/cmd/mongodbflex/user/update/update_test.go +++ b/internal/cmd/mongodbflex/user/update/update_test.go @@ -109,7 +109,7 @@ func TestParseInput(t *testing.T) { description: "update roles", argValues: fixtureArgValues(), flagValues: fixtureFlagValues(func(flagValues map[string]string) { - flagValues[roleFlag] = "read" + flagValues[roleFlag.Name()] = "read" }), isValid: true, expectedModel: fixtureInputModel(func(model *inputModel) { @@ -183,7 +183,7 @@ func TestParseInput(t *testing.T) { description: "invalid role", argValues: fixtureArgValues(), flagValues: fixtureFlagValues(func(flagValues map[string]string) { - flagValues[roleFlag] = "invalid-role" + flagValues[roleFlag.Name()] = "invalid-role" }), isValid: false, }, @@ -192,7 +192,7 @@ func TestParseInput(t *testing.T) { argValues: fixtureArgValues(), flagValues: fixtureFlagValues(func(flagValues map[string]string) { delete(flagValues, databaseFlag) - delete(flagValues, roleFlag) + delete(flagValues, roleFlag.Name()) }), isValid: false, }, diff --git a/internal/cmd/network-area/routingtable/route/create/create.go b/internal/cmd/network-area/routingtable/route/create/create.go index 5f479299f..c43f94af5 100644 --- a/internal/cmd/network-area/routingtable/route/create/create.go +++ b/internal/cmd/network-area/routingtable/route/create/create.go @@ -21,11 +21,9 @@ import ( ) const ( - destinationTypeFlag = "destination-type" destinationValueFlag = "destination-value" labelFlag = "labels" networkAreaIdFlag = "network-area-id" - nextHopTypeFlag = "nexthop-type" nextHopValueFlag = "nexthop-value" organizationIdFlag = "organization-id" routingTableIdFlag = "routing-table-id" @@ -41,6 +39,21 @@ const ( nextHopTypeBlackhole = "blackhole" ) +var ( + destinationTypeFlag = flags.StringEnumFlag( + "destination-type", + []string{destTypeCIDRv4, destTypeCIDRv6}, + "Destination type", + flags.StringEnumIgnoreCase[string](), + ) + nextHopTypeFlag = flags.StringEnumFlag( + "nexthop-type", + []string{nextHopTypeIPv4, nextHopTypeIPv6, nextHopTypeInternet, nextHopTypeBlackhole}, + "Next hop type", + flags.StringEnumIgnoreCase[string](), + ) +) + type inputModel struct { *globalflags.GlobalFlagModel DestinationType string @@ -118,20 +131,12 @@ func configureFlags(cmd *cobra.Command) { cmd.Flags().Var(flags.UUIDFlag(), networkAreaIdFlag, "Network-Area ID") cmd.Flags().Var(flags.UUIDFlag(), organizationIdFlag, "Organization ID") cmd.Flags().Var(flags.UUIDFlag(), routingTableIdFlag, "Routing-Table ID") - - cmd.Flags().Var( - flags.EnumFlag(true, "", destTypeCIDRv4, destTypeCIDRv6), - destinationTypeFlag, - "Destination type") - - cmd.Flags().Var( - flags.EnumFlag(true, "", nextHopTypeIPv4, nextHopTypeIPv6, nextHopTypeInternet, nextHopTypeBlackhole), - nextHopTypeFlag, - "Next hop type") + destinationTypeFlag.Register(cmd.Flags()) + nextHopTypeFlag.Register(cmd.Flags()) cmd.Flags().StringToString(labelFlag, nil, "Key=value labels") - err := flags.MarkFlagsRequired(cmd, organizationIdFlag, networkAreaIdFlag, routingTableIdFlag, destinationTypeFlag, destinationValueFlag, nextHopTypeFlag) + err := flags.MarkFlagsRequired(cmd, organizationIdFlag, networkAreaIdFlag, routingTableIdFlag, destinationTypeFlag.Name(), destinationValueFlag, nextHopTypeFlag.Name()) cobra.CheckErr(err) } @@ -140,11 +145,11 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, model := &inputModel{ GlobalFlagModel: globalFlags, - DestinationType: flags.FlagToStringValue(p, cmd, destinationTypeFlag), + DestinationType: destinationTypeFlag.Get(), DestinationValue: flags.FlagToStringPointer(p, cmd, destinationValueFlag), Labels: flags.FlagToStringToAny(p, cmd, labelFlag), NetworkAreaId: flags.FlagToStringValue(p, cmd, networkAreaIdFlag), - NextHopType: flags.FlagToStringValue(p, cmd, nextHopTypeFlag), + NextHopType: nextHopTypeFlag.Get(), NextHopValue: flags.FlagToStringPointer(p, cmd, nextHopValueFlag), OrganizationId: flags.FlagToStringValue(p, cmd, organizationIdFlag), RoutingTableId: flags.FlagToStringValue(p, cmd, routingTableIdFlag), diff --git a/internal/cmd/network-area/routingtable/route/create/create_test.go b/internal/cmd/network-area/routingtable/route/create/create_test.go index 2f0de6965..3a4622542 100644 --- a/internal/cmd/network-area/routingtable/route/create/create_test.go +++ b/internal/cmd/network-area/routingtable/route/create/create_test.go @@ -41,15 +41,15 @@ var testLabels = map[string]any{ func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string { flagValues := map[string]string{ - globalflags.RegionFlag: testRegion, - labelFlag: testLabelSelectorFlag, - organizationIdFlag: testOrgId, - networkAreaIdFlag: testNetworkAreaId, - routingTableIdFlag: testRoutingTableId, - destinationTypeFlag: testDestinationTypeFlag, - destinationValueFlag: testDestinationValueFlag, - nextHopTypeFlag: testNextHopTypeFlag, - nextHopValueFlag: testNextHopValueFlag, + globalflags.RegionFlag: testRegion, + labelFlag: testLabelSelectorFlag, + organizationIdFlag: testOrgId, + networkAreaIdFlag: testNetworkAreaId, + routingTableIdFlag: testRoutingTableId, + destinationTypeFlag.Name(): testDestinationTypeFlag, + destinationValueFlag: testDestinationValueFlag, + nextHopTypeFlag.Name(): testNextHopTypeFlag, + nextHopValueFlag: testNextHopValueFlag, } for _, mod := range mods { mod(flagValues) @@ -144,14 +144,14 @@ func TestParseInput(t *testing.T) { { description: "destination type missing", flagValues: fixtureFlagValues(func(flagValues map[string]string) { - delete(flagValues, destinationTypeFlag) + delete(flagValues, destinationTypeFlag.Name()) }), isValid: false, }, { description: "next hop type missing", flagValues: fixtureFlagValues(func(flagValues map[string]string) { - delete(flagValues, nextHopTypeFlag) + delete(flagValues, nextHopTypeFlag.Name()) }), isValid: false, }, @@ -212,7 +212,7 @@ func TestParseInput(t *testing.T) { { description: "invalid destination type enum", flagValues: fixtureFlagValues(func(flagValues map[string]string) { - flagValues[destinationTypeFlag] = nextHopTypeIPv4 // Deliberately invalid for dest + flagValues[destinationTypeFlag.Name()] = nextHopTypeIPv4 // Deliberately invalid for dest }), isValid: false, }, @@ -226,7 +226,7 @@ func TestParseInput(t *testing.T) { { description: "destination value not IPv6 CIDR", flagValues: fixtureFlagValues(func(flagValues map[string]string) { - flagValues[destinationTypeFlag] = destTypeCIDRv6 + flagValues[destinationTypeFlag.Name()] = destTypeCIDRv6 flagValues[destinationValueFlag] = "2001:db8::" }), isValid: false, @@ -234,7 +234,7 @@ func TestParseInput(t *testing.T) { { description: "destination value is IPv6 CIDR", flagValues: fixtureFlagValues(func(flagValues map[string]string) { - flagValues[destinationTypeFlag] = destTypeCIDRv6 + flagValues[destinationTypeFlag.Name()] = destTypeCIDRv6 flagValues[destinationValueFlag] = "2001:db8::/32" }), isValid: true, @@ -246,14 +246,14 @@ func TestParseInput(t *testing.T) { { description: "invalid next hop type enum", flagValues: fixtureFlagValues(func(flagValues map[string]string) { - flagValues[nextHopTypeFlag] = destTypeCIDRv4 // Deliberately invalid for hop + flagValues[nextHopTypeFlag.Name()] = destTypeCIDRv4 // Deliberately invalid for hop }), isValid: false, }, { description: "next hop type is internet and next hop value is provided", flagValues: fixtureFlagValues(func(flagValues map[string]string) { - flagValues[nextHopTypeFlag] = nextHopTypeInternet + flagValues[nextHopTypeFlag.Name()] = nextHopTypeInternet flagValues[nextHopValueFlag] = "1.1.1.1" // should not be allowed }), isValid: false, @@ -261,7 +261,7 @@ func TestParseInput(t *testing.T) { { description: "next hop type is blackhole and next hop value is provided", flagValues: fixtureFlagValues(func(flagValues map[string]string) { - flagValues[nextHopTypeFlag] = nextHopTypeBlackhole + flagValues[nextHopTypeFlag.Name()] = nextHopTypeBlackhole flagValues[nextHopValueFlag] = "1.1.1.1" }), isValid: false, @@ -269,7 +269,7 @@ func TestParseInput(t *testing.T) { { description: "next hop type is internet and next hop value is not provided", flagValues: fixtureFlagValues(func(flagValues map[string]string) { - flagValues[nextHopTypeFlag] = nextHopTypeInternet + flagValues[nextHopTypeFlag.Name()] = nextHopTypeInternet delete(flagValues, nextHopValueFlag) }), expectedModel: fixtureInputModel(func(model *inputModel) { @@ -281,7 +281,7 @@ func TestParseInput(t *testing.T) { { description: "next hop type is blackhole and next hop value is not provided", flagValues: fixtureFlagValues(func(flagValues map[string]string) { - flagValues[nextHopTypeFlag] = nextHopTypeBlackhole + flagValues[nextHopTypeFlag.Name()] = nextHopTypeBlackhole delete(flagValues, nextHopValueFlag) }), expectedModel: fixtureInputModel(func(model *inputModel) { @@ -293,7 +293,7 @@ func TestParseInput(t *testing.T) { { description: "next hop type is IPv4 and next hop value is missing", flagValues: fixtureFlagValues(func(flagValues map[string]string) { - flagValues[nextHopTypeFlag] = nextHopTypeIPv4 + flagValues[nextHopTypeFlag.Name()] = nextHopTypeIPv4 delete(flagValues, nextHopValueFlag) }), isValid: false, @@ -301,7 +301,7 @@ func TestParseInput(t *testing.T) { { description: "next hop type is IPv6 and next hop value is missing", flagValues: fixtureFlagValues(func(flagValues map[string]string) { - flagValues[nextHopTypeFlag] = nextHopTypeIPv6 + flagValues[nextHopTypeFlag.Name()] = nextHopTypeIPv6 delete(flagValues, nextHopValueFlag) }), isValid: false, @@ -309,7 +309,7 @@ func TestParseInput(t *testing.T) { { description: "invalid next hop type provided", flagValues: fixtureFlagValues(func(flagValues map[string]string) { - flagValues[nextHopTypeFlag] = "invalid-type" + flagValues[nextHopTypeFlag.Name()] = "invalid-type" }), isValid: false, }, diff --git a/internal/cmd/organization/member/list/list.go b/internal/cmd/organization/member/list/list.go index fef787e39..3858c277e 100644 --- a/internal/cmd/organization/member/list/list.go +++ b/internal/cmd/organization/member/list/list.go @@ -25,11 +25,17 @@ const ( organizationIdFlag = "organization-id" subjectFlag = "subject" limitFlag = "limit" - sortByFlag = "sort-by" organizationResourceType = "organization" ) +var sortByFlag = flags.StringEnumFlag( + "sort-by", + []string{"subject", "role"}, + "Sort entries by a specific field,", + flags.StringEnumDefaultValue("subject"), +) + type inputModel struct { *globalflags.GlobalFlagModel @@ -94,12 +100,10 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } func configureFlags(cmd *cobra.Command) { - sortByFlagOptions := []string{"subject", "role"} - cmd.Flags().String(organizationIdFlag, "", "The organization ID") cmd.Flags().String(subjectFlag, "", "Filter by subject (Identifier of user, service account or client. Usually email address in case of users or name in case of clients)") cmd.Flags().Int64(limitFlag, 0, "Maximum number of entries to list") - cmd.Flags().Var(flags.EnumFlag(false, "subject", sortByFlagOptions...), sortByFlag, fmt.Sprintf("Sort entries by a specific field, one of %q", sortByFlagOptions)) + sortByFlag.Register(cmd.Flags()) err := flags.MarkFlagsRequired(cmd, organizationIdFlag) cobra.CheckErr(err) @@ -121,7 +125,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, OrganizationId: flags.FlagToStringPointer(p, cmd, organizationIdFlag), Subject: flags.FlagToStringPointer(p, cmd, subjectFlag), Limit: flags.FlagToInt64Pointer(p, cmd, limitFlag), - SortBy: flags.FlagWithDefaultToStringValue(p, cmd, sortByFlag), + SortBy: sortByFlag.Get(), } p.DebugInputModel(model) diff --git a/internal/cmd/organization/member/list/list_test.go b/internal/cmd/organization/member/list/list_test.go index e2224a91f..cd553c654 100644 --- a/internal/cmd/organization/member/list/list_test.go +++ b/internal/cmd/organization/member/list/list_test.go @@ -107,7 +107,7 @@ func TestParseInput(t *testing.T) { { description: "sort by role", flagValues: fixtureFlagValues(func(flagValues map[string]string) { - flagValues[sortByFlag] = "role" + flagValues[sortByFlag.Name()] = "role" }), isValid: true, expectedModel: fixtureInputModel(func(model *inputModel) { @@ -117,7 +117,7 @@ func TestParseInput(t *testing.T) { { description: "sort by invalid", flagValues: fixtureFlagValues(func(flagValues map[string]string) { - flagValues[sortByFlag] = "invalid" + flagValues[sortByFlag.Name()] = "invalid" }), isValid: false, }, diff --git a/internal/cmd/postgresflex/instance/create/create.go b/internal/cmd/postgresflex/instance/create/create.go index 7cad848d6..d3530b87e 100644 --- a/internal/cmd/postgresflex/instance/create/create.go +++ b/internal/cmd/postgresflex/instance/create/create.go @@ -34,7 +34,6 @@ const ( storageClassFlag = "storage-class" storageSizeFlag = "storage-size" versionFlag = "version" - typeFlag = "type" defaultBackupSchedule = "0 0 * * *" defaultStorageClass = "premium-perf2-stackit" @@ -42,6 +41,15 @@ const ( defaultType = "Replica" ) +var ( + typeFlag = flags.StringEnumFlag( + "type", + postgresflexUtils.AvailableInstanceTypes(), + "Instance type,", + flags.StringEnumDefaultValue(defaultType), + ) +) + type inputModel struct { *globalflags.GlobalFlagModel @@ -139,8 +147,6 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } func configureFlags(cmd *cobra.Command) { - typeFlagOptions := postgresflexUtils.AvailableInstanceTypes() - cmd.Flags().StringP(instanceNameFlag, "n", "", "Instance name") cmd.Flags().Var(flags.CIDRSliceFlag(), aclFlag, "The access control list (ACL). Must contain at least one valid subnet, for instance '0.0.0.0/0' for open access (discouraged), '1.2.3.0/24 for a public IP range of an organization, '1.2.3.4/32' for a single IP range, etc.") cmd.Flags().String(backupScheduleFlag, defaultBackupSchedule, "Backup schedule") @@ -150,7 +156,7 @@ func configureFlags(cmd *cobra.Command) { cmd.Flags().String(storageClassFlag, defaultStorageClass, "Storage class") cmd.Flags().Int64(storageSizeFlag, defaultStorageSize, "Storage size (in GB)") cmd.Flags().String(versionFlag, "", "PostgreSQL version. Defaults to the latest version available") - cmd.Flags().Var(flags.EnumFlag(false, defaultType, typeFlagOptions...), typeFlag, fmt.Sprintf("Instance type, one of %q", typeFlagOptions)) + typeFlag.Register(cmd.Flags()) err := flags.MarkFlagsRequired(cmd, instanceNameFlag, aclFlag) cobra.CheckErr(err) @@ -190,7 +196,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, StorageClass: utils.Ptr(flags.FlagWithDefaultToStringValue(p, cmd, storageClassFlag)), StorageSize: &storageSize, Version: flags.FlagToStringPointer(p, cmd, versionFlag), - Type: utils.Ptr(flags.FlagWithDefaultToStringValue(p, cmd, typeFlag)), + Type: typeFlag.Ptr(), } p.DebugInputModel(model) diff --git a/internal/cmd/postgresflex/instance/create/create_test.go b/internal/cmd/postgresflex/instance/create/create_test.go index 4c17e1e47..54f1b3087 100644 --- a/internal/cmd/postgresflex/instance/create/create_test.go +++ b/internal/cmd/postgresflex/instance/create/create_test.go @@ -61,7 +61,7 @@ func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]st storageClassFlag: "premium-perf4-stackit", // Non-default storageSizeFlag: "10", versionFlag: "6.0", - typeFlag: "Replica", + typeFlag.Name(): "Replica", } for _, mod := range mods { mod(flagValues) @@ -141,7 +141,7 @@ func TestParseInput(t *testing.T) { description: "with defaults", flagValues: fixtureFlagValues(func(flagValues map[string]string) { delete(flagValues, backupScheduleFlag) - delete(flagValues, typeFlag) + delete(flagValues, typeFlag.Name()) }), isValid: true, expectedModel: fixtureInputModel(), diff --git a/internal/cmd/postgresflex/instance/update/update.go b/internal/cmd/postgresflex/instance/update/update.go index 74a3a402d..fc2bc8986 100644 --- a/internal/cmd/postgresflex/instance/update/update.go +++ b/internal/cmd/postgresflex/instance/update/update.go @@ -35,7 +35,12 @@ const ( storageClassFlag = "storage-class" storageSizeFlag = "storage-size" versionFlag = "version" - typeFlag = "type" +) + +var typeFlag = flags.StringEnumFlag( + "type", + postgresflexUtils.AvailableInstanceTypes(), + "Instance type,", ) type inputModel struct { @@ -124,8 +129,6 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } func configureFlags(cmd *cobra.Command) { - typeFlagOptions := postgresflexUtils.AvailableInstanceTypes() - cmd.Flags().StringP(instanceNameFlag, "n", "", "Instance name") cmd.Flags().Var(flags.CIDRSliceFlag(), aclFlag, "List of IP networks in CIDR notation which are allowed to access this instance") cmd.Flags().String(backupScheduleFlag, "", "Backup schedule") @@ -135,7 +138,7 @@ func configureFlags(cmd *cobra.Command) { cmd.Flags().String(storageClassFlag, "", "Storage class") cmd.Flags().Int64(storageSizeFlag, 0, "Storage size (in GB)") cmd.Flags().String(versionFlag, "", "Version") - cmd.Flags().Var(flags.EnumFlag(false, "", typeFlagOptions...), typeFlag, fmt.Sprintf("Instance type, one of %q", typeFlagOptions)) + typeFlag.Register(cmd.Flags()) } func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inputModel, error) { @@ -155,7 +158,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu storageClass := flags.FlagToStringPointer(p, cmd, storageClassFlag) storageSize := flags.FlagToInt64Pointer(p, cmd, storageSizeFlag) version := flags.FlagToStringPointer(p, cmd, versionFlag) - instanceType := flags.FlagToStringPointer(p, cmd, typeFlag) + instanceType := typeFlag.Ptr() if instanceName == nil && flavorId == nil && cpu == nil && ram == nil && acl == nil && backupSchedule == nil && storageClass == nil && storageSize == nil && version == nil && instanceType == nil { diff --git a/internal/cmd/postgresflex/instance/update/update_test.go b/internal/cmd/postgresflex/instance/update/update_test.go index 7715abf81..401348b92 100644 --- a/internal/cmd/postgresflex/instance/update/update_test.go +++ b/internal/cmd/postgresflex/instance/update/update_test.go @@ -92,7 +92,7 @@ func fixtureStandardFlagValues(mods ...func(flagValues map[string]string)) map[s storageClassFlag: "class", storageSizeFlag: "10", versionFlag: "5.0", - typeFlag: "Single", + typeFlag.Name(): "Single", } for _, mod := range mods { mod(flagValues) @@ -283,6 +283,7 @@ func TestParseInput(t *testing.T) { for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { + typeFlag.Reset() params := testparams.NewTestParams() cmd := NewCmd(params.CmdParams) err := globalflags.Configure(cmd.Flags()) diff --git a/internal/cmd/postgresflex/user/create/create.go b/internal/cmd/postgresflex/user/create/create.go index 97dc0c520..c4742e2a0 100644 --- a/internal/cmd/postgresflex/user/create/create.go +++ b/internal/cmd/postgresflex/user/create/create.go @@ -23,11 +23,16 @@ import ( const ( instanceIdFlag = "instance-id" usernameFlag = "username" - roleFlag = "role" ) var ( rolesDefault = []string{"login"} + roleFlag = flags.StringEnumSliceFlag( + "role", + []string{"login", "createdb"}, + "Roles of the user,", + flags.DefaultValues(rolesDefault...), + ) ) type inputModel struct { @@ -98,11 +103,9 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } func configureFlags(cmd *cobra.Command) { - roleOptions := []string{"login", "createdb"} - cmd.Flags().Var(flags.UUIDFlag(), instanceIdFlag, "ID of the instance") cmd.Flags().String(usernameFlag, "", "Username of the user") - cmd.Flags().Var(flags.EnumSliceFlag(false, rolesDefault, roleOptions...), roleFlag, fmt.Sprintf("Roles of the user, possible values are %q", roleOptions)) + roleFlag.Register(cmd) err := flags.MarkFlagsRequired(cmd, instanceIdFlag, usernameFlag) cobra.CheckErr(err) @@ -118,7 +121,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, GlobalFlagModel: globalFlags, InstanceId: flags.FlagToStringValue(p, cmd, instanceIdFlag), Username: flags.FlagToStringPointer(p, cmd, usernameFlag), - Roles: flags.FlagWithDefaultToStringSlicePointer(p, cmd, roleFlag), + Roles: roleFlag.Ptr(), } p.DebugInputModel(model) diff --git a/internal/cmd/postgresflex/user/create/create_test.go b/internal/cmd/postgresflex/user/create/create_test.go index f07ee7859..2c9e50a7c 100644 --- a/internal/cmd/postgresflex/user/create/create_test.go +++ b/internal/cmd/postgresflex/user/create/create_test.go @@ -29,7 +29,7 @@ func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]st globalflags.RegionFlag: testRegion, instanceIdFlag: testInstanceId, usernameFlag: "johndoe", - roleFlag: "login", + roleFlag.Name(): "login", } for _, mod := range mods { mod(flagValues) @@ -132,7 +132,7 @@ func TestParseInput(t *testing.T) { { description: "roles missing", flagValues: fixtureFlagValues(func(flagValues map[string]string) { - delete(flagValues, roleFlag) + delete(flagValues, roleFlag.Name()) }), isValid: true, expectedModel: fixtureInputModel(func(model *inputModel) { @@ -142,7 +142,7 @@ func TestParseInput(t *testing.T) { { description: "invalid role", flagValues: fixtureFlagValues(func(flagValues map[string]string) { - flagValues[roleFlag] = "invalid-role" + flagValues[roleFlag.Name()] = "invalid-role" }), isValid: false, }, diff --git a/internal/cmd/postgresflex/user/update/update.go b/internal/cmd/postgresflex/user/update/update.go index fa8d8e445..33ca9d18d 100644 --- a/internal/cmd/postgresflex/user/update/update.go +++ b/internal/cmd/postgresflex/user/update/update.go @@ -23,7 +23,12 @@ const ( userIdArg = "USER_ID" instanceIdFlag = "instance-id" - roleFlag = "role" +) + +var roleFlag = flags.StringEnumSliceFlag( + "role", + []string{"login", "createdb"}, + "Roles of the user,", ) type inputModel struct { @@ -93,10 +98,8 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } func configureFlags(cmd *cobra.Command) { - roleOptions := []string{"login", "createdb"} - cmd.Flags().Var(flags.UUIDFlag(), instanceIdFlag, "ID of the instance") - cmd.Flags().Var(flags.EnumSliceFlag(false, nil, roleOptions...), roleFlag, fmt.Sprintf("Roles of the user, possible values are %q", roleOptions)) + roleFlag.Register(cmd) err := flags.MarkFlagsRequired(cmd, instanceIdFlag) cobra.CheckErr(err) @@ -110,7 +113,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu return nil, &errors.ProjectIdError{} } - roles := flags.FlagToStringSlicePointer(p, cmd, roleFlag) + roles := roleFlag.Ptr() if roles == nil { return nil, &errors.EmptyUpdateError{} } diff --git a/internal/cmd/postgresflex/user/update/update_test.go b/internal/cmd/postgresflex/user/update/update_test.go index c20ded9b7..c2192e84f 100644 --- a/internal/cmd/postgresflex/user/update/update_test.go +++ b/internal/cmd/postgresflex/user/update/update_test.go @@ -38,7 +38,7 @@ func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]st globalflags.ProjectIdFlag: testProjectId, globalflags.RegionFlag: testRegion, instanceIdFlag: testInstanceId, - roleFlag: "login", + roleFlag.Name(): "login", } for _, mod := range mods { mod(flagValues) @@ -152,7 +152,7 @@ func TestParseInput(t *testing.T) { description: "invalid role", argValues: fixtureArgValues(), flagValues: fixtureFlagValues(func(flagValues map[string]string) { - flagValues[roleFlag] = "invalid-role" + flagValues[roleFlag.Name()] = "invalid-role" }), isValid: false, }, @@ -160,7 +160,7 @@ func TestParseInput(t *testing.T) { description: "empty update", argValues: fixtureArgValues(), flagValues: fixtureFlagValues(func(flagValues map[string]string) { - delete(flagValues, roleFlag) + delete(flagValues, roleFlag.Name()) }), isValid: false, }, diff --git a/internal/cmd/project/member/list/list.go b/internal/cmd/project/member/list/list.go index 97b3003ef..1dd53f369 100644 --- a/internal/cmd/project/member/list/list.go +++ b/internal/cmd/project/member/list/list.go @@ -25,11 +25,17 @@ import ( const ( subjectFlag = "subject" limitFlag = "limit" - sortByFlag = "sort-by" projectResourceType = "project" ) +var sortByFlag = flags.StringEnumFlag( + "sort-by", + []string{"subject", "role"}, + "Sort entries by a specific field,", + flags.StringEnumDefaultValue("subject"), +) + type inputModel struct { *globalflags.GlobalFlagModel @@ -98,11 +104,9 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } func configureFlags(cmd *cobra.Command) { - sortByFlagOptions := []string{"subject", "role"} - cmd.Flags().String(subjectFlag, "", "Filter by subject (the identifier of a user, service account or client). This is usually the email address (for users) or name (for clients)") cmd.Flags().Int64(limitFlag, 0, "Maximum number of entries to list") - cmd.Flags().Var(flags.EnumFlag(false, "subject", sortByFlagOptions...), sortByFlag, fmt.Sprintf("Sort entries by a specific field, one of %q", sortByFlagOptions)) + sortByFlag.Register(cmd.Flags()) } func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, error) { @@ -123,7 +127,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, GlobalFlagModel: globalFlags, Subject: flags.FlagToStringPointer(p, cmd, subjectFlag), Limit: flags.FlagToInt64Pointer(p, cmd, limitFlag), - SortBy: flags.FlagWithDefaultToStringValue(p, cmd, sortByFlag), + SortBy: sortByFlag.Get(), } p.DebugInputModel(model) diff --git a/internal/cmd/project/member/list/list_test.go b/internal/cmd/project/member/list/list_test.go index 37918bef2..4c31dc91c 100644 --- a/internal/cmd/project/member/list/list_test.go +++ b/internal/cmd/project/member/list/list_test.go @@ -112,7 +112,7 @@ func TestParseInput(t *testing.T) { { description: "sort by role", flagValues: fixtureFlagValues(func(flagValues map[string]string) { - flagValues[sortByFlag] = "role" + flagValues[sortByFlag.Name()] = "role" }), isValid: true, expectedModel: fixtureInputModel(func(model *inputModel) { @@ -122,7 +122,7 @@ func TestParseInput(t *testing.T) { { description: "sort by invalid", flagValues: fixtureFlagValues(func(flagValues map[string]string) { - flagValues[sortByFlag] = "invalid" + flagValues[sortByFlag.Name()] = "invalid" }), isValid: false, }, diff --git a/internal/cmd/server/create/create.go b/internal/cmd/server/create/create.go index d476c1883..fdd623727 100644 --- a/internal/cmd/server/create/create.go +++ b/internal/cmd/server/create/create.go @@ -29,7 +29,6 @@ const ( machineTypeFlag = "machine-type" affinityGroupFlag = "affinity-group" availabilityZoneFlag = "availability-zone" - agentProvisioningPolicyFlag = "agent-provisioning-policy" bootVolumeSourceIdFlag = "boot-volume-source-id" bootVolumeSourceTypeFlag = "boot-volume-source-type" bootVolumeSizeFlag = "boot-volume-size" @@ -46,6 +45,13 @@ const ( volumesFlag = "volumes" ) +var agentProvisioningPolicyFlag = flags.StringEnumFlag( + "agent-provisioning-policy", + []string{"ALWAYS", "NEVER", "INHERIT"}, + "Whether to provision an agent on server creation,", + flags.StringEnumDefaultValue("INHERIT"), +) + type inputModel struct { *globalflags.GlobalFlagModel Name string @@ -157,8 +163,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } func configureFlags(cmd *cobra.Command) { - agentProvisioningPolicyOptions := []string{"ALWAYS", "NEVER", "INHERIT"} - cmd.Flags().Var(flags.EnumFlag(false, "INHERIT", agentProvisioningPolicyOptions...), agentProvisioningPolicyFlag, fmt.Sprintf("Whether to provision an agent on server creation, one of %q", agentProvisioningPolicyOptions)) + agentProvisioningPolicyFlag.Register(cmd.Flags()) cmd.Flags().StringP(nameFlag, "n", "", "Server name") cmd.Flags().String(machineTypeFlag, "", "Name of the type of the machine for the server. Possible values are documented in https://docs.stackit.cloud/products/compute-engine/server/basics/machine-types/") cmd.Flags().String(affinityGroupFlag, "", "The affinity group the server is assigned to") @@ -252,7 +257,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, MachineType: flags.FlagToStringValue(p, cmd, machineTypeFlag), AffinityGroup: flags.FlagToStringPointer(p, cmd, affinityGroupFlag), AvailabilityZone: flags.FlagToStringPointer(p, cmd, availabilityZoneFlag), - AgentProvisioningPolicy: flags.FlagToStringPointer(p, cmd, agentProvisioningPolicyFlag), + AgentProvisioningPolicy: agentProvisioningPolicyFlag.Ptr(), BootVolumeSourceId: flags.FlagToStringValue(p, cmd, bootVolumeSourceIdFlag), BootVolumeSourceType: flags.FlagToStringValue(p, cmd, bootVolumeSourceTypeFlag), BootVolumeSize: flags.FlagToInt64Pointer(p, cmd, bootVolumeSizeFlag), diff --git a/internal/cmd/server/create/create_test.go b/internal/cmd/server/create/create_test.go index 3eecfa4e5..a79f69b03 100644 --- a/internal/cmd/server/create/create_test.go +++ b/internal/cmd/server/create/create_test.go @@ -35,23 +35,23 @@ func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]st globalflags.ProjectIdFlag: testProjectId, globalflags.RegionFlag: testRegion, - agentProvisioningPolicyFlag: "INHERIT", - availabilityZoneFlag: "eu01-1", - nameFlag: "test-server-name", - machineTypeFlag: "t1.1", - affinityGroupFlag: "test-affinity-group", - labelFlag: "key=value", - bootVolumePerformanceClassFlag: "test-perf-class", - bootVolumeSizeFlag: "5", - bootVolumeSourceIdFlag: testSourceId, - bootVolumeSourceTypeFlag: "test-source-type", - bootVolumeDeleteOnTerminationFlag: "false", - keypairNameFlag: "test-keypair-name", - networkIdFlag: testNetworkId, - securityGroupsFlag: "test-security-groups", - serviceAccountEmailsFlag: "test-service-account", - userDataFlag: "test-user-data", - volumesFlag: testVolumeId, + agentProvisioningPolicyFlag.Name(): "INHERIT", + availabilityZoneFlag: "eu01-1", + nameFlag: "test-server-name", + machineTypeFlag: "t1.1", + affinityGroupFlag: "test-affinity-group", + labelFlag: "key=value", + bootVolumePerformanceClassFlag: "test-perf-class", + bootVolumeSizeFlag: "5", + bootVolumeSourceIdFlag: testSourceId, + bootVolumeSourceTypeFlag: "test-source-type", + bootVolumeDeleteOnTerminationFlag: "false", + keypairNameFlag: "test-keypair-name", + networkIdFlag: testNetworkId, + securityGroupsFlag: "test-security-groups", + serviceAccountEmailsFlag: "test-service-account", + userDataFlag: "test-user-data", + volumesFlag: testVolumeId, } for _, mod := range mods { mod(flagValues) @@ -166,7 +166,7 @@ func TestParseInput(t *testing.T) { description: "required only", flagValues: fixtureFlagValues(func(flagValues map[string]string) { delete(flagValues, affinityGroupFlag) - delete(flagValues, agentProvisioningPolicyFlag) + delete(flagValues, agentProvisioningPolicyFlag.Name()) delete(flagValues, availabilityZoneFlag) delete(flagValues, labelFlag) delete(flagValues, bootVolumeSourceIdFlag) @@ -185,7 +185,7 @@ func TestParseInput(t *testing.T) { isValid: true, expectedModel: fixtureInputModel(func(model *inputModel) { model.AffinityGroup = nil - model.AgentProvisioningPolicy = nil + model.AgentProvisioningPolicy = utils.Ptr("INHERIT") model.AvailabilityZone = nil model.Labels = nil model.BootVolumeSourceId = "" @@ -334,17 +334,17 @@ func TestParseInput(t *testing.T) { { description: "valid with agent-provisioned flag missing", flagValues: fixtureFlagValues(func(flagValues map[string]string) { - delete(flagValues, agentProvisioningPolicyFlag) + delete(flagValues, agentProvisioningPolicyFlag.Name()) }), isValid: true, expectedModel: fixtureInputModel(func(model *inputModel) { - model.AgentProvisioningPolicy = nil + model.AgentProvisioningPolicy = utils.Ptr("INHERIT") }), }, { description: "agent-provisioned flag properly handled", flagValues: fixtureFlagValues(func(flagValues map[string]string) { - flagValues[agentProvisioningPolicyFlag] = "ALWAYS" + flagValues[agentProvisioningPolicyFlag.Name()] = "ALWAYS" }), isValid: true, expectedModel: fixtureInputModel(func(model *inputModel) { diff --git a/internal/cmd/ske/kubeconfig/create/create_test.go b/internal/cmd/ske/kubeconfig/create/create_test.go index b2e7797b4..c12c06887 100644 --- a/internal/cmd/ske/kubeconfig/create/create_test.go +++ b/internal/cmd/ske/kubeconfig/create/create_test.go @@ -194,7 +194,7 @@ func TestParseInput(t *testing.T) { argValues: fixtureArgValues(), flagValues: fixtureFlagValues(func(flagValues map[string]string) { flagValues[disableWritingFlag] = "true" - flagValues[globalflags.OutputFormatFlag] = print.YAMLOutputFormat + flagValues[globalflags.OutputFormatFlag.Name()] = print.YAMLOutputFormat }), expectedModel: fixtureInputModel(func(model *inputModel) { model.DisableWriting = true diff --git a/internal/cmd/volume/backup/create/create.go b/internal/cmd/volume/backup/create/create.go index 2c5022ce2..5823edcb8 100644 --- a/internal/cmd/volume/backup/create/create.go +++ b/internal/cmd/volume/backup/create/create.go @@ -24,13 +24,16 @@ import ( ) const ( - sourceIdFlag = "source-id" - sourceTypeFlag = "source-type" - nameFlag = "name" - labelsFlag = "labels" + sourceIdFlag = "source-id" + nameFlag = "name" + labelsFlag = "labels" ) -var sourceTypeFlagOptions = []string{"volume", "snapshot"} +var sourceTypeFlag = flags.StringEnumFlag( + "source-type", + []string{"volume", "snapshot"}, + "Source type of the backup,", +) type inputModel struct { *globalflags.GlobalFlagModel @@ -133,11 +136,11 @@ func NewCmd(params *types.CmdParams) *cobra.Command { func configureFlags(cmd *cobra.Command) { cmd.Flags().String(sourceIdFlag, "", "ID of the source from which a backup should be created") - cmd.Flags().Var(flags.EnumFlag(false, "", sourceTypeFlagOptions...), sourceTypeFlag, fmt.Sprintf("Source type of the backup, one of %q", sourceTypeFlagOptions)) + sourceTypeFlag.Register(cmd.Flags()) cmd.Flags().String(nameFlag, "", "Name of the backup") cmd.Flags().StringToString(labelsFlag, nil, "Key-value string pairs as labels") - err := flags.MarkFlagsRequired(cmd, sourceIdFlag, sourceTypeFlag) + err := flags.MarkFlagsRequired(cmd, sourceIdFlag, sourceTypeFlag.Name()) cobra.CheckErr(err) } @@ -152,8 +155,6 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, return nil, fmt.Errorf("source-id is required") } - sourceType := flags.FlagToStringValue(p, cmd, sourceTypeFlag) - name := flags.FlagToStringPointer(p, cmd, nameFlag) labels := flags.FlagToStringToAny(p, cmd, labelsFlag) if labels == nil { @@ -163,7 +164,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, model := inputModel{ GlobalFlagModel: globalFlags, SourceID: sourceID, - SourceType: sourceType, + SourceType: sourceTypeFlag.Get(), Name: name, Labels: labels, } diff --git a/internal/cmd/volume/backup/create/create_test.go b/internal/cmd/volume/backup/create/create_test.go index 36689449b..3add919a4 100644 --- a/internal/cmd/volume/backup/create/create_test.go +++ b/internal/cmd/volume/backup/create/create_test.go @@ -37,10 +37,10 @@ func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]st globalflags.ProjectIdFlag: testProjectId, globalflags.RegionFlag: testRegion, - sourceIdFlag: testSourceId, - sourceTypeFlag: testSourceType, - nameFlag: testName, - labelsFlag: "key1=value1", + sourceIdFlag: testSourceId, + sourceTypeFlag.Name(): testSourceType, + nameFlag: testName, + labelsFlag: "key1=value1", } for _, mod := range mods { mod(flagValues) @@ -115,14 +115,14 @@ func TestParseInput(t *testing.T) { { description: "no source type", flagValues: fixtureFlagValues(func(flagValues map[string]string) { - delete(flagValues, sourceTypeFlag) + delete(flagValues, sourceTypeFlag.Name()) }), isValid: false, }, { description: "invalid source type", flagValues: fixtureFlagValues(func(flagValues map[string]string) { - flagValues[sourceTypeFlag] = "invalid" + flagValues[sourceTypeFlag.Name()] = "invalid" }), isValid: false, }, diff --git a/internal/pkg/flags/enum.go b/internal/pkg/flags/enum.go deleted file mode 100644 index 7ac3a531e..000000000 --- a/internal/pkg/flags/enum.go +++ /dev/null @@ -1,65 +0,0 @@ -package flags - -import ( - "fmt" - "strings" - - "github.com/spf13/pflag" -) - -type enumFlag struct { - ignoreCase bool - options []string - value string -} - -// Ensure the implementation satisfies the expected interface -var _ pflag.Value = &enumFlag{} - -// EnumFlag returns a flag which must be one of the given values. -// If ignoreCase is true, flag value is returned in lower case. -func EnumFlag(ignoreCase bool, defaultValue string, options ...string) *enumFlag { - if defaultValue == "" { - return &enumFlag{ignoreCase: ignoreCase, options: options} - } - - validDefault := false - for _, o := range options { - if !ignoreCase && defaultValue == o { - validDefault = true - break - } - if ignoreCase && strings.EqualFold(defaultValue, o) { - validDefault = true - break - } - } - if !validDefault { - panic(fmt.Sprintf("default value %q is not one of %q", defaultValue, options)) - } - - return &enumFlag{ignoreCase: ignoreCase, options: options, value: defaultValue} -} - -func (f *enumFlag) String() string { - return f.value -} - -func (f *enumFlag) Set(value string) error { - for _, o := range f.options { - if !f.ignoreCase && value == o { - f.value = value - return nil - } - if f.ignoreCase && strings.EqualFold(value, o) { - f.value = strings.ToLower(value) - return nil - } - } - - return fmt.Errorf("expected one of %q", f.options) -} - -func (f *enumFlag) Type() string { - return "string" -} diff --git a/internal/pkg/flags/enumslice.go b/internal/pkg/flags/enumslice.go deleted file mode 100644 index 4b68c9025..000000000 --- a/internal/pkg/flags/enumslice.go +++ /dev/null @@ -1,76 +0,0 @@ -package flags - -import ( - "fmt" - "strings" - - "github.com/spf13/pflag" -) - -type enumSliceFlag struct { - ignoreCase bool - options []string - value []string - valueSet bool -} - -// Ensure the implementation satisfies the expected interface -var _ pflag.Value = &enumFlag{} - -// EnumSliceFlag returns a flag which is a slice which values must be one of the given values. -// If ignoreCase is true, values are returned in lower case. -func EnumSliceFlag(ignoreCase bool, defaultValues []string, options ...string) *enumSliceFlag { - f := &enumSliceFlag{ignoreCase: ignoreCase, options: options} - err := f.appendToValue(defaultValues) - if err != nil { - panic(err) - } - return f -} - -func (f *enumSliceFlag) appendToValue(values []string) error { - for _, v := range values { - v = strings.TrimSpace(v) - - foundValid := false - for _, o := range f.options { - if !f.ignoreCase && v == o { - f.value = append(f.value, v) - foundValid = true - break - } else if f.ignoreCase && strings.EqualFold(v, o) { - f.value = append(f.value, strings.ToLower(v)) - foundValid = true - break - } - } - - if !foundValid { - return fmt.Errorf("found value %q, expected one of %q", v, f.options) - } - } - return nil -} - -func (f *enumSliceFlag) String() string { - return "[" + strings.Join(f.value, ",") + "]" -} - -func (f *enumSliceFlag) Set(value string) error { - // If the default value is still set, remove it - // (Since we're going to append the incoming values to f.value) - if !f.valueSet { - f.value = []string{} - f.valueSet = true - } - - if value == "" { - return fmt.Errorf("value cannot be empty") - } - values := strings.Split(value, ",") - return f.appendToValue(values) -} - -func (f *enumSliceFlag) Type() string { - return "stringSlice" -} diff --git a/internal/pkg/flags/flags_test.go b/internal/pkg/flags/flags_test.go index 1021941de..ddc97fdd7 100644 --- a/internal/pkg/flags/flags_test.go +++ b/internal/pkg/flags/flags_test.go @@ -3,7 +3,6 @@ package flags import ( "fmt" "reflect" - "strings" "testing" "github.com/stackitcloud/stackit-cli/internal/pkg/utils" @@ -12,268 +11,6 @@ import ( "github.com/spf13/cobra" ) -func TestEnumFlag(t *testing.T) { - options := []string{"foo", "BaR"} - - tests := []struct { - description string - ignoreCase bool - value string - isValid bool - }{ - { - description: "valid", - value: "foo", - isValid: true, - }, - { - description: "empty", - value: "", - isValid: false, - }, - { - description: "invalid 1", - value: "ba", - isValid: false, - }, - { - description: "invalid 2", - value: "foo ", - isValid: false, - }, - { - description: "invalid 3", - value: "bar", - isValid: false, - }, - { - description: "ignore case - valid 1", - ignoreCase: true, - value: "foo", - isValid: true, - }, - { - description: "ignore case - valid 2", - ignoreCase: true, - value: "fOO", - isValid: true, - }, - { - description: "ignore case - valid 3", - ignoreCase: true, - value: "bar", - isValid: true, - }, - { - description: "ignore case - invalid 1", - ignoreCase: true, - value: "ba", - isValid: false, - }, - { - description: "ignore case - invalid 2", - ignoreCase: true, - value: "foo ", - isValid: false, - }, - } - - for _, tt := range tests { - t.Run(tt.description, func(t *testing.T) { - flag := EnumFlag(tt.ignoreCase, "", options...) - cmd := &cobra.Command{ - Use: "test", - RunE: func(_ *cobra.Command, _ []string) error { - return nil - }, - } - cmd.Flags().Var(flag, "test-flag", "test") - - err := cmd.Flags().Set("test-flag", tt.value) - - if !tt.isValid && err == nil { - t.Fatalf("did not fail on invalid input") - } - if !tt.isValid { - return - } - - if err != nil { - t.Fatalf("failed on valid input: %v", err) - } - value := FlagToStringValue(nil, cmd, "test-flag") - if !tt.ignoreCase && value != tt.value { - t.Fatalf("flag did not return set value") - } - if tt.ignoreCase && !strings.EqualFold(value, tt.value) { - t.Fatalf("flag did not return set value") - } - }) - } -} - -func TestEnumSliceFlag(t *testing.T) { - validOption1 := "foo" - validOption2 := "BaR" - validOption3 := "baz" - - validOption2Lower := strings.ToLower(validOption2) - - options := []string{validOption1, validOption2, validOption3} - - tests := []struct { - description string - ignoreCase bool - defaultValue []string - value1 *string - value2 *string - expectedValue []string - isValid bool - }{ - { - description: "valid two single values", - value1: utils.Ptr(validOption1), - value2: utils.Ptr(validOption2), - expectedValue: []string{validOption1, validOption2}, - isValid: true, - }, - { - description: "valid list value", - value1: utils.Ptr(fmt.Sprintf("%s,%s", validOption1, validOption2)), - expectedValue: []string{validOption1, validOption2}, - isValid: true, - }, - { - description: "valid list value and single value", - value1: utils.Ptr(fmt.Sprintf("%s,%s", validOption1, validOption2)), - value2: utils.Ptr(validOption3), - expectedValue: []string{validOption1, validOption2, validOption3}, - isValid: true, - }, - { - description: "valid two list values", - value1: utils.Ptr(fmt.Sprintf("%s,%s", validOption1, validOption2)), - value2: utils.Ptr(fmt.Sprintf("%s,%s", validOption2, validOption3)), - expectedValue: []string{validOption1, validOption2, validOption2, validOption3}, - isValid: true, - }, - { - description: "invalid value", - value1: utils.Ptr("invalid-value"), - value2: utils.Ptr(validOption1), - isValid: false, - }, - { - description: "invalid value in list", - value1: utils.Ptr(fmt.Sprintf("invalid-value,%s", validOption1)), - isValid: false, - }, - { - description: "invalid empty value", - value1: utils.Ptr(""), - isValid: false, - }, - { - description: "invalid empty value in list", - value1: utils.Ptr(fmt.Sprintf(",%s", validOption1)), - isValid: false, - }, - { - description: "no values", - expectedValue: []string{}, - isValid: true, - }, - { - description: "ignore case - valid single value", - value1: utils.Ptr(validOption2Lower), - ignoreCase: true, - expectedValue: []string{validOption2Lower}, - isValid: true, - }, - { - description: "ignore case - valid in list", - value1: utils.Ptr(fmt.Sprintf("%s,%s", validOption1, validOption2Lower)), - ignoreCase: true, - expectedValue: []string{validOption1, validOption2Lower}, - isValid: true, - }, - { - description: "ignore case - invalid single value", - value1: utils.Ptr("ba"), - ignoreCase: true, - isValid: false, - }, - { - description: "ignore case - invalid in list", - value1: utils.Ptr(fmt.Sprintf("%s,%s", validOption1, "ba")), - ignoreCase: true, - isValid: false, - }, - { - description: "default value", - defaultValue: []string{validOption1, validOption2}, - expectedValue: []string{validOption1, validOption2}, - isValid: true, - }, - { - description: "default value - set value", - defaultValue: []string{validOption1, validOption2}, - value1: utils.Ptr(validOption1), - expectedValue: []string{validOption1}, - isValid: true, - }, - { - description: "ignore case - default value", - defaultValue: []string{validOption2}, - ignoreCase: true, - expectedValue: []string{validOption2Lower}, - isValid: true, - }, - } - - for _, tt := range tests { - t.Run(tt.description, func(t *testing.T) { - flag := EnumSliceFlag(tt.ignoreCase, tt.defaultValue, options...) - cmd := &cobra.Command{ - Use: "test", - RunE: func(_ *cobra.Command, _ []string) error { - return nil - }, - } - cmd.Flags().Var(flag, "test-flag", "test") - - var err1, err2 error - if tt.value1 != nil { - err1 = cmd.Flags().Set("test-flag", *tt.value1) - } - if tt.value2 != nil { - err2 = cmd.Flags().Set("test-flag", *tt.value2) - } - - if !tt.isValid && err1 == nil && err2 == nil { - t.Fatalf("did not fail on invalid input") - } - if !tt.isValid { - return - } - - if err1 != nil { - t.Fatalf("failed on valid input: %v", err1) - } - if err2 != nil { - t.Fatalf("failed on valid input: %v", err2) - } - value, err := cmd.Flags().GetStringSlice("test-flag") - if err != nil { - t.Fatalf("failed to get value: %v", err) - } - if !reflect.DeepEqual(tt.expectedValue, value) { - t.Fatalf("flag did not return set value (expected %s, got %s)", tt.expectedValue, value) - } - }) - } -} - func TestUUIDFlag(t *testing.T) { tests := []struct { description string diff --git a/internal/pkg/flags/string_enum.go b/internal/pkg/flags/string_enum.go index 760c5f6d8..003074650 100644 --- a/internal/pkg/flags/string_enum.go +++ b/internal/pkg/flags/string_enum.go @@ -4,17 +4,18 @@ import ( "fmt" "strings" - "github.com/spf13/cobra" "github.com/spf13/pflag" ) type stringEnumFlag[T ~string] struct { - ignoreCase bool - options []T - value T - valueSet bool - docs string - name string + ignoreCase bool + options []T + value T + defaultValue T + valueSet bool + docs string + name string + shortHand *string } type StringEnumFlagOption[T ~string] func(*stringEnumFlag[T]) @@ -28,10 +29,17 @@ func StringEnumIgnoreCase[T ~string]() StringEnumFlagOption[T] { func StringEnumDefaultValue[T ~string](value T) StringEnumFlagOption[T] { return func(f *stringEnumFlag[T]) { f.value = value + f.defaultValue = value f.valueSet = true } } +func StringEnumShortHand[T ~string](short string) StringEnumFlagOption[T] { + return func(f *stringEnumFlag[T]) { + f.shortHand = &short + } +} + func StringEnumFlag[T ~string](name string, possibleValues []T, docs string, opts ...StringEnumFlagOption[T]) *stringEnumFlag[T] { f := &stringEnumFlag[T]{ name: name, @@ -50,12 +58,16 @@ func StringEnumFlag[T ~string](name string, possibleValues []T, docs string, opt var _ pflag.Value = &stringEnumFlag[string]{} -func (s *stringEnumFlag[T]) Register(cmd *cobra.Command) { - cmd.Flags().Var(s, s.name, s.Usage()) +func (s *stringEnumFlag[T]) Register(fs *pflag.FlagSet) { + if s.shortHand == nil { + fs.Var(s, s.name, s.Usage()) + } else { + fs.VarP(s, s.name, *s.shortHand, s.Usage()) + } } func (s *stringEnumFlag[T]) Usage() string { - return s.docs + fmt.Sprintf(" (possible values: %s)", s.fmtValues(s.options)) + return s.docs + fmt.Sprintf(" (one of: %s)", s.fmtValues(s.options)) } func (s *stringEnumFlag[T]) Get() T { @@ -90,13 +102,7 @@ func (s *stringEnumFlag[T]) fmtValues(xs []T) string { return sb.String() } -func (s *stringEnumFlag[T]) Set(value string) error { - v := strings.TrimSpace(value) - - if v == "" { - return fmt.Errorf("value cannot be empty") - } - +func (s *stringEnumFlag[T]) Set(v string) error { for _, o := range s.options { if !s.ignoreCase && v == string(o) { s.value = T(v) @@ -115,3 +121,14 @@ func (s *stringEnumFlag[T]) Set(value string) error { func (s *stringEnumFlag[T]) Type() string { return "string" } + +func (s *stringEnumFlag[T]) Reset() { + if s.defaultValue == "" { + var zero T + s.value = zero + s.valueSet = false + } else { + s.value = s.defaultValue + s.valueSet = true + } +} diff --git a/internal/pkg/flags/string_enum_test.go b/internal/pkg/flags/string_enum_test.go index a59f9b4ae..966c41b44 100644 --- a/internal/pkg/flags/string_enum_test.go +++ b/internal/pkg/flags/string_enum_test.go @@ -94,7 +94,7 @@ func TestStringEnumFlag_DefaultValue(t *testing.T) { func TestStringEnumFlag_Usage(t *testing.T) { f := StringEnumFlag("test", []string{"a", "b"}, "docs") usage := f.Usage() - if usage != "docs (possible values: [a, b])" { + if usage != "docs (one of: [a, b])" { t.Errorf("Expected usage 'docs (possible values: [a, b])', got %q", usage) } } @@ -102,7 +102,7 @@ func TestStringEnumFlag_Usage(t *testing.T) { func TestStringEnumFlag_UnknownDefaultOpenAPI(t *testing.T) { f := StringEnumFlag("test", []string{"a", "unknown_default_open_api", "b"}, "docs") usage := f.Usage() - if usage != "docs (possible values: [a, b])" { + if usage != "docs (one of: [a, b])" { t.Errorf("Expected unknown_default_open_api to be filtered out, got %q", usage) } } @@ -110,13 +110,13 @@ func TestStringEnumFlag_UnknownDefaultOpenAPI(t *testing.T) { func TestStringEnumFlag_Register(t *testing.T) { cmd := &cobra.Command{Use: "test"} f := StringEnumFlag("my-flag", []string{"a", "b"}, "docs") - f.Register(cmd) + f.Register(cmd.Flags()) flag := cmd.Flags().Lookup("my-flag") if flag == nil { t.Fatalf("Expected flag 'my-flag' to be registered") } - if flag.Usage != "docs (possible values: [a, b])" { + if flag.Usage != "docs (one of: [a, b])" { t.Errorf("Expected flag usage to be set correctly") } } diff --git a/internal/pkg/flags/string_enumslice.go b/internal/pkg/flags/string_enumslice.go index 2feb3705f..22b8048c2 100644 --- a/internal/pkg/flags/string_enumslice.go +++ b/internal/pkg/flags/string_enumslice.go @@ -9,12 +9,13 @@ import ( ) type stringEnumSliceFlag[T ~string] struct { - ignoreCase bool - options []T - value []T - valueSet bool - docs string - name string + ignoreCase bool + options []T + value []T + defaultValues []T + valueSet bool + docs string + name string } type StringEnumSliceFlagOption[T ~string] func(*stringEnumSliceFlag[T]) @@ -28,6 +29,7 @@ func IgnoreCase[T ~string]() StringEnumSliceFlagOption[T] { func DefaultValues[T ~string](values ...T) StringEnumSliceFlagOption[T] { return func(f *stringEnumSliceFlag[T]) { f.value = append(f.value, values...) + f.defaultValues = append(f.defaultValues, values...) } } @@ -54,13 +56,20 @@ func (s *stringEnumSliceFlag[T]) Register(cmd *cobra.Command) { } func (s *stringEnumSliceFlag[T]) Usage() string { - return s.docs + fmt.Sprintf(" (possible values: %s)", s.fmtValues(s.options)) + return s.docs + fmt.Sprintf(" (multiple of: %s)", s.fmtValues(s.options)) } func (s *stringEnumSliceFlag[T]) Get() []T { return s.value } +func (s *stringEnumSliceFlag[T]) Ptr() *[]T { + if s.valueSet || s.value != nil { + return &s.value + } + return nil +} + func (s *stringEnumSliceFlag[T]) Name() string { return s.name } @@ -86,7 +95,7 @@ func (s *stringEnumSliceFlag[T]) Set(value string) error { // If the default value is still set, remove it // (Since we're going to append the incoming values to f.value) if !s.valueSet { - s.value = []T{} + s.value = nil s.valueSet = true } @@ -124,3 +133,12 @@ func (s *stringEnumSliceFlag[T]) appendToValue(values []string) error { } return nil } + +func (s *stringEnumSliceFlag[T]) Reset() { + if s.defaultValues == nil { + s.value = nil + s.valueSet = false + } else { + s.value = append([]T{}, s.defaultValues...) + } +} diff --git a/internal/pkg/flags/string_enumslice_test.go b/internal/pkg/flags/string_enumslice_test.go index ff0be55c9..6a04732e8 100644 --- a/internal/pkg/flags/string_enumslice_test.go +++ b/internal/pkg/flags/string_enumslice_test.go @@ -133,7 +133,7 @@ func TestStringEnumSliceFlag_DefaultValues(t *testing.T) { func TestStringEnumSliceFlag_Usage(t *testing.T) { f := StringEnumSliceFlag("test", []string{"a", "b"}, "docs") usage := f.Usage() - if usage != "docs (possible values: [a, b])" { + if usage != "docs (multiple of: [a, b])" { t.Errorf("Expected usage 'docs (possible values: [a, b])', got %q", usage) } } @@ -141,7 +141,7 @@ func TestStringEnumSliceFlag_Usage(t *testing.T) { func TestStringEnumSliceFlag_UnknownDefaultOpenAPI(t *testing.T) { f := StringEnumSliceFlag("test", []string{"a", "unknown_default_open_api", "b"}, "docs") usage := f.Usage() - if usage != "docs (possible values: [a, b])" { + if usage != "docs (multiple of: [a, b])" { t.Errorf("Expected unknown_default_open_api to be filtered out, got %q", usage) } } @@ -155,7 +155,7 @@ func TestStringEnumSliceFlag_Register(t *testing.T) { if flag == nil { t.Fatalf("Expected flag 'my-flag' to be registered") } - if flag.Usage != "docs (possible values: [a, b])" { + if flag.Usage != "docs (multiple of: [a, b])" { t.Errorf("Expected flag usage to be set correctly") } } diff --git a/internal/pkg/globalflags/global_flags.go b/internal/pkg/globalflags/global_flags.go index 63b51c6c8..0f08767f0 100644 --- a/internal/pkg/globalflags/global_flags.go +++ b/internal/pkg/globalflags/global_flags.go @@ -13,12 +13,10 @@ import ( ) const ( - AsyncFlag = "async" - AssumeYesFlag = "assume-yes" - OutputFormatFlag = "output-format" - ProjectIdFlag = "project-id" - RegionFlag = "region" - VerbosityFlag = "verbosity" + AsyncFlag = "async" + AssumeYesFlag = "assume-yes" + ProjectIdFlag = "project-id" + RegionFlag = "region" DebugVerbosity = string(print.DebugLevel) InfoVerbosity = string(print.InfoLevel) @@ -28,8 +26,22 @@ const ( VerbosityDefault = InfoVerbosity ) -var outputFormatFlagOptions = []string{print.JSONOutputFormat, print.PrettyOutputFormat, print.NoneOutputFormat, print.YAMLOutputFormat} -var verbosityFlagOptions = []string{DebugVerbosity, InfoVerbosity, WarningVerbosity, ErrorVerbosity} +var ( + OutputFormatFlag = flags.StringEnumFlag( + "output-format", + []string{print.JSONOutputFormat, print.PrettyOutputFormat, print.NoneOutputFormat, print.YAMLOutputFormat}, + "Output format,", + flags.StringEnumIgnoreCase[string](), + flags.StringEnumShortHand[string]("o"), + ) + VerbosityFlag = flags.StringEnumFlag( + "verbosity", + []string{DebugVerbosity, InfoVerbosity, WarningVerbosity, ErrorVerbosity}, + "Verbosity of the CLI,", + flags.StringEnumDefaultValue(VerbosityDefault), + flags.StringEnumIgnoreCase[string](), + ) +) type GlobalFlagModel struct { Async bool @@ -47,10 +59,10 @@ func Configure(flagSet *pflag.FlagSet) error { return fmt.Errorf("bind --%s flag to config: %w", ProjectIdFlag, err) } - flagSet.VarP(flags.EnumFlag(true, "", outputFormatFlagOptions...), OutputFormatFlag, "o", fmt.Sprintf("Output format, one of %q", outputFormatFlagOptions)) - err = viper.BindPFlag(config.OutputFormatKey, flagSet.Lookup(OutputFormatFlag)) + OutputFormatFlag.Register(flagSet) + err = viper.BindPFlag(config.OutputFormatKey, flagSet.Lookup(OutputFormatFlag.Name())) if err != nil { - return fmt.Errorf("bind --%s flag to config: %w", OutputFormatFlag, err) + return fmt.Errorf("bind --%s flag to config: %w", OutputFormatFlag.Name(), err) } flagSet.Bool(AsyncFlag, false, "If set, runs the command asynchronously") @@ -65,10 +77,10 @@ func Configure(flagSet *pflag.FlagSet) error { return fmt.Errorf("bind --%s flag to config: %w", AssumeYesFlag, err) } - flagSet.Var(flags.EnumFlag(true, VerbosityDefault, verbosityFlagOptions...), VerbosityFlag, fmt.Sprintf("Verbosity of the CLI, one of %q", verbosityFlagOptions)) - err = viper.BindPFlag(config.VerbosityKey, flagSet.Lookup(VerbosityFlag)) + VerbosityFlag.Register(flagSet) + err = viper.BindPFlag(config.VerbosityKey, flagSet.Lookup(VerbosityFlag.Name())) if err != nil { - return fmt.Errorf("bind --%s flag to config: %w", VerbosityFlag, err) + return fmt.Errorf("bind --%s flag to config: %w", VerbosityFlag.Name(), err) } flagSet.String(RegionFlag, "", "Target region for region-specific requests") diff --git a/internal/pkg/testutils/parse_input.go b/internal/pkg/testutils/parse_input.go index 64588a63e..394105da0 100755 --- a/internal/pkg/testutils/parse_input.go +++ b/internal/pkg/testutils/parse_input.go @@ -7,6 +7,7 @@ import ( "testing" "github.com/spf13/cobra" + "github.com/spf13/pflag" "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" @@ -79,6 +80,14 @@ func RunParseInputCase[T any](t *testing.T, tc ParseInputTestCase[T], opts ...Pa if err := globalflags.Configure(cmd.Flags()); err != nil { t.Fatalf("configure global flags: %v", err) } + cmd.Flags().VisitAll(func(flag *pflag.Flag) { + if flag.Value == nil { + return + } + if r, ok := flag.Value.(Resettable); ok { + r.Reset() + } + }) // Set regular flag values. for flag, value := range tc.Flags { diff --git a/internal/pkg/testutils/testutils.go b/internal/pkg/testutils/testutils.go index 64540b52d..74a07befc 100644 --- a/internal/pkg/testutils/testutils.go +++ b/internal/pkg/testutils/testutils.go @@ -3,6 +3,8 @@ package testutils import ( "testing" + "github.com/spf13/pflag" + "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" "github.com/stackitcloud/stackit-cli/internal/pkg/types" @@ -25,6 +27,10 @@ func TestParseInputWithAdditionalFlags[T any](t *testing.T, cmdFactory func(*typ TestParseInputWithOptions(t, cmdFactory, parseInputFunc, expectedModel, argValues, flagValues, additionalFlagValues, isValid, nil) } +type Resettable interface { + Reset() +} + func TestParseInputWithOptions[T any](t *testing.T, cmdFactory func(*types.CmdParams) *cobra.Command, parseInputFunc func(*print.Printer, *cobra.Command, []string) (T, error), expectedModel T, argValues []string, flagValues map[string]string, additionalFlagValues map[string][]string, isValid bool, testingOptions []TestingOption) { opts := Option{} for _, option := range testingOptions { @@ -41,6 +47,15 @@ func TestParseInputWithOptions[T any](t *testing.T, cmdFactory func(*types.CmdPa if err != nil { t.Fatalf("configure global flags: %v", err) } + cmd.Flags().VisitAll(func(flag *pflag.Flag) { + if flag.Value == nil { + return + } + // StringEnum and StringEnumSlice Flags are stateful singletons. During tests we reset their state. + if r, ok := flag.Value.(Resettable); ok { + r.Reset() + } + }) // set regular flag values for flag, value := range flagValues { From 49c93943972b8601a0a35213591016cf14a876e7 Mon Sep 17 00:00:00 2001 From: Jonas Schlecht <73650029+SerseusWasTaken@users.noreply.github.com> Date: Thu, 2 Jul 2026 16:03:33 +0200 Subject: [PATCH 14/44] SDK migration Secrets-Manager (#1454) * chore(secretsmanager): SDK migration * refactor(secretsmanager): PR feedback Relates to STACKITCLI-377 --- go.mod | 2 +- go.sum | 4 +- .../secrets-manager/instance/create/create.go | 27 +++++---- .../instance/create/create_test.go | 42 +++++++------- .../secrets-manager/instance/delete/delete.go | 6 +- .../instance/delete/delete_test.go | 8 ++- .../instance/describe/describe.go | 37 ++++++------- .../instance/describe/describe_test.go | 19 ++++--- .../cmd/secrets-manager/instance/list/list.go | 22 ++++---- .../instance/list/list_test.go | 8 ++- .../secrets-manager/instance/update/update.go | 37 +++++++------ .../instance/update/update_test.go | 51 ++++++++++------- .../cmd/secrets-manager/user/create/create.go | 25 ++++----- .../user/create/create_test.go | 21 +++---- .../cmd/secrets-manager/user/delete/delete.go | 8 +-- .../user/delete/delete_test.go | 8 ++- .../secrets-manager/user/describe/describe.go | 22 ++++---- .../user/describe/describe_test.go | 11 ++-- .../cmd/secrets-manager/user/list/list.go | 24 ++++---- .../secrets-manager/user/list/list_test.go | 8 ++- .../cmd/secrets-manager/user/update/update.go | 8 +-- .../user/update/update_test.go | 8 ++- .../services/secrets-manager/client/client.go | 2 +- .../services/secrets-manager/utils/utils.go | 20 +++---- .../secrets-manager/utils/utils_test.go | 55 ++++++++++--------- 25 files changed, 258 insertions(+), 225 deletions(-) diff --git a/go.mod b/go.mod index 0c13822ad..1b8eddab8 100644 --- a/go.mod +++ b/go.mod @@ -30,7 +30,7 @@ require ( github.com/stackitcloud/stackit-sdk-go/services/postgresflex v1.3.5 github.com/stackitcloud/stackit-sdk-go/services/resourcemanager v0.24.0 github.com/stackitcloud/stackit-sdk-go/services/runcommand v1.4.3 - github.com/stackitcloud/stackit-sdk-go/services/secretsmanager v0.14.3 + github.com/stackitcloud/stackit-sdk-go/services/secretsmanager v0.18.1 github.com/stackitcloud/stackit-sdk-go/services/serverbackup v1.3.8 github.com/stackitcloud/stackit-sdk-go/services/serverupdate v1.2.6 github.com/stackitcloud/stackit-sdk-go/services/serviceaccount v0.12.0 diff --git a/go.sum b/go.sum index 4e08a22b7..cd852cc55 100644 --- a/go.sum +++ b/go.sum @@ -640,8 +640,8 @@ github.com/stackitcloud/stackit-sdk-go/services/resourcemanager v0.24.0 h1:JPP6a github.com/stackitcloud/stackit-sdk-go/services/resourcemanager v0.24.0/go.mod h1:NEz3f+GV5G++BE9/MmZCsXJyCih7jtg0pZuSyG2sLEs= github.com/stackitcloud/stackit-sdk-go/services/runcommand v1.4.3 h1:AiGNJmpQ/f9cglaIQQ4SyePbtCI3K1DQLNvqVN9jKSo= github.com/stackitcloud/stackit-sdk-go/services/runcommand v1.4.3/go.mod h1:U/q0V89fvCF2O1ZJfi68/Chie9YY/5s7xBHI1Klq7wA= -github.com/stackitcloud/stackit-sdk-go/services/secretsmanager v0.14.3 h1:3hZSg3z+4AXa5LbR2Vl38VmSA83ABItE63E53LuyWv8= -github.com/stackitcloud/stackit-sdk-go/services/secretsmanager v0.14.3/go.mod h1:5unx5r0IgeFCtJDEgsWddtgKvYSw442FDNdhtfyJnQI= +github.com/stackitcloud/stackit-sdk-go/services/secretsmanager v0.18.1 h1:U5rstX5e6Am2t+Ukv5K1Sbftzxt5aFALMa9YS4jCJoo= +github.com/stackitcloud/stackit-sdk-go/services/secretsmanager v0.18.1/go.mod h1:2XA8PE05Qg6BL2YXO4XgfGI9qskJ3cicLE5Qq0aqDdY= github.com/stackitcloud/stackit-sdk-go/services/serverbackup v1.3.8 h1:LLyANBzE8sQa0/49tQBqq4sVLhNgwdqCeQm76srJHWw= github.com/stackitcloud/stackit-sdk-go/services/serverbackup v1.3.8/go.mod h1:/bmg57XZu+bGczzcoumrukiGMPGzI2mOyTT4BVIQUBs= github.com/stackitcloud/stackit-sdk-go/services/serverupdate v1.2.6 h1:sQ3fdtUjgIL2Ul8nRYVVacHOwi5aSMTGGbYVL30oQBU= diff --git a/internal/cmd/secrets-manager/instance/create/create.go b/internal/cmd/secrets-manager/instance/create/create.go index 83662cf44..39310121e 100644 --- a/internal/cmd/secrets-manager/instance/create/create.go +++ b/internal/cmd/secrets-manager/instance/create/create.go @@ -6,7 +6,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/types" - "github.com/stackitcloud/stackit-sdk-go/services/secretsmanager" + secretsmanager "github.com/stackitcloud/stackit-sdk-go/services/secretsmanager/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/args" cliErr "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -16,7 +16,6 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/print" "github.com/stackitcloud/stackit-cli/internal/pkg/projectname" "github.com/stackitcloud/stackit-cli/internal/pkg/services/secrets-manager/client" - "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/spf13/cobra" ) @@ -34,7 +33,7 @@ const ( type inputModel struct { *globalflags.GlobalFlagModel - InstanceName *string + InstanceName string Acls *[]string KmsKeyId *string @@ -92,7 +91,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { if err != nil { return fmt.Errorf("create Secrets Manager instance: %w", err) } - instanceId := *resp.Id + instanceId := resp.Id // Call API to create ACLs for instance, if ACLs are provided if model.Acls != nil { @@ -136,7 +135,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, model := inputModel{ GlobalFlagModel: globalFlags, - InstanceName: flags.FlagToStringPointer(p, cmd, instanceNameFlag), + InstanceName: flags.FlagToStringValue(p, cmd, instanceNameFlag), Acls: flags.FlagToStringSlicePointer(p, cmd, aclFlag), KmsKeyId: flags.FlagToStringPointer(p, cmd, kmsKeyIdFlag), KmsKeyringId: flags.FlagToStringPointer(p, cmd, kmsKeyringIdFlag), @@ -149,18 +148,18 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, } func buildCreateInstanceRequest(ctx context.Context, model *inputModel, apiClient *secretsmanager.APIClient) secretsmanager.ApiCreateInstanceRequest { - req := apiClient.CreateInstance(ctx, model.ProjectId) + req := apiClient.DefaultAPI.CreateInstance(ctx, model.ProjectId) payload := secretsmanager.CreateInstancePayload{ Name: model.InstanceName, } - if model.KmsKeyId != nil { + if model.KmsKeyId != nil && model.KmsKeyringId != nil && model.KmsKeyVersion != nil && model.KmsServiceAccountEmail != nil { payload.KmsKey = &secretsmanager.KmsKeyPayload{ - KeyId: model.KmsKeyId, - KeyRingId: model.KmsKeyringId, - KeyVersion: model.KmsKeyVersion, - ServiceAccountEmail: model.KmsServiceAccountEmail, + KeyId: *model.KmsKeyId, + KeyRingId: *model.KmsKeyringId, + KeyVersion: *model.KmsKeyVersion, + ServiceAccountEmail: *model.KmsServiceAccountEmail, } } @@ -170,15 +169,15 @@ func buildCreateInstanceRequest(ctx context.Context, model *inputModel, apiClien } func buildUpdateACLsRequest(ctx context.Context, model *inputModel, instanceId string, apiClient *secretsmanager.APIClient) secretsmanager.ApiUpdateACLsRequest { - req := apiClient.UpdateACLs(ctx, model.ProjectId, instanceId) + req := apiClient.DefaultAPI.UpdateACLs(ctx, model.ProjectId, instanceId) cidrs := make([]secretsmanager.UpdateACLPayload, len(*model.Acls)) for i, acl := range *model.Acls { - cidrs[i] = secretsmanager.UpdateACLPayload{Cidr: utils.Ptr(acl)} + cidrs[i] = secretsmanager.UpdateACLPayload{Cidr: acl} } - req = req.UpdateACLsPayload(secretsmanager.UpdateACLsPayload{Cidrs: &cidrs}) + req = req.UpdateACLsPayload(secretsmanager.UpdateACLsPayload{Cidrs: cidrs}) return req } diff --git a/internal/cmd/secrets-manager/instance/create/create_test.go b/internal/cmd/secrets-manager/instance/create/create_test.go index 021b6fc19..930730c70 100644 --- a/internal/cmd/secrets-manager/instance/create/create_test.go +++ b/internal/cmd/secrets-manager/instance/create/create_test.go @@ -7,7 +7,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/secretsmanager" + secretsmanager "github.com/stackitcloud/stackit-sdk-go/services/secretsmanager/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" @@ -20,7 +20,9 @@ var projectIdFlag = globalflags.ProjectIdFlag type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &secretsmanager.APIClient{} +var testClient = &secretsmanager.APIClient{ + DefaultAPI: secretsmanager.DefaultAPIServiceMock{}, +} var testProjectId = uuid.NewString() var testInstanceId = uuid.NewString() @@ -49,7 +51,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { ProjectId: testProjectId, Verbosity: globalflags.VerbosityDefault, }, - InstanceName: utils.Ptr("example"), + InstanceName: "example", Acls: utils.Ptr([]string{"198.51.100.14/24"}), } for _, mod := range mods { @@ -59,9 +61,9 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *secretsmanager.ApiCreateInstanceRequest)) secretsmanager.ApiCreateInstanceRequest { - request := testClient.CreateInstance(testCtx, testProjectId) + request := testClient.DefaultAPI.CreateInstance(testCtx, testProjectId) request = request.CreateInstancePayload(secretsmanager.CreateInstancePayload{ - Name: utils.Ptr("example"), + Name: "example", }) for _, mod := range mods { mod(&request) @@ -70,11 +72,11 @@ func fixtureRequest(mods ...func(request *secretsmanager.ApiCreateInstanceReques } func fixtureUpdateACLsRequest(mods ...func(request *secretsmanager.ApiUpdateACLsRequest)) secretsmanager.ApiUpdateACLsRequest { - request := testClient.UpdateACLs(testCtx, testProjectId, testInstanceId) + request := testClient.DefaultAPI.UpdateACLs(testCtx, testProjectId, testInstanceId) request = request.UpdateACLsPayload(secretsmanager.UpdateACLsPayload{ - Cidrs: utils.Ptr([]secretsmanager.UpdateACLPayload{ - {Cidr: utils.Ptr("198.51.100.14/24")}, - })}) + Cidrs: []secretsmanager.UpdateACLPayload{ + {Cidr: "198.51.100.14/24"}, + }}) for _, mod := range mods { mod(&request) @@ -115,7 +117,7 @@ func TestParseInput(t *testing.T) { ProjectId: testProjectId, Verbosity: globalflags.VerbosityDefault, }, - InstanceName: utils.Ptr(""), + InstanceName: "", Acls: &[]string{}, }, }, @@ -240,15 +242,15 @@ func TestBuildCreateInstanceRequest(t *testing.T) { }), expectedRequest: fixtureRequest(func(request *secretsmanager.ApiCreateInstanceRequest) { payload := secretsmanager.CreateInstancePayload{ - Name: utils.Ptr("example"), + Name: "example", KmsKey: &secretsmanager.KmsKeyPayload{ - KeyId: utils.Ptr(testKmsKeyId), - KeyRingId: utils.Ptr(testKmsKeyringId), - KeyVersion: utils.Ptr(testKmsKeyVersion), - ServiceAccountEmail: utils.Ptr(testKmsServiceAccountEmail), + KeyId: testKmsKeyId, + KeyRingId: testKmsKeyringId, + KeyVersion: testKmsKeyVersion, + ServiceAccountEmail: testKmsServiceAccountEmail, }, } - *request = (*request).CreateInstancePayload(payload) + *request = request.CreateInstancePayload(payload) }), }, } @@ -284,10 +286,10 @@ func TestBuildCreateACLRequests(t *testing.T) { *model.Acls = append(*model.Acls, "1.2.3.4/32") }), expectedRequest: fixtureUpdateACLsRequest().UpdateACLsPayload(secretsmanager.UpdateACLsPayload{ - Cidrs: utils.Ptr([]secretsmanager.UpdateACLPayload{ - {Cidr: utils.Ptr("198.51.100.14/24")}, - {Cidr: utils.Ptr("1.2.3.4/32")}, - })}), + Cidrs: []secretsmanager.UpdateACLPayload{ + {Cidr: "198.51.100.14/24"}, + {Cidr: "1.2.3.4/32"}, + }}), }, } diff --git a/internal/cmd/secrets-manager/instance/delete/delete.go b/internal/cmd/secrets-manager/instance/delete/delete.go index c4c2d1602..792dffdb5 100644 --- a/internal/cmd/secrets-manager/instance/delete/delete.go +++ b/internal/cmd/secrets-manager/instance/delete/delete.go @@ -7,7 +7,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/types" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/secretsmanager" + secretsmanager "github.com/stackitcloud/stackit-sdk-go/services/secretsmanager/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/args" "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -52,7 +52,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return err } - instanceLabel, err := secretsmanagerUtils.GetInstanceName(ctx, apiClient, model.ProjectId, model.InstanceId) + instanceLabel, err := secretsmanagerUtils.GetInstanceName(ctx, apiClient.DefaultAPI, model.ProjectId, model.InstanceId) if err != nil { params.Printer.Debug(print.ErrorLevel, "get instance name: %v", err) instanceLabel = model.InstanceId @@ -96,6 +96,6 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *secretsmanager.APIClient) secretsmanager.ApiDeleteInstanceRequest { - req := apiClient.DeleteInstance(ctx, model.ProjectId, model.InstanceId) + req := apiClient.DefaultAPI.DeleteInstance(ctx, model.ProjectId, model.InstanceId) return req } diff --git a/internal/cmd/secrets-manager/instance/delete/delete_test.go b/internal/cmd/secrets-manager/instance/delete/delete_test.go index 6a1909548..902073fa8 100644 --- a/internal/cmd/secrets-manager/instance/delete/delete_test.go +++ b/internal/cmd/secrets-manager/instance/delete/delete_test.go @@ -10,7 +10,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/secretsmanager" + secretsmanager "github.com/stackitcloud/stackit-sdk-go/services/secretsmanager/v1api" ) var projectIdFlag = globalflags.ProjectIdFlag @@ -18,7 +18,9 @@ var projectIdFlag = globalflags.ProjectIdFlag type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &secretsmanager.APIClient{} +var testClient = &secretsmanager.APIClient{ + DefaultAPI: secretsmanager.DefaultAPIServiceMock{}, +} var testProjectId = uuid.NewString() var testInstanceId = uuid.NewString() @@ -57,7 +59,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *secretsmanager.ApiDeleteInstanceRequest)) secretsmanager.ApiDeleteInstanceRequest { - request := testClient.DeleteInstance(testCtx, testProjectId, testInstanceId) + request := testClient.DefaultAPI.DeleteInstance(testCtx, testProjectId, testInstanceId) for _, mod := range mods { mod(&request) } diff --git a/internal/cmd/secrets-manager/instance/describe/describe.go b/internal/cmd/secrets-manager/instance/describe/describe.go index 75c8cbd7c..3787c5fab 100644 --- a/internal/cmd/secrets-manager/instance/describe/describe.go +++ b/internal/cmd/secrets-manager/instance/describe/describe.go @@ -17,7 +17,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/secretsmanager" + secretsmanager "github.com/stackitcloud/stackit-sdk-go/services/secretsmanager/v1api" ) const ( @@ -93,12 +93,12 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildGetInstanceRequest(ctx context.Context, model *inputModel, apiClient *secretsmanager.APIClient) secretsmanager.ApiGetInstanceRequest { - req := apiClient.GetInstance(ctx, model.ProjectId, model.InstanceId) + req := apiClient.DefaultAPI.GetInstance(ctx, model.ProjectId, model.InstanceId) return req } func buildListACLsRequest(ctx context.Context, model *inputModel, apiClient *secretsmanager.APIClient) secretsmanager.ApiListACLsRequest { - req := apiClient.ListACLs(ctx, model.ProjectId, model.InstanceId) + req := apiClient.DefaultAPI.ListACLs(ctx, model.ProjectId, model.InstanceId) return req } @@ -116,38 +116,37 @@ func outputResult(p *print.Printer, outputFormat string, instance *secretsmanage return p.OutputResult(outputFormat, output, func() error { table := tables.NewTable() - table.AddRow("ID", utils.PtrString(instance.Id)) + table.AddRow("ID", instance.Id) table.AddSeparator() - table.AddRow("NAME", utils.PtrString(instance.Name)) + table.AddRow("NAME", instance.Name) table.AddSeparator() - table.AddRow("STATE", utils.PtrString(instance.State)) + table.AddRow("STATE", instance.State) table.AddSeparator() - table.AddRow("SECRETS", utils.PtrString(instance.SecretCount)) + table.AddRow("SECRETS", instance.SecretCount) table.AddSeparator() - table.AddRow("ENGINE", utils.PtrString(instance.SecretsEngine)) + table.AddRow("ENGINE", instance.SecretsEngine) table.AddSeparator() - table.AddRow("CREATION DATE", utils.PtrString(instance.CreationStartDate)) + table.AddRow("CREATION DATE", instance.CreationStartDate) table.AddSeparator() kmsKey := instance.KmsKey - showKms := kmsKey != nil && (kmsKey.KeyId != nil || kmsKey.KeyRingId != nil || kmsKey.KeyVersion != nil || kmsKey.ServiceAccountEmail != nil) - if showKms { - table.AddRow("KMS KEY ID", utils.PtrString(kmsKey.KeyId)) + if kmsKey != nil { + table.AddRow("KMS KEY ID", kmsKey.KeyId) table.AddSeparator() - table.AddRow("KMS KEYRING ID", utils.PtrString(kmsKey.KeyRingId)) + table.AddRow("KMS KEYRING ID", kmsKey.KeyRingId) table.AddSeparator() - table.AddRow("KMS KEY VERSION", utils.PtrString(kmsKey.KeyVersion)) + table.AddRow("KMS KEY VERSION", kmsKey.KeyVersion) table.AddSeparator() - table.AddRow("KMS SERVICE ACCOUNT EMAIL", utils.PtrString(kmsKey.ServiceAccountEmail)) + table.AddRow("KMS SERVICE ACCOUNT EMAIL", kmsKey.ServiceAccountEmail) } // Only show ACL if it's present and not empty - if aclList.Acls != nil && len(*aclList.Acls) > 0 { + if len(aclList.Acls) > 0 { var cidrs []string - for _, acl := range *aclList.Acls { - cidrs = append(cidrs, *acl.Cidr) + for _, acl := range aclList.Acls { + cidrs = append(cidrs, acl.Cidr) } - if showKms { + if kmsKey != nil { table.AddSeparator() } table.AddRow("ACL", strings.Join(cidrs, ",")) diff --git a/internal/cmd/secrets-manager/instance/describe/describe_test.go b/internal/cmd/secrets-manager/instance/describe/describe_test.go index 620961a69..19d6ba050 100644 --- a/internal/cmd/secrets-manager/instance/describe/describe_test.go +++ b/internal/cmd/secrets-manager/instance/describe/describe_test.go @@ -7,12 +7,11 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" "github.com/stackitcloud/stackit-cli/internal/pkg/testutils" - "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/secretsmanager" + secretsmanager "github.com/stackitcloud/stackit-sdk-go/services/secretsmanager/v1api" ) var projectIdFlag = globalflags.ProjectIdFlag @@ -20,7 +19,9 @@ var projectIdFlag = globalflags.ProjectIdFlag type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &secretsmanager.APIClient{} +var testClient = &secretsmanager.APIClient{ + DefaultAPI: secretsmanager.DefaultAPIServiceMock{}, +} var testProjectId = uuid.NewString() var testInstanceId = uuid.NewString() @@ -59,7 +60,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureGetInstanceRequest(mods ...func(request *secretsmanager.ApiGetInstanceRequest)) secretsmanager.ApiGetInstanceRequest { - request := testClient.GetInstance(testCtx, testProjectId, testInstanceId) + request := testClient.DefaultAPI.GetInstance(testCtx, testProjectId, testInstanceId) for _, mod := range mods { mod(&request) } @@ -67,7 +68,7 @@ func fixtureGetInstanceRequest(mods ...func(request *secretsmanager.ApiGetInstan } func fixtureListACLsRequest(mods ...func(request *secretsmanager.ApiListACLsRequest)) secretsmanager.ApiListACLsRequest { - request := testClient.ListACLs(testCtx, testProjectId, testInstanceId) + request := testClient.DefaultAPI.ListACLs(testCtx, testProjectId, testInstanceId) for _, mod := range mods { mod(&request) } @@ -251,10 +252,10 @@ func TestOutputResult(t *testing.T) { args: args{ instance: &secretsmanager.Instance{ KmsKey: &secretsmanager.KmsKeyPayload{ - KeyId: utils.Ptr("key-id"), - KeyRingId: utils.Ptr("keyring-id"), - KeyVersion: utils.Ptr(int64(1)), - ServiceAccountEmail: utils.Ptr("my-service-account-1234567@sa.stackit.cloud"), + KeyId: "key-id", + KeyRingId: "keyring-id", + KeyVersion: 1, + ServiceAccountEmail: "my-service-account-1234567@sa.stackit.cloud", }, }, aclList: &secretsmanager.ListACLsResponse{}, diff --git a/internal/cmd/secrets-manager/instance/list/list.go b/internal/cmd/secrets-manager/instance/list/list.go index a8f7b9391..a67e730ac 100644 --- a/internal/cmd/secrets-manager/instance/list/list.go +++ b/internal/cmd/secrets-manager/instance/list/list.go @@ -7,7 +7,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/types" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/secretsmanager" + secretsmanager "github.com/stackitcloud/stackit-sdk-go/services/secretsmanager/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/args" "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -18,7 +18,6 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/projectname" "github.com/stackitcloud/stackit-cli/internal/pkg/services/secrets-manager/client" "github.com/stackitcloud/stackit-cli/internal/pkg/tables" - "github.com/stackitcloud/stackit-cli/internal/pkg/utils" ) const ( @@ -67,7 +66,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return fmt.Errorf("get Secrets Manager instances: %w", err) } - if resp.Instances == nil || len(*resp.Instances) == 0 { + if len(resp.Instances) == 0 { projectLabel, err := projectname.GetProjectName(ctx, params.Printer, params.CliVersion, cmd) if err != nil { params.Printer.Debug(print.ErrorLevel, "get project name: %v", err) @@ -76,14 +75,13 @@ func NewCmd(params *types.CmdParams) *cobra.Command { params.Printer.Info("No instances found for project %q\n", projectLabel) return nil } - instances := *resp.Instances // Truncate output - if model.Limit != nil && len(instances) > int(*model.Limit) { - instances = instances[:*model.Limit] + if model.Limit != nil && len(resp.Instances) > int(*model.Limit) { + resp.Instances = resp.Instances[:*model.Limit] } - return outputResult(params.Printer, model.OutputFormat, instances) + return outputResult(params.Printer, model.OutputFormat, resp.Instances) }, } @@ -119,7 +117,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, } func buildRequest(ctx context.Context, model *inputModel, apiClient *secretsmanager.APIClient) secretsmanager.ApiListInstancesRequest { - req := apiClient.ListInstances(ctx, model.ProjectId) + req := apiClient.DefaultAPI.ListInstances(ctx, model.ProjectId) return req } @@ -130,10 +128,10 @@ func outputResult(p *print.Printer, outputFormat string, instances []secretsmana for i := range instances { instance := instances[i] table.AddRow( - utils.PtrString(instance.Id), - utils.PtrString(instance.Name), - utils.PtrString(instance.State), - utils.PtrString(instance.SecretCount), + instance.Id, + instance.Name, + instance.State, + instance.SecretCount, ) } err := table.Display(p) diff --git a/internal/cmd/secrets-manager/instance/list/list_test.go b/internal/cmd/secrets-manager/instance/list/list_test.go index 88b87609a..e512553e4 100644 --- a/internal/cmd/secrets-manager/instance/list/list_test.go +++ b/internal/cmd/secrets-manager/instance/list/list_test.go @@ -12,7 +12,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/secretsmanager" + secretsmanager "github.com/stackitcloud/stackit-sdk-go/services/secretsmanager/v1api" ) var projectIdFlag = globalflags.ProjectIdFlag @@ -20,7 +20,9 @@ var projectIdFlag = globalflags.ProjectIdFlag type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &secretsmanager.APIClient{} +var testClient = &secretsmanager.APIClient{ + DefaultAPI: secretsmanager.DefaultAPIServiceMock{}, +} var testProjectId = uuid.NewString() func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string { @@ -49,7 +51,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *secretsmanager.ApiListInstancesRequest)) secretsmanager.ApiListInstancesRequest { - request := testClient.ListInstances(testCtx, testProjectId) + request := testClient.DefaultAPI.ListInstances(testCtx, testProjectId) for _, mod := range mods { mod(&request) } diff --git a/internal/cmd/secrets-manager/instance/update/update.go b/internal/cmd/secrets-manager/instance/update/update.go index 0a066ec01..7dc79fc56 100644 --- a/internal/cmd/secrets-manager/instance/update/update.go +++ b/internal/cmd/secrets-manager/instance/update/update.go @@ -18,7 +18,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/secretsmanager" + secretsmanager "github.com/stackitcloud/stackit-sdk-go/services/secretsmanager/v1api" ) const ( @@ -79,7 +79,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return err } - existingInstanceName, err := secretsManagerUtils.GetInstanceName(ctx, apiClient, model.ProjectId, model.InstanceId) + existingInstanceName, err := secretsManagerUtils.GetInstanceName(ctx, apiClient.DefaultAPI, model.ProjectId, model.InstanceId) if err != nil { params.Printer.Debug(print.ErrorLevel, "get instance name: %v", err) existingInstanceName = model.InstanceId @@ -93,7 +93,10 @@ func NewCmd(params *types.CmdParams) *cobra.Command { // Call API - execute UpdateInstance and/or UpdateACLs based on flags if model.InstanceName != nil { - req := buildUpdateInstanceRequest(ctx, model, apiClient) + req, err := buildUpdateInstanceRequest(ctx, model, apiClient) + if err != nil { + return fmt.Errorf("unable to build update instance request: %w", err) + } err = req.Execute() if err != nil { return fmt.Errorf("update Secrets Manager instance: %w", err) @@ -162,37 +165,39 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu return &model, nil } -func buildUpdateInstanceRequest(ctx context.Context, model *inputModel, apiClient *secretsmanager.APIClient) secretsmanager.ApiUpdateInstanceRequest { - req := apiClient.UpdateInstance(ctx, model.ProjectId, model.InstanceId) +func buildUpdateInstanceRequest(ctx context.Context, model *inputModel, apiClient *secretsmanager.APIClient) (secretsmanager.ApiUpdateInstanceRequest, error) { + if model.InstanceName == nil { + return secretsmanager.ApiUpdateInstanceRequest{}, fmt.Errorf("instanceName must not be null") + } + req := apiClient.DefaultAPI.UpdateInstance(ctx, model.ProjectId, model.InstanceId) payload := secretsmanager.UpdateInstancePayload{ - Name: model.InstanceName, + Name: *model.InstanceName, } - if model.KmsKeyId != nil { + if model.KmsKeyId != nil && model.KmsKeyringId != nil && model.KmsKeyVersion != nil && model.KmsServiceAccountEmail != nil { payload.KmsKey = &secretsmanager.KmsKeyPayload{ - KeyId: model.KmsKeyId, - KeyRingId: model.KmsKeyringId, - KeyVersion: model.KmsKeyVersion, - ServiceAccountEmail: model.KmsServiceAccountEmail, + KeyId: *model.KmsKeyId, + KeyRingId: *model.KmsKeyringId, + KeyVersion: *model.KmsKeyVersion, + ServiceAccountEmail: *model.KmsServiceAccountEmail, } } - req = req.UpdateInstancePayload(payload) - return req + return req, nil } func buildUpdateACLsRequest(ctx context.Context, model *inputModel, apiClient *secretsmanager.APIClient) secretsmanager.ApiUpdateACLsRequest { - req := apiClient.UpdateACLs(ctx, model.ProjectId, model.InstanceId) + req := apiClient.DefaultAPI.UpdateACLs(ctx, model.ProjectId, model.InstanceId) cidrs := []secretsmanager.UpdateACLPayload{} for _, acl := range *model.Acls { - cidrs = append(cidrs, secretsmanager.UpdateACLPayload{Cidr: utils.Ptr(acl)}) + cidrs = append(cidrs, secretsmanager.UpdateACLPayload{Cidr: acl}) } - req = req.UpdateACLsPayload(secretsmanager.UpdateACLsPayload{Cidrs: &cidrs}) + req = req.UpdateACLsPayload(secretsmanager.UpdateACLsPayload{Cidrs: cidrs}) return req } diff --git a/internal/cmd/secrets-manager/instance/update/update_test.go b/internal/cmd/secrets-manager/instance/update/update_test.go index 02a2641b3..2ddd2a8d1 100644 --- a/internal/cmd/secrets-manager/instance/update/update_test.go +++ b/internal/cmd/secrets-manager/instance/update/update_test.go @@ -11,7 +11,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/secretsmanager" + secretsmanager "github.com/stackitcloud/stackit-sdk-go/services/secretsmanager/v1api" ) const ( @@ -24,7 +24,9 @@ var projectIdFlag = globalflags.ProjectIdFlag type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &secretsmanager.APIClient{} +var testClient = &secretsmanager.APIClient{ + DefaultAPI: secretsmanager.DefaultAPIServiceMock{}, +} var ( testProjectId = uuid.NewString() @@ -76,11 +78,11 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *secretsmanager.ApiUpdateACLsRequest)) secretsmanager.ApiUpdateACLsRequest { - request := testClient.UpdateACLs(testCtx, testProjectId, testInstanceId) + request := testClient.DefaultAPI.UpdateACLs(testCtx, testProjectId, testInstanceId) request = request.UpdateACLsPayload(secretsmanager.UpdateACLsPayload{ - Cidrs: utils.Ptr([]secretsmanager.UpdateACLPayload{ - {Cidr: utils.Ptr(testACL1)}, - })}) + Cidrs: []secretsmanager.UpdateACLPayload{ + {Cidr: testACL1}, + }}) for _, mod := range mods { mod(&request) @@ -89,14 +91,14 @@ func fixtureRequest(mods ...func(request *secretsmanager.ApiUpdateACLsRequest)) } func fixtureUpdateInstanceRequest(mods ...func(request *secretsmanager.ApiUpdateInstanceRequest)) secretsmanager.ApiUpdateInstanceRequest { - request := testClient.UpdateInstance(testCtx, testProjectId, testInstanceId) + request := testClient.DefaultAPI.UpdateInstance(testCtx, testProjectId, testInstanceId) request = request.UpdateInstancePayload(secretsmanager.UpdateInstancePayload{ - Name: utils.Ptr(testInstanceName), + Name: testInstanceName, KmsKey: &secretsmanager.KmsKeyPayload{ - KeyId: utils.Ptr(testKmsKeyId), - KeyRingId: utils.Ptr(testKmsKeyringId), - KeyVersion: utils.Ptr(testKmsKeyVersion), - ServiceAccountEmail: utils.Ptr(testKmsServiceAccountEmail), + KeyId: testKmsKeyId, + KeyRingId: testKmsKeyringId, + KeyVersion: testKmsKeyVersion, + ServiceAccountEmail: testKmsServiceAccountEmail, }, }) @@ -329,10 +331,10 @@ func TestBuildUpdateACLsRequest(t *testing.T) { *model.Acls = append(*model.Acls, testACL2) }), expectedRequest: fixtureRequest().UpdateACLsPayload(secretsmanager.UpdateACLsPayload{ - Cidrs: utils.Ptr([]secretsmanager.UpdateACLPayload{ - {Cidr: utils.Ptr(testACL1)}, - {Cidr: utils.Ptr(testACL2)}, - })}), + Cidrs: []secretsmanager.UpdateACLPayload{ + {Cidr: testACL1}, + {Cidr: testACL2}, + }}), }, } @@ -356,6 +358,7 @@ func TestBuildUpdateInstanceRequest(t *testing.T) { description string model *inputModel expectedRequest secretsmanager.ApiUpdateInstanceRequest + wantErr bool }{ { description: "with name only", @@ -363,9 +366,9 @@ func TestBuildUpdateInstanceRequest(t *testing.T) { model.Acls = nil model.InstanceName = utils.Ptr(testInstanceName) }), - expectedRequest: testClient.UpdateInstance(testCtx, testProjectId, testInstanceId). + expectedRequest: testClient.DefaultAPI.UpdateInstance(testCtx, testProjectId, testInstanceId). UpdateInstancePayload(secretsmanager.UpdateInstancePayload{ - Name: utils.Ptr(testInstanceName), + Name: testInstanceName, }), }, { @@ -380,11 +383,21 @@ func TestBuildUpdateInstanceRequest(t *testing.T) { }), expectedRequest: fixtureUpdateInstanceRequest(), }, + { + description: "nil instance name", + model: fixtureInputModel(func(model *inputModel) { + model.InstanceName = nil + }), + wantErr: true, + }, } for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { - request := buildUpdateInstanceRequest(testCtx, tt.model, testClient) + request, err := buildUpdateInstanceRequest(testCtx, tt.model, testClient) + if (err != nil) != tt.wantErr { + t.Fatalf("buildUpdateInstanceRequest() error = %v, wantErr %v", err, tt.wantErr) + } diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), diff --git a/internal/cmd/secrets-manager/user/create/create.go b/internal/cmd/secrets-manager/user/create/create.go index 1584b5cf5..b186eaf9f 100644 --- a/internal/cmd/secrets-manager/user/create/create.go +++ b/internal/cmd/secrets-manager/user/create/create.go @@ -14,10 +14,9 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/print" "github.com/stackitcloud/stackit-cli/internal/pkg/services/secrets-manager/client" secretsManagerUtils "github.com/stackitcloud/stackit-cli/internal/pkg/services/secrets-manager/utils" - "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/secretsmanager" + secretsmanager "github.com/stackitcloud/stackit-sdk-go/services/secretsmanager/v1api" ) const ( @@ -30,8 +29,8 @@ type inputModel struct { *globalflags.GlobalFlagModel InstanceId string - Description *string - Write *bool + Description string + Write bool } func NewCmd(params *types.CmdParams) *cobra.Command { @@ -65,7 +64,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return err } - instanceLabel, err := secretsManagerUtils.GetInstanceName(ctx, apiClient, model.ProjectId, model.InstanceId) + instanceLabel, err := secretsManagerUtils.GetInstanceName(ctx, apiClient.DefaultAPI, model.ProjectId, model.InstanceId) if err != nil { params.Printer.Debug(print.ErrorLevel, "get instance name: %v", err) instanceLabel = model.InstanceId @@ -110,8 +109,8 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, model := inputModel{ GlobalFlagModel: globalFlags, InstanceId: flags.FlagToStringValue(p, cmd, instanceIdFlag), - Description: utils.Ptr(flags.FlagToStringValue(p, cmd, descriptionFlag)), - Write: utils.Ptr(flags.FlagToBoolValue(p, cmd, writeFlag)), + Description: flags.FlagToStringValue(p, cmd, descriptionFlag), + Write: flags.FlagToBoolValue(p, cmd, writeFlag), } p.DebugInputModel(model) @@ -119,7 +118,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, } func buildRequest(ctx context.Context, model *inputModel, apiClient *secretsmanager.APIClient) secretsmanager.ApiCreateUserRequest { - req := apiClient.CreateUser(ctx, model.ProjectId, model.InstanceId) + req := apiClient.DefaultAPI.CreateUser(ctx, model.ProjectId, model.InstanceId) req = req.CreateUserPayload(secretsmanager.CreateUserPayload{ Description: model.Description, Write: model.Write, @@ -133,11 +132,11 @@ func outputResult(p *print.Printer, outputFormat, instanceLabel string, user *se } return p.OutputResult(outputFormat, user, func() error { - p.Outputf("Created user for instance %q. User ID: %s\n\n", instanceLabel, utils.PtrString(user.Id)) - p.Outputf("Username: %s\n", utils.PtrString(user.Username)) - p.Outputf("Password: %s\n", utils.PtrString(user.Password)) - p.Outputf("Description: %s\n", utils.PtrString(user.Description)) - p.Outputf("Write Access: %s\n", utils.PtrString(user.Write)) + p.Outputf("Created user for instance %q. User ID: %s\n\n", instanceLabel, user.Id) + p.Outputf("Username: %s\n", user.Username) + p.Outputf("Password: %s\n", user.Password) + p.Outputf("Description: %s\n", user.Description) + p.Outputf("Write Access: %t\n", user.Write) return nil }) diff --git a/internal/cmd/secrets-manager/user/create/create_test.go b/internal/cmd/secrets-manager/user/create/create_test.go index df0037f9a..591cf991e 100644 --- a/internal/cmd/secrets-manager/user/create/create_test.go +++ b/internal/cmd/secrets-manager/user/create/create_test.go @@ -7,12 +7,11 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" "github.com/stackitcloud/stackit-cli/internal/pkg/testutils" - "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/secretsmanager" + secretsmanager "github.com/stackitcloud/stackit-sdk-go/services/secretsmanager/v1api" ) var projectIdFlag = globalflags.ProjectIdFlag @@ -20,7 +19,9 @@ var projectIdFlag = globalflags.ProjectIdFlag type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &secretsmanager.APIClient{} +var testClient = &secretsmanager.APIClient{ + DefaultAPI: secretsmanager.DefaultAPIServiceMock{}, +} var testProjectId = uuid.NewString() var testInstanceId = uuid.NewString() @@ -44,8 +45,8 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { Verbosity: globalflags.VerbosityDefault, }, InstanceId: testInstanceId, - Description: utils.Ptr("sample description"), - Write: utils.Ptr(false), + Description: "sample description", + Write: false, } for _, mod := range mods { mod(model) @@ -54,10 +55,10 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *secretsmanager.ApiCreateUserRequest)) secretsmanager.ApiCreateUserRequest { - request := testClient.CreateUser(testCtx, testProjectId, testInstanceId) + request := testClient.DefaultAPI.CreateUser(testCtx, testProjectId, testInstanceId) request = request.CreateUserPayload(secretsmanager.CreateUserPayload{ - Description: utils.Ptr("sample description"), - Write: utils.Ptr(false), + Description: "sample description", + Write: false, }) for _, mod := range mods { @@ -88,7 +89,7 @@ func TestParseInput(t *testing.T) { }), isValid: true, expectedModel: fixtureInputModel(func(model *inputModel) { - model.Description = utils.Ptr("") + model.Description = "" }), }, { @@ -146,7 +147,7 @@ func TestParseInput(t *testing.T) { }), isValid: true, expectedModel: fixtureInputModel(func(model *inputModel) { - model.Write = utils.Ptr(true) + model.Write = true }), }, } diff --git a/internal/cmd/secrets-manager/user/delete/delete.go b/internal/cmd/secrets-manager/user/delete/delete.go index 65193fac3..e5bdd4a19 100644 --- a/internal/cmd/secrets-manager/user/delete/delete.go +++ b/internal/cmd/secrets-manager/user/delete/delete.go @@ -17,7 +17,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/secretsmanager" + secretsmanager "github.com/stackitcloud/stackit-sdk-go/services/secretsmanager/v1api" ) const ( @@ -60,13 +60,13 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return err } - instanceLabel, err := secretsManagerUtils.GetInstanceName(ctx, apiClient, model.ProjectId, model.InstanceId) + instanceLabel, err := secretsManagerUtils.GetInstanceName(ctx, apiClient.DefaultAPI, model.ProjectId, model.InstanceId) if err != nil { params.Printer.Debug(print.ErrorLevel, "get instance name: %v", err) instanceLabel = model.InstanceId } - userLabel, err := secretsManagerUtils.GetUserLabel(ctx, apiClient, model.ProjectId, model.InstanceId, model.UserId) + userLabel, err := secretsManagerUtils.GetUserLabel(ctx, apiClient.DefaultAPI, model.ProjectId, model.InstanceId, model.UserId) if err != nil { params.Printer.Debug(print.ErrorLevel, "get user label: %v", err) userLabel = fmt.Sprintf("%q", model.UserId) @@ -119,6 +119,6 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *secretsmanager.APIClient) secretsmanager.ApiDeleteUserRequest { - req := apiClient.DeleteUser(ctx, model.ProjectId, model.InstanceId, model.UserId) + req := apiClient.DefaultAPI.DeleteUser(ctx, model.ProjectId, model.InstanceId, model.UserId) return req } diff --git a/internal/cmd/secrets-manager/user/delete/delete_test.go b/internal/cmd/secrets-manager/user/delete/delete_test.go index 8b66aa96a..c105aab13 100644 --- a/internal/cmd/secrets-manager/user/delete/delete_test.go +++ b/internal/cmd/secrets-manager/user/delete/delete_test.go @@ -10,7 +10,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/secretsmanager" + secretsmanager "github.com/stackitcloud/stackit-sdk-go/services/secretsmanager/v1api" ) var projectIdFlag = globalflags.ProjectIdFlag @@ -18,7 +18,9 @@ var projectIdFlag = globalflags.ProjectIdFlag type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &secretsmanager.APIClient{} +var testClient = &secretsmanager.APIClient{ + DefaultAPI: secretsmanager.DefaultAPIServiceMock{}, +} var testProjectId = uuid.NewString() var testInstanceId = uuid.NewString() var testUserId = uuid.NewString() @@ -60,7 +62,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *secretsmanager.ApiDeleteUserRequest)) secretsmanager.ApiDeleteUserRequest { - request := testClient.DeleteUser(testCtx, testProjectId, testInstanceId, testUserId) + request := testClient.DefaultAPI.DeleteUser(testCtx, testProjectId, testInstanceId, testUserId) for _, mod := range mods { mod(&request) } diff --git a/internal/cmd/secrets-manager/user/describe/describe.go b/internal/cmd/secrets-manager/user/describe/describe.go index 5a658385c..61033277e 100644 --- a/internal/cmd/secrets-manager/user/describe/describe.go +++ b/internal/cmd/secrets-manager/user/describe/describe.go @@ -17,7 +17,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/secretsmanager" + secretsmanager "github.com/stackitcloud/stackit-sdk-go/services/secretsmanager/v1api" ) const ( @@ -67,7 +67,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return fmt.Errorf("get Secrets Manager user: %w", err) } - return outputResult(params.Printer, model.OutputFormat, *resp) + return outputResult(params.Printer, model.OutputFormat, resp) }, } @@ -101,26 +101,26 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *secretsmanager.APIClient) secretsmanager.ApiGetUserRequest { - req := apiClient.GetUser(ctx, model.ProjectId, model.InstanceId, model.UserId) + req := apiClient.DefaultAPI.GetUser(ctx, model.ProjectId, model.InstanceId, model.UserId) return req } -func outputResult(p *print.Printer, outputFormat string, user secretsmanager.User) error { +func outputResult(p *print.Printer, outputFormat string, user *secretsmanager.User) error { return p.OutputResult(outputFormat, user, func() error { table := tables.NewTable() - table.AddRow("ID", utils.PtrString(user.Id)) + table.AddRow("ID", user.Id) table.AddSeparator() - table.AddRow("USERNAME", utils.PtrString(user.Username)) + table.AddRow("USERNAME", user.Username) table.AddSeparator() - if user.Description != nil && *user.Description != "" { - table.AddRow("DESCRIPTION", *user.Description) + if user.Description != "" { + table.AddRow("DESCRIPTION", user.Description) table.AddSeparator() } - if user.Password != nil && *user.Password != "" { - table.AddRow("PASSWORD", *user.Password) + if user.Password != "" { + table.AddRow("PASSWORD", user.Password) table.AddSeparator() } - table.AddRow("WRITE ACCESS", utils.PtrString(user.Write)) + table.AddRow("WRITE ACCESS", user.Write) err := table.Display(p) if err != nil { diff --git a/internal/cmd/secrets-manager/user/describe/describe_test.go b/internal/cmd/secrets-manager/user/describe/describe_test.go index bcf45743b..f62123748 100644 --- a/internal/cmd/secrets-manager/user/describe/describe_test.go +++ b/internal/cmd/secrets-manager/user/describe/describe_test.go @@ -7,11 +7,12 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" "github.com/stackitcloud/stackit-cli/internal/pkg/testutils" + "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/secretsmanager" + secretsmanager "github.com/stackitcloud/stackit-sdk-go/services/secretsmanager/v1api" ) var projectIdFlag = globalflags.ProjectIdFlag @@ -19,7 +20,9 @@ var projectIdFlag = globalflags.ProjectIdFlag type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &secretsmanager.APIClient{} +var testClient = &secretsmanager.APIClient{ + DefaultAPI: secretsmanager.DefaultAPIServiceMock{}, +} var testProjectId = uuid.NewString() var testInstanceId = uuid.NewString() var testUserId = uuid.NewString() @@ -61,7 +64,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *secretsmanager.ApiGetUserRequest)) secretsmanager.ApiGetUserRequest { - request := testClient.GetUser(testCtx, testProjectId, testInstanceId, testUserId) + request := testClient.DefaultAPI.GetUser(testCtx, testProjectId, testInstanceId, testUserId) for _, mod := range mods { mod(&request) } @@ -224,7 +227,7 @@ func TestOutputResult(t *testing.T) { params := testparams.NewTestParams() for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - if err := outputResult(params.Printer, tt.args.outputFormat, tt.args.user); (err != nil) != tt.wantErr { + if err := outputResult(params.Printer, tt.args.outputFormat, utils.Ptr(tt.args.user)); (err != nil) != tt.wantErr { t.Errorf("outputResult() error = %v, wantErr %v", err, tt.wantErr) } }) diff --git a/internal/cmd/secrets-manager/user/list/list.go b/internal/cmd/secrets-manager/user/list/list.go index 163c523c9..81fb7b25b 100644 --- a/internal/cmd/secrets-manager/user/list/list.go +++ b/internal/cmd/secrets-manager/user/list/list.go @@ -7,7 +7,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/types" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/secretsmanager" + secretsmanager "github.com/stackitcloud/stackit-sdk-go/services/secretsmanager/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/args" "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -18,7 +18,6 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/services/secrets-manager/client" secretsManagerUtils "github.com/stackitcloud/stackit-cli/internal/pkg/services/secrets-manager/utils" "github.com/stackitcloud/stackit-cli/internal/pkg/tables" - "github.com/stackitcloud/stackit-cli/internal/pkg/utils" ) const ( @@ -69,8 +68,8 @@ func NewCmd(params *types.CmdParams) *cobra.Command { if err != nil { return fmt.Errorf("get Secrets Manager users: %w", err) } - if resp.Users == nil || len(*resp.Users) == 0 { - instanceLabel, err := secretsManagerUtils.GetInstanceName(ctx, apiClient, model.ProjectId, *model.InstanceId) + if len(resp.Users) == 0 { + instanceLabel, err := secretsManagerUtils.GetInstanceName(ctx, apiClient.DefaultAPI, model.ProjectId, *model.InstanceId) if err != nil { params.Printer.Debug(print.ErrorLevel, "get instance name: %v", err) instanceLabel = *model.InstanceId @@ -78,14 +77,13 @@ func NewCmd(params *types.CmdParams) *cobra.Command { params.Printer.Info("No users found for instance %q\n", instanceLabel) return nil } - users := *resp.Users // Truncate output - if model.Limit != nil && len(users) > int(*model.Limit) { - users = users[:*model.Limit] + if model.Limit != nil && len(resp.Users) > int(*model.Limit) { + resp.Users = resp.Users[:*model.Limit] } - return outputResult(params.Printer, model.OutputFormat, users) + return outputResult(params.Printer, model.OutputFormat, (resp.Users)) }, } @@ -126,7 +124,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, } func buildRequest(ctx context.Context, model *inputModel, apiClient *secretsmanager.APIClient) secretsmanager.ApiListUsersRequest { - req := apiClient.ListUsers(ctx, model.ProjectId, *model.InstanceId) + req := apiClient.DefaultAPI.ListUsers(ctx, model.ProjectId, *model.InstanceId) return req } @@ -137,10 +135,10 @@ func outputResult(p *print.Printer, outputFormat string, users []secretsmanager. for i := range users { user := users[i] table.AddRow( - utils.PtrString(user.Id), - utils.PtrString(user.Username), - utils.PtrString(user.Description), - utils.PtrString(user.Write), + user.Id, + user.Username, + user.Description, + user.Write, ) } err := table.Display(p) diff --git a/internal/cmd/secrets-manager/user/list/list_test.go b/internal/cmd/secrets-manager/user/list/list_test.go index 844c47e07..bba7c86d4 100644 --- a/internal/cmd/secrets-manager/user/list/list_test.go +++ b/internal/cmd/secrets-manager/user/list/list_test.go @@ -12,7 +12,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/secretsmanager" + secretsmanager "github.com/stackitcloud/stackit-sdk-go/services/secretsmanager/v1api" ) var projectIdFlag = globalflags.ProjectIdFlag @@ -20,7 +20,9 @@ var projectIdFlag = globalflags.ProjectIdFlag type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &secretsmanager.APIClient{} +var testClient = &secretsmanager.APIClient{ + DefaultAPI: secretsmanager.DefaultAPIServiceMock{}, +} var testProjectId = uuid.NewString() var testInstanceId = uuid.NewString() @@ -52,7 +54,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *secretsmanager.ApiListUsersRequest)) secretsmanager.ApiListUsersRequest { - request := testClient.ListUsers(testCtx, testProjectId, testInstanceId) + request := testClient.DefaultAPI.ListUsers(testCtx, testProjectId, testInstanceId) for _, mod := range mods { mod(&request) } diff --git a/internal/cmd/secrets-manager/user/update/update.go b/internal/cmd/secrets-manager/user/update/update.go index 38507699b..efffd6fe3 100644 --- a/internal/cmd/secrets-manager/user/update/update.go +++ b/internal/cmd/secrets-manager/user/update/update.go @@ -17,7 +17,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/secretsmanager" + secretsmanager "github.com/stackitcloud/stackit-sdk-go/services/secretsmanager/v1api" ) const ( @@ -64,13 +64,13 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return err } - instanceLabel, err := secretsManagerUtils.GetInstanceName(ctx, apiClient, model.ProjectId, model.InstanceId) + instanceLabel, err := secretsManagerUtils.GetInstanceName(ctx, apiClient.DefaultAPI, model.ProjectId, model.InstanceId) if err != nil { params.Printer.Debug(print.ErrorLevel, "get instance name: %v", err) instanceLabel = model.InstanceId } - userLabel, err := secretsManagerUtils.GetUserLabel(ctx, apiClient, model.ProjectId, model.InstanceId, model.UserId) + userLabel, err := secretsManagerUtils.GetUserLabel(ctx, apiClient.DefaultAPI, model.ProjectId, model.InstanceId, model.UserId) if err != nil { params.Printer.Debug(print.ErrorLevel, "get user label: %v", err) userLabel = fmt.Sprintf("%q", model.UserId) @@ -141,7 +141,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *secretsmanager.APIClient) (secretsmanager.ApiUpdateUserRequest, error) { - req := apiClient.UpdateUser(ctx, model.ProjectId, model.InstanceId, model.UserId) + req := apiClient.DefaultAPI.UpdateUser(ctx, model.ProjectId, model.InstanceId, model.UserId) var write bool diff --git a/internal/cmd/secrets-manager/user/update/update_test.go b/internal/cmd/secrets-manager/user/update/update_test.go index 417070b19..24ec6dd3b 100644 --- a/internal/cmd/secrets-manager/user/update/update_test.go +++ b/internal/cmd/secrets-manager/user/update/update_test.go @@ -11,7 +11,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/secretsmanager" + secretsmanager "github.com/stackitcloud/stackit-sdk-go/services/secretsmanager/v1api" ) var projectIdFlag = globalflags.ProjectIdFlag @@ -19,7 +19,9 @@ var projectIdFlag = globalflags.ProjectIdFlag type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &secretsmanager.APIClient{} +var testClient = &secretsmanager.APIClient{ + DefaultAPI: secretsmanager.DefaultAPIServiceMock{}, +} var testProjectId = uuid.NewString() var testInstanceId = uuid.NewString() var testUserId = uuid.NewString() @@ -64,7 +66,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *secretsmanager.ApiUpdateUserRequest)) secretsmanager.ApiUpdateUserRequest { - request := testClient.UpdateUser(testCtx, testProjectId, testInstanceId, testUserId) + request := testClient.DefaultAPI.UpdateUser(testCtx, testProjectId, testInstanceId, testUserId) request = request.UpdateUserPayload(secretsmanager.UpdateUserPayload{ Write: utils.Ptr(true), }) diff --git a/internal/pkg/services/secrets-manager/client/client.go b/internal/pkg/services/secrets-manager/client/client.go index dfedcb0e3..1f2350556 100644 --- a/internal/pkg/services/secrets-manager/client/client.go +++ b/internal/pkg/services/secrets-manager/client/client.go @@ -6,7 +6,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/print" "github.com/spf13/viper" - "github.com/stackitcloud/stackit-sdk-go/services/secretsmanager" + secretsmanager "github.com/stackitcloud/stackit-sdk-go/services/secretsmanager/v1api" ) func ConfigureClient(p *print.Printer, cliVersion string) (*secretsmanager.APIClient, error) { diff --git a/internal/pkg/services/secrets-manager/utils/utils.go b/internal/pkg/services/secrets-manager/utils/utils.go index 0b53f64f5..1bbd315e0 100644 --- a/internal/pkg/services/secrets-manager/utils/utils.go +++ b/internal/pkg/services/secrets-manager/utils/utils.go @@ -4,38 +4,38 @@ import ( "context" "fmt" - "github.com/stackitcloud/stackit-sdk-go/services/secretsmanager" + secretsmanager "github.com/stackitcloud/stackit-sdk-go/services/secretsmanager/v1api" ) type SecretsManagerClient interface { - GetInstanceExecute(ctx context.Context, projectId, instanceId string) (*secretsmanager.Instance, error) - GetUserExecute(ctx context.Context, projectId string, instanceId string, userId string) (*secretsmanager.User, error) + GetInstance(ctx context.Context, projectId, instanceId string) secretsmanager.ApiGetInstanceRequest + GetUser(ctx context.Context, projectId string, instanceId string, userId string) secretsmanager.ApiGetUserRequest } func GetInstanceName(ctx context.Context, apiClient SecretsManagerClient, projectId, instanceId string) (string, error) { - resp, err := apiClient.GetInstanceExecute(ctx, projectId, instanceId) + resp, err := apiClient.GetInstance(ctx, projectId, instanceId).Execute() if err != nil { return "", fmt.Errorf("get Secrets Manager instance: %w", err) } - return *resp.Name, nil + return resp.Name, nil } func GetUserLabel(ctx context.Context, apiClient SecretsManagerClient, projectId, instanceId, userId string) (string, error) { - resp, err := apiClient.GetUserExecute(ctx, projectId, instanceId, userId) + resp, err := apiClient.GetUser(ctx, projectId, instanceId, userId).Execute() if err != nil { return "", fmt.Errorf("get Secrets Manager user: %w", err) } - if resp.Username == nil || *resp.Username == "" { + if resp.Username == "" { // Should never happen, username is auto-generated return "", fmt.Errorf("username is empty") } var userLabel string - if resp.Description == nil || *resp.Description == "" { - userLabel = fmt.Sprintf("%q", *resp.Username) + if resp.Description == "" { + userLabel = fmt.Sprintf("%q", resp.Username) } else { - userLabel = fmt.Sprintf("%q (%s)", *resp.Username, *resp.Description) + userLabel = fmt.Sprintf("%q (%s)", resp.Username, resp.Description) } return userLabel, nil } diff --git a/internal/pkg/services/secrets-manager/utils/utils_test.go b/internal/pkg/services/secrets-manager/utils/utils_test.go index f0d926b0b..92f4ab9f6 100644 --- a/internal/pkg/services/secrets-manager/utils/utils_test.go +++ b/internal/pkg/services/secrets-manager/utils/utils_test.go @@ -6,7 +6,7 @@ import ( "testing" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/secretsmanager" + secretsmanager "github.com/stackitcloud/stackit-sdk-go/services/secretsmanager/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/utils" ) @@ -23,25 +23,30 @@ const ( testDescription = "sample description" ) -type secretsManagerClientMocked struct { +type apiClientMockOptions struct { getInstanceFails bool getInstanceResp *secretsmanager.Instance getUserFails bool getUserResp *secretsmanager.User } -func (s *secretsManagerClientMocked) GetInstanceExecute(_ context.Context, _, _ string) (*secretsmanager.Instance, error) { - if s.getInstanceFails { - return nil, fmt.Errorf("could not get instance") - } - return s.getInstanceResp, nil -} - -func (s *secretsManagerClientMocked) GetUserExecute(_ context.Context, _, _, _ string) (*secretsmanager.User, error) { - if s.getUserFails { - return nil, fmt.Errorf("could not get user") +func newAPIClient(options apiClientMockOptions) secretsmanager.APIClient { + return secretsmanager.APIClient{ + DefaultAPI: secretsmanager.DefaultAPIServiceMock{ + GetUserExecuteMock: utils.Ptr(func(_ secretsmanager.ApiGetUserRequest) (*secretsmanager.User, error) { + if options.getUserFails { + return nil, fmt.Errorf("could not get user") + } + return options.getUserResp, nil + }), + GetInstanceExecuteMock: utils.Ptr(func(_ secretsmanager.ApiGetInstanceRequest) (*secretsmanager.Instance, error) { + if options.getInstanceFails { + return nil, fmt.Errorf("could not get instance") + } + return options.getInstanceResp, nil + }), + }, } - return s.getUserResp, nil } func TestGetInstanceName(t *testing.T) { @@ -55,7 +60,7 @@ func TestGetInstanceName(t *testing.T) { { description: "base", getInstanceResp: &secretsmanager.Instance{ - Name: utils.Ptr(testInstanceName), + Name: testInstanceName, }, isValid: true, expectedOutput: testInstanceName, @@ -69,12 +74,12 @@ func TestGetInstanceName(t *testing.T) { for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { - client := &secretsManagerClientMocked{ + mockOptions := apiClientMockOptions{ getInstanceFails: tt.getInstanceFails, getInstanceResp: tt.getInstanceResp, } - output, err := GetInstanceName(context.Background(), client, testProjectId, testInstanceId) + output, err := GetInstanceName(context.Background(), newAPIClient(mockOptions).DefaultAPI, testProjectId, testInstanceId) if tt.isValid && err != nil { t.Errorf("failed on valid input") @@ -103,8 +108,8 @@ func TestGetUserDetails(t *testing.T) { { description: "base", GetUserResp: &secretsmanager.User{ - Username: utils.Ptr(testUserName), - Description: utils.Ptr(testDescription), + Username: testUserName, + Description: testDescription, }, isValid: true, expectedOutput: fmt.Sprintf("%q (%s)", testUserName, testDescription), @@ -112,7 +117,7 @@ func TestGetUserDetails(t *testing.T) { { description: "user has no description", GetUserResp: &secretsmanager.User{ - Username: utils.Ptr(testUserName), + Username: testUserName, }, isValid: true, expectedOutput: fmt.Sprintf("%q", testUserName), @@ -120,8 +125,8 @@ func TestGetUserDetails(t *testing.T) { { description: "user has empty description", GetUserResp: &secretsmanager.User{ - Username: utils.Ptr(testUserName), - Description: utils.Ptr(""), + Username: testUserName, + Description: "", }, isValid: true, expectedOutput: fmt.Sprintf("%q", testUserName), @@ -129,14 +134,14 @@ func TestGetUserDetails(t *testing.T) { { description: "user has empty username", GetUserResp: &secretsmanager.User{ - Username: utils.Ptr(""), + Username: "", }, isValid: false, }, { description: "user has no username", GetUserResp: &secretsmanager.User{ - Username: nil, + Username: "", }, isValid: false, }, @@ -149,12 +154,12 @@ func TestGetUserDetails(t *testing.T) { for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { - client := &secretsManagerClientMocked{ + options := &apiClientMockOptions{ getUserFails: tt.getUserFails, getUserResp: tt.GetUserResp, } - userLabel, err := GetUserLabel(context.Background(), client, testProjectId, testInstanceId, testUserId) + userLabel, err := GetUserLabel(context.Background(), newAPIClient(*options).DefaultAPI, testProjectId, testInstanceId, testUserId) if tt.isValid && err != nil { t.Errorf("failed on valid input") From 3dd453abb635c20a74d721233ac6e3f5ea9ee4d0 Mon Sep 17 00:00:00 2001 From: cgoetz-inovex Date: Fri, 3 Jul 2026 09:24:26 +0200 Subject: [PATCH 15/44] feat(docs): homebrew: trust stackit cli cask (#1455) * feat(docs): homebrew: trust stackit cli cask * fix(docs): directly trust cask on install --- INSTALLATION.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/INSTALLATION.md b/INSTALLATION.md index f622b56ce..a20cf097e 100644 --- a/INSTALLATION.md +++ b/INSTALLATION.md @@ -24,10 +24,10 @@ The STACKIT CLI can be installed through the [Homebrew](https://brew.sh/) packag brew tap stackitcloud/tap ``` -2. You can then install the CLI via: +2. You can then install the CLI via (this also trusts the STACKIT CLI cask): ```shell -brew install --cask stackit +brew install --cask stackitcloud/tap/stackit ``` ### Linux From 3f95acddbac165d0a8ad1f9edd32f398955492d5 Mon Sep 17 00:00:00 2001 From: Jonas Schlecht <73650029+SerseusWasTaken@users.noreply.github.com> Date: Mon, 6 Jul 2026 17:23:01 +0200 Subject: [PATCH 16/44] feat(rabbitmqa): region adjustment (#1449) relates to STACKITCLI-407 --- docs/stackit_rabbitmq_instance_create.md | 4 +- docs/stackit_rabbitmq_instance_update.md | 4 +- go.mod | 2 +- go.sum | 4 +- .../cmd/rabbitmq/credentials/create/create.go | 27 ++- .../credentials/create/create_test.go | 11 +- .../cmd/rabbitmq/credentials/delete/delete.go | 8 +- .../credentials/delete/delete_test.go | 11 +- .../rabbitmq/credentials/describe/describe.go | 14 +- .../credentials/describe/describe_test.go | 11 +- .../cmd/rabbitmq/credentials/list/list.go | 9 +- .../rabbitmq/credentials/list/list_test.go | 11 +- .../cmd/rabbitmq/instance/create/create.go | 52 ++--- .../rabbitmq/instance/create/create_test.go | 128 ++++++------ .../cmd/rabbitmq/instance/delete/delete.go | 10 +- .../rabbitmq/instance/delete/delete_test.go | 12 +- .../rabbitmq/instance/describe/describe.go | 20 +- .../instance/describe/describe_test.go | 13 +- internal/cmd/rabbitmq/instance/list/list.go | 14 +- .../cmd/rabbitmq/instance/list/list_test.go | 11 +- .../cmd/rabbitmq/instance/update/update.go | 41 ++-- .../rabbitmq/instance/update/update_test.go | 182 ++++++------------ internal/cmd/rabbitmq/plans/plans.go | 19 +- internal/cmd/rabbitmq/plans/plans_test.go | 11 +- .../pkg/services/rabbitmq/client/client.go | 4 +- internal/pkg/services/rabbitmq/utils/utils.go | 42 ++-- .../pkg/services/rabbitmq/utils/utils_test.go | 44 +++-- 27 files changed, 341 insertions(+), 378 deletions(-) diff --git a/docs/stackit_rabbitmq_instance_create.md b/docs/stackit_rabbitmq_instance_create.md index cff51b9e0..92d74caa0 100644 --- a/docs/stackit_rabbitmq_instance_create.md +++ b/docs/stackit_rabbitmq_instance_create.md @@ -30,13 +30,13 @@ stackit rabbitmq instance create [flags] --enable-monitoring Enable monitoring --graphite string Graphite host -h, --help Help for "stackit rabbitmq instance create" - --metrics-frequency int Metrics frequency + --metrics-frequency int32 Metrics frequency --metrics-prefix string Metrics prefix --monitoring-instance-id string Monitoring instance ID -n, --name string Instance name --plan-id string Plan ID --plan-name string Plan name - --plugin strings Plugin + --plugin strings Plugins (multiple of: [rabbitmq_consistent_hash_exchange, rabbitmq_federation, rabbitmq_federation_management, rabbitmq_mqtt, rabbitmq_sharding, rabbitmq_shovel, rabbitmq_shovel_management, rabbitmq_stomp, rabbitmq_tracing, rabbitmq_event_exchange]) (default []) --syslog strings Syslog --version string Instance RabbitMQ version ``` diff --git a/docs/stackit_rabbitmq_instance_update.md b/docs/stackit_rabbitmq_instance_update.md index 1635bbc4a..1cc196bae 100644 --- a/docs/stackit_rabbitmq_instance_update.md +++ b/docs/stackit_rabbitmq_instance_update.md @@ -27,12 +27,12 @@ stackit rabbitmq instance update INSTANCE_ID [flags] --enable-monitoring Enable monitoring --graphite string Graphite host -h, --help Help for "stackit rabbitmq instance update" - --metrics-frequency int Metrics frequency + --metrics-frequency int32 Metrics frequency --metrics-prefix string Metrics prefix --monitoring-instance-id string Monitoring instance ID --plan-id string Plan ID --plan-name string Plan name - --plugin strings Plugin + --plugin strings Plugins (multiple of: [rabbitmq_consistent_hash_exchange, rabbitmq_federation, rabbitmq_federation_management, rabbitmq_mqtt, rabbitmq_sharding, rabbitmq_shovel, rabbitmq_shovel_management, rabbitmq_stomp, rabbitmq_tracing, rabbitmq_event_exchange]) (default []) --syslog strings Syslog --version string Instance RabbitMQ version ``` diff --git a/go.mod b/go.mod index 1b8eddab8..2ebc99c95 100644 --- a/go.mod +++ b/go.mod @@ -271,7 +271,7 @@ require ( github.com/stackitcloud/stackit-sdk-go/services/mariadb v0.25.6 github.com/stackitcloud/stackit-sdk-go/services/objectstorage v1.7.0 github.com/stackitcloud/stackit-sdk-go/services/observability v0.17.0 - github.com/stackitcloud/stackit-sdk-go/services/rabbitmq v0.26.0 + github.com/stackitcloud/stackit-sdk-go/services/rabbitmq v1.1.0 github.com/stackitcloud/stackit-sdk-go/services/redis v0.25.6 github.com/stackitcloud/stackit-sdk-go/services/sfs v0.9.0 github.com/subosito/gotenv v1.6.0 // indirect diff --git a/go.sum b/go.sum index cd852cc55..7b6f8dd14 100644 --- a/go.sum +++ b/go.sum @@ -632,8 +632,8 @@ github.com/stackitcloud/stackit-sdk-go/services/opensearch v0.24.6 h1:oTVx1+O177 github.com/stackitcloud/stackit-sdk-go/services/opensearch v0.24.6/go.mod h1:6ZBeCCY6qG8w1oK7osf61Egyv3mp7Ahv6GDGxiarDGo= github.com/stackitcloud/stackit-sdk-go/services/postgresflex v1.3.5 h1:H67e3KnHQx954yI8fuQmxXwRf/myqAdLg2KvxImp00g= github.com/stackitcloud/stackit-sdk-go/services/postgresflex v1.3.5/go.mod h1:xmAWk9eom8wznvLuLfm0F4xyeiBX8LaggXsKFmos+dw= -github.com/stackitcloud/stackit-sdk-go/services/rabbitmq v0.26.0 h1:/8lmviszgrB+0Cz7HdhFELyTiTeqIs7LfnI6sNX4rW8= -github.com/stackitcloud/stackit-sdk-go/services/rabbitmq v0.26.0/go.mod h1:hnhvlLX1Y71R8KIQqLBeoSZqkU5ZJOG0J4wz0LeUdaw= +github.com/stackitcloud/stackit-sdk-go/services/rabbitmq v1.1.0 h1:HRJwodJX4aOn/487zaqJIKw13yIj4T6dn7/kEHLxeTg= +github.com/stackitcloud/stackit-sdk-go/services/rabbitmq v1.1.0/go.mod h1:TwfVVynB/+AKbccSOLk2qZpPL1tdK43BBAiACP6EtSg= github.com/stackitcloud/stackit-sdk-go/services/redis v0.25.6 h1:CXM9cZ9WeTyJd+Aw/hnJnDsKRVAQi4qgtd0RJ3zoPwo= github.com/stackitcloud/stackit-sdk-go/services/redis v0.25.6/go.mod h1:KJNceOHRefjku1oVBoHG7idCS/SeW42WJ+55bN3AxrQ= github.com/stackitcloud/stackit-sdk-go/services/resourcemanager v0.24.0 h1:JPP6a0ME1tZXr4iB69d/LtJsCAr58ENBadFaK9f48/c= diff --git a/internal/cmd/rabbitmq/credentials/create/create.go b/internal/cmd/rabbitmq/credentials/create/create.go index 8fcf54748..aceb05727 100644 --- a/internal/cmd/rabbitmq/credentials/create/create.go +++ b/internal/cmd/rabbitmq/credentials/create/create.go @@ -4,10 +4,11 @@ import ( "context" "fmt" + rabbitmq "github.com/stackitcloud/stackit-sdk-go/services/rabbitmq/v2api" + "github.com/stackitcloud/stackit-cli/internal/pkg/types" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/rabbitmq" "github.com/stackitcloud/stackit-cli/internal/pkg/args" "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -58,7 +59,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return err } - instanceLabel, err := rabbitmqUtils.GetInstanceName(ctx, apiClient, model.ProjectId, model.InstanceId) + instanceLabel, err := rabbitmqUtils.GetInstanceName(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, model.InstanceId) if err != nil { params.Printer.Debug(print.ErrorLevel, "get instance name: %v", err) instanceLabel = model.InstanceId @@ -109,7 +110,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, } func buildRequest(ctx context.Context, model *inputModel, apiClient *rabbitmq.APIClient) rabbitmq.ApiCreateCredentialsRequest { - req := apiClient.CreateCredentials(ctx, model.ProjectId, model.InstanceId) + req := apiClient.DefaultAPI.CreateCredentials(ctx, model.ProjectId, model.Region, model.InstanceId) return req } @@ -123,29 +124,27 @@ func outputResult(p *print.Printer, model inputModel, instanceLabel string, resp if !model.ShowPassword { if resp.Raw == nil { - resp.Raw = &rabbitmq.RawCredentials{Credentials: &rabbitmq.Credentials{}} - } else if resp.Raw.Credentials == nil { - resp.Raw.Credentials = &rabbitmq.Credentials{} + resp.Raw = &rabbitmq.RawCredentials{Credentials: rabbitmq.Credentials{}} } - resp.Raw.Credentials.Password = utils.Ptr("hidden") + resp.Raw.Credentials.Password = "hidden" } return p.OutputResult(model.OutputFormat, resp, func() error { - p.Outputf("Created credentials for instance %q. Credentials ID: %s\n\n", instanceLabel, utils.PtrString(resp.Id)) + p.Outputf("Created credentials for instance %q. Credentials ID: %s\n\n", instanceLabel, resp.Id) // The username field cannot be set by the user so we only display it if it's not returned empty - if resp.HasRaw() && resp.Raw.Credentials != nil { - if username := resp.Raw.Credentials.Username; username != nil && *username != "" { - p.Outputf("Username: %s\n", *username) + if resp.HasRaw() { + if username := resp.Raw.Credentials.Username; username != "" { + p.Outputf("Username: %s\n", username) } if !model.ShowPassword { p.Outputf("Password: \n") } else { - p.Outputf("Password: %s\n", utils.PtrString(resp.Raw.Credentials.Password)) + p.Outputf("Password: %s\n", resp.Raw.Credentials.Password) } - p.Outputf("Host: %s\n", utils.PtrString(resp.Raw.Credentials.Host)) + p.Outputf("Host: %s\n", resp.Raw.Credentials.Host) p.Outputf("Port: %s\n", utils.PtrString(resp.Raw.Credentials.Port)) } - p.Outputf("URI: %s\n", utils.PtrString(resp.Uri)) + p.Outputf("URI: %s\n", resp.Uri) return nil }) } diff --git a/internal/cmd/rabbitmq/credentials/create/create_test.go b/internal/cmd/rabbitmq/credentials/create/create_test.go index ab96d5013..90703282e 100644 --- a/internal/cmd/rabbitmq/credentials/create/create_test.go +++ b/internal/cmd/rabbitmq/credentials/create/create_test.go @@ -7,7 +7,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/rabbitmq" + rabbitmq "github.com/stackitcloud/stackit-sdk-go/services/rabbitmq/v2api" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" @@ -17,13 +17,15 @@ import ( type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &rabbitmq.APIClient{} +var testClient = &rabbitmq.APIClient{DefaultAPI: &rabbitmq.DefaultAPIService{}} var testProjectId = uuid.NewString() var testInstanceId = uuid.NewString() +var testRegion = "eu01" func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string { flagValues := map[string]string{ globalflags.ProjectIdFlag: testProjectId, + globalflags.RegionFlag: testRegion, instanceIdFlag: testInstanceId, } for _, mod := range mods { @@ -36,6 +38,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { model := &inputModel{ GlobalFlagModel: &globalflags.GlobalFlagModel{ ProjectId: testProjectId, + Region: testRegion, Verbosity: globalflags.VerbosityDefault, }, InstanceId: testInstanceId, @@ -47,7 +50,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *rabbitmq.ApiCreateCredentialsRequest)) rabbitmq.ApiCreateCredentialsRequest { - request := testClient.CreateCredentials(testCtx, testProjectId, testInstanceId) + request := testClient.DefaultAPI.CreateCredentials(testCtx, testProjectId, testRegion, testInstanceId) for _, mod := range mods { mod(&request) } @@ -153,7 +156,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, rabbitmq.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/rabbitmq/credentials/delete/delete.go b/internal/cmd/rabbitmq/credentials/delete/delete.go index a30d2e9d0..8defa0092 100644 --- a/internal/cmd/rabbitmq/credentials/delete/delete.go +++ b/internal/cmd/rabbitmq/credentials/delete/delete.go @@ -17,7 +17,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/rabbitmq" + rabbitmq "github.com/stackitcloud/stackit-sdk-go/services/rabbitmq/v2api" ) const ( @@ -56,13 +56,13 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return err } - instanceLabel, err := rabbitmqUtils.GetInstanceName(ctx, apiClient, model.ProjectId, model.InstanceId) + instanceLabel, err := rabbitmqUtils.GetInstanceName(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, model.InstanceId) if err != nil { params.Printer.Debug(print.ErrorLevel, "get instance name: %v", err) instanceLabel = model.InstanceId } - credentialsLabel, err := rabbitmqUtils.GetCredentialsUsername(ctx, apiClient, model.ProjectId, model.InstanceId, model.CredentialsId) + credentialsLabel, err := rabbitmqUtils.GetCredentialsUsername(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, model.InstanceId, model.CredentialsId) if err != nil { params.Printer.Debug(print.ErrorLevel, "get credentials user name: %v", err) credentialsLabel = model.CredentialsId @@ -115,6 +115,6 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *rabbitmq.APIClient) rabbitmq.ApiDeleteCredentialsRequest { - req := apiClient.DeleteCredentials(ctx, model.ProjectId, model.InstanceId, model.CredentialsId) + req := apiClient.DefaultAPI.DeleteCredentials(ctx, model.ProjectId, model.Region, model.InstanceId, model.CredentialsId) return req } diff --git a/internal/cmd/rabbitmq/credentials/delete/delete_test.go b/internal/cmd/rabbitmq/credentials/delete/delete_test.go index 176138ad9..4e31acc35 100644 --- a/internal/cmd/rabbitmq/credentials/delete/delete_test.go +++ b/internal/cmd/rabbitmq/credentials/delete/delete_test.go @@ -10,14 +10,15 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/rabbitmq" + rabbitmq "github.com/stackitcloud/stackit-sdk-go/services/rabbitmq/v2api" ) type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &rabbitmq.APIClient{} +var testClient = &rabbitmq.APIClient{DefaultAPI: &rabbitmq.DefaultAPIService{}} var testProjectId = uuid.NewString() +var testRegion = "eu01" var testInstanceId = uuid.NewString() var testCredentialsId = uuid.NewString() @@ -34,6 +35,7 @@ func fixtureArgValues(mods ...func(argValues []string)) []string { func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string { flagValues := map[string]string{ globalflags.ProjectIdFlag: testProjectId, + globalflags.RegionFlag: testRegion, instanceIdFlag: testInstanceId, } for _, mod := range mods { @@ -46,6 +48,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { model := &inputModel{ GlobalFlagModel: &globalflags.GlobalFlagModel{ ProjectId: testProjectId, + Region: testRegion, Verbosity: globalflags.VerbosityDefault, }, InstanceId: testInstanceId, @@ -58,7 +61,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *rabbitmq.ApiDeleteCredentialsRequest)) rabbitmq.ApiDeleteCredentialsRequest { - request := testClient.DeleteCredentials(testCtx, testProjectId, testInstanceId, testCredentialsId) + request := testClient.DefaultAPI.DeleteCredentials(testCtx, testProjectId, testRegion, testInstanceId, testCredentialsId) for _, mod := range mods { mod(&request) } @@ -186,7 +189,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, rabbitmq.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/rabbitmq/credentials/describe/describe.go b/internal/cmd/rabbitmq/credentials/describe/describe.go index e17a39f73..820560667 100644 --- a/internal/cmd/rabbitmq/credentials/describe/describe.go +++ b/internal/cmd/rabbitmq/credentials/describe/describe.go @@ -17,7 +17,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/rabbitmq" + rabbitmq "github.com/stackitcloud/stackit-sdk-go/services/rabbitmq/v2api" ) const ( @@ -99,7 +99,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *rabbitmq.APIClient) rabbitmq.ApiGetCredentialsRequest { - req := apiClient.GetCredentials(ctx, model.ProjectId, model.InstanceId, model.CredentialsId) + req := apiClient.DefaultAPI.GetCredentials(ctx, model.ProjectId, model.Region, model.InstanceId, model.CredentialsId) return req } @@ -110,15 +110,15 @@ func outputResult(p *print.Printer, outputFormat string, credentials *rabbitmq.C return p.OutputResult(outputFormat, credentials, func() error { table := tables.NewTable() - table.AddRow("ID", utils.PtrString(credentials.Id)) + table.AddRow("ID", credentials.Id) table.AddSeparator() // The username field cannot be set by the user so we only display it if it's not returned empty - if credentials.HasRaw() && credentials.Raw.Credentials != nil { - if username := credentials.Raw.Credentials.Username; username != nil && *username != "" { - table.AddRow("USERNAME", *username) + if credentials.HasRaw() { + if username := credentials.Raw.Credentials.Username; username != "" { + table.AddRow("USERNAME", username) table.AddSeparator() } - table.AddRow("PASSWORD", utils.PtrString(credentials.Raw.Credentials.Password)) + table.AddRow("PASSWORD", credentials.Raw.Credentials.Password) table.AddSeparator() table.AddRow("URI", utils.PtrString(credentials.Raw.Credentials.Uri)) } diff --git a/internal/cmd/rabbitmq/credentials/describe/describe_test.go b/internal/cmd/rabbitmq/credentials/describe/describe_test.go index 3f6fb1f1a..580ec41ff 100644 --- a/internal/cmd/rabbitmq/credentials/describe/describe_test.go +++ b/internal/cmd/rabbitmq/credentials/describe/describe_test.go @@ -7,7 +7,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/rabbitmq" + rabbitmq "github.com/stackitcloud/stackit-sdk-go/services/rabbitmq/v2api" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" @@ -17,8 +17,9 @@ import ( type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &rabbitmq.APIClient{} +var testClient = &rabbitmq.APIClient{DefaultAPI: &rabbitmq.DefaultAPIService{}} var testProjectId = uuid.NewString() +var testRegion = "eu01" var testInstanceId = uuid.NewString() var testCredentialsId = uuid.NewString() @@ -35,6 +36,7 @@ func fixtureArgValues(mods ...func(argValues []string)) []string { func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string { flagValues := map[string]string{ globalflags.ProjectIdFlag: testProjectId, + globalflags.RegionFlag: testRegion, instanceIdFlag: testInstanceId, } for _, mod := range mods { @@ -47,6 +49,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { model := &inputModel{ GlobalFlagModel: &globalflags.GlobalFlagModel{ ProjectId: testProjectId, + Region: testRegion, Verbosity: globalflags.VerbosityDefault, }, InstanceId: testInstanceId, @@ -59,7 +62,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *rabbitmq.ApiGetCredentialsRequest)) rabbitmq.ApiGetCredentialsRequest { - request := testClient.GetCredentials(testCtx, testProjectId, testInstanceId, testCredentialsId) + request := testClient.DefaultAPI.GetCredentials(testCtx, testProjectId, testRegion, testInstanceId, testCredentialsId) for _, mod := range mods { mod(&request) } @@ -187,7 +190,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, rabbitmq.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/rabbitmq/credentials/list/list.go b/internal/cmd/rabbitmq/credentials/list/list.go index 3c8b44a3c..1a3591147 100644 --- a/internal/cmd/rabbitmq/credentials/list/list.go +++ b/internal/cmd/rabbitmq/credentials/list/list.go @@ -7,7 +7,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/types" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/rabbitmq" + rabbitmq "github.com/stackitcloud/stackit-sdk-go/services/rabbitmq/v2api" "github.com/stackitcloud/stackit-cli/internal/pkg/args" "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -18,7 +18,6 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/services/rabbitmq/client" rabbitmqUtils "github.com/stackitcloud/stackit-cli/internal/pkg/services/rabbitmq/utils" "github.com/stackitcloud/stackit-cli/internal/pkg/tables" - "github.com/stackitcloud/stackit-cli/internal/pkg/utils" ) const ( @@ -70,7 +69,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } credentials := resp.GetCredentialsList() - instanceLabel, err := rabbitmqUtils.GetInstanceName(ctx, apiClient, model.ProjectId, model.InstanceId) + instanceLabel, err := rabbitmqUtils.GetInstanceName(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, model.InstanceId) if err != nil { params.Printer.Debug(print.ErrorLevel, "get instance name: %v", err) instanceLabel = model.InstanceId @@ -121,7 +120,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, } func buildRequest(ctx context.Context, model *inputModel, apiClient *rabbitmq.APIClient) rabbitmq.ApiListCredentialsRequest { - req := apiClient.ListCredentials(ctx, model.ProjectId, model.InstanceId) + req := apiClient.DefaultAPI.ListCredentials(ctx, model.ProjectId, model.Region, model.InstanceId) return req } @@ -136,7 +135,7 @@ func outputResult(p *print.Printer, outputFormat, instanceLabel string, credenti table.SetHeader("ID") for i := range credentials { c := credentials[i] - table.AddRow(utils.PtrString(c.Id)) + table.AddRow(c.Id) } err := table.Display(p) if err != nil { diff --git a/internal/cmd/rabbitmq/credentials/list/list_test.go b/internal/cmd/rabbitmq/credentials/list/list_test.go index 6f35a9b29..65fc5d867 100644 --- a/internal/cmd/rabbitmq/credentials/list/list_test.go +++ b/internal/cmd/rabbitmq/credentials/list/list_test.go @@ -7,7 +7,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/rabbitmq" + rabbitmq "github.com/stackitcloud/stackit-sdk-go/services/rabbitmq/v2api" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" @@ -18,13 +18,15 @@ import ( type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &rabbitmq.APIClient{} +var testClient = &rabbitmq.APIClient{DefaultAPI: &rabbitmq.DefaultAPIService{}} var testProjectId = uuid.NewString() +var testRegion = "eu01" var testInstanceId = uuid.NewString() func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string { flagValues := map[string]string{ globalflags.ProjectIdFlag: testProjectId, + globalflags.RegionFlag: testRegion, instanceIdFlag: testInstanceId, limitFlag: "10", } @@ -38,6 +40,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { model := &inputModel{ GlobalFlagModel: &globalflags.GlobalFlagModel{ ProjectId: testProjectId, + Region: testRegion, Verbosity: globalflags.VerbosityDefault, }, InstanceId: testInstanceId, @@ -50,7 +53,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *rabbitmq.ApiListCredentialsRequest)) rabbitmq.ApiListCredentialsRequest { - request := testClient.ListCredentials(testCtx, testProjectId, testInstanceId) + request := testClient.DefaultAPI.ListCredentials(testCtx, testProjectId, testRegion, testInstanceId) for _, mod := range mods { mod(&request) } @@ -160,7 +163,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, rabbitmq.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/rabbitmq/instance/create/create.go b/internal/cmd/rabbitmq/instance/create/create.go index cb2bf470a..8be9c6a37 100644 --- a/internal/cmd/rabbitmq/instance/create/create.go +++ b/internal/cmd/rabbitmq/instance/create/create.go @@ -21,8 +21,8 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/rabbitmq" - "github.com/stackitcloud/stackit-sdk-go/services/rabbitmq/wait" + rabbitmq "github.com/stackitcloud/stackit-sdk-go/services/rabbitmq/v2api" + wait "github.com/stackitcloud/stackit-sdk-go/services/rabbitmq/v2api/wait" ) const ( @@ -32,7 +32,6 @@ const ( metricsFrequencyFlag = "metrics-frequency" metricsPrefixFlag = "metrics-prefix" monitoringInstanceIdFlag = "monitoring-instance-id" - pluginFlag = "plugin" sgwAclFlag = "acl" syslogFlag = "syslog" planIdFlag = "plan-id" @@ -40,20 +39,26 @@ const ( versionFlag = "version" ) +var flagPlugins = flags.StringEnumSliceFlag( + "plugin", + rabbitmq.AllowedInstanceParametersPluginsInnerEnumValues, + "Plugins", +) + type inputModel struct { *globalflags.GlobalFlagModel PlanName string Version string - InstanceName *string + InstanceName string EnableMonitoring *bool Graphite *string - MetricsFrequency *int64 + MetricsFrequency *int32 MetricsPrefix *string MonitoringInstanceId *string - Plugin *[]string + Plugin []rabbitmq.InstanceParametersPluginsInner SgwAcl *[]string - Syslog *[]string + Syslog []string PlanId *string } @@ -100,7 +105,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } // Call API - req, err := buildRequest(ctx, model, apiClient) + req, err := buildRequest(ctx, model, apiClient.DefaultAPI) if err != nil { var dsaInvalidPlanError *cliErr.DSAInvalidPlanError if !errors.As(err, &dsaInvalidPlanError) { @@ -112,12 +117,12 @@ func NewCmd(params *types.CmdParams) *cobra.Command { if err != nil { return fmt.Errorf("create RabbitMQ instance: %w", err) } - instanceId := *resp.InstanceId + instanceId := resp.InstanceId // Wait for async operation, if async mode not enabled if !model.Async { err := spinner.Run(params.Printer, "Creating instance", func() error { - _, err = wait.CreateInstanceWaitHandler(ctx, apiClient, model.ProjectId, instanceId).WaitWithContext(ctx) + _, err = wait.CreateInstanceWaitHandler(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, instanceId).WaitWithContext(ctx) return err }) if err != nil { @@ -136,10 +141,10 @@ func configureFlags(cmd *cobra.Command) { cmd.Flags().StringP(instanceNameFlag, "n", "", "Instance name") cmd.Flags().Bool(enableMonitoringFlag, false, "Enable monitoring") cmd.Flags().String(graphiteFlag, "", "Graphite host") - cmd.Flags().Int64(metricsFrequencyFlag, 0, "Metrics frequency") + cmd.Flags().Int32(metricsFrequencyFlag, 0, "Metrics frequency") cmd.Flags().String(metricsPrefixFlag, "", "Metrics prefix") cmd.Flags().Var(flags.UUIDFlag(), monitoringInstanceIdFlag, "Monitoring instance ID") - cmd.Flags().StringSlice(pluginFlag, []string{}, "Plugin") + flagPlugins.Register(cmd) cmd.Flags().Var(flags.CIDRSliceFlag(), sgwAclFlag, "List of IP networks in CIDR notation which are allowed to access this instance") cmd.Flags().StringSlice(syslogFlag, []string{}, "Syslog") cmd.Flags().Var(flags.UUIDFlag(), planIdFlag, "Plan ID") @@ -173,15 +178,15 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, model := inputModel{ GlobalFlagModel: globalFlags, - InstanceName: flags.FlagToStringPointer(p, cmd, instanceNameFlag), + InstanceName: flags.FlagToStringValue(p, cmd, instanceNameFlag), EnableMonitoring: flags.FlagToBoolPointer(p, cmd, enableMonitoringFlag), MonitoringInstanceId: flags.FlagToStringPointer(p, cmd, monitoringInstanceIdFlag), Graphite: flags.FlagToStringPointer(p, cmd, graphiteFlag), - MetricsFrequency: flags.FlagToInt64Pointer(p, cmd, metricsFrequencyFlag), + MetricsFrequency: flags.FlagToInt32Pointer(p, cmd, metricsFrequencyFlag), MetricsPrefix: flags.FlagToStringPointer(p, cmd, metricsPrefixFlag), - Plugin: flags.FlagToStringSlicePointer(p, cmd, pluginFlag), + Plugin: flagPlugins.Get(), SgwAcl: flags.FlagToStringSlicePointer(p, cmd, sgwAclFlag), - Syslog: flags.FlagToStringSlicePointer(p, cmd, syslogFlag), + Syslog: flags.FlagToStringSliceValue(p, cmd, syslogFlag), PlanId: planId, PlanName: planName, Version: version, @@ -192,23 +197,23 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, } type rabbitMQClient interface { - CreateInstance(ctx context.Context, projectId string) rabbitmq.ApiCreateInstanceRequest - ListOfferingsExecute(ctx context.Context, projectId string) (*rabbitmq.ListOfferingsResponse, error) + CreateInstance(ctx context.Context, projectId, region string) rabbitmq.ApiCreateInstanceRequest + ListOfferings(ctx context.Context, projectId, region string) rabbitmq.ApiListOfferingsRequest } func buildRequest(ctx context.Context, model *inputModel, apiClient rabbitMQClient) (rabbitmq.ApiCreateInstanceRequest, error) { - req := apiClient.CreateInstance(ctx, model.ProjectId) + req := apiClient.CreateInstance(ctx, model.ProjectId, model.Region) - var planId *string + var planId string var err error - offerings, err := apiClient.ListOfferingsExecute(ctx, model.ProjectId) + offerings, err := apiClient.ListOfferings(ctx, model.ProjectId, model.Region).Execute() if err != nil { return req, fmt.Errorf("get RabbitMQ offerings: %w", err) } if model.PlanId == nil { - planId, err = rabbitmqUtils.LoadPlanId(model.PlanName, model.Version, offerings) + foundPlanId, err := rabbitmqUtils.LoadPlanId(model.PlanName, model.Version, offerings) if err != nil { var dsaInvalidPlanError *cliErr.DSAInvalidPlanError if !errors.As(err, &dsaInvalidPlanError) { @@ -216,12 +221,13 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient rabbitMQClie } return req, err } + planId = *foundPlanId } else { err := rabbitmqUtils.ValidatePlanId(*model.PlanId, offerings) if err != nil { return req, err } - planId = model.PlanId + planId = *model.PlanId } var sgwAcl *string diff --git a/internal/cmd/rabbitmq/instance/create/create_test.go b/internal/cmd/rabbitmq/instance/create/create_test.go index 3f722392a..e14e3a0b6 100644 --- a/internal/cmd/rabbitmq/instance/create/create_test.go +++ b/internal/cmd/rabbitmq/instance/create/create_test.go @@ -11,7 +11,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/rabbitmq" + rabbitmq "github.com/stackitcloud/stackit-sdk-go/services/rabbitmq/v2api" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/utils" @@ -20,38 +20,42 @@ import ( type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &rabbitmq.APIClient{} +var testClient = &rabbitmq.APIClient{DefaultAPI: &rabbitmq.DefaultAPIService{}} -type rabbitMQClientMocked struct { +type mockSettings struct { returnError bool listOfferingsResp *rabbitmq.ListOfferingsResponse } -func (c *rabbitMQClientMocked) CreateInstance(ctx context.Context, projectId string) rabbitmq.ApiCreateInstanceRequest { - return testClient.CreateInstance(ctx, projectId) -} - -func (c *rabbitMQClientMocked) ListOfferingsExecute(_ context.Context, _ string) (*rabbitmq.ListOfferingsResponse, error) { - if c.returnError { - return nil, fmt.Errorf("list flavors failed") +func newAPIMock(settings mockSettings) rabbitmq.DefaultAPI { + return rabbitmq.DefaultAPIServiceMock{ + ListOfferingsExecuteMock: utils.Ptr(func(_ rabbitmq.ApiListOfferingsRequest) (*rabbitmq.ListOfferingsResponse, error) { + if settings.returnError { + return nil, fmt.Errorf("list flavors failed") + } + return settings.listOfferingsResp, nil + }), } - return c.listOfferingsResp, nil } var testProjectId = uuid.NewString() var testPlanId = uuid.NewString() var testMonitoringInstanceId = uuid.NewString() +var testInstanceName = "instance" + +const testRegion = "eu01" func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string { flagValues := map[string]string{ globalflags.ProjectIdFlag: testProjectId, + globalflags.RegionFlag: testRegion, instanceNameFlag: "example-name", enableMonitoringFlag: "true", graphiteFlag: "example-graphite", metricsFrequencyFlag: "100", metricsPrefixFlag: "example-prefix", monitoringInstanceIdFlag: testMonitoringInstanceId, - pluginFlag: "example-plugin", + flagPlugins.Name(): string(rabbitmq.INSTANCEPARAMETERSPLUGINSINNER_RABBITMQ_MQTT), sgwAclFlag: "198.51.100.14/24", syslogFlag: "example-syslog", planIdFlag: testPlanId, @@ -66,17 +70,18 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { model := &inputModel{ GlobalFlagModel: &globalflags.GlobalFlagModel{ ProjectId: testProjectId, + Region: testRegion, Verbosity: globalflags.VerbosityDefault, }, - InstanceName: utils.Ptr("example-name"), + InstanceName: "example-name", EnableMonitoring: utils.Ptr(true), Graphite: utils.Ptr("example-graphite"), - MetricsFrequency: utils.Ptr(int64(100)), + MetricsFrequency: utils.Ptr(int32(100)), MetricsPrefix: utils.Ptr("example-prefix"), MonitoringInstanceId: utils.Ptr(testMonitoringInstanceId), - Plugin: utils.Ptr([]string{"example-plugin"}), + Plugin: []rabbitmq.InstanceParametersPluginsInner{rabbitmq.INSTANCEPARAMETERSPLUGINSINNER_RABBITMQ_MQTT}, SgwAcl: utils.Ptr([]string{"198.51.100.14/24"}), - Syslog: utils.Ptr([]string{"example-syslog"}), + Syslog: []string{"example-syslog"}, PlanId: utils.Ptr(testPlanId), } for _, mod := range mods { @@ -86,20 +91,20 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *rabbitmq.ApiCreateInstanceRequest)) rabbitmq.ApiCreateInstanceRequest { - request := testClient.CreateInstance(testCtx, testProjectId) + request := testClient.DefaultAPI.CreateInstance(testCtx, testProjectId, testRegion) request = request.CreateInstancePayload(rabbitmq.CreateInstancePayload{ - InstanceName: utils.Ptr("example-name"), + InstanceName: "example-name", Parameters: &rabbitmq.InstanceParameters{ EnableMonitoring: utils.Ptr(true), Graphite: utils.Ptr("example-graphite"), - MetricsFrequency: utils.Ptr(int64(100)), + MetricsFrequency: utils.Ptr(int32(100)), MetricsPrefix: utils.Ptr("example-prefix"), MonitoringInstanceId: utils.Ptr(testMonitoringInstanceId), - Plugins: utils.Ptr([]string{"example-plugin"}), + Plugins: []rabbitmq.InstanceParametersPluginsInner{rabbitmq.INSTANCEPARAMETERSPLUGINSINNER_RABBITMQ_MQTT}, SgwAcl: utils.Ptr("198.51.100.14/24"), - Syslog: utils.Ptr([]string{"example-syslog"}), + Syslog: []string{"example-syslog"}, }, - PlanId: utils.Ptr(testPlanId), + PlanId: testPlanId, }) for _, mod := range mods { mod(&request) @@ -156,7 +161,7 @@ func TestParseInput(t *testing.T) { ProjectId: testProjectId, Verbosity: globalflags.VerbosityDefault, }, - InstanceName: utils.Ptr("example-name"), + InstanceName: "example-name", PlanId: utils.Ptr(testPlanId), }, }, @@ -178,10 +183,10 @@ func TestParseInput(t *testing.T) { Verbosity: globalflags.VerbosityDefault, }, PlanId: utils.Ptr(testPlanId), - InstanceName: utils.Ptr(""), + InstanceName: "", EnableMonitoring: utils.Ptr(false), Graphite: utils.Ptr(""), - MetricsFrequency: utils.Ptr(int64(0)), + MetricsFrequency: utils.Ptr(int32(0)), MetricsPrefix: utils.Ptr(""), }, }, @@ -254,12 +259,11 @@ func TestParseInput(t *testing.T) { { description: "repeated plugin flags", flagValues: fixtureFlagValues(), - pluginValues: []string{"example-plugin-1", "example-plugin-2"}, + pluginValues: []string{string(rabbitmq.INSTANCEPARAMETERSPLUGINSINNER_RABBITMQ_MQTT), string(rabbitmq.INSTANCEPARAMETERSPLUGINSINNER_RABBITMQ_CONSISTENT_HASH_EXCHANGE)}, isValid: true, expectedModel: fixtureInputModel(func(model *inputModel) { - model.Plugin = utils.Ptr( - append(*model.Plugin, "example-plugin-1", "example-plugin-2"), - ) + model.Plugin = + append(model.Plugin, rabbitmq.INSTANCEPARAMETERSPLUGINSINNER_RABBITMQ_MQTT, rabbitmq.INSTANCEPARAMETERSPLUGINSINNER_RABBITMQ_CONSISTENT_HASH_EXCHANGE) }), }, { @@ -268,9 +272,8 @@ func TestParseInput(t *testing.T) { syslogValues: []string{"example-syslog-1", "example-syslog-2"}, isValid: true, expectedModel: fixtureInputModel(func(model *inputModel) { - model.Syslog = utils.Ptr( - append(*model.Syslog, "example-syslog-1", "example-syslog-2"), - ) + model.Syslog = + append(model.Syslog, "example-syslog-1", "example-syslog-2") }), }, } @@ -278,9 +281,9 @@ func TestParseInput(t *testing.T) { for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { testutils.TestParseInputWithAdditionalFlags(t, NewCmd, parseInput, tt.expectedModel, tt.argValues, tt.flagValues, map[string][]string{ - sgwAclFlag: tt.sgwAclValues, - syslogFlag: tt.syslogValues, - pluginFlag: tt.pluginValues, + sgwAclFlag: tt.sgwAclValues, + syslogFlag: tt.syslogValues, + flagPlugins.Name(): tt.pluginValues, }, tt.isValid) }) } @@ -300,13 +303,13 @@ func TestBuildRequest(t *testing.T) { model: fixtureInputModel(), expectedRequest: fixtureRequest(), getOfferingsResp: &rabbitmq.ListOfferingsResponse{ - Offerings: &[]rabbitmq.Offering{ + Offerings: []rabbitmq.Offering{ { - Version: utils.Ptr("example-version"), - Plans: &[]rabbitmq.Plan{ + Version: "example-version", + Plans: []rabbitmq.Plan{ { - Name: utils.Ptr("example-plan-name"), - Id: utils.Ptr(testPlanId), + Name: "example-plan-name", + Id: testPlanId, }, }, }, @@ -324,13 +327,13 @@ func TestBuildRequest(t *testing.T) { ), expectedRequest: fixtureRequest(), getOfferingsResp: &rabbitmq.ListOfferingsResponse{ - Offerings: &[]rabbitmq.Offering{ + Offerings: []rabbitmq.Offering{ { - Version: utils.Ptr("example-version"), - Plans: &[]rabbitmq.Plan{ + Version: "example-version", + Plans: []rabbitmq.Plan{ { - Name: utils.Ptr("example-plan-name"), - Id: utils.Ptr(testPlanId), + Name: "example-plan-name", + Id: testPlanId, }, }, }, @@ -359,13 +362,13 @@ func TestBuildRequest(t *testing.T) { }, ), getOfferingsResp: &rabbitmq.ListOfferingsResponse{ - Offerings: &[]rabbitmq.Offering{ + Offerings: []rabbitmq.Offering{ { - Version: utils.Ptr("example-version"), - Plans: &[]rabbitmq.Plan{ + Version: "example-version", + Plans: []rabbitmq.Plan{ { - Name: utils.Ptr("other-plan-name"), - Id: utils.Ptr(testPlanId), + Name: "other-plan-name", + Id: testPlanId, }, }, }, @@ -376,37 +379,39 @@ func TestBuildRequest(t *testing.T) { { description: "required fields only", model: &inputModel{ + InstanceName: testInstanceName, GlobalFlagModel: &globalflags.GlobalFlagModel{ ProjectId: testProjectId, + Region: testRegion, Verbosity: globalflags.VerbosityDefault, }, PlanId: utils.Ptr(testPlanId), }, getOfferingsResp: &rabbitmq.ListOfferingsResponse{ - Offerings: &[]rabbitmq.Offering{ + Offerings: []rabbitmq.Offering{ { - Version: utils.Ptr("example-version"), - Plans: &[]rabbitmq.Plan{ + Version: "example-version", + Plans: []rabbitmq.Plan{ { - Name: utils.Ptr("example-plan-name"), - Id: utils.Ptr(testPlanId), + Name: "example-plan-name", + Id: testPlanId, }, }, }, }, }, - expectedRequest: testClient.CreateInstance(testCtx, testProjectId). - CreateInstancePayload(rabbitmq.CreateInstancePayload{PlanId: utils.Ptr(testPlanId), Parameters: &rabbitmq.InstanceParameters{}}), + expectedRequest: testClient.DefaultAPI.CreateInstance(testCtx, testProjectId, testRegion). + CreateInstancePayload(rabbitmq.CreateInstancePayload{InstanceName: testInstanceName, PlanId: testPlanId, Parameters: &rabbitmq.InstanceParameters{}}), }, } for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { - client := &rabbitMQClientMocked{ + settings := mockSettings{ returnError: tt.getOfferingsFails, listOfferingsResp: tt.getOfferingsResp, } - request, err := buildRequest(testCtx, tt.model, client) + request, err := buildRequest(testCtx, tt.model, newAPIMock(settings)) if err != nil { if !tt.isValid { return @@ -416,7 +421,10 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, rabbitmq.DefaultAPIService{}), + cmp.FilterPath(func(p cmp.Path) bool { + return p.String() == "ApiService" + }, cmp.Ignore()), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/rabbitmq/instance/delete/delete.go b/internal/cmd/rabbitmq/instance/delete/delete.go index ec5c35104..06d705609 100644 --- a/internal/cmd/rabbitmq/instance/delete/delete.go +++ b/internal/cmd/rabbitmq/instance/delete/delete.go @@ -17,8 +17,8 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/rabbitmq" - "github.com/stackitcloud/stackit-sdk-go/services/rabbitmq/wait" + rabbitmq "github.com/stackitcloud/stackit-sdk-go/services/rabbitmq/v2api" + wait "github.com/stackitcloud/stackit-sdk-go/services/rabbitmq/v2api/wait" ) const ( @@ -54,7 +54,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return err } - instanceLabel, err := rabbitmqUtils.GetInstanceName(ctx, apiClient, model.ProjectId, model.InstanceId) + instanceLabel, err := rabbitmqUtils.GetInstanceName(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, model.InstanceId) if err != nil { params.Printer.Debug(print.ErrorLevel, "get instance name: %v", err) instanceLabel = model.InstanceId @@ -76,7 +76,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { // Wait for async operation, if async mode not enabled if !model.Async { err := spinner.Run(params.Printer, "Deleting instance", func() error { - _, err = wait.DeleteInstanceWaitHandler(ctx, apiClient, model.ProjectId, model.InstanceId).WaitWithContext(ctx) + _, err = wait.DeleteInstanceWaitHandler(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, model.InstanceId).WaitWithContext(ctx) return err }) if err != nil { @@ -113,6 +113,6 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *rabbitmq.APIClient) rabbitmq.ApiDeleteInstanceRequest { - req := apiClient.DeleteInstance(ctx, model.ProjectId, model.InstanceId) + req := apiClient.DefaultAPI.DeleteInstance(ctx, model.ProjectId, model.Region, model.InstanceId) return req } diff --git a/internal/cmd/rabbitmq/instance/delete/delete_test.go b/internal/cmd/rabbitmq/instance/delete/delete_test.go index 4ffdd36a8..0670ebd87 100644 --- a/internal/cmd/rabbitmq/instance/delete/delete_test.go +++ b/internal/cmd/rabbitmq/instance/delete/delete_test.go @@ -10,16 +10,18 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/rabbitmq" + rabbitmq "github.com/stackitcloud/stackit-sdk-go/services/rabbitmq/v2api" ) type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &rabbitmq.APIClient{} +var testClient = &rabbitmq.APIClient{DefaultAPI: &rabbitmq.DefaultAPIService{}} var testProjectId = uuid.NewString() var testInstanceId = uuid.NewString() +const testRegion = "eu01" + func fixtureArgValues(mods ...func(argValues []string)) []string { argValues := []string{ testInstanceId, @@ -33,6 +35,7 @@ func fixtureArgValues(mods ...func(argValues []string)) []string { func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string { flagValues := map[string]string{ globalflags.ProjectIdFlag: testProjectId, + globalflags.RegionFlag: testRegion, } for _, mod := range mods { mod(flagValues) @@ -44,6 +47,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { model := &inputModel{ GlobalFlagModel: &globalflags.GlobalFlagModel{ ProjectId: testProjectId, + Region: testRegion, Verbosity: globalflags.VerbosityDefault, }, InstanceId: testInstanceId, @@ -55,7 +59,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *rabbitmq.ApiDeleteInstanceRequest)) rabbitmq.ApiDeleteInstanceRequest { - request := testClient.DeleteInstance(testCtx, testProjectId, testInstanceId) + request := testClient.DefaultAPI.DeleteInstance(testCtx, testProjectId, testRegion, testInstanceId) for _, mod := range mods { mod(&request) } @@ -159,7 +163,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, rabbitmq.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/rabbitmq/instance/describe/describe.go b/internal/cmd/rabbitmq/instance/describe/describe.go index 8385bfe7e..19dd2b928 100644 --- a/internal/cmd/rabbitmq/instance/describe/describe.go +++ b/internal/cmd/rabbitmq/instance/describe/describe.go @@ -16,7 +16,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/rabbitmq" + rabbitmq "github.com/stackitcloud/stackit-sdk-go/services/rabbitmq/v2api" ) const ( @@ -87,7 +87,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *rabbitmq.APIClient) rabbitmq.ApiGetInstanceRequest { - req := apiClient.GetInstance(ctx, model.ProjectId, model.InstanceId) + req := apiClient.DefaultAPI.GetInstance(ctx, model.ProjectId, model.Region, model.InstanceId) return req } @@ -100,18 +100,16 @@ func outputResult(p *print.Printer, outputFormat string, instance *rabbitmq.Inst table := tables.NewTable() table.AddRow("ID", utils.PtrString(instance.InstanceId)) table.AddSeparator() - table.AddRow("NAME", utils.PtrString(instance.Name)) + table.AddRow("NAME", instance.Name) table.AddSeparator() - if lastOperation := instance.LastOperation; lastOperation != nil { - table.AddRow("LAST OPERATION TYPE", utils.PtrString(lastOperation.Type)) - table.AddSeparator() - table.AddRow("LAST OPERATION STATE", utils.PtrString(lastOperation.State)) - table.AddSeparator() - } - table.AddRow("PLAN ID", utils.PtrString(instance.PlanId)) + table.AddRow("LAST OPERATION TYPE", instance.LastOperation.Type) + table.AddSeparator() + table.AddRow("LAST OPERATION STATE", instance.LastOperation.State) + table.AddSeparator() + table.AddRow("PLAN ID", instance.PlanId) // Only show ACL if it's present and not empty if parameters := instance.Parameters; parameters != nil { - acl := (*instance.Parameters)[aclParameterKey] + acl := instance.Parameters[aclParameterKey] aclStr, ok := acl.(string) if ok { if aclStr != "" { diff --git a/internal/cmd/rabbitmq/instance/describe/describe_test.go b/internal/cmd/rabbitmq/instance/describe/describe_test.go index 30043e006..76f4f5023 100644 --- a/internal/cmd/rabbitmq/instance/describe/describe_test.go +++ b/internal/cmd/rabbitmq/instance/describe/describe_test.go @@ -7,7 +7,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/rabbitmq" + rabbitmq "github.com/stackitcloud/stackit-sdk-go/services/rabbitmq/v2api" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" @@ -17,8 +17,9 @@ import ( type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &rabbitmq.APIClient{} +var testClient = &rabbitmq.APIClient{DefaultAPI: &rabbitmq.DefaultAPIService{}} var testProjectId = uuid.NewString() +var testRegion = "eu01" var testInstanceId = uuid.NewString() func fixtureArgValues(mods ...func(argValues []string)) []string { @@ -34,6 +35,7 @@ func fixtureArgValues(mods ...func(argValues []string)) []string { func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string { flagValues := map[string]string{ globalflags.ProjectIdFlag: testProjectId, + globalflags.RegionFlag: testRegion, } for _, mod := range mods { mod(flagValues) @@ -45,6 +47,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { model := &inputModel{ GlobalFlagModel: &globalflags.GlobalFlagModel{ ProjectId: testProjectId, + Region: testRegion, Verbosity: globalflags.VerbosityDefault, }, InstanceId: testInstanceId, @@ -56,7 +59,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *rabbitmq.ApiGetInstanceRequest)) rabbitmq.ApiGetInstanceRequest { - request := testClient.GetInstance(testCtx, testProjectId, testInstanceId) + request := testClient.DefaultAPI.GetInstance(testCtx, testProjectId, testRegion, testInstanceId) for _, mod := range mods { mod(&request) } @@ -160,7 +163,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, rabbitmq.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) @@ -194,7 +197,7 @@ func Test_outputResult(t *testing.T) { args: args{ outputFormat: "", instance: &rabbitmq.Instance{ - Parameters: &map[string]interface{}{ + Parameters: map[string]any{ "foo": nil, }, }, diff --git a/internal/cmd/rabbitmq/instance/list/list.go b/internal/cmd/rabbitmq/instance/list/list.go index 70e47500e..c2b75ecca 100644 --- a/internal/cmd/rabbitmq/instance/list/list.go +++ b/internal/cmd/rabbitmq/instance/list/list.go @@ -7,7 +7,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/types" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/rabbitmq" + rabbitmq "github.com/stackitcloud/stackit-sdk-go/services/rabbitmq/v2api" "github.com/stackitcloud/stackit-cli/internal/pkg/args" "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -115,7 +115,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, } func buildRequest(ctx context.Context, model *inputModel, apiClient *rabbitmq.APIClient) rabbitmq.ApiListInstancesRequest { - req := apiClient.ListInstances(ctx, model.ProjectId) + req := apiClient.DefaultAPI.ListInstances(ctx, model.ProjectId, model.Region) return req } @@ -133,15 +133,11 @@ func outputResult(p *print.Printer, outputFormat, projectLabel string, instances var ( opType, opState string ) - if lastOperation := instance.LastOperation; lastOperation != nil { - opType = utils.PtrString(lastOperation.Type) - opState = utils.PtrString(lastOperation.State) - } else { - opType, opState = "n/a", "n/a" - } + opType = string(instance.LastOperation.Type) + opState = string(instance.LastOperation.State) table.AddRow( utils.PtrString(instance.InstanceId), - utils.PtrString(instance.Name), + instance.Name, opType, opState, ) diff --git a/internal/cmd/rabbitmq/instance/list/list_test.go b/internal/cmd/rabbitmq/instance/list/list_test.go index 347758b2d..d123d6c88 100644 --- a/internal/cmd/rabbitmq/instance/list/list_test.go +++ b/internal/cmd/rabbitmq/instance/list/list_test.go @@ -7,7 +7,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/rabbitmq" + rabbitmq "github.com/stackitcloud/stackit-sdk-go/services/rabbitmq/v2api" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" @@ -18,12 +18,14 @@ import ( type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &rabbitmq.APIClient{} +var testClient = &rabbitmq.APIClient{DefaultAPI: &rabbitmq.DefaultAPIService{}} var testProjectId = uuid.NewString() +var testRegion = "eu01" func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string { flagValues := map[string]string{ globalflags.ProjectIdFlag: testProjectId, + globalflags.RegionFlag: testRegion, limitFlag: "10", } for _, mod := range mods { @@ -36,6 +38,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { model := &inputModel{ GlobalFlagModel: &globalflags.GlobalFlagModel{ ProjectId: testProjectId, + Region: testRegion, Verbosity: globalflags.VerbosityDefault, }, Limit: utils.Ptr(int64(10)), @@ -47,7 +50,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *rabbitmq.ApiListInstancesRequest)) rabbitmq.ApiListInstancesRequest { - request := testClient.ListInstances(testCtx, testProjectId) + request := testClient.DefaultAPI.ListInstances(testCtx, testProjectId, testRegion) for _, mod := range mods { mod(&request) } @@ -136,7 +139,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, rabbitmq.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/rabbitmq/instance/update/update.go b/internal/cmd/rabbitmq/instance/update/update.go index b58590a6e..60582d027 100644 --- a/internal/cmd/rabbitmq/instance/update/update.go +++ b/internal/cmd/rabbitmq/instance/update/update.go @@ -20,8 +20,8 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/rabbitmq" - "github.com/stackitcloud/stackit-sdk-go/services/rabbitmq/wait" + rabbitmq "github.com/stackitcloud/stackit-sdk-go/services/rabbitmq/v2api" + wait "github.com/stackitcloud/stackit-sdk-go/services/rabbitmq/v2api/wait" ) const ( @@ -33,7 +33,6 @@ const ( metricsFrequencyFlag = "metrics-frequency" metricsPrefixFlag = "metrics-prefix" monitoringInstanceIdFlag = "monitoring-instance-id" - pluginFlag = "plugin" sgwAclFlag = "acl" syslogFlag = "syslog" planIdFlag = "plan-id" @@ -41,6 +40,12 @@ const ( versionFlag = "version" ) +var flagPlugins = flags.StringEnumSliceFlag( + "plugin", + rabbitmq.AllowedInstanceParametersPluginsInnerEnumValues, + "Plugins", +) + type inputModel struct { *globalflags.GlobalFlagModel InstanceId string @@ -49,12 +54,12 @@ type inputModel struct { EnableMonitoring *bool Graphite *string - MetricsFrequency *int64 + MetricsFrequency *int32 MetricsPrefix *string MonitoringInstanceId *string - Plugin *[]string + Plugin []rabbitmq.InstanceParametersPluginsInner SgwAcl *[]string - Syslog *[]string + Syslog []string PlanId *string } @@ -85,7 +90,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return err } - instanceLabel, err := rabbitmqUtils.GetInstanceName(ctx, apiClient, model.ProjectId, model.InstanceId) + instanceLabel, err := rabbitmqUtils.GetInstanceName(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, model.InstanceId) if err != nil { params.Printer.Debug(print.ErrorLevel, "get instance name: %v", err) instanceLabel = model.InstanceId @@ -98,7 +103,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } // Call API - req, err := buildRequest(ctx, model, apiClient) + req, err := buildRequest(ctx, model, apiClient.DefaultAPI) if err != nil { var dsaInvalidPlanError *cliErr.DSAInvalidPlanError if !errors.As(err, &dsaInvalidPlanError) { @@ -115,7 +120,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { // Wait for async operation, if async mode not enabled if !model.Async { err := spinner.Run(params.Printer, "Updating instance", func() error { - _, err = wait.PartialUpdateInstanceWaitHandler(ctx, apiClient, model.ProjectId, instanceId).WaitWithContext(ctx) + _, err = wait.PartialUpdateInstanceWaitHandler(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, instanceId).WaitWithContext(ctx) return err }) if err != nil { @@ -138,10 +143,10 @@ func NewCmd(params *types.CmdParams) *cobra.Command { func configureFlags(cmd *cobra.Command) { cmd.Flags().Bool(enableMonitoringFlag, false, "Enable monitoring") cmd.Flags().String(graphiteFlag, "", "Graphite host") - cmd.Flags().Int64(metricsFrequencyFlag, 0, "Metrics frequency") + cmd.Flags().Int32(metricsFrequencyFlag, 0, "Metrics frequency") cmd.Flags().String(metricsPrefixFlag, "", "Metrics prefix") cmd.Flags().Var(flags.UUIDFlag(), monitoringInstanceIdFlag, "Monitoring instance ID") - cmd.Flags().StringSlice(pluginFlag, []string{}, "Plugin") + flagPlugins.Register(cmd) cmd.Flags().Var(flags.CIDRSliceFlag(), sgwAclFlag, "List of IP networks in CIDR notation which are allowed to access this instance") cmd.Flags().StringSlice(syslogFlag, []string{}, "Syslog") cmd.Flags().Var(flags.UUIDFlag(), planIdFlag, "Plan ID") @@ -160,11 +165,11 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu enableMonitoring := flags.FlagToBoolPointer(p, cmd, enableMonitoringFlag) monitoringInstanceId := flags.FlagToStringPointer(p, cmd, monitoringInstanceIdFlag) graphite := flags.FlagToStringPointer(p, cmd, graphiteFlag) - metricsFrequency := flags.FlagToInt64Pointer(p, cmd, metricsFrequencyFlag) + metricsFrequency := flags.FlagToInt32Pointer(p, cmd, metricsFrequencyFlag) metricsPrefix := flags.FlagToStringPointer(p, cmd, metricsPrefixFlag) - plugin := flags.FlagToStringSlicePointer(p, cmd, pluginFlag) + plugin := flagPlugins.Get() sgwAcl := flags.FlagToStringSlicePointer(p, cmd, sgwAclFlag) - syslog := flags.FlagToStringSlicePointer(p, cmd, syslogFlag) + syslog := flags.FlagToStringSliceValue(p, cmd, syslogFlag) planId := flags.FlagToStringPointer(p, cmd, planIdFlag) planName := flags.FlagToStringValue(p, cmd, planNameFlag) version := flags.FlagToStringValue(p, cmd, versionFlag) @@ -204,17 +209,17 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } type rabbitMQClient interface { - PartialUpdateInstance(ctx context.Context, projectId, instanceId string) rabbitmq.ApiPartialUpdateInstanceRequest - ListOfferingsExecute(ctx context.Context, projectId string) (*rabbitmq.ListOfferingsResponse, error) + PartialUpdateInstance(ctx context.Context, projectId, regionId, instanceId string) rabbitmq.ApiPartialUpdateInstanceRequest + ListOfferings(ctx context.Context, projectId, regionId string) rabbitmq.ApiListOfferingsRequest } func buildRequest(ctx context.Context, model *inputModel, apiClient rabbitMQClient) (rabbitmq.ApiPartialUpdateInstanceRequest, error) { - req := apiClient.PartialUpdateInstance(ctx, model.ProjectId, model.InstanceId) + req := apiClient.PartialUpdateInstance(ctx, model.ProjectId, model.Region, model.InstanceId) var planId *string var err error - offerings, err := apiClient.ListOfferingsExecute(ctx, model.ProjectId) + offerings, err := apiClient.ListOfferings(ctx, model.ProjectId, model.Region).Execute() if err != nil { return req, fmt.Errorf("get RabbitMQ offerings: %w", err) } diff --git a/internal/cmd/rabbitmq/instance/update/update_test.go b/internal/cmd/rabbitmq/instance/update/update_test.go index bc50cea83..b636409c9 100644 --- a/internal/cmd/rabbitmq/instance/update/update_test.go +++ b/internal/cmd/rabbitmq/instance/update/update_test.go @@ -6,39 +6,40 @@ import ( "testing" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" - "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" + "github.com/stackitcloud/stackit-cli/internal/pkg/testutils" "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/rabbitmq" + rabbitmq "github.com/stackitcloud/stackit-sdk-go/services/rabbitmq/v2api" ) type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &rabbitmq.APIClient{} +var testClient = &rabbitmq.APIClient{DefaultAPI: &rabbitmq.DefaultAPIService{}} -type rabbitMQClientMocked struct { +type mockSettings struct { returnError bool listOfferingsResp *rabbitmq.ListOfferingsResponse } -func (c *rabbitMQClientMocked) PartialUpdateInstance(ctx context.Context, projectId, instanceId string) rabbitmq.ApiPartialUpdateInstanceRequest { - return testClient.PartialUpdateInstance(ctx, projectId, instanceId) -} - -func (c *rabbitMQClientMocked) ListOfferingsExecute(_ context.Context, _ string) (*rabbitmq.ListOfferingsResponse, error) { - if c.returnError { - return nil, fmt.Errorf("list flavors failed") +func newAPIMock(settings mockSettings) rabbitmq.DefaultAPI { + return rabbitmq.DefaultAPIServiceMock{ + ListOfferingsExecuteMock: utils.Ptr(func(_ rabbitmq.ApiListOfferingsRequest) (*rabbitmq.ListOfferingsResponse, error) { + if settings.returnError { + return nil, fmt.Errorf("list flavors failed") + } + return settings.listOfferingsResp, nil + }), } - return c.listOfferingsResp, nil } var ( testProjectId = uuid.NewString() testInstanceId = uuid.NewString() + testRegion = "eu01" testPlanId = uuid.NewString() testMonitoringInstanceId = uuid.NewString() ) @@ -56,12 +57,13 @@ func fixtureArgValues(mods ...func(argValues []string)) []string { func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string { flagValues := map[string]string{ globalflags.ProjectIdFlag: testProjectId, + globalflags.RegionFlag: testRegion, enableMonitoringFlag: "true", graphiteFlag: "example-graphite", metricsFrequencyFlag: "100", metricsPrefixFlag: "example-prefix", monitoringInstanceIdFlag: testMonitoringInstanceId, - pluginFlag: "example-plugin", + flagPlugins.Name(): string(rabbitmq.INSTANCEPARAMETERSPLUGINSINNER_RABBITMQ_MQTT), sgwAclFlag: "198.51.100.14/24", syslogFlag: "example-syslog", planIdFlag: testPlanId, @@ -76,17 +78,18 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { model := &inputModel{ GlobalFlagModel: &globalflags.GlobalFlagModel{ ProjectId: testProjectId, + Region: testRegion, Verbosity: globalflags.VerbosityDefault, }, InstanceId: testInstanceId, EnableMonitoring: utils.Ptr(true), Graphite: utils.Ptr("example-graphite"), - MetricsFrequency: utils.Ptr(int64(100)), + MetricsFrequency: utils.Ptr(int32(100)), MetricsPrefix: utils.Ptr("example-prefix"), MonitoringInstanceId: utils.Ptr(testMonitoringInstanceId), - Plugin: utils.Ptr([]string{"example-plugin"}), + Plugin: []rabbitmq.InstanceParametersPluginsInner{rabbitmq.INSTANCEPARAMETERSPLUGINSINNER_RABBITMQ_MQTT}, SgwAcl: utils.Ptr([]string{"198.51.100.14/24"}), - Syslog: utils.Ptr([]string{"example-syslog"}), + Syslog: []string{"example-syslog"}, PlanId: utils.Ptr(testPlanId), } for _, mod := range mods { @@ -96,17 +99,17 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *rabbitmq.ApiPartialUpdateInstanceRequest)) rabbitmq.ApiPartialUpdateInstanceRequest { - request := testClient.PartialUpdateInstance(testCtx, testProjectId, testInstanceId) + request := testClient.DefaultAPI.PartialUpdateInstance(testCtx, testProjectId, testRegion, testInstanceId) request = request.PartialUpdateInstancePayload(rabbitmq.PartialUpdateInstancePayload{ Parameters: &rabbitmq.InstanceParameters{ EnableMonitoring: utils.Ptr(true), Graphite: utils.Ptr("example-graphite"), - MetricsFrequency: utils.Ptr(int64(100)), + MetricsFrequency: utils.Ptr(int32(100)), MetricsPrefix: utils.Ptr("example-prefix"), MonitoringInstanceId: utils.Ptr(testMonitoringInstanceId), - Plugins: utils.Ptr([]string{"example-plugin"}), + Plugins: []rabbitmq.InstanceParametersPluginsInner{rabbitmq.INSTANCEPARAMETERSPLUGINSINNER_RABBITMQ_MQTT}, SgwAcl: utils.Ptr("198.51.100.14/24"), - Syslog: utils.Ptr([]string{"example-syslog"}), + Syslog: []string{"example-syslog"}, }, PlanId: utils.Ptr(testPlanId), }) @@ -188,7 +191,7 @@ func TestParseInput(t *testing.T) { PlanId: utils.Ptr(testPlanId), EnableMonitoring: utils.Ptr(false), Graphite: utils.Ptr(""), - MetricsFrequency: utils.Ptr(int64(0)), + MetricsFrequency: utils.Ptr(int32(0)), MetricsPrefix: utils.Ptr(""), }, }, @@ -267,12 +270,11 @@ func TestParseInput(t *testing.T) { description: "repeated plugin flags", argValues: fixtureArgValues(), flagValues: fixtureFlagValues(), - pluginValues: []string{"example-plugin-1", "example-plugin-2"}, + pluginValues: []string{string(rabbitmq.INSTANCEPARAMETERSPLUGINSINNER_RABBITMQ_MQTT), string(rabbitmq.INSTANCEPARAMETERSPLUGINSINNER_RABBITMQ_CONSISTENT_HASH_EXCHANGE)}, isValid: true, expectedModel: fixtureInputModel(func(model *inputModel) { - model.Plugin = utils.Ptr( - append(*model.Plugin, "example-plugin-1", "example-plugin-2"), - ) + model.Plugin = + append(model.Plugin, rabbitmq.INSTANCEPARAMETERSPLUGINSINNER_RABBITMQ_MQTT, rabbitmq.INSTANCEPARAMETERSPLUGINSINNER_RABBITMQ_CONSISTENT_HASH_EXCHANGE) }), }, { @@ -282,93 +284,19 @@ func TestParseInput(t *testing.T) { syslogValues: []string{"example-syslog-1", "example-syslog-2"}, isValid: true, expectedModel: fixtureInputModel(func(model *inputModel) { - model.Syslog = utils.Ptr( - append(*model.Syslog, "example-syslog-1", "example-syslog-2"), - ) + model.Syslog = + append(model.Syslog, "example-syslog-1", "example-syslog-2") }), }, } for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { - params := testparams.NewTestParams() - cmd := NewCmd(params.CmdParams) - err := globalflags.Configure(cmd.Flags()) - if err != nil { - t.Fatalf("configure global flags: %v", err) - } - - for flag, value := range tt.flagValues { - err := cmd.Flags().Set(flag, value) - if err != nil { - if !tt.isValid { - return - } - t.Fatalf("setting flag --%s=%s: %v", flag, value, err) - } - } - - for _, value := range tt.sgwAclValues { - err := cmd.Flags().Set(sgwAclFlag, value) - if err != nil { - if !tt.isValid { - return - } - t.Fatalf("setting flag --%s=%s: %v", sgwAclFlag, value, err) - } - } - - for _, value := range tt.pluginValues { - err := cmd.Flags().Set(pluginFlag, value) - if err != nil { - if !tt.isValid { - return - } - t.Fatalf("setting flag --%s=%s: %v", pluginFlag, value, err) - } - } - - for _, value := range tt.syslogValues { - err := cmd.Flags().Set(syslogFlag, value) - if err != nil { - if !tt.isValid { - return - } - t.Fatalf("setting flag --%s=%s: %v", syslogFlag, value, err) - } - } - - err = cmd.ValidateArgs(tt.argValues) - if err != nil { - if !tt.isValid { - return - } - t.Fatalf("error validating args: %v", err) - } - - err = cmd.ValidateRequiredFlags() - if err != nil { - if !tt.isValid { - return - } - t.Fatalf("error validating flags: %v", err) - } - - model, err := parseInput(params.Printer, cmd, tt.argValues) - if err != nil { - if !tt.isValid { - return - } - t.Fatalf("error parsing flags: %v", err) - } - - if !tt.isValid { - t.Fatalf("did not fail on invalid input") - } - diff := cmp.Diff(model, tt.expectedModel) - if diff != "" { - t.Fatalf("Data does not match: %s", diff) - } + testutils.TestParseInputWithAdditionalFlags(t, NewCmd, parseInput, tt.expectedModel, tt.argValues, tt.flagValues, map[string][]string{ + sgwAclFlag: tt.sgwAclValues, + syslogFlag: tt.syslogValues, + flagPlugins.Name(): tt.pluginValues, + }, tt.isValid) }) } } @@ -387,13 +315,13 @@ func TestBuildRequest(t *testing.T) { model: fixtureInputModel(), expectedRequest: fixtureRequest(), listOfferingsResp: &rabbitmq.ListOfferingsResponse{ - Offerings: &[]rabbitmq.Offering{ + Offerings: []rabbitmq.Offering{ { - Version: utils.Ptr("example-version"), - Plans: &[]rabbitmq.Plan{ + Version: "example-version", + Plans: []rabbitmq.Plan{ { - Name: utils.Ptr("example-plan-name"), - Id: utils.Ptr(testPlanId), + Name: "example-plan-name", + Id: testPlanId, }, }, }, @@ -411,13 +339,13 @@ func TestBuildRequest(t *testing.T) { ), expectedRequest: fixtureRequest(), listOfferingsResp: &rabbitmq.ListOfferingsResponse{ - Offerings: &[]rabbitmq.Offering{ + Offerings: []rabbitmq.Offering{ { - Version: utils.Ptr("example-version"), - Plans: &[]rabbitmq.Plan{ + Version: "example-version", + Plans: []rabbitmq.Plan{ { - Name: utils.Ptr("example-plan-name"), - Id: utils.Ptr(testPlanId), + Name: "example-plan-name", + Id: testPlanId, }, }, }, @@ -446,13 +374,13 @@ func TestBuildRequest(t *testing.T) { }, ), listOfferingsResp: &rabbitmq.ListOfferingsResponse{ - Offerings: &[]rabbitmq.Offering{ + Offerings: []rabbitmq.Offering{ { - Version: utils.Ptr("example-version"), - Plans: &[]rabbitmq.Plan{ + Version: "example-version", + Plans: []rabbitmq.Plan{ { - Name: utils.Ptr("other-plan-name"), - Id: utils.Ptr(testPlanId), + Name: "other-plan-name", + Id: testPlanId, }, }, }, @@ -465,22 +393,23 @@ func TestBuildRequest(t *testing.T) { model: &inputModel{ GlobalFlagModel: &globalflags.GlobalFlagModel{ ProjectId: testProjectId, + Region: testRegion, Verbosity: globalflags.VerbosityDefault, }, InstanceId: testInstanceId, }, - expectedRequest: testClient.PartialUpdateInstance(testCtx, testProjectId, testInstanceId). + expectedRequest: testClient.DefaultAPI.PartialUpdateInstance(testCtx, testProjectId, testRegion, testInstanceId). PartialUpdateInstancePayload(rabbitmq.PartialUpdateInstancePayload{Parameters: &rabbitmq.InstanceParameters{}}), }, } for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { - client := &rabbitMQClientMocked{ + settings := mockSettings{ returnError: tt.getOfferingsFails, listOfferingsResp: tt.listOfferingsResp, } - request, err := buildRequest(testCtx, tt.model, client) + request, err := buildRequest(testCtx, tt.model, newAPIMock(settings)) if err != nil { if !tt.isValid { return @@ -490,7 +419,10 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, rabbitmq.DefaultAPIService{}), + cmp.FilterPath(func(p cmp.Path) bool { + return p.String() == "ApiService" + }, cmp.Ignore()), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/rabbitmq/plans/plans.go b/internal/cmd/rabbitmq/plans/plans.go index cc9cc3e1b..13f18dabf 100644 --- a/internal/cmd/rabbitmq/plans/plans.go +++ b/internal/cmd/rabbitmq/plans/plans.go @@ -15,10 +15,9 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/projectname" "github.com/stackitcloud/stackit-cli/internal/pkg/services/rabbitmq/client" "github.com/stackitcloud/stackit-cli/internal/pkg/tables" - "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/rabbitmq" + rabbitmq "github.com/stackitcloud/stackit-sdk-go/services/rabbitmq/v2api" ) const ( @@ -115,7 +114,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, } func buildRequest(ctx context.Context, model *inputModel, apiClient *rabbitmq.APIClient) rabbitmq.ApiListOfferingsRequest { - req := apiClient.ListOfferings(ctx, model.ProjectId) + req := apiClient.DefaultAPI.ListOfferings(ctx, model.ProjectId, model.Region) return req } @@ -131,14 +130,14 @@ func outputResult(p *print.Printer, outputFormat, projectLabel string, plans []r for i := range plans { o := plans[i] if o.Plans != nil { - for j := range *o.Plans { - plan := (*o.Plans)[j] + for j := range o.Plans { + plan := o.Plans[j] table.AddRow( - utils.PtrString(o.Name), - utils.PtrString(o.Version), - utils.PtrString(plan.Id), - utils.PtrString(plan.Name), - utils.PtrString(plan.Description), + o.Name, + o.Version, + plan.Id, + plan.Name, + plan.Description, ) } table.AddSeparator() diff --git a/internal/cmd/rabbitmq/plans/plans_test.go b/internal/cmd/rabbitmq/plans/plans_test.go index 2a41f6ae9..0eaa9f024 100644 --- a/internal/cmd/rabbitmq/plans/plans_test.go +++ b/internal/cmd/rabbitmq/plans/plans_test.go @@ -7,7 +7,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/rabbitmq" + rabbitmq "github.com/stackitcloud/stackit-sdk-go/services/rabbitmq/v2api" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" @@ -18,12 +18,14 @@ import ( type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &rabbitmq.APIClient{} +var testClient = &rabbitmq.APIClient{DefaultAPI: &rabbitmq.DefaultAPIService{}} var testProjectId = uuid.NewString() +var testRegion = "eu01" func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string { flagValues := map[string]string{ globalflags.ProjectIdFlag: testProjectId, + globalflags.RegionFlag: testRegion, limitFlag: "10", } for _, mod := range mods { @@ -36,6 +38,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { model := &inputModel{ GlobalFlagModel: &globalflags.GlobalFlagModel{ ProjectId: testProjectId, + Region: testRegion, Verbosity: globalflags.VerbosityDefault, }, Limit: utils.Ptr(int64(10)), @@ -47,7 +50,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *rabbitmq.ApiListOfferingsRequest)) rabbitmq.ApiListOfferingsRequest { - request := testClient.ListOfferings(testCtx, testProjectId) + request := testClient.DefaultAPI.ListOfferings(testCtx, testProjectId, testRegion) for _, mod := range mods { mod(&request) } @@ -136,7 +139,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, rabbitmq.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/pkg/services/rabbitmq/client/client.go b/internal/pkg/services/rabbitmq/client/client.go index df717b305..999a2446a 100644 --- a/internal/pkg/services/rabbitmq/client/client.go +++ b/internal/pkg/services/rabbitmq/client/client.go @@ -6,9 +6,9 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/print" "github.com/spf13/viper" - "github.com/stackitcloud/stackit-sdk-go/services/rabbitmq" + rabbitmq "github.com/stackitcloud/stackit-sdk-go/services/rabbitmq/v2api" ) func ConfigureClient(p *print.Printer, cliVersion string) (*rabbitmq.APIClient, error) { - return genericclient.ConfigureClientGeneric(p, cliVersion, viper.GetString(config.RabbitMQCustomEndpointKey), true, genericclient.CreateApiClient[*rabbitmq.APIClient](rabbitmq.NewAPIClient)) + return genericclient.ConfigureClientGeneric(p, cliVersion, viper.GetString(config.RabbitMQCustomEndpointKey), false, genericclient.CreateApiClient[*rabbitmq.APIClient](rabbitmq.NewAPIClient)) } diff --git a/internal/pkg/services/rabbitmq/utils/utils.go b/internal/pkg/services/rabbitmq/utils/utils.go index 6eced8759..4d33c2cfb 100644 --- a/internal/pkg/services/rabbitmq/utils/utils.go +++ b/internal/pkg/services/rabbitmq/utils/utils.go @@ -7,7 +7,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/errors" - "github.com/stackitcloud/stackit-sdk-go/services/rabbitmq" + rabbitmq "github.com/stackitcloud/stackit-sdk-go/services/rabbitmq/v2api" ) const ( @@ -15,9 +15,9 @@ const ( ) func ValidatePlanId(planId string, offerings *rabbitmq.ListOfferingsResponse) error { - for _, offer := range *offerings.Offerings { - for _, plan := range *offer.Plans { - if plan.Id != nil && strings.EqualFold(*plan.Id, planId) { + for _, offer := range offerings.GetOfferings() { + for _, plan := range offer.Plans { + if strings.EqualFold(plan.Id, planId) { return nil } } @@ -33,21 +33,18 @@ func LoadPlanId(planName, version string, offerings *rabbitmq.ListOfferingsRespo availableVersions := "" availablePlanNames := "" isValidVersion := false - for _, offer := range *offerings.Offerings { - if !strings.EqualFold(*offer.Version, version) { - availableVersions = fmt.Sprintf("%s\n- %s", availableVersions, *offer.Version) + for _, offer := range offerings.GetOfferings() { + if !strings.EqualFold(offer.Version, version) { + availableVersions = fmt.Sprintf("%s\n- %s", availableVersions, offer.Version) continue } isValidVersion = true - for _, plan := range *offer.Plans { - if plan.Name == nil { - continue + for _, plan := range offer.Plans { + if strings.EqualFold(plan.Name, planName) { + return &plan.Id, nil } - if strings.EqualFold(*plan.Name, planName) && plan.Id != nil { - return plan.Id, nil - } - availablePlanNames = fmt.Sprintf("%s\n- %s", availablePlanNames, *plan.Name) + availablePlanNames = fmt.Sprintf("%s\n- %s", availablePlanNames, plan.Name) } } @@ -65,23 +62,18 @@ func LoadPlanId(planName, version string, offerings *rabbitmq.ListOfferingsRespo } } -type RabbitMQClient interface { - GetInstanceExecute(ctx context.Context, projectId, instanceId string) (*rabbitmq.Instance, error) - GetCredentialsExecute(ctx context.Context, projectId, instanceId, credentialsId string) (*rabbitmq.CredentialsResponse, error) -} - -func GetInstanceName(ctx context.Context, apiClient RabbitMQClient, projectId, instanceId string) (string, error) { - resp, err := apiClient.GetInstanceExecute(ctx, projectId, instanceId) +func GetInstanceName(ctx context.Context, apiClient rabbitmq.DefaultAPI, projectId, region, instanceId string) (string, error) { + resp, err := apiClient.GetInstance(ctx, projectId, region, instanceId).Execute() if err != nil { return "", fmt.Errorf("get RabbitMQ instance: %w", err) } - return *resp.Name, nil + return resp.Name, nil } -func GetCredentialsUsername(ctx context.Context, apiClient RabbitMQClient, projectId, instanceId, credentialsId string) (string, error) { - resp, err := apiClient.GetCredentialsExecute(ctx, projectId, instanceId, credentialsId) +func GetCredentialsUsername(ctx context.Context, apiClient rabbitmq.DefaultAPI, projectId, region, instanceId, credentialsId string) (string, error) { + resp, err := apiClient.GetCredentials(ctx, projectId, region, instanceId, credentialsId).Execute() if err != nil { return "", fmt.Errorf("get RabbitMQ credentials: %w", err) } - return *resp.Raw.Credentials.Username, nil + return resp.Raw.Credentials.Username, nil } diff --git a/internal/pkg/services/rabbitmq/utils/utils_test.go b/internal/pkg/services/rabbitmq/utils/utils_test.go index 7c468c02c..7939cb86b 100644 --- a/internal/pkg/services/rabbitmq/utils/utils_test.go +++ b/internal/pkg/services/rabbitmq/utils/utils_test.go @@ -8,7 +8,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/rabbitmq" + rabbitmq "github.com/stackitcloud/stackit-sdk-go/services/rabbitmq/v2api" ) var ( @@ -19,28 +19,32 @@ var ( const ( testInstanceName = "instance" + testRegion = "eu01" testCredentialsUsername = "username" ) -type rabbitMQClientMocked struct { +type rabbitMQClientMockSettings struct { getInstanceFails bool getInstanceResp *rabbitmq.Instance getCredentialsFails bool getCredentialsResp *rabbitmq.CredentialsResponse } -func (m *rabbitMQClientMocked) GetInstanceExecute(_ context.Context, _, _ string) (*rabbitmq.Instance, error) { - if m.getInstanceFails { - return nil, fmt.Errorf("could not get instance") - } - return m.getInstanceResp, nil -} - -func (m *rabbitMQClientMocked) GetCredentialsExecute(_ context.Context, _, _, _ string) (*rabbitmq.CredentialsResponse, error) { - if m.getCredentialsFails { - return nil, fmt.Errorf("could not get user") +func newApiMock(s *rabbitMQClientMockSettings) rabbitmq.DefaultAPI { + return &rabbitmq.DefaultAPIServiceMock{ + GetInstanceExecuteMock: utils.Ptr(func(_ rabbitmq.ApiGetInstanceRequest) (*rabbitmq.Instance, error) { + if s.getInstanceFails { + return nil, fmt.Errorf("could not get instance") + } + return s.getInstanceResp, nil + }), + GetCredentialsExecuteMock: utils.Ptr(func(_ rabbitmq.ApiGetCredentialsRequest) (*rabbitmq.CredentialsResponse, error) { + if s.getCredentialsFails { + return nil, fmt.Errorf("could not get user") + } + return s.getCredentialsResp, nil + }), } - return m.getCredentialsResp, nil } func TestGetInstanceName(t *testing.T) { @@ -54,7 +58,7 @@ func TestGetInstanceName(t *testing.T) { { description: "base", getInstanceResp: &rabbitmq.Instance{ - Name: utils.Ptr(testInstanceName), + Name: testInstanceName, }, isValid: true, expectedOutput: testInstanceName, @@ -68,12 +72,12 @@ func TestGetInstanceName(t *testing.T) { for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { - client := &rabbitMQClientMocked{ + settings := &rabbitMQClientMockSettings{ getInstanceFails: tt.getInstanceFails, getInstanceResp: tt.getInstanceResp, } - output, err := GetInstanceName(context.Background(), client, testProjectId, testInstanceId) + output, err := GetInstanceName(context.Background(), newApiMock(settings), testProjectId, testRegion, testInstanceId) if tt.isValid && err != nil { t.Errorf("failed on valid input") @@ -103,8 +107,8 @@ func TestGetCredentialsUsername(t *testing.T) { description: "base", getCredentialsResp: &rabbitmq.CredentialsResponse{ Raw: &rabbitmq.RawCredentials{ - Credentials: &rabbitmq.Credentials{ - Username: utils.Ptr(testCredentialsUsername), + Credentials: rabbitmq.Credentials{ + Username: testCredentialsUsername, }, }, }, @@ -120,12 +124,12 @@ func TestGetCredentialsUsername(t *testing.T) { for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { - client := &rabbitMQClientMocked{ + settings := &rabbitMQClientMockSettings{ getCredentialsFails: tt.getCredentialsFails, getCredentialsResp: tt.getCredentialsResp, } - output, err := GetCredentialsUsername(context.Background(), client, testProjectId, testInstanceId, testCredentialsId) + output, err := GetCredentialsUsername(context.Background(), newApiMock(settings), testProjectId, testRegion, testInstanceId, testCredentialsId) if tt.isValid && err != nil { t.Errorf("failed on valid input") From 8f27014e212987699c4d4503b2000264e752d225 Mon Sep 17 00:00:00 2001 From: Jan Obernberger <52105660+j1n-o9r@users.noreply.github.com> Date: Mon, 6 Jul 2026 17:45:57 +0200 Subject: [PATCH 17/44] chore(logme): sdk migration (#1440) relates to STACKITCLI-366 --- docs/stackit_logme_instance_create.md | 2 +- docs/stackit_logme_instance_update.md | 3 +- go.mod | 2 +- go.sum | 4 +- .../cmd/logme/credentials/create/create.go | 25 ++--- .../logme/credentials/create/create_test.go | 16 +-- .../cmd/logme/credentials/delete/delete.go | 8 +- .../logme/credentials/delete/delete_test.go | 15 ++- .../logme/credentials/describe/describe.go | 20 ++-- .../credentials/describe/describe_test.go | 8 +- internal/cmd/logme/credentials/list/list.go | 13 +-- .../cmd/logme/credentials/list/list_test.go | 11 +- internal/cmd/logme/instance/create/create.go | 35 +++--- .../cmd/logme/instance/create/create_test.go | 104 +++++++++--------- internal/cmd/logme/instance/delete/delete.go | 12 +- .../cmd/logme/instance/delete/delete_test.go | 8 +- .../cmd/logme/instance/describe/describe.go | 16 +-- .../logme/instance/describe/describe_test.go | 8 +- internal/cmd/logme/instance/list/list.go | 14 +-- internal/cmd/logme/instance/list/list_test.go | 8 +- internal/cmd/logme/instance/update/update.go | 38 +++---- .../cmd/logme/instance/update/update_test.go | 86 +++++++-------- internal/cmd/logme/plans/plans.go | 19 ++-- internal/cmd/logme/plans/plans_test.go | 8 +- internal/pkg/services/logme/client/client.go | 4 +- internal/pkg/services/logme/utils/utils.go | 42 +++---- .../pkg/services/logme/utils/utils_test.go | 43 ++++---- 27 files changed, 282 insertions(+), 290 deletions(-) diff --git a/docs/stackit_logme_instance_create.md b/docs/stackit_logme_instance_create.md index f7e8d4327..cf71af87a 100644 --- a/docs/stackit_logme_instance_create.md +++ b/docs/stackit_logme_instance_create.md @@ -30,7 +30,7 @@ stackit logme instance create [flags] --enable-monitoring Enable monitoring --graphite string Graphite host -h, --help Help for "stackit logme instance create" - --metrics-frequency int Metrics frequency + --metrics-frequency int32 Metrics frequency --metrics-prefix string Metrics prefix --monitoring-instance-id string Monitoring instance ID -n, --name string Instance name diff --git a/docs/stackit_logme_instance_update.md b/docs/stackit_logme_instance_update.md index 27e3bcf8a..11e3c6963 100644 --- a/docs/stackit_logme_instance_update.md +++ b/docs/stackit_logme_instance_update.md @@ -27,9 +27,10 @@ stackit logme instance update INSTANCE_ID [flags] --enable-monitoring Enable monitoring --graphite string Graphite host -h, --help Help for "stackit logme instance update" - --metrics-frequency int Metrics frequency + --metrics-frequency int32 Metrics frequency --metrics-prefix string Metrics prefix --monitoring-instance-id string Monitoring instance ID + -n, --name string Instance name --plan-id string Plan ID --plan-name string Plan name --syslog strings Syslog diff --git a/go.mod b/go.mod index 2ebc99c95..b66fc9bae 100644 --- a/go.mod +++ b/go.mod @@ -267,7 +267,7 @@ require ( github.com/spf13/cast v1.10.0 // indirect github.com/stackitcloud/stackit-sdk-go/services/kms v1.11.0 github.com/stackitcloud/stackit-sdk-go/services/loadbalancer v1.14.0 - github.com/stackitcloud/stackit-sdk-go/services/logme v0.25.6 + github.com/stackitcloud/stackit-sdk-go/services/logme v0.30.0 github.com/stackitcloud/stackit-sdk-go/services/mariadb v0.25.6 github.com/stackitcloud/stackit-sdk-go/services/objectstorage v1.7.0 github.com/stackitcloud/stackit-sdk-go/services/observability v0.17.0 diff --git a/go.sum b/go.sum index 7b6f8dd14..3fcbb9244 100644 --- a/go.sum +++ b/go.sum @@ -616,8 +616,8 @@ github.com/stackitcloud/stackit-sdk-go/services/kms v1.11.0 h1:OrUaDypQNr1nOXZfV github.com/stackitcloud/stackit-sdk-go/services/kms v1.11.0/go.mod h1:pVaCmb1ZHAPGVRlSlBlVOjThp9Tb2sX9+nRX0M+d1KU= github.com/stackitcloud/stackit-sdk-go/services/loadbalancer v1.14.0 h1:1dvL7tX91ziklayQmOupniE3jM4D5Nbtc0auNcx2p18= github.com/stackitcloud/stackit-sdk-go/services/loadbalancer v1.14.0/go.mod h1:+Ld3dn648I+YKcBV3fEkYpDSr3fel421+LurJGywSBs= -github.com/stackitcloud/stackit-sdk-go/services/logme v0.25.6 h1:4x30lC+YBmo7XpsAzTn0W+C/oP5flnLVgIh5u3O/P0o= -github.com/stackitcloud/stackit-sdk-go/services/logme v0.25.6/go.mod h1:ewaYUiZcBTSS6urE5zEJBPCqxu70w2IjnBHCvnKdFKE= +github.com/stackitcloud/stackit-sdk-go/services/logme v0.30.0 h1:csZlzmvAB+klgUQo7AjoGO+YkpdxRFY3yE5Y7SDeB5w= +github.com/stackitcloud/stackit-sdk-go/services/logme v0.30.0/go.mod h1:JDOOYaGgcBts2x52nKPRMFgSZe7qqOFmfz1xIXCQgRY= github.com/stackitcloud/stackit-sdk-go/services/logs v0.5.2 h1:vr4atxFRT+EL+DqONMT5R44f7AzEMbePa9U7PEE0THU= github.com/stackitcloud/stackit-sdk-go/services/logs v0.5.2/go.mod h1:CAPsiTX7osAImfrG5RnIjaJ/Iz3QpoBKuH2fS346wuQ= github.com/stackitcloud/stackit-sdk-go/services/mariadb v0.25.6 h1:Y/byRjX2u/OZl0gKS/Rau6ob2bDyv26xnw6A6JNkKJk= diff --git a/internal/cmd/logme/credentials/create/create.go b/internal/cmd/logme/credentials/create/create.go index aab7a20ae..0c5fdd1e3 100644 --- a/internal/cmd/logme/credentials/create/create.go +++ b/internal/cmd/logme/credentials/create/create.go @@ -7,7 +7,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/types" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/logme" + logme "github.com/stackitcloud/stackit-sdk-go/services/logme/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/args" "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -51,14 +51,13 @@ func NewCmd(params *types.CmdParams) *cobra.Command { if err != nil { return err } - // Configure API client apiClient, err := client.ConfigureClient(params.Printer, params.CliVersion) if err != nil { return err } - instanceLabel, err := logmeUtils.GetInstanceName(ctx, apiClient, model.ProjectId, model.InstanceId) + instanceLabel, err := logmeUtils.GetInstanceName(ctx, apiClient.DefaultAPI, model.ProjectId, model.InstanceId) if err != nil { params.Printer.Debug(print.ErrorLevel, "get instance name: %v", err) instanceLabel = model.InstanceId @@ -109,7 +108,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, } func buildRequest(ctx context.Context, model *inputModel, apiClient *logme.APIClient) logme.ApiCreateCredentialsRequest { - req := apiClient.CreateCredentials(ctx, model.ProjectId, model.InstanceId) + req := apiClient.DefaultAPI.CreateCredentials(ctx, model.ProjectId, model.InstanceId) return req } @@ -118,26 +117,26 @@ func outputResult(p *print.Printer, outputFormat string, showPassword bool, inst return fmt.Errorf("credentials response is empty") } - if !showPassword && resp.HasRaw() && resp.Raw.Credentials != nil { - resp.Raw.Credentials.Password = utils.Ptr("hidden") + if !showPassword && resp.HasRaw() { + resp.Raw.Credentials.Password = "hidden" } return p.OutputResult(outputFormat, resp, func() error { - p.Outputf("Created credentials for instance %q. Credentials ID: %s\n\n", instanceLabel, utils.PtrString(resp.Id)) + p.Outputf("Created credentials for instance %q. Credentials ID: %s\n\n", instanceLabel, resp.Id) // The username field cannot be set by the user so we only display it if it's not returned empty - if resp.HasRaw() && resp.Raw.Credentials != nil { - if username := resp.Raw.Credentials.Username; username != nil && *username != "" { - p.Outputf("Username: %s\n", utils.PtrString(username)) + if resp.HasRaw() { + if username := resp.Raw.Credentials.Username; username != "" { + p.Outputf("Username: %s\n", username) } if !showPassword { p.Outputf("Password: \n") } else { - p.Outputf("Password: %s\n", utils.PtrString(resp.Raw.Credentials.Password)) + p.Outputf("Password: %s\n", resp.Raw.Credentials.Password) } - p.Outputf("Host: %s\n", utils.PtrString(resp.Raw.Credentials.Host)) + p.Outputf("Host: %s\n", resp.Raw.Credentials.Host) p.Outputf("Port: %s\n", utils.PtrString(resp.Raw.Credentials.Port)) } - p.Outputf("URI: %s\n", utils.PtrString(resp.Uri)) + p.Outputf("URI: %s\n", resp.Uri) return nil }) } diff --git a/internal/cmd/logme/credentials/create/create_test.go b/internal/cmd/logme/credentials/create/create_test.go index b3ca3489f..87dc6fd13 100644 --- a/internal/cmd/logme/credentials/create/create_test.go +++ b/internal/cmd/logme/credentials/create/create_test.go @@ -4,14 +4,14 @@ import ( "context" "testing" - "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" - "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" - "github.com/stackitcloud/stackit-cli/internal/pkg/testutils" - "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/logme" + logme "github.com/stackitcloud/stackit-sdk-go/services/logme/v1api" + + "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" + "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" + "github.com/stackitcloud/stackit-cli/internal/pkg/testutils" ) var projectIdFlag = globalflags.ProjectIdFlag @@ -19,7 +19,7 @@ var projectIdFlag = globalflags.ProjectIdFlag type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &logme.APIClient{} +var testClient = &logme.APIClient{DefaultAPI: &logme.DefaultAPIService{}} var testProjectId = uuid.NewString() var testInstanceId = uuid.NewString() @@ -49,7 +49,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *logme.ApiCreateCredentialsRequest)) logme.ApiCreateCredentialsRequest { - request := testClient.CreateCredentials(testCtx, testProjectId, testInstanceId) + request := testClient.DefaultAPI.CreateCredentials(testCtx, testProjectId, testInstanceId) for _, mod := range mods { mod(&request) } @@ -155,7 +155,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, logme.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/logme/credentials/delete/delete.go b/internal/cmd/logme/credentials/delete/delete.go index 26d2750fd..95247df08 100644 --- a/internal/cmd/logme/credentials/delete/delete.go +++ b/internal/cmd/logme/credentials/delete/delete.go @@ -17,7 +17,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/logme" + logme "github.com/stackitcloud/stackit-sdk-go/services/logme/v1api" ) const ( @@ -56,13 +56,13 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return err } - instanceLabel, err := logmeUtils.GetInstanceName(ctx, apiClient, model.ProjectId, model.InstanceId) + instanceLabel, err := logmeUtils.GetInstanceName(ctx, apiClient.DefaultAPI, model.ProjectId, model.InstanceId) if err != nil { params.Printer.Debug(print.ErrorLevel, "get instance name: %v", err) instanceLabel = model.InstanceId } - credentialsLabel, err := logmeUtils.GetCredentialsUsername(ctx, apiClient, model.ProjectId, model.InstanceId, model.CredentialsId) + credentialsLabel, err := logmeUtils.GetCredentialsUsername(ctx, apiClient.DefaultAPI, model.ProjectId, model.InstanceId, model.CredentialsId) if err != nil { params.Printer.Debug(print.ErrorLevel, "get credentials username: %v", err) credentialsLabel = model.CredentialsId @@ -115,6 +115,6 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *logme.APIClient) logme.ApiDeleteCredentialsRequest { - req := apiClient.DeleteCredentials(ctx, model.ProjectId, model.InstanceId, model.CredentialsId) + req := apiClient.DefaultAPI.DeleteCredentials(ctx, model.ProjectId, model.InstanceId, model.CredentialsId) return req } diff --git a/internal/cmd/logme/credentials/delete/delete_test.go b/internal/cmd/logme/credentials/delete/delete_test.go index 466250e72..8842fd6a9 100644 --- a/internal/cmd/logme/credentials/delete/delete_test.go +++ b/internal/cmd/logme/credentials/delete/delete_test.go @@ -10,7 +10,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/logme" + logme "github.com/stackitcloud/stackit-sdk-go/services/logme/v1api" ) var projectIdFlag = globalflags.ProjectIdFlag @@ -18,10 +18,11 @@ var projectIdFlag = globalflags.ProjectIdFlag type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &logme.APIClient{} +var testClient = &logme.APIClient{DefaultAPI: &logme.DefaultAPIService{}} var testProjectId = uuid.NewString() var testInstanceId = uuid.NewString() var testCredentialsId = uuid.NewString() +var testRegion = "region" func fixtureArgValues(mods ...func(argValues []string)) []string { argValues := []string{ @@ -35,8 +36,9 @@ func fixtureArgValues(mods ...func(argValues []string)) []string { func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string { flagValues := map[string]string{ - projectIdFlag: testProjectId, - instanceIdFlag: testInstanceId, + projectIdFlag: testProjectId, + instanceIdFlag: testInstanceId, + globalflags.RegionFlag: testRegion, } for _, mod := range mods { mod(flagValues) @@ -48,6 +50,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { model := &inputModel{ GlobalFlagModel: &globalflags.GlobalFlagModel{ ProjectId: testProjectId, + Region: testRegion, Verbosity: globalflags.VerbosityDefault, }, InstanceId: testInstanceId, @@ -60,7 +63,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *logme.ApiDeleteCredentialsRequest)) logme.ApiDeleteCredentialsRequest { - request := testClient.DeleteCredentials(testCtx, testProjectId, testInstanceId, testCredentialsId) + request := testClient.DefaultAPI.DeleteCredentials(testCtx, testProjectId, testInstanceId, testCredentialsId) for _, mod := range mods { mod(&request) } @@ -188,7 +191,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, logme.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/logme/credentials/describe/describe.go b/internal/cmd/logme/credentials/describe/describe.go index 670b064c0..ea65abdc2 100644 --- a/internal/cmd/logme/credentials/describe/describe.go +++ b/internal/cmd/logme/credentials/describe/describe.go @@ -17,7 +17,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/logme" + logme "github.com/stackitcloud/stackit-sdk-go/services/logme/v1api" ) const ( @@ -99,7 +99,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *logme.APIClient) logme.ApiGetCredentialsRequest { - req := apiClient.GetCredentials(ctx, model.ProjectId, model.InstanceId, model.CredentialsId) + req := apiClient.DefaultAPI.GetCredentials(ctx, model.ProjectId, model.InstanceId, model.CredentialsId) return req } @@ -110,19 +110,19 @@ func outputResult(p *print.Printer, outputFormat string, credentials *logme.Cred return p.OutputResult(outputFormat, credentials, func() error { table := tables.NewTable() - table.AddRow("ID", utils.PtrString(credentials.Id)) + table.AddRow("ID", credentials.Id) table.AddSeparator() // The username field cannot be set by the user so we only display it if it's not returned empty if raw := credentials.Raw; raw != nil { - if cred := raw.Credentials; cred != nil { - if username := cred.Username; username != nil && *username != "" { - table.AddRow("USERNAME", *username) - table.AddSeparator() - } - table.AddRow("PASSWORD", utils.PtrString(cred.Password)) + cred := raw.Credentials + + if username := cred.Username; username != "" { + table.AddRow("USERNAME", username) table.AddSeparator() - table.AddRow("URI", utils.PtrString(cred.Uri)) } + table.AddRow("PASSWORD", cred.Password) + table.AddSeparator() + table.AddRow("URI", utils.PtrString(cred.Uri)) } err := table.Display(p) if err != nil { diff --git a/internal/cmd/logme/credentials/describe/describe_test.go b/internal/cmd/logme/credentials/describe/describe_test.go index 8f2389ce2..20e706f8d 100644 --- a/internal/cmd/logme/credentials/describe/describe_test.go +++ b/internal/cmd/logme/credentials/describe/describe_test.go @@ -11,7 +11,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/logme" + logme "github.com/stackitcloud/stackit-sdk-go/services/logme/v1api" ) var projectIdFlag = globalflags.ProjectIdFlag @@ -19,7 +19,7 @@ var projectIdFlag = globalflags.ProjectIdFlag type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &logme.APIClient{} +var testClient = &logme.APIClient{DefaultAPI: &logme.DefaultAPIService{}} var testProjectId = uuid.NewString() var testInstanceId = uuid.NewString() var testCredentialsId = uuid.NewString() @@ -61,7 +61,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *logme.ApiGetCredentialsRequest)) logme.ApiGetCredentialsRequest { - request := testClient.GetCredentials(testCtx, testProjectId, testInstanceId, testCredentialsId) + request := testClient.DefaultAPI.GetCredentials(testCtx, testProjectId, testInstanceId, testCredentialsId) for _, mod := range mods { mod(&request) } @@ -189,7 +189,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, logme.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/logme/credentials/list/list.go b/internal/cmd/logme/credentials/list/list.go index ac2660747..355b10a29 100644 --- a/internal/cmd/logme/credentials/list/list.go +++ b/internal/cmd/logme/credentials/list/list.go @@ -6,6 +6,9 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/types" + "github.com/spf13/cobra" + logme "github.com/stackitcloud/stackit-sdk-go/services/logme/v1api" + "github.com/stackitcloud/stackit-cli/internal/pkg/args" "github.com/stackitcloud/stackit-cli/internal/pkg/errors" "github.com/stackitcloud/stackit-cli/internal/pkg/examples" @@ -15,10 +18,6 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/services/logme/client" logmeUtils "github.com/stackitcloud/stackit-cli/internal/pkg/services/logme/utils" "github.com/stackitcloud/stackit-cli/internal/pkg/tables" - "github.com/stackitcloud/stackit-cli/internal/pkg/utils" - - "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/logme" ) const ( @@ -70,7 +69,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } credentials := resp.GetCredentialsList() - instanceLabel, err := logmeUtils.GetInstanceName(ctx, apiClient, model.ProjectId, model.InstanceId) + instanceLabel, err := logmeUtils.GetInstanceName(ctx, apiClient.DefaultAPI, model.ProjectId, model.InstanceId) if err != nil { params.Printer.Debug(print.ErrorLevel, "get instance name: %v", err) instanceLabel = model.InstanceId @@ -120,7 +119,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, } func buildRequest(ctx context.Context, model *inputModel, apiClient *logme.APIClient) logme.ApiListCredentialsRequest { - req := apiClient.ListCredentials(ctx, model.ProjectId, model.InstanceId) + req := apiClient.DefaultAPI.ListCredentials(ctx, model.ProjectId, model.InstanceId) return req } @@ -135,7 +134,7 @@ func outputResult(p *print.Printer, outputFormat, instanceLabel string, credenti table.SetHeader("ID") for i := range credentials { c := credentials[i] - table.AddRow(utils.PtrString(c.Id)) + table.AddRow(c.Id) } err := table.Display(p) if err != nil { diff --git a/internal/cmd/logme/credentials/list/list_test.go b/internal/cmd/logme/credentials/list/list_test.go index c803f1d84..1f2de370e 100644 --- a/internal/cmd/logme/credentials/list/list_test.go +++ b/internal/cmd/logme/credentials/list/list_test.go @@ -12,21 +12,23 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/logme" + logme "github.com/stackitcloud/stackit-sdk-go/services/logme/v1api" ) type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &logme.APIClient{} +var testClient = &logme.APIClient{DefaultAPI: &logme.DefaultAPIService{}} var testProjectId = uuid.NewString() var testInstanceId = uuid.NewString() +var testRegion = "region" func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string { flagValues := map[string]string{ globalflags.ProjectIdFlag: testProjectId, instanceIdFlag: testInstanceId, limitFlag: "10", + globalflags.RegionFlag: testRegion, } for _, mod := range mods { mod(flagValues) @@ -38,6 +40,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { model := &inputModel{ GlobalFlagModel: &globalflags.GlobalFlagModel{ ProjectId: testProjectId, + Region: testRegion, Verbosity: globalflags.VerbosityDefault, }, InstanceId: testInstanceId, @@ -50,7 +53,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *logme.ApiListCredentialsRequest)) logme.ApiListCredentialsRequest { - request := testClient.ListCredentials(testCtx, testProjectId, testInstanceId) + request := testClient.DefaultAPI.ListCredentials(testCtx, testProjectId, testInstanceId) for _, mod := range mods { mod(&request) } @@ -160,7 +163,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, logme.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/logme/instance/create/create.go b/internal/cmd/logme/instance/create/create.go index 367c9cc60..ba0d1aa0a 100644 --- a/internal/cmd/logme/instance/create/create.go +++ b/internal/cmd/logme/instance/create/create.go @@ -21,8 +21,8 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/logme" - "github.com/stackitcloud/stackit-sdk-go/services/logme/wait" + logme "github.com/stackitcloud/stackit-sdk-go/services/logme/v1api" + "github.com/stackitcloud/stackit-sdk-go/services/logme/v1api/wait" ) const ( @@ -47,11 +47,11 @@ type inputModel struct { InstanceName *string EnableMonitoring *bool Graphite *string - MetricsFrequency *int64 + MetricsFrequency *int32 MetricsPrefix *string MonitoringInstanceId *string SgwAcl *[]string - Syslog *[]string + Syslog []string PlanId *string } @@ -98,7 +98,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } // Call API - req, err := buildRequest(ctx, model, apiClient) + req, err := buildRequest(ctx, model, apiClient.DefaultAPI) if err != nil { var dsaInvalidPlanError *cliErr.DSAInvalidPlanError if !errors.As(err, &dsaInvalidPlanError) { @@ -110,12 +110,12 @@ func NewCmd(params *types.CmdParams) *cobra.Command { if err != nil { return fmt.Errorf("create LogMe instance: %w", err) } - instanceId := *resp.InstanceId + instanceId := resp.InstanceId // Wait for async operation, if async mode not enabled if !model.Async { err := spinner.Run(params.Printer, "Creating instance", func() error { - _, err = wait.CreateInstanceWaitHandler(ctx, apiClient, model.ProjectId, instanceId).WaitWithContext(ctx) + _, err = wait.CreateInstanceWaitHandler(ctx, apiClient.DefaultAPI, model.ProjectId, instanceId).WaitWithContext(ctx) return err }) if err != nil { @@ -134,7 +134,7 @@ func configureFlags(cmd *cobra.Command) { cmd.Flags().StringP(instanceNameFlag, "n", "", "Instance name") cmd.Flags().Bool(enableMonitoringFlag, false, "Enable monitoring") cmd.Flags().String(graphiteFlag, "", "Graphite host") - cmd.Flags().Int64(metricsFrequencyFlag, 0, "Metrics frequency") + cmd.Flags().Int32(metricsFrequencyFlag, 0, "Metrics frequency") cmd.Flags().String(metricsPrefixFlag, "", "Metrics prefix") cmd.Flags().Var(flags.UUIDFlag(), monitoringInstanceIdFlag, "Monitoring instance ID") cmd.Flags().Var(flags.CIDRSliceFlag(), sgwAclFlag, "List of IP networks in CIDR notation which are allowed to access this instance") @@ -174,10 +174,10 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, EnableMonitoring: flags.FlagToBoolPointer(p, cmd, enableMonitoringFlag), MonitoringInstanceId: flags.FlagToStringPointer(p, cmd, monitoringInstanceIdFlag), Graphite: flags.FlagToStringPointer(p, cmd, graphiteFlag), - MetricsFrequency: flags.FlagToInt64Pointer(p, cmd, metricsFrequencyFlag), + MetricsFrequency: flags.FlagToInt32Pointer(p, cmd, metricsFrequencyFlag), MetricsPrefix: flags.FlagToStringPointer(p, cmd, metricsPrefixFlag), SgwAcl: flags.FlagToStringSlicePointer(p, cmd, sgwAclFlag), - Syslog: flags.FlagToStringSlicePointer(p, cmd, syslogFlag), + Syslog: flags.FlagToStringSliceValue(p, cmd, syslogFlag), PlanId: planId, PlanName: planName, Version: version, @@ -187,18 +187,13 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, return &model, nil } -type logMeClient interface { - CreateInstance(ctx context.Context, projectId string) logme.ApiCreateInstanceRequest - ListOfferingsExecute(ctx context.Context, projectId string) (*logme.ListOfferingsResponse, error) -} - -func buildRequest(ctx context.Context, model *inputModel, apiClient logMeClient) (logme.ApiCreateInstanceRequest, error) { +func buildRequest(ctx context.Context, model *inputModel, apiClient logme.DefaultAPI) (logme.ApiCreateInstanceRequest, error) { req := apiClient.CreateInstance(ctx, model.ProjectId) var planId *string var err error - offerings, err := apiClient.ListOfferingsExecute(ctx, model.ProjectId) + offerings, err := apiClient.ListOfferings(ctx, model.ProjectId).Execute() if err != nil { return req, fmt.Errorf("get LogMe offerings: %w", err) } @@ -226,7 +221,7 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient logMeClient) } req = req.CreateInstancePayload(logme.CreateInstancePayload{ - InstanceName: model.InstanceName, + InstanceName: utils.PtrValue(model.InstanceName), Parameters: &logme.InstanceParameters{ EnableMonitoring: model.EnableMonitoring, Graphite: model.Graphite, @@ -236,7 +231,7 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient logMeClient) SgwAcl: sgwAcl, Syslog: model.Syslog, }, - PlanId: planId, + PlanId: utils.PtrValue(planId), }) return req, nil } @@ -251,7 +246,7 @@ func outputResult(p *print.Printer, outputFormat string, async bool, projectLabe if async { operationState = "Triggered creation of" } - p.Outputf("%s instance for project %q. Instance ID: %s\n", operationState, projectLabel, utils.PtrString(resp.InstanceId)) + p.Outputf("%s instance for project %q. Instance ID: %s\n", operationState, projectLabel, resp.InstanceId) return nil }) } diff --git a/internal/cmd/logme/instance/create/create_test.go b/internal/cmd/logme/instance/create/create_test.go index a7caf394c..7180961db 100644 --- a/internal/cmd/logme/instance/create/create_test.go +++ b/internal/cmd/logme/instance/create/create_test.go @@ -13,7 +13,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/logme" + logme "github.com/stackitcloud/stackit-sdk-go/services/logme/v1api" ) var projectIdFlag = globalflags.ProjectIdFlag @@ -21,22 +21,22 @@ var projectIdFlag = globalflags.ProjectIdFlag type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &logme.APIClient{} +var testClient = &logme.APIClient{DefaultAPI: &logme.DefaultAPIService{}} -type logMeClientMocked struct { +type mockSettings struct { returnError bool listOfferingsResp *logme.ListOfferingsResponse } -func (c *logMeClientMocked) CreateInstance(ctx context.Context, projectId string) logme.ApiCreateInstanceRequest { - return testClient.CreateInstance(ctx, projectId) -} - -func (c *logMeClientMocked) ListOfferingsExecute(_ context.Context, _ string) (*logme.ListOfferingsResponse, error) { - if c.returnError { - return nil, fmt.Errorf("list flavors failed") +func newAPIMock(s mockSettings) logme.DefaultAPI { + return &logme.DefaultAPIServiceMock{ + ListOfferingsExecuteMock: utils.Ptr(func(_ logme.ApiListOfferingsRequest) (*logme.ListOfferingsResponse, error) { + if s.returnError { + return nil, fmt.Errorf("list flavors failed") + } + return s.listOfferingsResp, nil + }), } - return c.listOfferingsResp, nil } var testProjectId = uuid.NewString() @@ -71,12 +71,12 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { InstanceName: utils.Ptr("example-name"), EnableMonitoring: utils.Ptr(true), Graphite: utils.Ptr("example-graphite"), - MetricsFrequency: utils.Ptr(int64(100)), + MetricsFrequency: utils.Ptr(int32(100)), MetricsPrefix: utils.Ptr("example-prefix"), - MonitoringInstanceId: utils.Ptr(testMonitoringInstanceId), + MonitoringInstanceId: &testMonitoringInstanceId, SgwAcl: utils.Ptr([]string{"198.51.100.14/24"}), - Syslog: utils.Ptr([]string{"example-syslog"}), - PlanId: utils.Ptr(testPlanId), + Syslog: []string{"example-syslog"}, + PlanId: &testPlanId, } for _, mod := range mods { mod(model) @@ -85,19 +85,19 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *logme.ApiCreateInstanceRequest)) logme.ApiCreateInstanceRequest { - request := testClient.CreateInstance(testCtx, testProjectId) + request := testClient.DefaultAPI.CreateInstance(testCtx, testProjectId) request = request.CreateInstancePayload(logme.CreateInstancePayload{ - InstanceName: utils.Ptr("example-name"), + InstanceName: "example-name", Parameters: &logme.InstanceParameters{ EnableMonitoring: utils.Ptr(true), Graphite: utils.Ptr("example-graphite"), - MetricsFrequency: utils.Ptr(int64(100)), + MetricsFrequency: utils.Ptr(int32(100)), MetricsPrefix: utils.Ptr("example-prefix"), - MonitoringInstanceId: utils.Ptr(testMonitoringInstanceId), + MonitoringInstanceId: &testMonitoringInstanceId, SgwAcl: utils.Ptr("198.51.100.14/24"), - Syslog: utils.Ptr([]string{"example-syslog"}), + Syslog: []string{"example-syslog"}, }, - PlanId: utils.Ptr(testPlanId), + PlanId: testPlanId, }) for _, mod := range mods { mod(&request) @@ -154,7 +154,7 @@ func TestParseInput(t *testing.T) { Verbosity: globalflags.VerbosityDefault, }, InstanceName: utils.Ptr("example-name"), - PlanId: utils.Ptr(testPlanId), + PlanId: &testPlanId, }, }, { @@ -174,11 +174,11 @@ func TestParseInput(t *testing.T) { ProjectId: testProjectId, Verbosity: globalflags.VerbosityDefault, }, - PlanId: utils.Ptr(testPlanId), + PlanId: &testPlanId, InstanceName: utils.Ptr(""), EnableMonitoring: utils.Ptr(false), Graphite: utils.Ptr(""), - MetricsFrequency: utils.Ptr(int64(0)), + MetricsFrequency: utils.Ptr(int32(0)), MetricsPrefix: utils.Ptr(""), }, }, @@ -254,9 +254,7 @@ func TestParseInput(t *testing.T) { syslogValues: []string{"example-syslog-1", "example-syslog-2"}, isValid: true, expectedModel: fixtureInputModel(func(model *inputModel) { - model.Syslog = utils.Ptr( - append(*model.Syslog, "example-syslog-1", "example-syslog-2"), - ) + model.Syslog = append(model.Syslog, "example-syslog-1", "example-syslog-2") }), }, } @@ -285,13 +283,13 @@ func TestBuildRequest(t *testing.T) { model: fixtureInputModel(), expectedRequest: fixtureRequest(), getOfferingsResp: &logme.ListOfferingsResponse{ - Offerings: &[]logme.Offering{ + Offerings: []logme.Offering{ { - Version: utils.Ptr("example-version"), - Plans: &[]logme.Plan{ + Version: "example-version", + Plans: []logme.Plan{ { - Name: utils.Ptr("example-plan-name"), - Id: utils.Ptr(testPlanId), + Name: "example-plan-name", + Id: testPlanId, }, }, }, @@ -309,13 +307,13 @@ func TestBuildRequest(t *testing.T) { ), expectedRequest: fixtureRequest(), getOfferingsResp: &logme.ListOfferingsResponse{ - Offerings: &[]logme.Offering{ + Offerings: []logme.Offering{ { - Version: utils.Ptr("example-version"), - Plans: &[]logme.Plan{ + Version: "example-version", + Plans: []logme.Plan{ { - Name: utils.Ptr("example-plan-name"), - Id: utils.Ptr(testPlanId), + Name: "example-plan-name", + Id: testPlanId, }, }, }, @@ -344,13 +342,13 @@ func TestBuildRequest(t *testing.T) { }, ), getOfferingsResp: &logme.ListOfferingsResponse{ - Offerings: &[]logme.Offering{ + Offerings: []logme.Offering{ { - Version: utils.Ptr("example-version"), - Plans: &[]logme.Plan{ + Version: "example-version", + Plans: []logme.Plan{ { - Name: utils.Ptr("other-plan-name"), - Id: utils.Ptr(testPlanId), + Name: "other-plan-name", + Id: testPlanId, }, }, }, @@ -365,33 +363,33 @@ func TestBuildRequest(t *testing.T) { ProjectId: testProjectId, Verbosity: globalflags.VerbosityDefault, }, - PlanId: utils.Ptr(testPlanId), + PlanId: &testPlanId, }, getOfferingsResp: &logme.ListOfferingsResponse{ - Offerings: &[]logme.Offering{ + Offerings: []logme.Offering{ { - Version: utils.Ptr("example-version"), - Plans: &[]logme.Plan{ + Version: "example-version", + Plans: []logme.Plan{ { - Name: utils.Ptr("example-plan-name"), - Id: utils.Ptr(testPlanId), + Name: "example-plan-name", + Id: testPlanId, }, }, }, }, }, - expectedRequest: testClient.CreateInstance(testCtx, testProjectId). - CreateInstancePayload(logme.CreateInstancePayload{PlanId: utils.Ptr(testPlanId), Parameters: &logme.InstanceParameters{}}), + expectedRequest: testClient.DefaultAPI.CreateInstance(testCtx, testProjectId). + CreateInstancePayload(logme.CreateInstancePayload{PlanId: testPlanId, Parameters: &logme.InstanceParameters{}}), }, } for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { - client := &logMeClientMocked{ + settings := mockSettings{ returnError: tt.getOfferingsFails, listOfferingsResp: tt.getOfferingsResp, } - request, err := buildRequest(testCtx, tt.model, client) + request, err := buildRequest(testCtx, tt.model, newAPIMock(settings)) if err != nil { if !tt.isValid { return @@ -402,6 +400,8 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), cmpopts.EquateComparable(testCtx), + cmpopts.EquateEmpty(), + cmpopts.IgnoreFields(tt.expectedRequest, "ApiService"), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/logme/instance/delete/delete.go b/internal/cmd/logme/instance/delete/delete.go index 0dc766e3b..60c23993b 100644 --- a/internal/cmd/logme/instance/delete/delete.go +++ b/internal/cmd/logme/instance/delete/delete.go @@ -17,8 +17,8 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/logme" - "github.com/stackitcloud/stackit-sdk-go/services/logme/wait" + logme "github.com/stackitcloud/stackit-sdk-go/services/logme/v1api" + "github.com/stackitcloud/stackit-sdk-go/services/logme/v1api/wait" ) const ( @@ -54,7 +54,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return err } - instanceLabel, err := logmeUtils.GetInstanceName(ctx, apiClient, model.ProjectId, model.InstanceId) + instanceLabel, err := logmeUtils.GetInstanceName(ctx, apiClient.DefaultAPI, model.ProjectId, model.InstanceId) if err != nil { params.Printer.Debug(print.ErrorLevel, "get instance name: %v", err) instanceLabel = model.InstanceId @@ -75,8 +75,8 @@ func NewCmd(params *types.CmdParams) *cobra.Command { // Wait for async operation, if async mode not enabled if !model.Async { - err := spinner.Run(params.Printer, "Deleting instacne", func() error { - _, err = wait.DeleteInstanceWaitHandler(ctx, apiClient, model.ProjectId, model.InstanceId).WaitWithContext(ctx) + err := spinner.Run(params.Printer, "Deleting instance", func() error { + _, err = wait.DeleteInstanceWaitHandler(ctx, apiClient.DefaultAPI, model.ProjectId, model.InstanceId).WaitWithContext(ctx) return err }) if err != nil { @@ -113,6 +113,6 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *logme.APIClient) logme.ApiDeleteInstanceRequest { - req := apiClient.DeleteInstance(ctx, model.ProjectId, model.InstanceId) + req := apiClient.DefaultAPI.DeleteInstance(ctx, model.ProjectId, model.InstanceId) return req } diff --git a/internal/cmd/logme/instance/delete/delete_test.go b/internal/cmd/logme/instance/delete/delete_test.go index f2d599f6e..f3376c4c0 100644 --- a/internal/cmd/logme/instance/delete/delete_test.go +++ b/internal/cmd/logme/instance/delete/delete_test.go @@ -10,7 +10,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/logme" + logme "github.com/stackitcloud/stackit-sdk-go/services/logme/v1api" ) var projectIdFlag = globalflags.ProjectIdFlag @@ -18,7 +18,7 @@ var projectIdFlag = globalflags.ProjectIdFlag type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &logme.APIClient{} +var testClient = &logme.APIClient{DefaultAPI: &logme.DefaultAPIService{}} var testProjectId = uuid.NewString() var testInstanceId = uuid.NewString() @@ -57,7 +57,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *logme.ApiDeleteInstanceRequest)) logme.ApiDeleteInstanceRequest { - request := testClient.DeleteInstance(testCtx, testProjectId, testInstanceId) + request := testClient.DefaultAPI.DeleteInstance(testCtx, testProjectId, testInstanceId) for _, mod := range mods { mod(&request) } @@ -161,7 +161,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, logme.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/logme/instance/describe/describe.go b/internal/cmd/logme/instance/describe/describe.go index 2c579779c..6803c7e50 100644 --- a/internal/cmd/logme/instance/describe/describe.go +++ b/internal/cmd/logme/instance/describe/describe.go @@ -16,7 +16,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/logme" + logme "github.com/stackitcloud/stackit-sdk-go/services/logme/v1api" ) const ( @@ -87,7 +87,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *logme.APIClient) logme.ApiGetInstanceRequest { - req := apiClient.GetInstance(ctx, model.ProjectId, model.InstanceId) + req := apiClient.DefaultAPI.GetInstance(ctx, model.ProjectId, model.InstanceId) return req } @@ -100,18 +100,18 @@ func outputResult(p *print.Printer, outputFormat string, instance *logme.Instanc table := tables.NewTable() table.AddRow("ID", utils.PtrString(instance.InstanceId)) table.AddSeparator() - table.AddRow("NAME", utils.PtrString(instance.Name)) + table.AddRow("NAME", instance.Name) table.AddSeparator() - if instance.LastOperation != nil { - table.AddRow("LAST OPERATION TYPE", utils.PtrString(instance.LastOperation.Type)) + if _, ok := instance.LastOperation.GetStateOk(); ok { + table.AddRow("LAST OPERATION TYPE", instance.LastOperation.Type) table.AddSeparator() - table.AddRow("LAST OPERATION STATE", utils.PtrString(instance.LastOperation.State)) + table.AddRow("LAST OPERATION STATE", instance.LastOperation.State) table.AddSeparator() } - table.AddRow("PLAN ID", utils.PtrString(instance.PlanId)) + table.AddRow("PLAN ID", instance.PlanId) // Only show ACL if it's present and not empty if instance.Parameters != nil { - acl := (*instance.Parameters)[aclParameterKey] + acl := (instance.Parameters)[aclParameterKey] aclStr, ok := acl.(string) if ok && aclStr != "" { table.AddSeparator() diff --git a/internal/cmd/logme/instance/describe/describe_test.go b/internal/cmd/logme/instance/describe/describe_test.go index 2003b29ec..7d7c08456 100644 --- a/internal/cmd/logme/instance/describe/describe_test.go +++ b/internal/cmd/logme/instance/describe/describe_test.go @@ -11,7 +11,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/logme" + logme "github.com/stackitcloud/stackit-sdk-go/services/logme/v1api" ) var projectIdFlag = globalflags.ProjectIdFlag @@ -19,7 +19,7 @@ var projectIdFlag = globalflags.ProjectIdFlag type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &logme.APIClient{} +var testClient = &logme.APIClient{DefaultAPI: &logme.DefaultAPIService{}} var testProjectId = uuid.NewString() var testInstanceId = uuid.NewString() @@ -58,7 +58,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *logme.ApiGetInstanceRequest)) logme.ApiGetInstanceRequest { - request := testClient.GetInstance(testCtx, testProjectId, testInstanceId) + request := testClient.DefaultAPI.GetInstance(testCtx, testProjectId, testInstanceId) for _, mod := range mods { mod(&request) } @@ -162,7 +162,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, logme.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/logme/instance/list/list.go b/internal/cmd/logme/instance/list/list.go index b3b15ce1c..f1f89b472 100644 --- a/internal/cmd/logme/instance/list/list.go +++ b/internal/cmd/logme/instance/list/list.go @@ -7,7 +7,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/types" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/logme" + logme "github.com/stackitcloud/stackit-sdk-go/services/logme/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/args" "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -115,7 +115,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, } func buildRequest(ctx context.Context, model *inputModel, apiClient *logme.APIClient) logme.ApiListInstancesRequest { - req := apiClient.ListInstances(ctx, model.ProjectId) + req := apiClient.DefaultAPI.ListInstances(ctx, model.ProjectId) return req } @@ -131,15 +131,15 @@ func outputResult(p *print.Printer, outputFormat, projectLabel string, instances for i := range instances { instance := instances[i] - lastOperationType, lastOperationState := "", "" - if instance.LastOperation != nil { - lastOperationType = utils.PtrString(instance.LastOperation.Type) - lastOperationState = utils.PtrString(instance.LastOperation.State) + lastOperationType, lastOperationState := logme.INSTANCELASTOPERATIONTYPE_UNKNOWN_DEFAULT_OPEN_API, logme.INSTANCELASTOPERATIONSTATE_UNKNOWN_DEFAULT_OPEN_API + if _, ok := instance.LastOperation.GetStateOk(); ok { + lastOperationType = instance.LastOperation.Type + lastOperationState = instance.LastOperation.State } table.AddRow( utils.PtrString(instance.InstanceId), - utils.PtrString(instance.Name), + instance.Name, lastOperationType, lastOperationState, ) diff --git a/internal/cmd/logme/instance/list/list_test.go b/internal/cmd/logme/instance/list/list_test.go index 40309b3d8..ca24cc560 100644 --- a/internal/cmd/logme/instance/list/list_test.go +++ b/internal/cmd/logme/instance/list/list_test.go @@ -12,13 +12,13 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/logme" + logme "github.com/stackitcloud/stackit-sdk-go/services/logme/v1api" ) type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &logme.APIClient{} +var testClient = &logme.APIClient{DefaultAPI: &logme.DefaultAPIService{}} var testProjectId = uuid.NewString() func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string { @@ -47,7 +47,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *logme.ApiListInstancesRequest)) logme.ApiListInstancesRequest { - request := testClient.ListInstances(testCtx, testProjectId) + request := testClient.DefaultAPI.ListInstances(testCtx, testProjectId) for _, mod := range mods { mod(&request) } @@ -136,7 +136,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, logme.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/logme/instance/update/update.go b/internal/cmd/logme/instance/update/update.go index 9a16545ad..681d27d86 100644 --- a/internal/cmd/logme/instance/update/update.go +++ b/internal/cmd/logme/instance/update/update.go @@ -20,8 +20,8 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/logme" - "github.com/stackitcloud/stackit-sdk-go/services/logme/wait" + logme "github.com/stackitcloud/stackit-sdk-go/services/logme/v1api" + "github.com/stackitcloud/stackit-sdk-go/services/logme/v1api/wait" ) const ( @@ -33,7 +33,6 @@ const ( metricsFrequencyFlag = "metrics-frequency" metricsPrefixFlag = "metrics-prefix" monitoringInstanceIdFlag = "monitoring-instance-id" - pluginFlag = "plugin" sgwAclFlag = "acl" syslogFlag = "syslog" planIdFlag = "plan-id" @@ -49,12 +48,13 @@ type inputModel struct { EnableMonitoring *bool Graphite *string - MetricsFrequency *int64 + MetricsFrequency *int32 MetricsPrefix *string MonitoringInstanceId *string SgwAcl *[]string - Syslog *[]string + Syslog []string PlanId *string + InstanceName *string } func NewCmd(params *types.CmdParams) *cobra.Command { @@ -84,7 +84,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return err } - instanceLabel, err := logmeUtils.GetInstanceName(ctx, apiClient, model.ProjectId, model.InstanceId) + instanceLabel, err := logmeUtils.GetInstanceName(ctx, apiClient.DefaultAPI, model.ProjectId, model.InstanceId) if err != nil { params.Printer.Debug(print.ErrorLevel, "get instance name: %v", err) instanceLabel = model.InstanceId @@ -97,7 +97,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } // Call API - req, err := buildRequest(ctx, model, apiClient) + req, err := buildRequest(ctx, model, apiClient.DefaultAPI) if err != nil { var dsaInvalidPlanError *cliErr.DSAInvalidPlanError if !errors.As(err, &dsaInvalidPlanError) { @@ -114,7 +114,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { // Wait for async operation, if async mode not enabled if !model.Async { err := spinner.Run(params.Printer, "Updating instance", func() error { - _, err = wait.PartialUpdateInstanceWaitHandler(ctx, apiClient, model.ProjectId, instanceId).WaitWithContext(ctx) + _, err = wait.PartialUpdateInstanceWaitHandler(ctx, apiClient.DefaultAPI, model.ProjectId, instanceId).WaitWithContext(ctx) return err }) if err != nil { @@ -137,7 +137,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { func configureFlags(cmd *cobra.Command) { cmd.Flags().Bool(enableMonitoringFlag, false, "Enable monitoring") cmd.Flags().String(graphiteFlag, "", "Graphite host") - cmd.Flags().Int64(metricsFrequencyFlag, 0, "Metrics frequency") + cmd.Flags().Int32(metricsFrequencyFlag, 0, "Metrics frequency") cmd.Flags().String(metricsPrefixFlag, "", "Metrics prefix") cmd.Flags().Var(flags.UUIDFlag(), monitoringInstanceIdFlag, "Monitoring instance ID") cmd.Flags().Var(flags.CIDRSliceFlag(), sgwAclFlag, "List of IP networks in CIDR notation which are allowed to access this instance") @@ -145,6 +145,7 @@ func configureFlags(cmd *cobra.Command) { cmd.Flags().Var(flags.UUIDFlag(), planIdFlag, "Plan ID") cmd.Flags().String(planNameFlag, "", "Plan name") cmd.Flags().String(versionFlag, "", "Instance LogMe version") + cmd.Flags().StringP(instanceNameFlag, "n", "", "Instance name") } func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inputModel, error) { @@ -158,13 +159,14 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu enableMonitoring := flags.FlagToBoolPointer(p, cmd, enableMonitoringFlag) monitoringInstanceId := flags.FlagToStringPointer(p, cmd, monitoringInstanceIdFlag) graphite := flags.FlagToStringPointer(p, cmd, graphiteFlag) - metricsFrequency := flags.FlagToInt64Pointer(p, cmd, metricsFrequencyFlag) + metricsFrequency := flags.FlagToInt32Pointer(p, cmd, metricsFrequencyFlag) metricsPrefix := flags.FlagToStringPointer(p, cmd, metricsPrefixFlag) sgwAcl := flags.FlagToStringSlicePointer(p, cmd, sgwAclFlag) - syslog := flags.FlagToStringSlicePointer(p, cmd, syslogFlag) + syslog := flags.FlagToStringSliceValue(p, cmd, syslogFlag) planId := flags.FlagToStringPointer(p, cmd, planIdFlag) planName := flags.FlagToStringValue(p, cmd, planNameFlag) version := flags.FlagToStringValue(p, cmd, versionFlag) + instanceName := flags.FlagToStringPointer(p, cmd, instanceNameFlag) if planId != nil && (planName != "" || version != "") { return nil, &cliErr.DSAInputPlanError{ @@ -174,8 +176,8 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } if enableMonitoring == nil && monitoringInstanceId == nil && graphite == nil && - metricsFrequency == nil && metricsPrefix == nil && - sgwAcl == nil && syslog == nil && planId == nil && + metricsFrequency == nil && metricsPrefix == nil && sgwAcl == nil && + syslog == nil && planId == nil && instanceName == nil && planName == "" && version == "" { return nil, &cliErr.EmptyUpdateError{} } @@ -193,24 +195,20 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu PlanId: planId, PlanName: planName, Version: version, + InstanceName: instanceName, } p.DebugInputModel(model) return &model, nil } -type logMeClient interface { - PartialUpdateInstance(ctx context.Context, projectId, instanceId string) logme.ApiPartialUpdateInstanceRequest - ListOfferingsExecute(ctx context.Context, projectId string) (*logme.ListOfferingsResponse, error) -} - -func buildRequest(ctx context.Context, model *inputModel, apiClient logMeClient) (logme.ApiPartialUpdateInstanceRequest, error) { +func buildRequest(ctx context.Context, model *inputModel, apiClient logme.DefaultAPI) (logme.ApiPartialUpdateInstanceRequest, error) { req := apiClient.PartialUpdateInstance(ctx, model.ProjectId, model.InstanceId) var planId *string var err error - offerings, err := apiClient.ListOfferingsExecute(ctx, model.ProjectId) + offerings, err := apiClient.ListOfferings(ctx, model.ProjectId).Execute() if err != nil { return req, fmt.Errorf("get LogMe offerings: %w", err) } diff --git a/internal/cmd/logme/instance/update/update_test.go b/internal/cmd/logme/instance/update/update_test.go index 957a5a340..985e06669 100644 --- a/internal/cmd/logme/instance/update/update_test.go +++ b/internal/cmd/logme/instance/update/update_test.go @@ -12,7 +12,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/logme" + logme "github.com/stackitcloud/stackit-sdk-go/services/logme/v1api" ) var projectIdFlag = globalflags.ProjectIdFlag @@ -20,22 +20,22 @@ var projectIdFlag = globalflags.ProjectIdFlag type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &logme.APIClient{} +var testClient = &logme.APIClient{DefaultAPI: &logme.DefaultAPIService{}} -type logMeClientMocked struct { +type mockSettings struct { returnError bool listOfferingsResp *logme.ListOfferingsResponse } -func (c *logMeClientMocked) PartialUpdateInstance(ctx context.Context, projectId, instanceId string) logme.ApiPartialUpdateInstanceRequest { - return testClient.PartialUpdateInstance(ctx, projectId, instanceId) -} - -func (c *logMeClientMocked) ListOfferingsExecute(_ context.Context, _ string) (*logme.ListOfferingsResponse, error) { - if c.returnError { - return nil, fmt.Errorf("list flavors failed") +func newAPIMock(s mockSettings) logme.DefaultAPI { + return &logme.DefaultAPIServiceMock{ + ListOfferingsExecuteMock: utils.Ptr(func(_ logme.ApiListOfferingsRequest) (*logme.ListOfferingsResponse, error) { + if s.returnError { + return nil, fmt.Errorf("list flavors failed") + } + return s.listOfferingsResp, nil + }), } - return c.listOfferingsResp, nil } var ( @@ -82,12 +82,12 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { InstanceId: testInstanceId, EnableMonitoring: utils.Ptr(true), Graphite: utils.Ptr("example-graphite"), - MetricsFrequency: utils.Ptr(int64(100)), + MetricsFrequency: utils.Ptr(int32(100)), MetricsPrefix: utils.Ptr("example-prefix"), - MonitoringInstanceId: utils.Ptr(testMonitoringInstanceId), + MonitoringInstanceId: &testMonitoringInstanceId, SgwAcl: utils.Ptr([]string{"198.51.100.14/24"}), - Syslog: utils.Ptr([]string{"example-syslog"}), - PlanId: utils.Ptr(testPlanId), + Syslog: []string{"example-syslog"}, + PlanId: &testPlanId, } for _, mod := range mods { mod(model) @@ -96,18 +96,18 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *logme.ApiPartialUpdateInstanceRequest)) logme.ApiPartialUpdateInstanceRequest { - request := testClient.PartialUpdateInstance(testCtx, testProjectId, testInstanceId) + request := testClient.DefaultAPI.PartialUpdateInstance(testCtx, testProjectId, testInstanceId) request = request.PartialUpdateInstancePayload(logme.PartialUpdateInstancePayload{ Parameters: &logme.InstanceParameters{ EnableMonitoring: utils.Ptr(true), Graphite: utils.Ptr("example-graphite"), - MetricsFrequency: utils.Ptr(int64(100)), + MetricsFrequency: utils.Ptr(int32(100)), MetricsPrefix: utils.Ptr("example-prefix"), - MonitoringInstanceId: utils.Ptr(testMonitoringInstanceId), + MonitoringInstanceId: &testMonitoringInstanceId, SgwAcl: utils.Ptr("198.51.100.14/24"), - Syslog: utils.Ptr([]string{"example-syslog"}), + Syslog: []string{"example-syslog"}, }, - PlanId: utils.Ptr(testPlanId), + PlanId: &testPlanId, }) for _, mod := range mods { mod(&request) @@ -183,10 +183,10 @@ func TestParseInput(t *testing.T) { Verbosity: globalflags.VerbosityDefault, }, InstanceId: testInstanceId, - PlanId: utils.Ptr(testPlanId), + PlanId: &testPlanId, EnableMonitoring: utils.Ptr(false), Graphite: utils.Ptr(""), - MetricsFrequency: utils.Ptr(int64(0)), + MetricsFrequency: utils.Ptr(int32(0)), MetricsPrefix: utils.Ptr(""), }, }, @@ -257,9 +257,7 @@ func TestParseInput(t *testing.T) { syslogValues: []string{"example-syslog-1", "example-syslog-2"}, isValid: true, expectedModel: fixtureInputModel(func(model *inputModel) { - model.Syslog = utils.Ptr( - append(*model.Syslog, "example-syslog-1", "example-syslog-2"), - ) + model.Syslog = append(model.Syslog, "example-syslog-1", "example-syslog-2") }), }, } @@ -352,13 +350,13 @@ func TestBuildRequest(t *testing.T) { model: fixtureInputModel(), expectedRequest: fixtureRequest(), listOfferingsResp: &logme.ListOfferingsResponse{ - Offerings: &[]logme.Offering{ + Offerings: []logme.Offering{ { - Version: utils.Ptr("example-version"), - Plans: &[]logme.Plan{ + Version: "example-version", + Plans: []logme.Plan{ { - Name: utils.Ptr("example-plan-name"), - Id: utils.Ptr(testPlanId), + Name: "example-plan-name", + Id: testPlanId, }, }, }, @@ -376,13 +374,13 @@ func TestBuildRequest(t *testing.T) { ), expectedRequest: fixtureRequest(), listOfferingsResp: &logme.ListOfferingsResponse{ - Offerings: &[]logme.Offering{ + Offerings: []logme.Offering{ { - Version: utils.Ptr("example-version"), - Plans: &[]logme.Plan{ + Version: "example-version", + Plans: []logme.Plan{ { - Name: utils.Ptr("example-plan-name"), - Id: utils.Ptr(testPlanId), + Name: "example-plan-name", + Id: testPlanId, }, }, }, @@ -411,13 +409,13 @@ func TestBuildRequest(t *testing.T) { }, ), listOfferingsResp: &logme.ListOfferingsResponse{ - Offerings: &[]logme.Offering{ + Offerings: []logme.Offering{ { - Version: utils.Ptr("example-version"), - Plans: &[]logme.Plan{ + Version: "example-version", + Plans: []logme.Plan{ { - Name: utils.Ptr("other-plan-name"), - Id: utils.Ptr(testPlanId), + Name: "other-plan-name", + Id: testPlanId, }, }, }, @@ -434,18 +432,18 @@ func TestBuildRequest(t *testing.T) { }, InstanceId: testInstanceId, }, - expectedRequest: testClient.PartialUpdateInstance(testCtx, testProjectId, testInstanceId). + expectedRequest: testClient.DefaultAPI.PartialUpdateInstance(testCtx, testProjectId, testInstanceId). PartialUpdateInstancePayload(logme.PartialUpdateInstancePayload{Parameters: &logme.InstanceParameters{}}), }, } for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { - client := &logMeClientMocked{ + settings := mockSettings{ returnError: tt.getOfferingsFails, listOfferingsResp: tt.listOfferingsResp, } - request, err := buildRequest(testCtx, tt.model, client) + request, err := buildRequest(testCtx, tt.model, newAPIMock(settings)) if err != nil { if !tt.isValid { return @@ -456,6 +454,8 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), cmpopts.EquateComparable(testCtx), + cmpopts.EquateEmpty(), + cmpopts.IgnoreFields(tt.expectedRequest, "ApiService"), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/logme/plans/plans.go b/internal/cmd/logme/plans/plans.go index 76d762a1d..2b8d58e9a 100644 --- a/internal/cmd/logme/plans/plans.go +++ b/internal/cmd/logme/plans/plans.go @@ -7,7 +7,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/types" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/logme" + logme "github.com/stackitcloud/stackit-sdk-go/services/logme/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/args" "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -18,7 +18,6 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/projectname" "github.com/stackitcloud/stackit-cli/internal/pkg/services/logme/client" "github.com/stackitcloud/stackit-cli/internal/pkg/tables" - "github.com/stackitcloud/stackit-cli/internal/pkg/utils" ) const ( @@ -115,7 +114,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, } func buildRequest(ctx context.Context, model *inputModel, apiClient *logme.APIClient) logme.ApiListOfferingsRequest { - req := apiClient.ListOfferings(ctx, model.ProjectId) + req := apiClient.DefaultAPI.ListOfferings(ctx, model.ProjectId) return req } @@ -131,14 +130,14 @@ func outputResult(p *print.Printer, outputFormat, projectLabel string, plans []l for i := range plans { o := plans[i] if o.Plans != nil { - for j := range *o.Plans { - p := (*o.Plans)[j] + for j := range o.Plans { + p := (o.Plans)[j] table.AddRow( - utils.PtrString(o.Name), - utils.PtrString(o.Version), - utils.PtrString(p.Id), - utils.PtrString(p.Name), - utils.PtrString(p.Description), + o.Name, + o.Version, + p.Id, + p.Name, + p.Description, ) } table.AddSeparator() diff --git a/internal/cmd/logme/plans/plans_test.go b/internal/cmd/logme/plans/plans_test.go index 1b3cedebb..9555d8840 100644 --- a/internal/cmd/logme/plans/plans_test.go +++ b/internal/cmd/logme/plans/plans_test.go @@ -12,13 +12,13 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/logme" + logme "github.com/stackitcloud/stackit-sdk-go/services/logme/v1api" ) type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &logme.APIClient{} +var testClient = &logme.APIClient{DefaultAPI: &logme.DefaultAPIService{}} var testProjectId = uuid.NewString() func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string { @@ -47,7 +47,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *logme.ApiListOfferingsRequest)) logme.ApiListOfferingsRequest { - request := testClient.ListOfferings(testCtx, testProjectId) + request := testClient.DefaultAPI.ListOfferings(testCtx, testProjectId) for _, mod := range mods { mod(&request) } @@ -136,7 +136,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, logme.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/pkg/services/logme/client/client.go b/internal/pkg/services/logme/client/client.go index f65bcfb6a..e07801cb8 100644 --- a/internal/pkg/services/logme/client/client.go +++ b/internal/pkg/services/logme/client/client.go @@ -6,9 +6,9 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/print" "github.com/spf13/viper" - "github.com/stackitcloud/stackit-sdk-go/services/logme" + logme "github.com/stackitcloud/stackit-sdk-go/services/logme/v1api" ) func ConfigureClient(p *print.Printer, cliVersion string) (*logme.APIClient, error) { - return genericclient.ConfigureClientGeneric(p, cliVersion, viper.GetString(config.LogMeCustomEndpointKey), true, genericclient.CreateApiClient[*logme.APIClient](logme.NewAPIClient)) + return genericclient.ConfigureClientGeneric(p, cliVersion, viper.GetString(config.LogMeCustomEndpointKey), true, logme.NewAPIClient) } diff --git a/internal/pkg/services/logme/utils/utils.go b/internal/pkg/services/logme/utils/utils.go index d63b4ea5d..072f6bafd 100644 --- a/internal/pkg/services/logme/utils/utils.go +++ b/internal/pkg/services/logme/utils/utils.go @@ -7,7 +7,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/errors" - "github.com/stackitcloud/stackit-sdk-go/services/logme" + logme "github.com/stackitcloud/stackit-sdk-go/services/logme/v1api" ) const ( @@ -15,9 +15,9 @@ const ( ) func ValidatePlanId(planId string, offerings *logme.ListOfferingsResponse) error { - for _, offer := range *offerings.Offerings { - for _, plan := range *offer.Plans { - if plan.Id != nil && strings.EqualFold(*plan.Id, planId) { + for _, offer := range offerings.Offerings { + for _, plan := range offer.Plans { + if strings.EqualFold(plan.Id, planId) { return nil } } @@ -33,21 +33,18 @@ func LoadPlanId(planName, version string, offerings *logme.ListOfferingsResponse availableVersions := "" availablePlanNames := "" isValidVersion := false - for _, offer := range *offerings.Offerings { - if !strings.EqualFold(*offer.Version, version) { - availableVersions = fmt.Sprintf("%s\n- %s", availableVersions, *offer.Version) + for _, offer := range offerings.Offerings { + if !strings.EqualFold(offer.Version, version) { + availableVersions = fmt.Sprintf("%s\n- %s", availableVersions, offer.Version) continue } isValidVersion = true - for _, plan := range *offer.Plans { - if plan.Name == nil { - continue + for _, plan := range offer.Plans { + if strings.EqualFold(plan.Name, planName) { + return &plan.Id, nil } - if strings.EqualFold(*plan.Name, planName) && plan.Id != nil { - return plan.Id, nil - } - availablePlanNames = fmt.Sprintf("%s\n- %s", availablePlanNames, *plan.Name) + availablePlanNames = fmt.Sprintf("%s\n- %s", availablePlanNames, plan.Name) } } @@ -65,23 +62,18 @@ func LoadPlanId(planName, version string, offerings *logme.ListOfferingsResponse } } -type LogMeClient interface { - GetInstanceExecute(ctx context.Context, projectId, instanceId string) (*logme.Instance, error) - GetCredentialsExecute(ctx context.Context, projectId, instanceId, credentialsId string) (*logme.CredentialsResponse, error) -} - -func GetInstanceName(ctx context.Context, apiClient LogMeClient, projectId, instanceId string) (string, error) { - resp, err := apiClient.GetInstanceExecute(ctx, projectId, instanceId) +func GetInstanceName(ctx context.Context, apiClient logme.DefaultAPI, projectId, instanceId string) (string, error) { + resp, err := apiClient.GetInstance(ctx, projectId, instanceId).Execute() if err != nil { return "", fmt.Errorf("get LogMe instance: %w", err) } - return *resp.Name, nil + return resp.Name, nil } -func GetCredentialsUsername(ctx context.Context, apiClient LogMeClient, projectId, instanceId, credentialsId string) (string, error) { - resp, err := apiClient.GetCredentialsExecute(ctx, projectId, instanceId, credentialsId) +func GetCredentialsUsername(ctx context.Context, apiClient logme.DefaultAPI, projectId, instanceId, credentialsId string) (string, error) { + resp, err := apiClient.GetCredentials(ctx, projectId, instanceId, credentialsId).Execute() if err != nil { return "", fmt.Errorf("get LogMe credentials: %w", err) } - return *resp.Raw.Credentials.Username, nil + return resp.Raw.Credentials.Username, nil } diff --git a/internal/pkg/services/logme/utils/utils_test.go b/internal/pkg/services/logme/utils/utils_test.go index 97fde111f..b9384e29a 100644 --- a/internal/pkg/services/logme/utils/utils_test.go +++ b/internal/pkg/services/logme/utils/utils_test.go @@ -8,7 +8,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/logme" + logme "github.com/stackitcloud/stackit-sdk-go/services/logme/v1api" ) var ( @@ -22,25 +22,28 @@ const ( testCredentialsUsername = "username" ) -type logMeClientMocked struct { +type mockSettings struct { getInstanceFails bool getInstanceResp *logme.Instance getCredentialsFails bool getCredentialsResp *logme.CredentialsResponse } -func (m *logMeClientMocked) GetInstanceExecute(_ context.Context, _, _ string) (*logme.Instance, error) { - if m.getInstanceFails { - return nil, fmt.Errorf("could not get instance") - } - return m.getInstanceResp, nil -} - -func (m *logMeClientMocked) GetCredentialsExecute(_ context.Context, _, _, _ string) (*logme.CredentialsResponse, error) { - if m.getCredentialsFails { - return nil, fmt.Errorf("could not get user") +func newAPIMock(s mockSettings) logme.DefaultAPI { + return &logme.DefaultAPIServiceMock{ + GetInstanceExecuteMock: utils.Ptr(func(_ logme.ApiGetInstanceRequest) (*logme.Instance, error) { + if s.getInstanceFails { + return nil, fmt.Errorf("could not get instance") + } + return s.getInstanceResp, nil + }), + GetCredentialsExecuteMock: utils.Ptr(func(_ logme.ApiGetCredentialsRequest) (*logme.CredentialsResponse, error) { + if s.getCredentialsFails { + return nil, fmt.Errorf("could not get user") + } + return s.getCredentialsResp, nil + }), } - return m.getCredentialsResp, nil } func TestGetInstanceName(t *testing.T) { @@ -54,7 +57,7 @@ func TestGetInstanceName(t *testing.T) { { description: "base", getInstanceResp: &logme.Instance{ - Name: utils.Ptr(testInstanceName), + Name: testInstanceName, }, isValid: true, expectedOutput: testInstanceName, @@ -68,12 +71,12 @@ func TestGetInstanceName(t *testing.T) { for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { - client := &logMeClientMocked{ + client := mockSettings{ getInstanceFails: tt.getInstanceFails, getInstanceResp: tt.getInstanceResp, } - output, err := GetInstanceName(context.Background(), client, testProjectId, testInstanceId) + output, err := GetInstanceName(context.Background(), newAPIMock(client), testProjectId, testInstanceId) if tt.isValid && err != nil { t.Errorf("failed on valid input") @@ -103,8 +106,8 @@ func TestGetCredentialsUsername(t *testing.T) { description: "base", getCredentialsResp: &logme.CredentialsResponse{ Raw: &logme.RawCredentials{ - Credentials: &logme.Credentials{ - Username: utils.Ptr(testCredentialsUsername), + Credentials: logme.Credentials{ + Username: testCredentialsUsername, }, }, }, @@ -120,12 +123,12 @@ func TestGetCredentialsUsername(t *testing.T) { for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { - client := &logMeClientMocked{ + client := mockSettings{ getCredentialsFails: tt.getCredentialsFails, getCredentialsResp: tt.getCredentialsResp, } - output, err := GetCredentialsUsername(context.Background(), client, testProjectId, testInstanceId, testCredentialsId) + output, err := GetCredentialsUsername(context.Background(), newAPIMock(client), testProjectId, testInstanceId, testCredentialsId) if tt.isValid && err != nil { t.Errorf("failed on valid input") From 57234f563051f51707c3e14431f46459201e0a0d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 7 Jul 2026 08:36:03 +0000 Subject: [PATCH 18/44] chore(deps): bump goreleaser/goreleaser-action from 7.2.2 to 7.2.3 (#1459) --- .github/workflows/ci.yaml | 2 +- .github/workflows/release.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index ed4736434..627fd852b 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -50,7 +50,7 @@ jobs: uses: actions/checkout@v7.0.0 - name: Check GoReleaser - uses: goreleaser/goreleaser-action@v7.2.2 + uses: goreleaser/goreleaser-action@v7.2.3 with: args: check diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 9f43854e3..70ea665b3 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -74,7 +74,7 @@ jobs: uses: samuelmeuli/action-snapcraft@v3 - name: Run GoReleaser - uses: goreleaser/goreleaser-action@v7.2.2 + uses: goreleaser/goreleaser-action@v7.2.3 with: args: release --clean env: From 59e76969c16a784fe235a15dd73607cf947658e9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 7 Jul 2026 08:41:28 +0000 Subject: [PATCH 19/44] chore(deps): bump actions/setup-go from 6.4.0 to 6.5.0 (#1450) --- .github/workflows/ci.yaml | 2 +- .github/workflows/release.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 627fd852b..3b2e9d7a2 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -20,7 +20,7 @@ jobs: uses: actions/checkout@v7.0.0 - name: Install go - uses: actions/setup-go@v6.4.0 + uses: actions/setup-go@v6.5.0 with: go-version-file: "go.mod" cache: true diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 70ea665b3..f8bb91e0c 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -29,7 +29,7 @@ jobs: fetch-depth: 0 - name: Install go - uses: actions/setup-go@v6.4.0 + uses: actions/setup-go@v6.5.0 with: go-version-file: "go.mod" cache: true From 72304226daeff1f57ed18fe1af6017359c85c96b Mon Sep 17 00:00:00 2001 From: Jan Obernberger <52105660+j1n-o9r@users.noreply.github.com> Date: Tue, 7 Jul 2026 14:07:12 +0200 Subject: [PATCH 20/44] chore(mariadb): sdk migration (#1447) relates to STACKITCLI-368 --- docs/stackit_mariadb_instance_create.md | 2 +- docs/stackit_mariadb_instance_update.md | 2 +- go.mod | 2 +- go.sum | 4 +- .../cmd/mariadb/credentials/create/create.go | 31 +++---- .../mariadb/credentials/create/create_test.go | 8 +- .../cmd/mariadb/credentials/delete/delete.go | 8 +- .../mariadb/credentials/delete/delete_test.go | 8 +- .../mariadb/credentials/describe/describe.go | 14 +-- .../credentials/describe/describe_test.go | 8 +- internal/cmd/mariadb/credentials/list/list.go | 9 +- .../cmd/mariadb/credentials/list/list_test.go | 8 +- .../cmd/mariadb/instance/create/create.go | 35 +++---- .../mariadb/instance/create/create_test.go | 92 +++++++++---------- .../cmd/mariadb/instance/delete/delete.go | 10 +- .../mariadb/instance/delete/delete_test.go | 8 +- .../cmd/mariadb/instance/describe/describe.go | 16 ++-- .../instance/describe/describe_test.go | 8 +- internal/cmd/mariadb/instance/list/list.go | 13 +-- .../cmd/mariadb/instance/list/list_test.go | 8 +- .../cmd/mariadb/instance/update/update.go | 29 +++--- .../mariadb/instance/update/update_test.go | 76 +++++++-------- internal/cmd/mariadb/plans/plans.go | 19 ++-- internal/cmd/mariadb/plans/plans_test.go | 8 +- .../pkg/services/mariadb/client/client.go | 4 +- internal/pkg/services/mariadb/utils/utils.go | 42 ++++----- .../pkg/services/mariadb/utils/utils_test.go | 43 +++++---- 27 files changed, 246 insertions(+), 269 deletions(-) diff --git a/docs/stackit_mariadb_instance_create.md b/docs/stackit_mariadb_instance_create.md index f37668d28..2fc227325 100644 --- a/docs/stackit_mariadb_instance_create.md +++ b/docs/stackit_mariadb_instance_create.md @@ -30,7 +30,7 @@ stackit mariadb instance create [flags] --enable-monitoring Enable monitoring --graphite string Graphite host -h, --help Help for "stackit mariadb instance create" - --metrics-frequency int Metrics frequency + --metrics-frequency int32 Metrics frequency --metrics-prefix string Metrics prefix --monitoring-instance-id string Monitoring instance ID -n, --name string Instance name diff --git a/docs/stackit_mariadb_instance_update.md b/docs/stackit_mariadb_instance_update.md index d6fbc7c49..8032fc982 100644 --- a/docs/stackit_mariadb_instance_update.md +++ b/docs/stackit_mariadb_instance_update.md @@ -27,7 +27,7 @@ stackit mariadb instance update INSTANCE_ID [flags] --enable-monitoring Enable monitoring --graphite string Graphite host -h, --help Help for "stackit mariadb instance update" - --metrics-frequency int Metrics frequency + --metrics-frequency int32 Metrics frequency --metrics-prefix string Metrics prefix --monitoring-instance-id string Monitoring instance ID --plan-id string Plan ID diff --git a/go.mod b/go.mod index b66fc9bae..c727cfa21 100644 --- a/go.mod +++ b/go.mod @@ -268,7 +268,7 @@ require ( github.com/stackitcloud/stackit-sdk-go/services/kms v1.11.0 github.com/stackitcloud/stackit-sdk-go/services/loadbalancer v1.14.0 github.com/stackitcloud/stackit-sdk-go/services/logme v0.30.0 - github.com/stackitcloud/stackit-sdk-go/services/mariadb v0.25.6 + github.com/stackitcloud/stackit-sdk-go/services/mariadb v0.30.0 github.com/stackitcloud/stackit-sdk-go/services/objectstorage v1.7.0 github.com/stackitcloud/stackit-sdk-go/services/observability v0.17.0 github.com/stackitcloud/stackit-sdk-go/services/rabbitmq v1.1.0 diff --git a/go.sum b/go.sum index 3fcbb9244..62fb2b288 100644 --- a/go.sum +++ b/go.sum @@ -620,8 +620,8 @@ github.com/stackitcloud/stackit-sdk-go/services/logme v0.30.0 h1:csZlzmvAB+klgUQ github.com/stackitcloud/stackit-sdk-go/services/logme v0.30.0/go.mod h1:JDOOYaGgcBts2x52nKPRMFgSZe7qqOFmfz1xIXCQgRY= github.com/stackitcloud/stackit-sdk-go/services/logs v0.5.2 h1:vr4atxFRT+EL+DqONMT5R44f7AzEMbePa9U7PEE0THU= github.com/stackitcloud/stackit-sdk-go/services/logs v0.5.2/go.mod h1:CAPsiTX7osAImfrG5RnIjaJ/Iz3QpoBKuH2fS346wuQ= -github.com/stackitcloud/stackit-sdk-go/services/mariadb v0.25.6 h1:Y/byRjX2u/OZl0gKS/Rau6ob2bDyv26xnw6A6JNkKJk= -github.com/stackitcloud/stackit-sdk-go/services/mariadb v0.25.6/go.mod h1:sY66ZgCgBc1mScPV95ek5WtUEGYizdP1RMsGaqbdbhw= +github.com/stackitcloud/stackit-sdk-go/services/mariadb v0.30.0 h1:LFIH1wAp633ZAJw/7H3F4nq1DZe0Qu3rlDeXhobZEZA= +github.com/stackitcloud/stackit-sdk-go/services/mariadb v0.30.0/go.mod h1:joa89Y1dyn0j22FstRcIKfW2ada3FDxNfttxSvq27uY= github.com/stackitcloud/stackit-sdk-go/services/mongodbflex v1.5.8 h1:S7t4wcT6SN8ZzdoY8d6VbF903zFpGjzqrU0FN27rJPg= github.com/stackitcloud/stackit-sdk-go/services/mongodbflex v1.5.8/go.mod h1:CdrhFUsBO7/iJleCc2yQjDChIbG6YaxKNBQRNCjgcF4= github.com/stackitcloud/stackit-sdk-go/services/objectstorage v1.7.0 h1:UxnbsKm6PQV8Gudw/EhySaEh9q1xSaTG8mzJz1EvhnE= diff --git a/internal/cmd/mariadb/credentials/create/create.go b/internal/cmd/mariadb/credentials/create/create.go index f3d9e1155..f81cb41cc 100644 --- a/internal/cmd/mariadb/credentials/create/create.go +++ b/internal/cmd/mariadb/credentials/create/create.go @@ -6,6 +6,9 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/types" + "github.com/spf13/cobra" + mariadb "github.com/stackitcloud/stackit-sdk-go/services/mariadb/v1api" + "github.com/stackitcloud/stackit-cli/internal/pkg/args" "github.com/stackitcloud/stackit-cli/internal/pkg/errors" "github.com/stackitcloud/stackit-cli/internal/pkg/examples" @@ -14,10 +17,6 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/print" "github.com/stackitcloud/stackit-cli/internal/pkg/services/mariadb/client" mariadbUtils "github.com/stackitcloud/stackit-cli/internal/pkg/services/mariadb/utils" - "github.com/stackitcloud/stackit-cli/internal/pkg/utils" - - "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/mariadb" ) const ( @@ -58,7 +57,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return err } - instanceLabel, err := mariadbUtils.GetInstanceName(ctx, apiClient, model.ProjectId, model.InstanceId) + instanceLabel, err := mariadbUtils.GetInstanceName(ctx, apiClient.DefaultAPI, model.ProjectId, model.InstanceId) if err != nil { params.Printer.Debug(print.ErrorLevel, "get instance name: %v", err) instanceLabel = model.InstanceId @@ -109,7 +108,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, } func buildRequest(ctx context.Context, model *inputModel, apiClient *mariadb.APIClient) mariadb.ApiCreateCredentialsRequest { - req := apiClient.CreateCredentials(ctx, model.ProjectId, model.InstanceId) + req := apiClient.DefaultAPI.CreateCredentials(ctx, model.ProjectId, model.InstanceId) return req } @@ -118,26 +117,26 @@ func outputResult(p *print.Printer, outputFormat string, showPassword bool, inst return fmt.Errorf("response is nil") } - if !showPassword && resp.HasRaw() && resp.Raw.Credentials != nil { - resp.Raw.Credentials.Password = utils.Ptr("hidden") + if !showPassword && resp.HasRaw() { + resp.Raw.Credentials.Password = "hidden" } return p.OutputResult(outputFormat, resp, func() error { - p.Outputf("Created credentials for instance %q. Credentials ID: %s\n\n", instanceLabel, utils.PtrString(resp.Id)) + p.Outputf("Created credentials for instance %q. Credentials ID: %s\n\n", instanceLabel, resp.Id) // The username field cannot be set by the user, so we only display it if it's not returned empty - if resp.HasRaw() && resp.Raw.Credentials != nil { - if username := resp.Raw.Credentials.Username; username != nil && *username != "" { - p.Outputf("Username: %s\n", *username) + if resp.HasRaw() { + if resp.Raw.Credentials.Username != "" { + p.Outputf("Username: %s\n", resp.Raw.Credentials.Username) } if !showPassword { p.Outputf("Password: \n") } else { - p.Outputf("Password: %s\n", utils.PtrString(resp.Raw.Credentials.Password)) + p.Outputf("Password: %s\n", resp.Raw.Credentials.Password) } - p.Outputf("Host: %s\n", utils.PtrString(resp.Raw.Credentials.Host)) - p.Outputf("Port: %s\n", utils.PtrString(resp.Raw.Credentials.Port)) + p.Outputf("Host: %s\n", resp.Raw.Credentials.Host) + p.Outputf("Port: %d\n", resp.Raw.Credentials.Port) } - p.Outputf("URI: %s\n", utils.PtrString(resp.Uri)) + p.Outputf("URI: %s\n", resp.Uri) return nil }) } diff --git a/internal/cmd/mariadb/credentials/create/create_test.go b/internal/cmd/mariadb/credentials/create/create_test.go index b3d6738e4..40b423653 100644 --- a/internal/cmd/mariadb/credentials/create/create_test.go +++ b/internal/cmd/mariadb/credentials/create/create_test.go @@ -11,7 +11,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/mariadb" + mariadb "github.com/stackitcloud/stackit-sdk-go/services/mariadb/v1api" ) var projectIdFlag = globalflags.ProjectIdFlag @@ -19,7 +19,7 @@ var projectIdFlag = globalflags.ProjectIdFlag type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &mariadb.APIClient{} +var testClient = &mariadb.APIClient{DefaultAPI: &mariadb.DefaultAPIService{}} var testProjectId = uuid.NewString() var testInstanceId = uuid.NewString() @@ -49,7 +49,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *mariadb.ApiCreateCredentialsRequest)) mariadb.ApiCreateCredentialsRequest { - request := testClient.CreateCredentials(testCtx, testProjectId, testInstanceId) + request := testClient.DefaultAPI.CreateCredentials(testCtx, testProjectId, testInstanceId) for _, mod := range mods { mod(&request) } @@ -155,7 +155,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, mariadb.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/mariadb/credentials/delete/delete.go b/internal/cmd/mariadb/credentials/delete/delete.go index 7fd89c4e9..f77d558cc 100644 --- a/internal/cmd/mariadb/credentials/delete/delete.go +++ b/internal/cmd/mariadb/credentials/delete/delete.go @@ -17,7 +17,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/mariadb" + mariadb "github.com/stackitcloud/stackit-sdk-go/services/mariadb/v1api" ) const ( @@ -56,13 +56,13 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return err } - instanceLabel, err := mariadbUtils.GetInstanceName(ctx, apiClient, model.ProjectId, model.InstanceId) + instanceLabel, err := mariadbUtils.GetInstanceName(ctx, apiClient.DefaultAPI, model.ProjectId, model.InstanceId) if err != nil { params.Printer.Debug(print.ErrorLevel, "get instance name: %v", err) instanceLabel = model.InstanceId } - credentialsLabel, err := mariadbUtils.GetCredentialsUsername(ctx, apiClient, model.ProjectId, model.InstanceId, model.CredentialsId) + credentialsLabel, err := mariadbUtils.GetCredentialsUsername(ctx, apiClient.DefaultAPI, model.ProjectId, model.InstanceId, model.CredentialsId) if err != nil { params.Printer.Debug(print.ErrorLevel, "get credentials username: %v", err) credentialsLabel = model.CredentialsId @@ -115,6 +115,6 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *mariadb.APIClient) mariadb.ApiDeleteCredentialsRequest { - req := apiClient.DeleteCredentials(ctx, model.ProjectId, model.InstanceId, model.CredentialsId) + req := apiClient.DefaultAPI.DeleteCredentials(ctx, model.ProjectId, model.InstanceId, model.CredentialsId) return req } diff --git a/internal/cmd/mariadb/credentials/delete/delete_test.go b/internal/cmd/mariadb/credentials/delete/delete_test.go index 5f8ba6638..c192ad5e1 100644 --- a/internal/cmd/mariadb/credentials/delete/delete_test.go +++ b/internal/cmd/mariadb/credentials/delete/delete_test.go @@ -10,7 +10,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/mariadb" + mariadb "github.com/stackitcloud/stackit-sdk-go/services/mariadb/v1api" ) var projectIdFlag = globalflags.ProjectIdFlag @@ -18,7 +18,7 @@ var projectIdFlag = globalflags.ProjectIdFlag type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &mariadb.APIClient{} +var testClient = &mariadb.APIClient{DefaultAPI: &mariadb.DefaultAPIService{}} var testProjectId = uuid.NewString() var testInstanceId = uuid.NewString() var testCredentialsId = uuid.NewString() @@ -60,7 +60,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *mariadb.ApiDeleteCredentialsRequest)) mariadb.ApiDeleteCredentialsRequest { - request := testClient.DeleteCredentials(testCtx, testProjectId, testInstanceId, testCredentialsId) + request := testClient.DefaultAPI.DeleteCredentials(testCtx, testProjectId, testInstanceId, testCredentialsId) for _, mod := range mods { mod(&request) } @@ -188,7 +188,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, mariadb.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/mariadb/credentials/describe/describe.go b/internal/cmd/mariadb/credentials/describe/describe.go index 368e13e88..e2f9f5f7f 100644 --- a/internal/cmd/mariadb/credentials/describe/describe.go +++ b/internal/cmd/mariadb/credentials/describe/describe.go @@ -17,7 +17,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/mariadb" + mariadb "github.com/stackitcloud/stackit-sdk-go/services/mariadb/v1api" ) const ( @@ -99,7 +99,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *mariadb.APIClient) mariadb.ApiGetCredentialsRequest { - req := apiClient.GetCredentials(ctx, model.ProjectId, model.InstanceId, model.CredentialsId) + req := apiClient.DefaultAPI.GetCredentials(ctx, model.ProjectId, model.InstanceId, model.CredentialsId) return req } @@ -110,15 +110,15 @@ func outputResult(p *print.Printer, outputFormat string, credentials *mariadb.Cr return p.OutputResult(outputFormat, credentials, func() error { table := tables.NewTable() - table.AddRow("ID", utils.PtrString(credentials.Id)) + table.AddRow("ID", credentials.Id) table.AddSeparator() // The username field cannot be set by the user so we only display it if it's not returned empty - if credentials.HasRaw() && credentials.Raw.Credentials != nil { - if username := credentials.Raw.Credentials.Username; username != nil && *username != "" { - table.AddRow("USERNAME", *username) + if credentials.HasRaw() { + if credentials.Raw.Credentials.Username != "" { + table.AddRow("USERNAME", credentials.Raw.Credentials.Username) table.AddSeparator() } - table.AddRow("PASSWORD", utils.PtrString(credentials.Raw.Credentials.Password)) + table.AddRow("PASSWORD", credentials.Raw.Credentials.Password) table.AddSeparator() table.AddRow("URI", utils.PtrString(credentials.Raw.Credentials.Uri)) } diff --git a/internal/cmd/mariadb/credentials/describe/describe_test.go b/internal/cmd/mariadb/credentials/describe/describe_test.go index dac137e39..d677079c4 100644 --- a/internal/cmd/mariadb/credentials/describe/describe_test.go +++ b/internal/cmd/mariadb/credentials/describe/describe_test.go @@ -11,7 +11,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/mariadb" + mariadb "github.com/stackitcloud/stackit-sdk-go/services/mariadb/v1api" ) var projectIdFlag = globalflags.ProjectIdFlag @@ -19,7 +19,7 @@ var projectIdFlag = globalflags.ProjectIdFlag type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &mariadb.APIClient{} +var testClient = &mariadb.APIClient{DefaultAPI: &mariadb.DefaultAPIService{}} var testProjectId = uuid.NewString() var testInstanceId = uuid.NewString() var testCredentialsId = uuid.NewString() @@ -61,7 +61,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *mariadb.ApiGetCredentialsRequest)) mariadb.ApiGetCredentialsRequest { - request := testClient.GetCredentials(testCtx, testProjectId, testInstanceId, testCredentialsId) + request := testClient.DefaultAPI.GetCredentials(testCtx, testProjectId, testInstanceId, testCredentialsId) for _, mod := range mods { mod(&request) } @@ -189,7 +189,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, mariadb.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/mariadb/credentials/list/list.go b/internal/cmd/mariadb/credentials/list/list.go index 339891e99..90f42ad12 100644 --- a/internal/cmd/mariadb/credentials/list/list.go +++ b/internal/cmd/mariadb/credentials/list/list.go @@ -7,7 +7,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/types" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/mariadb" + mariadb "github.com/stackitcloud/stackit-sdk-go/services/mariadb/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/args" "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -18,7 +18,6 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/services/mariadb/client" mariadbUtils "github.com/stackitcloud/stackit-cli/internal/pkg/services/mariadb/utils" "github.com/stackitcloud/stackit-cli/internal/pkg/tables" - "github.com/stackitcloud/stackit-cli/internal/pkg/utils" ) const ( @@ -70,7 +69,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } credentials := resp.GetCredentialsList() - instanceLabel, err := mariadbUtils.GetInstanceName(ctx, apiClient, model.ProjectId, model.InstanceId) + instanceLabel, err := mariadbUtils.GetInstanceName(ctx, apiClient.DefaultAPI, model.ProjectId, model.InstanceId) if err != nil { params.Printer.Debug(print.ErrorLevel, "get instance name: %v", err) instanceLabel = model.InstanceId @@ -120,7 +119,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, } func buildRequest(ctx context.Context, model *inputModel, apiClient *mariadb.APIClient) mariadb.ApiListCredentialsRequest { - req := apiClient.ListCredentials(ctx, model.ProjectId, model.InstanceId) + req := apiClient.DefaultAPI.ListCredentials(ctx, model.ProjectId, model.InstanceId) return req } @@ -135,7 +134,7 @@ func outputResult(p *print.Printer, outputFormat, instanceLabel string, credenti table.SetHeader("ID") for i := range credentials { c := credentials[i] - table.AddRow(utils.PtrString(c.Id)) + table.AddRow(c.Id) } err := table.Display(p) if err != nil { diff --git a/internal/cmd/mariadb/credentials/list/list_test.go b/internal/cmd/mariadb/credentials/list/list_test.go index 86b5f0d71..8b4f02f23 100644 --- a/internal/cmd/mariadb/credentials/list/list_test.go +++ b/internal/cmd/mariadb/credentials/list/list_test.go @@ -12,13 +12,13 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/mariadb" + mariadb "github.com/stackitcloud/stackit-sdk-go/services/mariadb/v1api" ) type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &mariadb.APIClient{} +var testClient = &mariadb.APIClient{DefaultAPI: &mariadb.DefaultAPIService{}} var testProjectId = uuid.NewString() var testInstanceId = uuid.NewString() @@ -50,7 +50,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *mariadb.ApiListCredentialsRequest)) mariadb.ApiListCredentialsRequest { - request := testClient.ListCredentials(testCtx, testProjectId, testInstanceId) + request := testClient.DefaultAPI.ListCredentials(testCtx, testProjectId, testInstanceId) for _, mod := range mods { mod(&request) } @@ -160,7 +160,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, mariadb.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/mariadb/instance/create/create.go b/internal/cmd/mariadb/instance/create/create.go index de4c22b70..5dad458e1 100644 --- a/internal/cmd/mariadb/instance/create/create.go +++ b/internal/cmd/mariadb/instance/create/create.go @@ -21,8 +21,8 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/mariadb" - "github.com/stackitcloud/stackit-sdk-go/services/mariadb/wait" + mariadb "github.com/stackitcloud/stackit-sdk-go/services/mariadb/v1api" + "github.com/stackitcloud/stackit-sdk-go/services/mariadb/v1api/wait" ) const ( @@ -47,11 +47,11 @@ type inputModel struct { InstanceName *string EnableMonitoring *bool Graphite *string - MetricsFrequency *int64 + MetricsFrequency *int32 MetricsPrefix *string MonitoringInstanceId *string SgwAcl *[]string - Syslog *[]string + Syslog []string PlanId *string } @@ -98,7 +98,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } // Call API - req, err := buildRequest(ctx, model, apiClient) + req, err := buildRequest(ctx, model, apiClient.DefaultAPI) if err != nil { var dsaInvalidPlanError *cliErr.DSAInvalidPlanError if !errors.As(err, &dsaInvalidPlanError) { @@ -110,12 +110,11 @@ func NewCmd(params *types.CmdParams) *cobra.Command { if err != nil { return fmt.Errorf("create MariaDB instance: %w", err) } - instanceId := *resp.InstanceId // Wait for async operation, if async mode not enabled if !model.Async { err := spinner.Run(params.Printer, "Creating instance", func() error { - _, err = wait.CreateInstanceWaitHandler(ctx, apiClient, model.ProjectId, instanceId).WaitWithContext(ctx) + _, err = wait.CreateInstanceWaitHandler(ctx, apiClient.DefaultAPI, model.ProjectId, resp.InstanceId).WaitWithContext(ctx) return err }) if err != nil { @@ -134,7 +133,7 @@ func configureFlags(cmd *cobra.Command) { cmd.Flags().StringP(instanceNameFlag, "n", "", "Instance name") cmd.Flags().Bool(enableMonitoringFlag, false, "Enable monitoring") cmd.Flags().String(graphiteFlag, "", "Graphite host") - cmd.Flags().Int64(metricsFrequencyFlag, 0, "Metrics frequency") + cmd.Flags().Int32(metricsFrequencyFlag, 0, "Metrics frequency") cmd.Flags().String(metricsPrefixFlag, "", "Metrics prefix") cmd.Flags().Var(flags.UUIDFlag(), monitoringInstanceIdFlag, "Monitoring instance ID") cmd.Flags().Var(flags.CIDRSliceFlag(), sgwAclFlag, "List of IP networks in CIDR notation which are allowed to access this instance") @@ -174,10 +173,10 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, EnableMonitoring: flags.FlagToBoolPointer(p, cmd, enableMonitoringFlag), MonitoringInstanceId: flags.FlagToStringPointer(p, cmd, monitoringInstanceIdFlag), Graphite: flags.FlagToStringPointer(p, cmd, graphiteFlag), - MetricsFrequency: flags.FlagToInt64Pointer(p, cmd, metricsFrequencyFlag), + MetricsFrequency: flags.FlagToInt32Pointer(p, cmd, metricsFrequencyFlag), MetricsPrefix: flags.FlagToStringPointer(p, cmd, metricsPrefixFlag), SgwAcl: flags.FlagToStringSlicePointer(p, cmd, sgwAclFlag), - Syslog: flags.FlagToStringSlicePointer(p, cmd, syslogFlag), + Syslog: flags.FlagToStringSliceValue(p, cmd, syslogFlag), PlanId: planId, PlanName: planName, Version: version, @@ -187,18 +186,13 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, return &model, nil } -type mariaDBClient interface { - CreateInstance(ctx context.Context, projectId string) mariadb.ApiCreateInstanceRequest - ListOfferingsExecute(ctx context.Context, projectId string) (*mariadb.ListOfferingsResponse, error) -} - -func buildRequest(ctx context.Context, model *inputModel, apiClient mariaDBClient) (mariadb.ApiCreateInstanceRequest, error) { +func buildRequest(ctx context.Context, model *inputModel, apiClient mariadb.DefaultAPI) (mariadb.ApiCreateInstanceRequest, error) { req := apiClient.CreateInstance(ctx, model.ProjectId) var planId *string var err error - offerings, err := apiClient.ListOfferingsExecute(ctx, model.ProjectId) + offerings, err := apiClient.ListOfferings(ctx, model.ProjectId).Execute() if err != nil { return req, fmt.Errorf("get MariaDB offerings: %w", err) } @@ -219,14 +213,13 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient mariaDBClien } planId = model.PlanId } - var sgwAcl *string if model.SgwAcl != nil { sgwAcl = utils.Ptr(strings.Join(*model.SgwAcl, ",")) } req = req.CreateInstancePayload(mariadb.CreateInstancePayload{ - InstanceName: model.InstanceName, + InstanceName: utils.PtrString(model.InstanceName), Parameters: &mariadb.InstanceParameters{ EnableMonitoring: model.EnableMonitoring, Graphite: model.Graphite, @@ -236,7 +229,7 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient mariaDBClien SgwAcl: sgwAcl, Syslog: model.Syslog, }, - PlanId: planId, + PlanId: utils.PtrString(planId), }) return req, nil } @@ -251,7 +244,7 @@ func outputResult(p *print.Printer, outputFormat string, async bool, projectLabe if async { operationState = "Triggered creation of" } - p.Outputf("%s instance for project %q. Instance ID: %s\n", operationState, projectLabel, utils.PtrString(resp.InstanceId)) + p.Outputf("%s instance for project %q. Instance ID: %s\n", operationState, projectLabel, resp.InstanceId) return nil }) } diff --git a/internal/cmd/mariadb/instance/create/create_test.go b/internal/cmd/mariadb/instance/create/create_test.go index daf2782e1..e338f7cc4 100644 --- a/internal/cmd/mariadb/instance/create/create_test.go +++ b/internal/cmd/mariadb/instance/create/create_test.go @@ -13,7 +13,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/mariadb" + mariadb "github.com/stackitcloud/stackit-sdk-go/services/mariadb/v1api" ) var projectIdFlag = globalflags.ProjectIdFlag @@ -21,22 +21,22 @@ var projectIdFlag = globalflags.ProjectIdFlag type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &mariadb.APIClient{} +var testClient = &mariadb.APIClient{DefaultAPI: &mariadb.DefaultAPIService{}} -type mariaDBClientMocked struct { +type mockSettings struct { returnError bool listOfferingsResp *mariadb.ListOfferingsResponse } -func (c *mariaDBClientMocked) CreateInstance(ctx context.Context, projectId string) mariadb.ApiCreateInstanceRequest { - return testClient.CreateInstance(ctx, projectId) -} - -func (c *mariaDBClientMocked) ListOfferingsExecute(_ context.Context, _ string) (*mariadb.ListOfferingsResponse, error) { - if c.returnError { - return nil, fmt.Errorf("list flavors failed") +func newAPIMock(s mockSettings) mariadb.DefaultAPI { + return &mariadb.DefaultAPIServiceMock{ + ListOfferingsExecuteMock: utils.Ptr(func(_ mariadb.ApiListOfferingsRequest) (*mariadb.ListOfferingsResponse, error) { + if s.returnError { + return nil, fmt.Errorf("list flavors failed") + } + return s.listOfferingsResp, nil + }), } - return c.listOfferingsResp, nil } var testProjectId = uuid.NewString() @@ -71,11 +71,11 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { InstanceName: utils.Ptr("example-name"), EnableMonitoring: utils.Ptr(true), Graphite: utils.Ptr("example-graphite"), - MetricsFrequency: utils.Ptr(int64(100)), + MetricsFrequency: utils.Ptr(int32(100)), MetricsPrefix: utils.Ptr("example-prefix"), MonitoringInstanceId: utils.Ptr(testMonitoringInstanceId), SgwAcl: utils.Ptr([]string{"198.51.100.14/24"}), - Syslog: utils.Ptr([]string{"example-syslog"}), + Syslog: []string{"example-syslog"}, PlanId: utils.Ptr(testPlanId), } for _, mod := range mods { @@ -85,19 +85,19 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *mariadb.ApiCreateInstanceRequest)) mariadb.ApiCreateInstanceRequest { - request := testClient.CreateInstance(testCtx, testProjectId) + request := testClient.DefaultAPI.CreateInstance(testCtx, testProjectId) request = request.CreateInstancePayload(mariadb.CreateInstancePayload{ - InstanceName: utils.Ptr("example-name"), + InstanceName: "example-name", Parameters: &mariadb.InstanceParameters{ EnableMonitoring: utils.Ptr(true), Graphite: utils.Ptr("example-graphite"), - MetricsFrequency: utils.Ptr(int64(100)), + MetricsFrequency: utils.Ptr(int32(100)), MetricsPrefix: utils.Ptr("example-prefix"), MonitoringInstanceId: utils.Ptr(testMonitoringInstanceId), SgwAcl: utils.Ptr("198.51.100.14/24"), - Syslog: utils.Ptr([]string{"example-syslog"}), + Syslog: []string{"example-syslog"}, }, - PlanId: utils.Ptr(testPlanId), + PlanId: testPlanId, }) for _, mod := range mods { mod(&request) @@ -178,7 +178,7 @@ func TestParseInput(t *testing.T) { InstanceName: utils.Ptr(""), EnableMonitoring: utils.Ptr(false), Graphite: utils.Ptr(""), - MetricsFrequency: utils.Ptr(int64(0)), + MetricsFrequency: utils.Ptr(int32(0)), MetricsPrefix: utils.Ptr(""), }, }, @@ -254,9 +254,7 @@ func TestParseInput(t *testing.T) { syslogValues: []string{"example-syslog-1", "example-syslog-2"}, isValid: true, expectedModel: fixtureInputModel(func(model *inputModel) { - model.Syslog = utils.Ptr( - append(*model.Syslog, "example-syslog-1", "example-syslog-2"), - ) + model.Syslog = append(model.Syslog, "example-syslog-1", "example-syslog-2") }), }, } @@ -285,13 +283,13 @@ func TestBuildRequest(t *testing.T) { model: fixtureInputModel(), expectedRequest: fixtureRequest(), getOfferingsResp: &mariadb.ListOfferingsResponse{ - Offerings: &[]mariadb.Offering{ + Offerings: []mariadb.Offering{ { - Version: utils.Ptr("example-version"), - Plans: &[]mariadb.Plan{ + Version: "example-version", + Plans: []mariadb.Plan{ { - Name: utils.Ptr("example-plan-name"), - Id: utils.Ptr(testPlanId), + Name: "example-plan-name", + Id: testPlanId, }, }, }, @@ -309,13 +307,13 @@ func TestBuildRequest(t *testing.T) { ), expectedRequest: fixtureRequest(), getOfferingsResp: &mariadb.ListOfferingsResponse{ - Offerings: &[]mariadb.Offering{ + Offerings: []mariadb.Offering{ { - Version: utils.Ptr("example-version"), - Plans: &[]mariadb.Plan{ + Version: "example-version", + Plans: []mariadb.Plan{ { - Name: utils.Ptr("example-plan-name"), - Id: utils.Ptr(testPlanId), + Name: "example-plan-name", + Id: testPlanId, }, }, }, @@ -344,13 +342,13 @@ func TestBuildRequest(t *testing.T) { }, ), getOfferingsResp: &mariadb.ListOfferingsResponse{ - Offerings: &[]mariadb.Offering{ + Offerings: []mariadb.Offering{ { - Version: utils.Ptr("example-version"), - Plans: &[]mariadb.Plan{ + Version: "example-version", + Plans: []mariadb.Plan{ { - Name: utils.Ptr("other-plan-name"), - Id: utils.Ptr(testPlanId), + Name: "other-plan-name", + Id: testPlanId, }, }, }, @@ -368,30 +366,30 @@ func TestBuildRequest(t *testing.T) { PlanId: utils.Ptr(testPlanId), }, getOfferingsResp: &mariadb.ListOfferingsResponse{ - Offerings: &[]mariadb.Offering{ + Offerings: []mariadb.Offering{ { - Version: utils.Ptr("example-version"), - Plans: &[]mariadb.Plan{ + Version: "example-version", + Plans: []mariadb.Plan{ { - Name: utils.Ptr("example-plan-name"), - Id: utils.Ptr(testPlanId), + Name: "example-plan-name", + Id: testPlanId, }, }, }, }, }, - expectedRequest: testClient.CreateInstance(testCtx, testProjectId). - CreateInstancePayload(mariadb.CreateInstancePayload{PlanId: utils.Ptr(testPlanId), Parameters: &mariadb.InstanceParameters{}}), + expectedRequest: testClient.DefaultAPI.CreateInstance(testCtx, testProjectId). + CreateInstancePayload(mariadb.CreateInstancePayload{PlanId: testPlanId, Parameters: &mariadb.InstanceParameters{}}), }, } for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { - client := &mariaDBClientMocked{ + settings := mockSettings{ returnError: tt.getOfferingsFails, listOfferingsResp: tt.getOfferingsResp, } - request, err := buildRequest(testCtx, tt.model, client) + request, err := buildRequest(testCtx, tt.model, newAPIMock(settings)) if err != nil { if !tt.isValid { return @@ -402,6 +400,8 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), cmpopts.EquateComparable(testCtx), + cmpopts.EquateEmpty(), + cmpopts.IgnoreFields(tt.expectedRequest, "ApiService"), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/mariadb/instance/delete/delete.go b/internal/cmd/mariadb/instance/delete/delete.go index db499df05..c0c5e1cc2 100644 --- a/internal/cmd/mariadb/instance/delete/delete.go +++ b/internal/cmd/mariadb/instance/delete/delete.go @@ -17,8 +17,8 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/mariadb" - "github.com/stackitcloud/stackit-sdk-go/services/mariadb/wait" + mariadb "github.com/stackitcloud/stackit-sdk-go/services/mariadb/v1api" + "github.com/stackitcloud/stackit-sdk-go/services/mariadb/v1api/wait" ) const ( @@ -54,7 +54,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return err } - instanceLabel, err := mariadbUtils.GetInstanceName(ctx, apiClient, model.ProjectId, model.InstanceId) + instanceLabel, err := mariadbUtils.GetInstanceName(ctx, apiClient.DefaultAPI, model.ProjectId, model.InstanceId) if err != nil { params.Printer.Debug(print.ErrorLevel, "get instance name: %v", err) instanceLabel = model.InstanceId @@ -76,7 +76,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { // Wait for async operation, if async mode not enabled if !model.Async { err := spinner.Run(params.Printer, "Deleting instance", func() error { - _, err = wait.DeleteInstanceWaitHandler(ctx, apiClient, model.ProjectId, model.InstanceId).WaitWithContext(ctx) + _, err = wait.DeleteInstanceWaitHandler(ctx, apiClient.DefaultAPI, model.ProjectId, model.InstanceId).WaitWithContext(ctx) return err }) if err != nil { @@ -113,6 +113,6 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *mariadb.APIClient) mariadb.ApiDeleteInstanceRequest { - req := apiClient.DeleteInstance(ctx, model.ProjectId, model.InstanceId) + req := apiClient.DefaultAPI.DeleteInstance(ctx, model.ProjectId, model.InstanceId) return req } diff --git a/internal/cmd/mariadb/instance/delete/delete_test.go b/internal/cmd/mariadb/instance/delete/delete_test.go index c3930a9c8..f4817c48e 100644 --- a/internal/cmd/mariadb/instance/delete/delete_test.go +++ b/internal/cmd/mariadb/instance/delete/delete_test.go @@ -10,7 +10,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/mariadb" + mariadb "github.com/stackitcloud/stackit-sdk-go/services/mariadb/v1api" ) var projectIdFlag = globalflags.ProjectIdFlag @@ -18,7 +18,7 @@ var projectIdFlag = globalflags.ProjectIdFlag type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &mariadb.APIClient{} +var testClient = &mariadb.APIClient{DefaultAPI: &mariadb.DefaultAPIService{}} var testProjectId = uuid.NewString() var testInstanceId = uuid.NewString() @@ -57,7 +57,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *mariadb.ApiDeleteInstanceRequest)) mariadb.ApiDeleteInstanceRequest { - request := testClient.DeleteInstance(testCtx, testProjectId, testInstanceId) + request := testClient.DefaultAPI.DeleteInstance(testCtx, testProjectId, testInstanceId) for _, mod := range mods { mod(&request) } @@ -161,7 +161,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, mariadb.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/mariadb/instance/describe/describe.go b/internal/cmd/mariadb/instance/describe/describe.go index 0757fbe74..4ce4c19a6 100644 --- a/internal/cmd/mariadb/instance/describe/describe.go +++ b/internal/cmd/mariadb/instance/describe/describe.go @@ -16,7 +16,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/mariadb" + mariadb "github.com/stackitcloud/stackit-sdk-go/services/mariadb/v1api" ) const ( @@ -87,7 +87,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *mariadb.APIClient) mariadb.ApiGetInstanceRequest { - req := apiClient.GetInstance(ctx, model.ProjectId, model.InstanceId) + req := apiClient.DefaultAPI.GetInstance(ctx, model.ProjectId, model.InstanceId) return req } @@ -100,18 +100,18 @@ func outputResult(p *print.Printer, outputFormat string, instance *mariadb.Insta table := tables.NewTable() table.AddRow("ID", utils.PtrString(instance.InstanceId)) table.AddSeparator() - table.AddRow("NAME", utils.PtrString(instance.Name)) + table.AddRow("NAME", instance.Name) table.AddSeparator() - if instance.LastOperation != nil { - table.AddRow("LAST OPERATION TYPE", utils.PtrString(instance.LastOperation.Type)) + if _, ok := instance.LastOperation.GetStateOk(); ok { + table.AddRow("LAST OPERATION TYPE", instance.LastOperation.GetType()) table.AddSeparator() - table.AddRow("LAST OPERATION STATE", utils.PtrString(instance.LastOperation.State)) + table.AddRow("LAST OPERATION STATE", instance.LastOperation.GetState()) table.AddSeparator() } - table.AddRow("PLAN ID", utils.PtrString(instance.PlanId)) + table.AddRow("PLAN ID", instance.PlanId) // Only show ACL if it's present and not empty if instance.Parameters != nil { - acl := (*instance.Parameters)[aclParameterKey] + acl := instance.Parameters[aclParameterKey] aclStr, ok := acl.(string) if ok { if aclStr != "" { diff --git a/internal/cmd/mariadb/instance/describe/describe_test.go b/internal/cmd/mariadb/instance/describe/describe_test.go index d9f9fa211..5f16c5344 100644 --- a/internal/cmd/mariadb/instance/describe/describe_test.go +++ b/internal/cmd/mariadb/instance/describe/describe_test.go @@ -11,7 +11,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/mariadb" + mariadb "github.com/stackitcloud/stackit-sdk-go/services/mariadb/v1api" ) var projectIdFlag = globalflags.ProjectIdFlag @@ -19,7 +19,7 @@ var projectIdFlag = globalflags.ProjectIdFlag type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &mariadb.APIClient{} +var testClient = &mariadb.APIClient{DefaultAPI: &mariadb.DefaultAPIService{}} var testProjectId = uuid.NewString() var testInstanceId = uuid.NewString() @@ -58,7 +58,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *mariadb.ApiGetInstanceRequest)) mariadb.ApiGetInstanceRequest { - request := testClient.GetInstance(testCtx, testProjectId, testInstanceId) + request := testClient.DefaultAPI.GetInstance(testCtx, testProjectId, testInstanceId) for _, mod := range mods { mod(&request) } @@ -162,7 +162,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, mariadb.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/mariadb/instance/list/list.go b/internal/cmd/mariadb/instance/list/list.go index a009ed2ee..f8da15fb2 100644 --- a/internal/cmd/mariadb/instance/list/list.go +++ b/internal/cmd/mariadb/instance/list/list.go @@ -7,7 +7,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/types" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/mariadb" + mariadb "github.com/stackitcloud/stackit-sdk-go/services/mariadb/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/args" "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -115,7 +115,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, } func buildRequest(ctx context.Context, model *inputModel, apiClient *mariadb.APIClient) mariadb.ApiListInstancesRequest { - req := apiClient.ListInstances(ctx, model.ProjectId) + req := apiClient.DefaultAPI.ListInstances(ctx, model.ProjectId) return req } @@ -131,15 +131,12 @@ func outputResult(p *print.Printer, outputFormat, projectLabel string, instances for i := range instances { instance := instances[i] - lastOperationType, lastOperationState := "", "" - if instance.LastOperation != nil { - lastOperationType = utils.PtrString(instance.LastOperation.Type) - lastOperationState = utils.PtrString(instance.LastOperation.State) - } + lastOperationType := string(instance.LastOperation.GetType()) + lastOperationState := string(instance.LastOperation.GetState()) table.AddRow( utils.PtrString(instance.InstanceId), - utils.PtrString(instance.Name), + instance.Name, lastOperationType, lastOperationState, ) diff --git a/internal/cmd/mariadb/instance/list/list_test.go b/internal/cmd/mariadb/instance/list/list_test.go index c5e120044..23f432c79 100644 --- a/internal/cmd/mariadb/instance/list/list_test.go +++ b/internal/cmd/mariadb/instance/list/list_test.go @@ -12,13 +12,13 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/mariadb" + mariadb "github.com/stackitcloud/stackit-sdk-go/services/mariadb/v1api" ) type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &mariadb.APIClient{} +var testClient = &mariadb.APIClient{DefaultAPI: &mariadb.DefaultAPIService{}} var testProjectId = uuid.NewString() func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string { @@ -47,7 +47,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *mariadb.ApiListInstancesRequest)) mariadb.ApiListInstancesRequest { - request := testClient.ListInstances(testCtx, testProjectId) + request := testClient.DefaultAPI.ListInstances(testCtx, testProjectId) for _, mod := range mods { mod(&request) } @@ -136,7 +136,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, mariadb.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/mariadb/instance/update/update.go b/internal/cmd/mariadb/instance/update/update.go index 94a7a871d..add9a31cd 100644 --- a/internal/cmd/mariadb/instance/update/update.go +++ b/internal/cmd/mariadb/instance/update/update.go @@ -20,8 +20,8 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/mariadb" - "github.com/stackitcloud/stackit-sdk-go/services/mariadb/wait" + mariadb "github.com/stackitcloud/stackit-sdk-go/services/mariadb/v1api" + "github.com/stackitcloud/stackit-sdk-go/services/mariadb/v1api/wait" ) const ( @@ -47,11 +47,11 @@ type inputModel struct { EnableMonitoring *bool Graphite *string - MetricsFrequency *int64 + MetricsFrequency *int32 MetricsPrefix *string MonitoringInstanceId *string SgwAcl *[]string - Syslog *[]string + Syslog []string PlanId *string } @@ -82,7 +82,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return err } - instanceLabel, err := mariadbUtils.GetInstanceName(ctx, apiClient, model.ProjectId, model.InstanceId) + instanceLabel, err := mariadbUtils.GetInstanceName(ctx, apiClient.DefaultAPI, model.ProjectId, model.InstanceId) if err != nil { params.Printer.Debug(print.ErrorLevel, "get instance name: %v", err) instanceLabel = model.InstanceId @@ -95,7 +95,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } // Call API - req, err := buildRequest(ctx, model, apiClient) + req, err := buildRequest(ctx, model, apiClient.DefaultAPI) if err != nil { var dsaInvalidPlanError *cliErr.DSAInvalidPlanError if !errors.As(err, &dsaInvalidPlanError) { @@ -112,7 +112,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { // Wait for async operation, if async mode not enabled if !model.Async { err := spinner.Run(params.Printer, "Updating instance", func() error { - _, err = wait.PartialUpdateInstanceWaitHandler(ctx, apiClient, model.ProjectId, instanceId).WaitWithContext(ctx) + _, err = wait.PartialUpdateInstanceWaitHandler(ctx, apiClient.DefaultAPI, model.ProjectId, instanceId).WaitWithContext(ctx) return err }) if err != nil { @@ -135,7 +135,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { func configureFlags(cmd *cobra.Command) { cmd.Flags().Bool(enableMonitoringFlag, false, "Enable monitoring") cmd.Flags().String(graphiteFlag, "", "Graphite host") - cmd.Flags().Int64(metricsFrequencyFlag, 0, "Metrics frequency") + cmd.Flags().Int32(metricsFrequencyFlag, 0, "Metrics frequency") cmd.Flags().String(metricsPrefixFlag, "", "Metrics prefix") cmd.Flags().Var(flags.UUIDFlag(), monitoringInstanceIdFlag, "Monitoring instance ID") cmd.Flags().Var(flags.CIDRSliceFlag(), sgwAclFlag, "List of IP networks in CIDR notation which are allowed to access this instance") @@ -156,10 +156,10 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu enableMonitoring := flags.FlagToBoolPointer(p, cmd, enableMonitoringFlag) monitoringInstanceId := flags.FlagToStringPointer(p, cmd, monitoringInstanceIdFlag) graphite := flags.FlagToStringPointer(p, cmd, graphiteFlag) - metricsFrequency := flags.FlagToInt64Pointer(p, cmd, metricsFrequencyFlag) + metricsFrequency := flags.FlagToInt32Pointer(p, cmd, metricsFrequencyFlag) metricsPrefix := flags.FlagToStringPointer(p, cmd, metricsPrefixFlag) sgwAcl := flags.FlagToStringSlicePointer(p, cmd, sgwAclFlag) - syslog := flags.FlagToStringSlicePointer(p, cmd, syslogFlag) + syslog := flags.FlagToStringSliceValue(p, cmd, syslogFlag) planId := flags.FlagToStringPointer(p, cmd, planIdFlag) planName := flags.FlagToStringValue(p, cmd, planNameFlag) version := flags.FlagToStringValue(p, cmd, versionFlag) @@ -197,18 +197,13 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu return &model, nil } -type mariaDBClient interface { - PartialUpdateInstance(ctx context.Context, projectId, instanceId string) mariadb.ApiPartialUpdateInstanceRequest - ListOfferingsExecute(ctx context.Context, projectId string) (*mariadb.ListOfferingsResponse, error) -} - -func buildRequest(ctx context.Context, model *inputModel, apiClient mariaDBClient) (mariadb.ApiPartialUpdateInstanceRequest, error) { +func buildRequest(ctx context.Context, model *inputModel, apiClient mariadb.DefaultAPI) (mariadb.ApiPartialUpdateInstanceRequest, error) { req := apiClient.PartialUpdateInstance(ctx, model.ProjectId, model.InstanceId) var planId *string var err error - offerings, err := apiClient.ListOfferingsExecute(ctx, model.ProjectId) + offerings, err := apiClient.ListOfferings(ctx, model.ProjectId).Execute() if err != nil { return req, fmt.Errorf("get MariaDB offerings: %w", err) } diff --git a/internal/cmd/mariadb/instance/update/update_test.go b/internal/cmd/mariadb/instance/update/update_test.go index eb04dc0b8..fdcefd87b 100644 --- a/internal/cmd/mariadb/instance/update/update_test.go +++ b/internal/cmd/mariadb/instance/update/update_test.go @@ -12,7 +12,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/mariadb" + mariadb "github.com/stackitcloud/stackit-sdk-go/services/mariadb/v1api" ) var projectIdFlag = globalflags.ProjectIdFlag @@ -20,22 +20,22 @@ var projectIdFlag = globalflags.ProjectIdFlag type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &mariadb.APIClient{} +var testClient = &mariadb.APIClient{DefaultAPI: &mariadb.DefaultAPIService{}} -type mariaDBClientMocked struct { +type mockSettings struct { returnError bool listOfferingsResp *mariadb.ListOfferingsResponse } -func (c *mariaDBClientMocked) PartialUpdateInstance(ctx context.Context, projectId, instanceId string) mariadb.ApiPartialUpdateInstanceRequest { - return testClient.PartialUpdateInstance(ctx, projectId, instanceId) -} - -func (c *mariaDBClientMocked) ListOfferingsExecute(_ context.Context, _ string) (*mariadb.ListOfferingsResponse, error) { - if c.returnError { - return nil, fmt.Errorf("list flavors failed") +func newAPIMock(s mockSettings) mariadb.DefaultAPI { + return &mariadb.DefaultAPIServiceMock{ + ListOfferingsExecuteMock: utils.Ptr(func(_ mariadb.ApiListOfferingsRequest) (*mariadb.ListOfferingsResponse, error) { + if s.returnError { + return nil, fmt.Errorf("list flavors failed") + } + return s.listOfferingsResp, nil + }), } - return c.listOfferingsResp, nil } var ( @@ -82,11 +82,11 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { InstanceId: testInstanceId, EnableMonitoring: utils.Ptr(true), Graphite: utils.Ptr("example-graphite"), - MetricsFrequency: utils.Ptr(int64(100)), + MetricsFrequency: utils.Ptr(int32(100)), MetricsPrefix: utils.Ptr("example-prefix"), MonitoringInstanceId: utils.Ptr(testMonitoringInstanceId), SgwAcl: utils.Ptr([]string{"198.51.100.14/24"}), - Syslog: utils.Ptr([]string{"example-syslog"}), + Syslog: []string{"example-syslog"}, PlanId: utils.Ptr(testPlanId), } for _, mod := range mods { @@ -96,16 +96,16 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *mariadb.ApiPartialUpdateInstanceRequest)) mariadb.ApiPartialUpdateInstanceRequest { - request := testClient.PartialUpdateInstance(testCtx, testProjectId, testInstanceId) + request := testClient.DefaultAPI.PartialUpdateInstance(testCtx, testProjectId, testInstanceId) request = request.PartialUpdateInstancePayload(mariadb.PartialUpdateInstancePayload{ Parameters: &mariadb.InstanceParameters{ EnableMonitoring: utils.Ptr(true), Graphite: utils.Ptr("example-graphite"), - MetricsFrequency: utils.Ptr(int64(100)), + MetricsFrequency: utils.Ptr(int32(100)), MetricsPrefix: utils.Ptr("example-prefix"), MonitoringInstanceId: utils.Ptr(testMonitoringInstanceId), SgwAcl: utils.Ptr("198.51.100.14/24"), - Syslog: utils.Ptr([]string{"example-syslog"}), + Syslog: []string{"example-syslog"}, }, PlanId: utils.Ptr(testPlanId), }) @@ -186,7 +186,7 @@ func TestParseInput(t *testing.T) { PlanId: utils.Ptr(testPlanId), EnableMonitoring: utils.Ptr(false), Graphite: utils.Ptr(""), - MetricsFrequency: utils.Ptr(int64(0)), + MetricsFrequency: utils.Ptr(int32(0)), MetricsPrefix: utils.Ptr(""), }, }, @@ -268,9 +268,7 @@ func TestParseInput(t *testing.T) { syslogValues: []string{"example-syslog-1", "example-syslog-2"}, isValid: true, expectedModel: fixtureInputModel(func(model *inputModel) { - model.Syslog = utils.Ptr( - append(*model.Syslog, "example-syslog-1", "example-syslog-2"), - ) + model.Syslog = append(model.Syslog, "example-syslog-1", "example-syslog-2") }), }, } @@ -363,13 +361,13 @@ func TestBuildRequest(t *testing.T) { model: fixtureInputModel(), expectedRequest: fixtureRequest(), listOfferingsResp: &mariadb.ListOfferingsResponse{ - Offerings: &[]mariadb.Offering{ + Offerings: []mariadb.Offering{ { - Version: utils.Ptr("example-version"), - Plans: &[]mariadb.Plan{ + Version: "example-version", + Plans: []mariadb.Plan{ { - Name: utils.Ptr("example-plan-name"), - Id: utils.Ptr(testPlanId), + Name: "example-plan-name", + Id: testPlanId, }, }, }, @@ -387,13 +385,13 @@ func TestBuildRequest(t *testing.T) { ), expectedRequest: fixtureRequest(), listOfferingsResp: &mariadb.ListOfferingsResponse{ - Offerings: &[]mariadb.Offering{ + Offerings: []mariadb.Offering{ { - Version: utils.Ptr("example-version"), - Plans: &[]mariadb.Plan{ + Version: "example-version", + Plans: []mariadb.Plan{ { - Name: utils.Ptr("example-plan-name"), - Id: utils.Ptr(testPlanId), + Name: "example-plan-name", + Id: testPlanId, }, }, }, @@ -422,13 +420,13 @@ func TestBuildRequest(t *testing.T) { }, ), listOfferingsResp: &mariadb.ListOfferingsResponse{ - Offerings: &[]mariadb.Offering{ + Offerings: []mariadb.Offering{ { - Version: utils.Ptr("example-version"), - Plans: &[]mariadb.Plan{ + Version: "example-version", + Plans: []mariadb.Plan{ { - Name: utils.Ptr("other-plan-name"), - Id: utils.Ptr(testPlanId), + Name: "other-plan-name", + Id: testPlanId, }, }, }, @@ -445,18 +443,18 @@ func TestBuildRequest(t *testing.T) { }, InstanceId: testInstanceId, }, - expectedRequest: testClient.PartialUpdateInstance(testCtx, testProjectId, testInstanceId). + expectedRequest: testClient.DefaultAPI.PartialUpdateInstance(testCtx, testProjectId, testInstanceId). PartialUpdateInstancePayload(mariadb.PartialUpdateInstancePayload{Parameters: &mariadb.InstanceParameters{}}), }, } for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { - client := &mariaDBClientMocked{ + settings := mockSettings{ returnError: tt.getOfferingsFails, listOfferingsResp: tt.listOfferingsResp, } - request, err := buildRequest(testCtx, tt.model, client) + request, err := buildRequest(testCtx, tt.model, newAPIMock(settings)) if err != nil { if !tt.isValid { return @@ -467,6 +465,8 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), cmpopts.EquateComparable(testCtx), + cmpopts.EquateEmpty(), + cmpopts.IgnoreFields(tt.expectedRequest, "ApiService"), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/mariadb/plans/plans.go b/internal/cmd/mariadb/plans/plans.go index 5c5819695..8f7c7d4d5 100644 --- a/internal/cmd/mariadb/plans/plans.go +++ b/internal/cmd/mariadb/plans/plans.go @@ -7,7 +7,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/types" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/mariadb" + mariadb "github.com/stackitcloud/stackit-sdk-go/services/mariadb/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/args" "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -18,7 +18,6 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/projectname" "github.com/stackitcloud/stackit-cli/internal/pkg/services/mariadb/client" "github.com/stackitcloud/stackit-cli/internal/pkg/tables" - "github.com/stackitcloud/stackit-cli/internal/pkg/utils" ) const ( @@ -115,7 +114,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, } func buildRequest(ctx context.Context, model *inputModel, apiClient *mariadb.APIClient) mariadb.ApiListOfferingsRequest { - req := apiClient.ListOfferings(ctx, model.ProjectId) + req := apiClient.DefaultAPI.ListOfferings(ctx, model.ProjectId) return req } @@ -131,14 +130,14 @@ func outputResult(p *print.Printer, outputFormat, projectLabel string, plans []m for i := range plans { o := plans[i] if o.Plans != nil { - for j := range *o.Plans { - plan := (*o.Plans)[j] + for j := range o.Plans { + plan := o.Plans[j] table.AddRow( - utils.PtrString(o.Name), - utils.PtrString(o.Version), - utils.PtrString(plan.Id), - utils.PtrString(plan.Name), - utils.PtrString(plan.Description), + o.Name, + o.Version, + plan.Id, + plan.Name, + plan.Description, ) } table.AddSeparator() diff --git a/internal/cmd/mariadb/plans/plans_test.go b/internal/cmd/mariadb/plans/plans_test.go index 97db8e3e7..a99ae091a 100644 --- a/internal/cmd/mariadb/plans/plans_test.go +++ b/internal/cmd/mariadb/plans/plans_test.go @@ -12,13 +12,13 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/mariadb" + mariadb "github.com/stackitcloud/stackit-sdk-go/services/mariadb/v1api" ) type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &mariadb.APIClient{} +var testClient = &mariadb.APIClient{DefaultAPI: &mariadb.DefaultAPIService{}} var testProjectId = uuid.NewString() func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string { @@ -47,7 +47,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *mariadb.ApiListOfferingsRequest)) mariadb.ApiListOfferingsRequest { - request := testClient.ListOfferings(testCtx, testProjectId) + request := testClient.DefaultAPI.ListOfferings(testCtx, testProjectId) for _, mod := range mods { mod(&request) } @@ -136,7 +136,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, mariadb.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/pkg/services/mariadb/client/client.go b/internal/pkg/services/mariadb/client/client.go index 9952a324c..dcbb70f74 100644 --- a/internal/pkg/services/mariadb/client/client.go +++ b/internal/pkg/services/mariadb/client/client.go @@ -6,9 +6,9 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/print" "github.com/spf13/viper" - "github.com/stackitcloud/stackit-sdk-go/services/mariadb" + mariadb "github.com/stackitcloud/stackit-sdk-go/services/mariadb/v1api" ) func ConfigureClient(p *print.Printer, cliVersion string) (*mariadb.APIClient, error) { - return genericclient.ConfigureClientGeneric(p, cliVersion, viper.GetString(config.MariaDBCustomEndpointKey), true, genericclient.CreateApiClient[*mariadb.APIClient](mariadb.NewAPIClient)) + return genericclient.ConfigureClientGeneric(p, cliVersion, viper.GetString(config.MariaDBCustomEndpointKey), true, mariadb.NewAPIClient) } diff --git a/internal/pkg/services/mariadb/utils/utils.go b/internal/pkg/services/mariadb/utils/utils.go index 44872397f..03dd0404f 100644 --- a/internal/pkg/services/mariadb/utils/utils.go +++ b/internal/pkg/services/mariadb/utils/utils.go @@ -7,7 +7,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/errors" - "github.com/stackitcloud/stackit-sdk-go/services/mariadb" + mariadb "github.com/stackitcloud/stackit-sdk-go/services/mariadb/v1api" ) const ( @@ -15,9 +15,9 @@ const ( ) func ValidatePlanId(planId string, offerings *mariadb.ListOfferingsResponse) error { - for _, offer := range *offerings.Offerings { - for _, plan := range *offer.Plans { - if plan.Id != nil && strings.EqualFold(*plan.Id, planId) { + for _, offer := range offerings.Offerings { + for _, plan := range offer.Plans { + if strings.EqualFold(plan.Id, planId) { return nil } } @@ -33,21 +33,18 @@ func LoadPlanId(planName, version string, offerings *mariadb.ListOfferingsRespon availableVersions := "" availablePlanNames := "" isValidVersion := false - for _, offer := range *offerings.Offerings { - if !strings.EqualFold(*offer.Version, version) { - availableVersions = fmt.Sprintf("%s\n- %s", availableVersions, *offer.Version) + for _, offer := range offerings.Offerings { + if !strings.EqualFold(offer.Version, version) { + availableVersions = fmt.Sprintf("%s\n- %s", availableVersions, offer.Version) continue } isValidVersion = true - for _, plan := range *offer.Plans { - if plan.Name == nil { - continue + for _, plan := range offer.Plans { + if strings.EqualFold(plan.Name, planName) { + return &plan.Id, nil } - if strings.EqualFold(*plan.Name, planName) && plan.Id != nil { - return plan.Id, nil - } - availablePlanNames = fmt.Sprintf("%s\n- %s", availablePlanNames, *plan.Name) + availablePlanNames = fmt.Sprintf("%s\n- %s", availablePlanNames, plan.Name) } } @@ -65,23 +62,18 @@ func LoadPlanId(planName, version string, offerings *mariadb.ListOfferingsRespon } } -type MariaDBClient interface { - GetInstanceExecute(ctx context.Context, projectId, instanceId string) (*mariadb.Instance, error) - GetCredentialsExecute(ctx context.Context, projectId, instanceId, credentialsId string) (*mariadb.CredentialsResponse, error) -} - -func GetInstanceName(ctx context.Context, apiClient MariaDBClient, projectId, instanceId string) (string, error) { - resp, err := apiClient.GetInstanceExecute(ctx, projectId, instanceId) +func GetInstanceName(ctx context.Context, apiClient mariadb.DefaultAPI, projectId, instanceId string) (string, error) { + resp, err := apiClient.GetInstance(ctx, projectId, instanceId).Execute() if err != nil { return "", fmt.Errorf("get MariaDB instance: %w", err) } - return *resp.Name, nil + return resp.Name, nil } -func GetCredentialsUsername(ctx context.Context, apiClient MariaDBClient, projectId, instanceId, credentialsId string) (string, error) { - resp, err := apiClient.GetCredentialsExecute(ctx, projectId, instanceId, credentialsId) +func GetCredentialsUsername(ctx context.Context, apiClient mariadb.DefaultAPI, projectId, instanceId, credentialsId string) (string, error) { + resp, err := apiClient.GetCredentials(ctx, projectId, instanceId, credentialsId).Execute() if err != nil { return "", fmt.Errorf("get MariaDB credentials: %w", err) } - return *resp.Raw.Credentials.Username, nil + return resp.Raw.Credentials.Username, nil } diff --git a/internal/pkg/services/mariadb/utils/utils_test.go b/internal/pkg/services/mariadb/utils/utils_test.go index cd4f1a162..154b44867 100644 --- a/internal/pkg/services/mariadb/utils/utils_test.go +++ b/internal/pkg/services/mariadb/utils/utils_test.go @@ -8,7 +8,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/mariadb" + mariadb "github.com/stackitcloud/stackit-sdk-go/services/mariadb/v1api" ) var ( @@ -22,25 +22,28 @@ const ( testCredentialsUsername = "username" ) -type mariaDBClientMocked struct { +type mockSettings struct { getInstanceFails bool getInstanceResp *mariadb.Instance getCredentialsFails bool getCredentialsResp *mariadb.CredentialsResponse } -func (m *mariaDBClientMocked) GetInstanceExecute(_ context.Context, _, _ string) (*mariadb.Instance, error) { - if m.getInstanceFails { - return nil, fmt.Errorf("could not get instance") - } - return m.getInstanceResp, nil -} - -func (m *mariaDBClientMocked) GetCredentialsExecute(_ context.Context, _, _, _ string) (*mariadb.CredentialsResponse, error) { - if m.getCredentialsFails { - return nil, fmt.Errorf("could not get user") +func newAPIMock(m mockSettings) mariadb.DefaultAPI { + return &mariadb.DefaultAPIServiceMock{ + GetInstanceExecuteMock: utils.Ptr(func(_ mariadb.ApiGetInstanceRequest) (*mariadb.Instance, error) { + if m.getInstanceFails { + return nil, fmt.Errorf("could not get instance") + } + return m.getInstanceResp, nil + }), + GetCredentialsExecuteMock: utils.Ptr(func(_ mariadb.ApiGetCredentialsRequest) (*mariadb.CredentialsResponse, error) { + if m.getCredentialsFails { + return nil, fmt.Errorf("could not get user") + } + return m.getCredentialsResp, nil + }), } - return m.getCredentialsResp, nil } func TestGetInstanceName(t *testing.T) { @@ -54,7 +57,7 @@ func TestGetInstanceName(t *testing.T) { { description: "base", getInstanceResp: &mariadb.Instance{ - Name: utils.Ptr(testInstanceName), + Name: testInstanceName, }, isValid: true, expectedOutput: testInstanceName, @@ -68,12 +71,12 @@ func TestGetInstanceName(t *testing.T) { for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { - client := &mariaDBClientMocked{ + settings := mockSettings{ getInstanceFails: tt.getInstanceFails, getInstanceResp: tt.getInstanceResp, } - output, err := GetInstanceName(context.Background(), client, testProjectId, testInstanceId) + output, err := GetInstanceName(context.Background(), newAPIMock(settings), testProjectId, testInstanceId) if tt.isValid && err != nil { t.Errorf("failed on valid input") @@ -103,8 +106,8 @@ func TestGetCredentialsUsername(t *testing.T) { description: "base", getCredentialsResp: &mariadb.CredentialsResponse{ Raw: &mariadb.RawCredentials{ - Credentials: &mariadb.Credentials{ - Username: utils.Ptr(testCredentialsUsername), + Credentials: mariadb.Credentials{ + Username: testCredentialsUsername, }, }, }, @@ -120,12 +123,12 @@ func TestGetCredentialsUsername(t *testing.T) { for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { - client := &mariaDBClientMocked{ + settings := mockSettings{ getCredentialsFails: tt.getCredentialsFails, getCredentialsResp: tt.getCredentialsResp, } - output, err := GetCredentialsUsername(context.Background(), client, testProjectId, testInstanceId, testCredentialsId) + output, err := GetCredentialsUsername(context.Background(), newAPIMock(settings), testProjectId, testInstanceId, testCredentialsId) if tt.isValid && err != nil { t.Errorf("failed on valid input") From 1da14bc6e2999b14af44d76225f12fe5ff3755dc Mon Sep 17 00:00:00 2001 From: Alexander Dahmen Date: Tue, 7 Jul 2026 14:24:24 +0200 Subject: [PATCH 21/44] feat(ske): Check service enablement only in error case (#1457) STACKITCLI-287 Signed-off-by: Alexander Dahmen --- internal/cmd/ske/cluster/create/create.go | 23 +++++++++++------------ internal/cmd/ske/cluster/list/list.go | 19 ++++++++++--------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/internal/cmd/ske/cluster/create/create.go b/internal/cmd/ske/cluster/create/create.go index eafcdc349..edcf85dfb 100644 --- a/internal/cmd/ske/cluster/create/create.go +++ b/internal/cmd/ske/cluster/create/create.go @@ -95,21 +95,20 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return err } - // Check if the project is enabled before trying to create - enabled, err := serviceEnablementUtils.ProjectEnabled(ctx, serviceEnablementApiClient, model.ProjectId, model.Region) - if err != nil { - return err - } - if !enabled { - return &errors.ServiceDisabledError{ - Service: "ske", - } - } - // Check if cluster exists exists, err := skeUtils.ClusterExists(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, model.ClusterName) if err != nil { - return err + // Check if the project is enabled + enabled, enabledErr := serviceEnablementUtils.ProjectEnabled(ctx, serviceEnablementApiClient, model.ProjectId, model.Region) + if enabledErr != nil { + return fmt.Errorf("check if project is enabled failed: %w", enabledErr) + } + if !enabled { + return &errors.ServiceDisabledError{ + Service: "ske", + } + } + return fmt.Errorf("cluster exists check failed: %w", err) } if exists { return fmt.Errorf("cluster with name %s already exists", model.ClusterName) diff --git a/internal/cmd/ske/cluster/list/list.go b/internal/cmd/ske/cluster/list/list.go index 054c4f508..543fa212e 100644 --- a/internal/cmd/ske/cluster/list/list.go +++ b/internal/cmd/ske/cluster/list/list.go @@ -68,19 +68,20 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return err } - // Check if SKE is enabled for this project - enabled, err := serviceEnablementUtils.ProjectEnabled(ctx, serviceEnablementApiClient, model.ProjectId, model.Region) - if err != nil { - return err - } - if !enabled { - return fmt.Errorf("SKE isn't enabled for this project, please run 'stackit ske enable'") - } - // Call API req := buildRequest(ctx, model, apiClient) resp, err := req.Execute() if err != nil { + // Check if SKE is enabled for this project + enabled, enabledErr := serviceEnablementUtils.ProjectEnabled(ctx, serviceEnablementApiClient, model.ProjectId, model.Region) + if enabledErr != nil { + return fmt.Errorf("check if project is enabled failed: %w", enabledErr) + } + if !enabled { + return &errors.ServiceDisabledError{ + Service: "ske", + } + } return fmt.Errorf("get SKE clusters: %w", err) } clusters := resp.Items From 7f1d6ad771f64766d9441f343783fdc9abf65c45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=B6kce=20G=C3=B6k=20Klingel?= <161626272+GokceGK@users.noreply.github.com> Date: Wed, 8 Jul 2026 09:59:43 +0200 Subject: [PATCH 22/44] feat(redis): region adjustments and migration to new SDK structure (#1458) relates to STACKITCLI-405 and STACKITCLI-376 --- docs/stackit_redis_instance_create.md | 2 +- docs/stackit_redis_instance_update.md | 2 +- go.mod | 2 +- go.sum | 4 +- .../cmd/redis/credentials/create/create.go | 27 ++--- .../redis/credentials/create/create_test.go | 15 ++- .../cmd/redis/credentials/delete/delete.go | 8 +- .../redis/credentials/delete/delete_test.go | 15 ++- .../redis/credentials/describe/describe.go | 14 +-- .../credentials/describe/describe_test.go | 15 ++- internal/cmd/redis/credentials/list/list.go | 11 +- .../cmd/redis/credentials/list/list_test.go | 17 +-- internal/cmd/redis/instance/create/create.go | 42 +++---- .../cmd/redis/instance/create/create_test.go | 112 +++++++++--------- internal/cmd/redis/instance/delete/delete.go | 10 +- .../cmd/redis/instance/delete/delete_test.go | 13 +- .../cmd/redis/instance/describe/describe.go | 20 ++-- .../redis/instance/describe/describe_test.go | 15 ++- internal/cmd/redis/instance/list/list.go | 13 +- internal/cmd/redis/instance/list/list_test.go | 15 ++- internal/cmd/redis/instance/update/update.go | 31 ++--- .../cmd/redis/instance/update/update_test.go | 83 +++++++------ internal/cmd/redis/plans/plans.go | 21 ++-- internal/cmd/redis/plans/plans_test.go | 15 ++- internal/pkg/services/redis/client/client.go | 4 +- internal/pkg/services/redis/utils/utils.go | 42 +++---- .../pkg/services/redis/utils/utils_test.go | 52 ++++---- 27 files changed, 317 insertions(+), 303 deletions(-) diff --git a/docs/stackit_redis_instance_create.md b/docs/stackit_redis_instance_create.md index a17e2b72b..590138129 100644 --- a/docs/stackit_redis_instance_create.md +++ b/docs/stackit_redis_instance_create.md @@ -30,7 +30,7 @@ stackit redis instance create [flags] --enable-monitoring Enable monitoring --graphite string Graphite host -h, --help Help for "stackit redis instance create" - --metrics-frequency int Metrics frequency + --metrics-frequency int32 Metrics frequency --metrics-prefix string Metrics prefix --monitoring-instance-id string Monitoring instance ID -n, --name string Instance name diff --git a/docs/stackit_redis_instance_update.md b/docs/stackit_redis_instance_update.md index bf84834fa..362b7e37b 100644 --- a/docs/stackit_redis_instance_update.md +++ b/docs/stackit_redis_instance_update.md @@ -27,7 +27,7 @@ stackit redis instance update INSTANCE_ID [flags] --enable-monitoring Enable monitoring --graphite string Graphite host -h, --help Help for "stackit redis instance update" - --metrics-frequency int Metrics frequency + --metrics-frequency int32 Metrics frequency --metrics-prefix string Metrics prefix --monitoring-instance-id string Monitoring instance ID --plan-id string Plan ID diff --git a/go.mod b/go.mod index c727cfa21..d504d6412 100644 --- a/go.mod +++ b/go.mod @@ -272,7 +272,7 @@ require ( github.com/stackitcloud/stackit-sdk-go/services/objectstorage v1.7.0 github.com/stackitcloud/stackit-sdk-go/services/observability v0.17.0 github.com/stackitcloud/stackit-sdk-go/services/rabbitmq v1.1.0 - github.com/stackitcloud/stackit-sdk-go/services/redis v0.25.6 + github.com/stackitcloud/stackit-sdk-go/services/redis v1.1.0 github.com/stackitcloud/stackit-sdk-go/services/sfs v0.9.0 github.com/subosito/gotenv v1.6.0 // indirect golang.org/x/sys v0.43.0 // indirect diff --git a/go.sum b/go.sum index 62fb2b288..837bae5bf 100644 --- a/go.sum +++ b/go.sum @@ -634,8 +634,8 @@ github.com/stackitcloud/stackit-sdk-go/services/postgresflex v1.3.5 h1:H67e3KnHQ github.com/stackitcloud/stackit-sdk-go/services/postgresflex v1.3.5/go.mod h1:xmAWk9eom8wznvLuLfm0F4xyeiBX8LaggXsKFmos+dw= github.com/stackitcloud/stackit-sdk-go/services/rabbitmq v1.1.0 h1:HRJwodJX4aOn/487zaqJIKw13yIj4T6dn7/kEHLxeTg= github.com/stackitcloud/stackit-sdk-go/services/rabbitmq v1.1.0/go.mod h1:TwfVVynB/+AKbccSOLk2qZpPL1tdK43BBAiACP6EtSg= -github.com/stackitcloud/stackit-sdk-go/services/redis v0.25.6 h1:CXM9cZ9WeTyJd+Aw/hnJnDsKRVAQi4qgtd0RJ3zoPwo= -github.com/stackitcloud/stackit-sdk-go/services/redis v0.25.6/go.mod h1:KJNceOHRefjku1oVBoHG7idCS/SeW42WJ+55bN3AxrQ= +github.com/stackitcloud/stackit-sdk-go/services/redis v1.1.0 h1:ckYMRXAGE2/vaxPeNGEuun9AGcFn/8xuu0ytfsiqfWU= +github.com/stackitcloud/stackit-sdk-go/services/redis v1.1.0/go.mod h1:yjej6QfYoYdRIyKXlmbVz8fZYxbuUdl+QBkvLDPgA4k= github.com/stackitcloud/stackit-sdk-go/services/resourcemanager v0.24.0 h1:JPP6a0ME1tZXr4iB69d/LtJsCAr58ENBadFaK9f48/c= github.com/stackitcloud/stackit-sdk-go/services/resourcemanager v0.24.0/go.mod h1:NEz3f+GV5G++BE9/MmZCsXJyCih7jtg0pZuSyG2sLEs= github.com/stackitcloud/stackit-sdk-go/services/runcommand v1.4.3 h1:AiGNJmpQ/f9cglaIQQ4SyePbtCI3K1DQLNvqVN9jKSo= diff --git a/internal/cmd/redis/credentials/create/create.go b/internal/cmd/redis/credentials/create/create.go index a3e3e8e63..99738fd25 100644 --- a/internal/cmd/redis/credentials/create/create.go +++ b/internal/cmd/redis/credentials/create/create.go @@ -17,7 +17,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/redis" + redis "github.com/stackitcloud/stackit-sdk-go/services/redis/v2api" ) const ( @@ -58,7 +58,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return err } - instanceLabel, err := redisUtils.GetInstanceName(ctx, apiClient, model.ProjectId, model.InstanceId) + instanceLabel, err := redisUtils.GetInstanceName(ctx, apiClient.DefaultAPI, model.ProjectId, model.InstanceId, model.Region) if err != nil { params.Printer.Debug(print.ErrorLevel, "get instance name: %v", err) instanceLabel = model.InstanceId @@ -109,7 +109,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, } func buildRequest(ctx context.Context, model *inputModel, apiClient *redis.APIClient) redis.ApiCreateCredentialsRequest { - req := apiClient.CreateCredentials(ctx, model.ProjectId, model.InstanceId) + req := apiClient.DefaultAPI.CreateCredentials(ctx, model.ProjectId, model.Region, model.InstanceId) return req } @@ -122,30 +122,27 @@ func outputResult(p *print.Printer, model inputModel, instanceLabel string, resp } if !model.ShowPassword { if resp.Raw == nil { - resp.Raw = &redis.RawCredentials{} + resp.Raw = &redis.RawCredentials{Credentials: redis.Credentials{}} } - if resp.Raw.Credentials == nil { - resp.Raw.Credentials = &redis.Credentials{} - } - resp.Raw.Credentials.Password = utils.Ptr("hidden") + resp.Raw.Credentials.Password = "hidden" } return p.OutputResult(model.OutputFormat, resp, func() error { - p.Outputf("Created credentials for instance %q. Credentials ID: %s\n\n", instanceLabel, utils.PtrString(resp.Id)) + p.Outputf("Created credentials for instance %q. Credentials ID: %s\n\n", instanceLabel, resp.Id) // The username field cannot be set by the user, so we only display it if it's not returned empty - if resp.HasRaw() && resp.Raw.Credentials != nil { - if username := resp.Raw.Credentials.Username; username != nil && *username != "" { - p.Outputf("Username: %s\n", utils.PtrString(username)) + if resp.HasRaw() { + if username := resp.Raw.Credentials.Username; username != "" { + p.Outputf("Username: %s\n", username) } if !model.ShowPassword { p.Outputf("Password: \n") } else { - p.Outputf("Password: %s\n", utils.PtrString(resp.Raw.Credentials.Password)) + p.Outputf("Password: %s\n", resp.Raw.Credentials.Password) } - p.Outputf("Host: %s\n", utils.PtrString(resp.Raw.Credentials.Host)) + p.Outputf("Host: %s\n", resp.Raw.Credentials.Host) p.Outputf("Port: %s\n", utils.PtrString(resp.Raw.Credentials.Port)) } - p.Outputf("URI: %s\n", utils.PtrString(resp.Uri)) + p.Outputf("URI: %s\n", resp.Uri) return nil }) } diff --git a/internal/cmd/redis/credentials/create/create_test.go b/internal/cmd/redis/credentials/create/create_test.go index 0c655b1e8..cf37c32b3 100644 --- a/internal/cmd/redis/credentials/create/create_test.go +++ b/internal/cmd/redis/credentials/create/create_test.go @@ -7,7 +7,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/redis" + redis "github.com/stackitcloud/stackit-sdk-go/services/redis/v2api" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" @@ -19,14 +19,16 @@ var projectIdFlag = globalflags.ProjectIdFlag type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &redis.APIClient{} +var testClient = &redis.APIClient{DefaultAPI: &redis.DefaultAPIService{}} var testProjectId = uuid.NewString() var testInstanceId = uuid.NewString() +var testRegion = "eu01" func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string { flagValues := map[string]string{ - projectIdFlag: testProjectId, - instanceIdFlag: testInstanceId, + projectIdFlag: testProjectId, + instanceIdFlag: testInstanceId, + globalflags.RegionFlag: testRegion, } for _, mod := range mods { mod(flagValues) @@ -39,6 +41,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { GlobalFlagModel: &globalflags.GlobalFlagModel{ ProjectId: testProjectId, Verbosity: globalflags.VerbosityDefault, + Region: testRegion, }, InstanceId: testInstanceId, } @@ -49,7 +52,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *redis.ApiCreateCredentialsRequest)) redis.ApiCreateCredentialsRequest { - request := testClient.CreateCredentials(testCtx, testProjectId, testInstanceId) + request := testClient.DefaultAPI.CreateCredentials(testCtx, testProjectId, testRegion, testInstanceId) for _, mod := range mods { mod(&request) } @@ -154,7 +157,7 @@ func TestBuildRequest(t *testing.T) { request := buildRequest(testCtx, tt.model, testClient) diff := cmp.Diff(request, tt.expectedRequest, - cmp.AllowUnexported(tt.expectedRequest), + cmp.AllowUnexported(tt.expectedRequest, redis.DefaultAPIService{}), cmpopts.EquateComparable(testCtx), ) if diff != "" { diff --git a/internal/cmd/redis/credentials/delete/delete.go b/internal/cmd/redis/credentials/delete/delete.go index 496a43dd2..90bcb67b4 100644 --- a/internal/cmd/redis/credentials/delete/delete.go +++ b/internal/cmd/redis/credentials/delete/delete.go @@ -17,7 +17,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/redis" + redis "github.com/stackitcloud/stackit-sdk-go/services/redis/v2api" ) const ( @@ -56,13 +56,13 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return err } - instanceLabel, err := redisUtils.GetInstanceName(ctx, apiClient, model.ProjectId, model.InstanceId) + instanceLabel, err := redisUtils.GetInstanceName(ctx, apiClient.DefaultAPI, model.ProjectId, model.InstanceId, model.Region) if err != nil { params.Printer.Debug(print.ErrorLevel, "get instance name: %v", err) instanceLabel = model.InstanceId } - credentialsLabel, err := redisUtils.GetCredentialsUsername(ctx, apiClient, model.ProjectId, model.InstanceId, model.CredentialsId) + credentialsLabel, err := redisUtils.GetCredentialsUsername(ctx, apiClient.DefaultAPI, model.ProjectId, model.InstanceId, model.CredentialsId, model.Region) if err != nil { params.Printer.Debug(print.ErrorLevel, "get credentials user name: %v", err) credentialsLabel = model.CredentialsId @@ -115,6 +115,6 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *redis.APIClient) redis.ApiDeleteCredentialsRequest { - req := apiClient.DeleteCredentials(ctx, model.ProjectId, model.InstanceId, model.CredentialsId) + req := apiClient.DefaultAPI.DeleteCredentials(ctx, model.ProjectId, model.Region, model.InstanceId, model.CredentialsId) return req } diff --git a/internal/cmd/redis/credentials/delete/delete_test.go b/internal/cmd/redis/credentials/delete/delete_test.go index 08960a15d..c6bf42dd6 100644 --- a/internal/cmd/redis/credentials/delete/delete_test.go +++ b/internal/cmd/redis/credentials/delete/delete_test.go @@ -10,7 +10,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/redis" + redis "github.com/stackitcloud/stackit-sdk-go/services/redis/v2api" ) var projectIdFlag = globalflags.ProjectIdFlag @@ -18,10 +18,11 @@ var projectIdFlag = globalflags.ProjectIdFlag type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &redis.APIClient{} +var testClient = &redis.APIClient{DefaultAPI: &redis.DefaultAPIService{}} var testProjectId = uuid.NewString() var testInstanceId = uuid.NewString() var testCredentialsId = uuid.NewString() +var testRegion = "eu01" func fixtureArgValues(mods ...func(argValues []string)) []string { argValues := []string{ @@ -35,8 +36,9 @@ func fixtureArgValues(mods ...func(argValues []string)) []string { func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string { flagValues := map[string]string{ - projectIdFlag: testProjectId, - instanceIdFlag: testInstanceId, + projectIdFlag: testProjectId, + instanceIdFlag: testInstanceId, + globalflags.RegionFlag: testRegion, } for _, mod := range mods { mod(flagValues) @@ -49,6 +51,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { GlobalFlagModel: &globalflags.GlobalFlagModel{ ProjectId: testProjectId, Verbosity: globalflags.VerbosityDefault, + Region: testRegion, }, InstanceId: testInstanceId, CredentialsId: testCredentialsId, @@ -60,7 +63,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *redis.ApiDeleteCredentialsRequest)) redis.ApiDeleteCredentialsRequest { - request := testClient.DeleteCredentials(testCtx, testProjectId, testInstanceId, testCredentialsId) + request := testClient.DefaultAPI.DeleteCredentials(testCtx, testProjectId, testRegion, testInstanceId, testCredentialsId) for _, mod := range mods { mod(&request) } @@ -187,7 +190,7 @@ func TestBuildRequest(t *testing.T) { request := buildRequest(testCtx, tt.model, testClient) diff := cmp.Diff(request, tt.expectedRequest, - cmp.AllowUnexported(tt.expectedRequest), + cmp.AllowUnexported(tt.expectedRequest, redis.DefaultAPIService{}), cmpopts.EquateComparable(testCtx), ) if diff != "" { diff --git a/internal/cmd/redis/credentials/describe/describe.go b/internal/cmd/redis/credentials/describe/describe.go index 115f23f4b..359e0f86e 100644 --- a/internal/cmd/redis/credentials/describe/describe.go +++ b/internal/cmd/redis/credentials/describe/describe.go @@ -17,7 +17,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/redis" + redis "github.com/stackitcloud/stackit-sdk-go/services/redis/v2api" ) const ( @@ -99,7 +99,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *redis.APIClient) redis.ApiGetCredentialsRequest { - req := apiClient.GetCredentials(ctx, model.ProjectId, model.InstanceId, model.CredentialsId) + req := apiClient.DefaultAPI.GetCredentials(ctx, model.ProjectId, model.Region, model.InstanceId, model.CredentialsId) return req } @@ -110,15 +110,15 @@ func outputResult(p *print.Printer, outputFormat string, credentials *redis.Cred return p.OutputResult(outputFormat, credentials, func() error { table := tables.NewTable() - table.AddRow("ID", utils.PtrString(credentials.Id)) + table.AddRow("ID", credentials.Id) table.AddSeparator() // The username field cannot be set by the user so we only display it if it's not returned empty - if credentials.HasRaw() && credentials.Raw.Credentials != nil { - if username := credentials.Raw.Credentials.Username; username != nil && *username != "" { - table.AddRow("USERNAME", *username) + if credentials.HasRaw() { + if username := credentials.Raw.Credentials.Username; username != "" { + table.AddRow("USERNAME", username) table.AddSeparator() } - table.AddRow("PASSWORD", utils.PtrString(credentials.Raw.Credentials.Password)) + table.AddRow("PASSWORD", credentials.Raw.Credentials.Password) table.AddSeparator() table.AddRow("URI", utils.PtrString(credentials.Raw.Credentials.Uri)) } diff --git a/internal/cmd/redis/credentials/describe/describe_test.go b/internal/cmd/redis/credentials/describe/describe_test.go index 9a90e3359..60474623f 100644 --- a/internal/cmd/redis/credentials/describe/describe_test.go +++ b/internal/cmd/redis/credentials/describe/describe_test.go @@ -7,7 +7,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/redis" + redis "github.com/stackitcloud/stackit-sdk-go/services/redis/v2api" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" @@ -19,10 +19,11 @@ var projectIdFlag = globalflags.ProjectIdFlag type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &redis.APIClient{} +var testClient = &redis.APIClient{DefaultAPI: &redis.DefaultAPIService{}} var testProjectId = uuid.NewString() var testInstanceId = uuid.NewString() var testCredentialsId = uuid.NewString() +var testRegion = "eu01" func fixtureArgValues(mods ...func(argValues []string)) []string { argValues := []string{ @@ -36,8 +37,9 @@ func fixtureArgValues(mods ...func(argValues []string)) []string { func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string { flagValues := map[string]string{ - projectIdFlag: testProjectId, - instanceIdFlag: testInstanceId, + projectIdFlag: testProjectId, + instanceIdFlag: testInstanceId, + globalflags.RegionFlag: testRegion, } for _, mod := range mods { mod(flagValues) @@ -50,6 +52,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { GlobalFlagModel: &globalflags.GlobalFlagModel{ ProjectId: testProjectId, Verbosity: globalflags.VerbosityDefault, + Region: testRegion, }, InstanceId: testInstanceId, CredentialsId: testCredentialsId, @@ -61,7 +64,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *redis.ApiGetCredentialsRequest)) redis.ApiGetCredentialsRequest { - request := testClient.GetCredentials(testCtx, testProjectId, testInstanceId, testCredentialsId) + request := testClient.DefaultAPI.GetCredentials(testCtx, testProjectId, testRegion, testInstanceId, testCredentialsId) for _, mod := range mods { mod(&request) } @@ -188,7 +191,7 @@ func TestBuildRequest(t *testing.T) { request := buildRequest(testCtx, tt.model, testClient) diff := cmp.Diff(request, tt.expectedRequest, - cmp.AllowUnexported(tt.expectedRequest), + cmp.AllowUnexported(tt.expectedRequest, redis.DefaultAPIService{}), cmpopts.EquateComparable(testCtx), ) if diff != "" { diff --git a/internal/cmd/redis/credentials/list/list.go b/internal/cmd/redis/credentials/list/list.go index 536ef13c7..948e57522 100644 --- a/internal/cmd/redis/credentials/list/list.go +++ b/internal/cmd/redis/credentials/list/list.go @@ -7,7 +7,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/types" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/redis" + redis "github.com/stackitcloud/stackit-sdk-go/services/redis/v2api" "github.com/stackitcloud/stackit-cli/internal/pkg/args" "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -18,7 +18,6 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/services/redis/client" redisUtils "github.com/stackitcloud/stackit-cli/internal/pkg/services/redis/utils" "github.com/stackitcloud/stackit-cli/internal/pkg/tables" - "github.com/stackitcloud/stackit-cli/internal/pkg/utils" ) const ( @@ -68,7 +67,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { if err != nil { return fmt.Errorf("list Redis credentials: %w", err) } - credentials := *resp.CredentialsList + credentials := resp.CredentialsList // Truncate output if model.Limit != nil && len(credentials) > int(*model.Limit) { @@ -77,7 +76,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { instanceLabel := model.InstanceId if len(credentials) == 0 { - instanceLabel, err = redisUtils.GetInstanceName(ctx, apiClient, model.ProjectId, model.InstanceId) + instanceLabel, err = redisUtils.GetInstanceName(ctx, apiClient.DefaultAPI, model.ProjectId, model.InstanceId, model.Region) if err != nil { params.Printer.Debug(print.ErrorLevel, "get instance name: %v", err) } @@ -123,7 +122,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, } func buildRequest(ctx context.Context, model *inputModel, apiClient *redis.APIClient) redis.ApiListCredentialsRequest { - req := apiClient.ListCredentials(ctx, model.ProjectId, model.InstanceId) + req := apiClient.DefaultAPI.ListCredentials(ctx, model.ProjectId, model.Region, model.InstanceId) return req } @@ -138,7 +137,7 @@ func outputResult(p *print.Printer, outputFormat, instanceLabel string, credenti table.SetHeader("ID") for i := range credentials { c := credentials[i] - table.AddRow(utils.PtrString(c.Id)) + table.AddRow(c.Id) } err := table.Display(p) if err != nil { diff --git a/internal/cmd/redis/credentials/list/list_test.go b/internal/cmd/redis/credentials/list/list_test.go index 8460b19af..4ac005e63 100644 --- a/internal/cmd/redis/credentials/list/list_test.go +++ b/internal/cmd/redis/credentials/list/list_test.go @@ -7,7 +7,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/redis" + redis "github.com/stackitcloud/stackit-sdk-go/services/redis/v2api" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" @@ -20,15 +20,17 @@ var projectIdFlag = globalflags.ProjectIdFlag type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &redis.APIClient{} +var testClient = &redis.APIClient{DefaultAPI: &redis.DefaultAPIService{}} var testProjectId = uuid.NewString() var testInstanceId = uuid.NewString() +var testRegion = "eu01" func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string { flagValues := map[string]string{ - projectIdFlag: testProjectId, - instanceIdFlag: testInstanceId, - limitFlag: "10", + projectIdFlag: testProjectId, + instanceIdFlag: testInstanceId, + limitFlag: "10", + globalflags.RegionFlag: testRegion, } for _, mod := range mods { mod(flagValues) @@ -41,6 +43,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { GlobalFlagModel: &globalflags.GlobalFlagModel{ ProjectId: testProjectId, Verbosity: globalflags.VerbosityDefault, + Region: testRegion, }, InstanceId: testInstanceId, Limit: utils.Ptr(int64(10)), @@ -52,7 +55,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *redis.ApiListCredentialsRequest)) redis.ApiListCredentialsRequest { - request := testClient.ListCredentials(testCtx, testProjectId, testInstanceId) + request := testClient.DefaultAPI.ListCredentials(testCtx, testProjectId, testRegion, testInstanceId) for _, mod := range mods { mod(&request) } @@ -161,7 +164,7 @@ func TestBuildRequest(t *testing.T) { request := buildRequest(testCtx, tt.model, testClient) diff := cmp.Diff(request, tt.expectedRequest, - cmp.AllowUnexported(tt.expectedRequest), + cmp.AllowUnexported(tt.expectedRequest, redis.DefaultAPIService{}), cmpopts.EquateComparable(testCtx), ) if diff != "" { diff --git a/internal/cmd/redis/instance/create/create.go b/internal/cmd/redis/instance/create/create.go index 817a769ce..ebcf4a828 100644 --- a/internal/cmd/redis/instance/create/create.go +++ b/internal/cmd/redis/instance/create/create.go @@ -21,8 +21,8 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/redis" - "github.com/stackitcloud/stackit-sdk-go/services/redis/wait" + redis "github.com/stackitcloud/stackit-sdk-go/services/redis/v2api" + "github.com/stackitcloud/stackit-sdk-go/services/redis/v2api/wait" ) const ( @@ -44,14 +44,14 @@ type inputModel struct { PlanName string Version string - InstanceName *string + InstanceName string EnableMonitoring *bool Graphite *string - MetricsFrequency *int64 + MetricsFrequency *int32 MetricsPrefix *string MonitoringInstanceId *string SgwAcl *[]string - Syslog *[]string + Syslog []string PlanId *string } @@ -98,7 +98,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } // Call API - req, err := buildRequest(ctx, model, apiClient) + req, err := buildRequest(ctx, model, apiClient.DefaultAPI) if err != nil { var dsaInvalidPlanError *cliErr.DSAInvalidPlanError if !errors.As(err, &dsaInvalidPlanError) { @@ -110,12 +110,12 @@ func NewCmd(params *types.CmdParams) *cobra.Command { if err != nil { return fmt.Errorf("create Redis instance: %w", err) } - instanceId := *resp.InstanceId + instanceId := resp.InstanceId // Wait for async operation, if async mode not enabled if !model.Async { err := spinner.Run(params.Printer, "Creating instance", func() error { - _, err = wait.CreateInstanceWaitHandler(ctx, apiClient, model.ProjectId, instanceId).WaitWithContext(ctx) + _, err = wait.CreateInstanceWaitHandler(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, instanceId).WaitWithContext(ctx) return err }) if err != nil { @@ -134,7 +134,7 @@ func configureFlags(cmd *cobra.Command) { cmd.Flags().StringP(instanceNameFlag, "n", "", "Instance name") cmd.Flags().Bool(enableMonitoringFlag, false, "Enable monitoring") cmd.Flags().String(graphiteFlag, "", "Graphite host") - cmd.Flags().Int64(metricsFrequencyFlag, 0, "Metrics frequency") + cmd.Flags().Int32(metricsFrequencyFlag, 0, "Metrics frequency") cmd.Flags().String(metricsPrefixFlag, "", "Metrics prefix") cmd.Flags().Var(flags.UUIDFlag(), monitoringInstanceIdFlag, "Monitoring instance ID") cmd.Flags().Var(flags.CIDRSliceFlag(), sgwAclFlag, "List of IP networks in CIDR notation which are allowed to access this instance") @@ -170,14 +170,14 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, model := inputModel{ GlobalFlagModel: globalFlags, - InstanceName: flags.FlagToStringPointer(p, cmd, instanceNameFlag), + InstanceName: flags.FlagToStringValue(p, cmd, instanceNameFlag), EnableMonitoring: flags.FlagToBoolPointer(p, cmd, enableMonitoringFlag), MonitoringInstanceId: flags.FlagToStringPointer(p, cmd, monitoringInstanceIdFlag), Graphite: flags.FlagToStringPointer(p, cmd, graphiteFlag), - MetricsFrequency: flags.FlagToInt64Pointer(p, cmd, metricsFrequencyFlag), + MetricsFrequency: flags.FlagToInt32Pointer(p, cmd, metricsFrequencyFlag), MetricsPrefix: flags.FlagToStringPointer(p, cmd, metricsPrefixFlag), SgwAcl: flags.FlagToStringSlicePointer(p, cmd, sgwAclFlag), - Syslog: flags.FlagToStringSlicePointer(p, cmd, syslogFlag), + Syslog: flags.FlagToStringSliceValue(p, cmd, syslogFlag), PlanId: planId, PlanName: planName, Version: version, @@ -187,24 +187,19 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, return &model, nil } -type redisClient interface { - CreateInstance(ctx context.Context, projectId string) redis.ApiCreateInstanceRequest - ListOfferingsExecute(ctx context.Context, projectId string) (*redis.ListOfferingsResponse, error) -} - -func buildRequest(ctx context.Context, model *inputModel, apiClient redisClient) (redis.ApiCreateInstanceRequest, error) { - req := apiClient.CreateInstance(ctx, model.ProjectId) +func buildRequest(ctx context.Context, model *inputModel, apiClient redis.DefaultAPI) (redis.ApiCreateInstanceRequest, error) { + req := apiClient.CreateInstance(ctx, model.ProjectId, model.Region) - var planId *string + var planId string var err error - offerings, err := apiClient.ListOfferingsExecute(ctx, model.ProjectId) + offerings, err := apiClient.ListOfferings(ctx, model.ProjectId, model.Region).Execute() if err != nil { return req, fmt.Errorf("get Redis offerings: %w", err) } if model.PlanId == nil { - planId, err = redisUtils.LoadPlanId(model.PlanName, model.Version, offerings) + foundPlanId, err := redisUtils.LoadPlanId(model.PlanName, model.Version, offerings) if err != nil { var dsaInvalidPlanError *cliErr.DSAInvalidPlanError if !errors.As(err, &dsaInvalidPlanError) { @@ -212,12 +207,13 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient redisClient) } return req, err } + planId = *foundPlanId } else { err := redisUtils.ValidatePlanId(*model.PlanId, offerings) if err != nil { return req, err } - planId = model.PlanId + planId = *model.PlanId } var sgwAcl *string diff --git a/internal/cmd/redis/instance/create/create_test.go b/internal/cmd/redis/instance/create/create_test.go index 76798dd9a..a4f1a3348 100644 --- a/internal/cmd/redis/instance/create/create_test.go +++ b/internal/cmd/redis/instance/create/create_test.go @@ -8,7 +8,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/redis" + redis "github.com/stackitcloud/stackit-sdk-go/services/redis/v2api" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" @@ -21,31 +21,32 @@ var projectIdFlag = globalflags.ProjectIdFlag type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &redis.APIClient{} +var testClient = &redis.APIClient{DefaultAPI: &redis.DefaultAPIService{}} +var testProjectId = uuid.NewString() +var testPlanId = uuid.NewString() +var testMonitoringInstanceId = uuid.NewString() +var testRegion = "eu01" -type redisClientMocked struct { +type mockSettings struct { returnError bool listOfferingsResp *redis.ListOfferingsResponse } -func (c *redisClientMocked) CreateInstance(ctx context.Context, projectId string) redis.ApiCreateInstanceRequest { - return testClient.CreateInstance(ctx, projectId) -} - -func (c *redisClientMocked) ListOfferingsExecute(_ context.Context, _ string) (*redis.ListOfferingsResponse, error) { - if c.returnError { - return nil, fmt.Errorf("list flavors failed") +func newAPIMock(s mockSettings) redis.DefaultAPI { + return &redis.DefaultAPIServiceMock{ + ListOfferingsExecuteMock: utils.Ptr(func(_ redis.ApiListOfferingsRequest) (*redis.ListOfferingsResponse, error) { + if s.returnError { + return nil, fmt.Errorf("list flavors failed") + } + return s.listOfferingsResp, nil + }), } - return c.listOfferingsResp, nil } -var testProjectId = uuid.NewString() -var testPlanId = uuid.NewString() -var testMonitoringInstanceId = uuid.NewString() - func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string { flagValues := map[string]string{ projectIdFlag: testProjectId, + globalflags.RegionFlag: testRegion, instanceNameFlag: "example-name", enableMonitoringFlag: "true", graphiteFlag: "example-graphite", @@ -67,15 +68,16 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { GlobalFlagModel: &globalflags.GlobalFlagModel{ ProjectId: testProjectId, Verbosity: globalflags.VerbosityDefault, + Region: testRegion, }, - InstanceName: utils.Ptr("example-name"), + InstanceName: "example-name", EnableMonitoring: utils.Ptr(true), Graphite: utils.Ptr("example-graphite"), - MetricsFrequency: utils.Ptr(int64(100)), + MetricsFrequency: utils.Ptr(int32(100)), MetricsPrefix: utils.Ptr("example-prefix"), MonitoringInstanceId: utils.Ptr(testMonitoringInstanceId), SgwAcl: utils.Ptr([]string{"198.51.100.14/24"}), - Syslog: utils.Ptr([]string{"example-syslog"}), + Syslog: []string{"example-syslog"}, PlanId: utils.Ptr(testPlanId), } for _, mod := range mods { @@ -85,19 +87,19 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *redis.ApiCreateInstanceRequest)) redis.ApiCreateInstanceRequest { - request := testClient.CreateInstance(testCtx, testProjectId) + request := testClient.DefaultAPI.CreateInstance(testCtx, testProjectId, testRegion) request = request.CreateInstancePayload(redis.CreateInstancePayload{ - InstanceName: utils.Ptr("example-name"), + InstanceName: "example-name", Parameters: &redis.InstanceParameters{ EnableMonitoring: utils.Ptr(true), Graphite: utils.Ptr("example-graphite"), - MetricsFrequency: utils.Ptr(int64(100)), + MetricsFrequency: utils.Ptr(int32(100)), MetricsPrefix: utils.Ptr("example-prefix"), MonitoringInstanceId: utils.Ptr(testMonitoringInstanceId), SgwAcl: utils.Ptr("198.51.100.14/24"), - Syslog: utils.Ptr([]string{"example-syslog"}), + Syslog: []string{"example-syslog"}, }, - PlanId: utils.Ptr(testPlanId), + PlanId: testPlanId, }) for _, mod := range mods { mod(&request) @@ -153,7 +155,7 @@ func TestParseInput(t *testing.T) { ProjectId: testProjectId, Verbosity: globalflags.VerbosityDefault, }, - InstanceName: utils.Ptr("example-name"), + InstanceName: "example-name", PlanId: utils.Ptr(testPlanId), }, }, @@ -175,10 +177,10 @@ func TestParseInput(t *testing.T) { Verbosity: globalflags.VerbosityDefault, }, PlanId: utils.Ptr(testPlanId), - InstanceName: utils.Ptr(""), + InstanceName: "", EnableMonitoring: utils.Ptr(false), Graphite: utils.Ptr(""), - MetricsFrequency: utils.Ptr(int64(0)), + MetricsFrequency: utils.Ptr(int32(0)), MetricsPrefix: utils.Ptr(""), }, }, @@ -254,9 +256,7 @@ func TestParseInput(t *testing.T) { syslogValues: []string{"example-syslog-1", "example-syslog-2"}, isValid: true, expectedModel: fixtureInputModel(func(model *inputModel) { - model.Syslog = utils.Ptr( - append(*model.Syslog, "example-syslog-1", "example-syslog-2"), - ) + model.Syslog = append(model.Syslog, "example-syslog-1", "example-syslog-2") }), }, } @@ -285,13 +285,13 @@ func TestBuildRequest(t *testing.T) { model: fixtureInputModel(), expectedRequest: fixtureRequest(), getOfferingsResp: &redis.ListOfferingsResponse{ - Offerings: &[]redis.Offering{ + Offerings: []redis.Offering{ { - Version: utils.Ptr("example-version"), - Plans: &[]redis.Plan{ + Version: "example-version", + Plans: []redis.Plan{ { - Name: utils.Ptr("example-plan-name"), - Id: utils.Ptr(testPlanId), + Name: "example-plan-name", + Id: testPlanId, }, }, }, @@ -309,13 +309,13 @@ func TestBuildRequest(t *testing.T) { ), expectedRequest: fixtureRequest(), getOfferingsResp: &redis.ListOfferingsResponse{ - Offerings: &[]redis.Offering{ + Offerings: []redis.Offering{ { - Version: utils.Ptr("example-version"), - Plans: &[]redis.Plan{ + Version: "example-version", + Plans: []redis.Plan{ { - Name: utils.Ptr("example-plan-name"), - Id: utils.Ptr(testPlanId), + Name: "example-plan-name", + Id: testPlanId, }, }, }, @@ -344,13 +344,13 @@ func TestBuildRequest(t *testing.T) { }, ), getOfferingsResp: &redis.ListOfferingsResponse{ - Offerings: &[]redis.Offering{ + Offerings: []redis.Offering{ { - Version: utils.Ptr("example-version"), - Plans: &[]redis.Plan{ + Version: "example-version", + Plans: []redis.Plan{ { - Name: utils.Ptr("other-plan-name"), - Id: utils.Ptr(testPlanId), + Name: "other-plan-name", + Id: testPlanId, }, }, }, @@ -364,34 +364,35 @@ func TestBuildRequest(t *testing.T) { GlobalFlagModel: &globalflags.GlobalFlagModel{ ProjectId: testProjectId, Verbosity: globalflags.VerbosityDefault, + Region: testRegion, }, PlanId: utils.Ptr(testPlanId), }, getOfferingsResp: &redis.ListOfferingsResponse{ - Offerings: &[]redis.Offering{ + Offerings: []redis.Offering{ { - Version: utils.Ptr("example-version"), - Plans: &[]redis.Plan{ + Version: "example-version", + Plans: []redis.Plan{ { - Name: utils.Ptr("example-plan-name"), - Id: utils.Ptr(testPlanId), + Name: "example-plan-name", + Id: testPlanId, }, }, }, }, }, - expectedRequest: testClient.CreateInstance(testCtx, testProjectId). - CreateInstancePayload(redis.CreateInstancePayload{PlanId: utils.Ptr(testPlanId), Parameters: &redis.InstanceParameters{}}), + expectedRequest: testClient.DefaultAPI.CreateInstance(testCtx, testProjectId, testRegion). + CreateInstancePayload(redis.CreateInstancePayload{PlanId: testPlanId, Parameters: &redis.InstanceParameters{}}), }, } for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { - client := &redisClientMocked{ + client := mockSettings{ returnError: tt.getOfferingsFails, listOfferingsResp: tt.getOfferingsResp, } - request, err := buildRequest(testCtx, tt.model, client) + request, err := buildRequest(testCtx, tt.model, newAPIMock(client)) if err != nil { if !tt.isValid { return @@ -400,8 +401,11 @@ func TestBuildRequest(t *testing.T) { } diff := cmp.Diff(request, tt.expectedRequest, - cmp.AllowUnexported(tt.expectedRequest), + cmp.AllowUnexported(tt.expectedRequest, redis.DefaultAPIService{}), cmpopts.EquateComparable(testCtx), + cmp.FilterPath(func(p cmp.Path) bool { + return p.String() == "ApiService" + }, cmp.Ignore()), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/redis/instance/delete/delete.go b/internal/cmd/redis/instance/delete/delete.go index f54412008..df23695e1 100644 --- a/internal/cmd/redis/instance/delete/delete.go +++ b/internal/cmd/redis/instance/delete/delete.go @@ -17,8 +17,8 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/redis" - "github.com/stackitcloud/stackit-sdk-go/services/redis/wait" + redis "github.com/stackitcloud/stackit-sdk-go/services/redis/v2api" + "github.com/stackitcloud/stackit-sdk-go/services/redis/v2api/wait" ) const ( @@ -54,7 +54,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return err } - instanceLabel, err := redisUtils.GetInstanceName(ctx, apiClient, model.ProjectId, model.InstanceId) + instanceLabel, err := redisUtils.GetInstanceName(ctx, apiClient.DefaultAPI, model.ProjectId, model.InstanceId, model.Region) if err != nil { params.Printer.Debug(print.ErrorLevel, "get instance name: %v", err) instanceLabel = model.InstanceId @@ -76,7 +76,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { // Wait for async operation, if async mode not enabled if !model.Async { err := spinner.Run(params.Printer, "Deleting instance", func() error { - _, err = wait.DeleteInstanceWaitHandler(ctx, apiClient, model.ProjectId, model.InstanceId).WaitWithContext(ctx) + _, err = wait.DeleteInstanceWaitHandler(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, model.InstanceId).WaitWithContext(ctx) return err }) if err != nil { @@ -113,6 +113,6 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *redis.APIClient) redis.ApiDeleteInstanceRequest { - req := apiClient.DeleteInstance(ctx, model.ProjectId, model.InstanceId) + req := apiClient.DefaultAPI.DeleteInstance(ctx, model.ProjectId, model.Region, model.InstanceId) return req } diff --git a/internal/cmd/redis/instance/delete/delete_test.go b/internal/cmd/redis/instance/delete/delete_test.go index 6372daa5b..68617b67c 100644 --- a/internal/cmd/redis/instance/delete/delete_test.go +++ b/internal/cmd/redis/instance/delete/delete_test.go @@ -10,7 +10,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/redis" + redis "github.com/stackitcloud/stackit-sdk-go/services/redis/v2api" ) var projectIdFlag = globalflags.ProjectIdFlag @@ -18,9 +18,10 @@ var projectIdFlag = globalflags.ProjectIdFlag type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &redis.APIClient{} +var testClient = &redis.APIClient{DefaultAPI: &redis.DefaultAPIService{}} var testProjectId = uuid.NewString() var testInstanceId = uuid.NewString() +var testRegion = "eu01" func fixtureArgValues(mods ...func(argValues []string)) []string { argValues := []string{ @@ -34,7 +35,8 @@ func fixtureArgValues(mods ...func(argValues []string)) []string { func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string { flagValues := map[string]string{ - projectIdFlag: testProjectId, + projectIdFlag: testProjectId, + globalflags.RegionFlag: testRegion, } for _, mod := range mods { mod(flagValues) @@ -47,6 +49,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { GlobalFlagModel: &globalflags.GlobalFlagModel{ ProjectId: testProjectId, Verbosity: globalflags.VerbosityDefault, + Region: testRegion, }, InstanceId: testInstanceId, } @@ -57,7 +60,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *redis.ApiDeleteInstanceRequest)) redis.ApiDeleteInstanceRequest { - request := testClient.DeleteInstance(testCtx, testProjectId, testInstanceId) + request := testClient.DefaultAPI.DeleteInstance(testCtx, testProjectId, testRegion, testInstanceId) for _, mod := range mods { mod(&request) } @@ -160,7 +163,7 @@ func TestBuildRequest(t *testing.T) { request := buildRequest(testCtx, tt.model, testClient) diff := cmp.Diff(request, tt.expectedRequest, - cmp.AllowUnexported(tt.expectedRequest), + cmp.AllowUnexported(tt.expectedRequest, redis.DefaultAPIService{}), cmpopts.EquateComparable(testCtx), ) if diff != "" { diff --git a/internal/cmd/redis/instance/describe/describe.go b/internal/cmd/redis/instance/describe/describe.go index aaa003478..6b5f395d7 100644 --- a/internal/cmd/redis/instance/describe/describe.go +++ b/internal/cmd/redis/instance/describe/describe.go @@ -16,7 +16,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/redis" + redis "github.com/stackitcloud/stackit-sdk-go/services/redis/v2api" ) const ( @@ -87,7 +87,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *redis.APIClient) redis.ApiGetInstanceRequest { - req := apiClient.GetInstance(ctx, model.ProjectId, model.InstanceId) + req := apiClient.DefaultAPI.GetInstance(ctx, model.ProjectId, model.Region, model.InstanceId) return req } @@ -100,18 +100,16 @@ func outputResult(p *print.Printer, outputFormat string, instance *redis.Instanc table := tables.NewTable() table.AddRow("ID", utils.PtrString(instance.InstanceId)) table.AddSeparator() - table.AddRow("NAME", utils.PtrString(instance.Name)) + table.AddRow("NAME", instance.Name) table.AddSeparator() - if lastOperation := instance.LastOperation; lastOperation != nil { - table.AddRow("LAST OPERATION TYPE", utils.PtrString(instance.LastOperation.Type)) - table.AddSeparator() - table.AddRow("LAST OPERATION STATE", utils.PtrString(instance.LastOperation.State)) - table.AddSeparator() - } - table.AddRow("PLAN ID", utils.PtrString(instance.PlanId)) + table.AddRow("LAST OPERATION TYPE", instance.LastOperation.Type) + table.AddSeparator() + table.AddRow("LAST OPERATION STATE", instance.LastOperation.State) + table.AddSeparator() + table.AddRow("PLAN ID", instance.PlanId) if parameters := instance.Parameters; parameters != nil { // Only show ACL if it's present and not empty - acl := (*parameters)[aclParameterKey] + acl := parameters[aclParameterKey] aclStr, ok := acl.(string) if ok { if aclStr != "" { diff --git a/internal/cmd/redis/instance/describe/describe_test.go b/internal/cmd/redis/instance/describe/describe_test.go index 55ace702c..24521eae9 100644 --- a/internal/cmd/redis/instance/describe/describe_test.go +++ b/internal/cmd/redis/instance/describe/describe_test.go @@ -7,7 +7,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/redis" + redis "github.com/stackitcloud/stackit-sdk-go/services/redis/v2api" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" @@ -19,9 +19,10 @@ var projectIdFlag = globalflags.ProjectIdFlag type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &redis.APIClient{} +var testClient = &redis.APIClient{DefaultAPI: &redis.DefaultAPIService{}} var testProjectId = uuid.NewString() var testInstanceId = uuid.NewString() +var testRegion = "eu01" func fixtureArgValues(mods ...func(argValues []string)) []string { argValues := []string{ @@ -35,7 +36,8 @@ func fixtureArgValues(mods ...func(argValues []string)) []string { func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string { flagValues := map[string]string{ - projectIdFlag: testProjectId, + projectIdFlag: testProjectId, + globalflags.RegionFlag: testRegion, } for _, mod := range mods { mod(flagValues) @@ -48,6 +50,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { GlobalFlagModel: &globalflags.GlobalFlagModel{ ProjectId: testProjectId, Verbosity: globalflags.VerbosityDefault, + Region: testRegion, }, InstanceId: testInstanceId, } @@ -58,7 +61,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *redis.ApiGetInstanceRequest)) redis.ApiGetInstanceRequest { - request := testClient.GetInstance(testCtx, testProjectId, testInstanceId) + request := testClient.DefaultAPI.GetInstance(testCtx, testProjectId, testRegion, testInstanceId) for _, mod := range mods { mod(&request) } @@ -161,7 +164,7 @@ func TestBuildRequest(t *testing.T) { request := buildRequest(testCtx, tt.model, testClient) diff := cmp.Diff(request, tt.expectedRequest, - cmp.AllowUnexported(tt.expectedRequest), + cmp.AllowUnexported(tt.expectedRequest, redis.DefaultAPIService{}), cmpopts.EquateComparable(testCtx), ) if diff != "" { @@ -197,7 +200,7 @@ func Test_outputResult(t *testing.T) { name: "nil parameter", args: args{ instance: &redis.Instance{ - Parameters: &map[string]interface{}{ + Parameters: map[string]interface{}{ "foo": nil, }, }, diff --git a/internal/cmd/redis/instance/list/list.go b/internal/cmd/redis/instance/list/list.go index b0d207907..9d9de28b7 100644 --- a/internal/cmd/redis/instance/list/list.go +++ b/internal/cmd/redis/instance/list/list.go @@ -7,7 +7,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/types" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/redis" + redis "github.com/stackitcloud/stackit-sdk-go/services/redis/v2api" "github.com/stackitcloud/stackit-cli/internal/pkg/args" "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -66,7 +66,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { if err != nil { return fmt.Errorf("get Redis instances: %w", err) } - instances := *resp.Instances + instances := resp.Instances // Truncate output if model.Limit != nil && len(instances) > int(*model.Limit) { @@ -117,7 +117,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, } func buildRequest(ctx context.Context, model *inputModel, apiClient *redis.APIClient) redis.ApiListInstancesRequest { - req := apiClient.ListInstances(ctx, model.ProjectId) + req := apiClient.DefaultAPI.ListInstances(ctx, model.ProjectId, model.Region) return req } @@ -135,12 +135,11 @@ func outputResult(p *print.Printer, outputFormat, projectLabel string, instances var ( lastOperationType, lastOperationState string ) - if lastOperation := instance.LastOperation; lastOperation != nil { - lastOperationType, lastOperationState = utils.PtrString(lastOperation.Type), utils.PtrString(lastOperation.State) - } + lastOperationType = string(instance.LastOperation.Type) + lastOperationState = string(instance.LastOperation.State) table.AddRow( utils.PtrString(instance.InstanceId), - utils.PtrString(instance.Name), + instance.Name, lastOperationType, lastOperationState, ) diff --git a/internal/cmd/redis/instance/list/list_test.go b/internal/cmd/redis/instance/list/list_test.go index 9b4645a8e..cc30a0ca2 100644 --- a/internal/cmd/redis/instance/list/list_test.go +++ b/internal/cmd/redis/instance/list/list_test.go @@ -7,7 +7,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/redis" + redis "github.com/stackitcloud/stackit-sdk-go/services/redis/v2api" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" @@ -20,13 +20,15 @@ var projectIdFlag = globalflags.ProjectIdFlag type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &redis.APIClient{} +var testClient = &redis.APIClient{DefaultAPI: &redis.DefaultAPIService{}} var testProjectId = uuid.NewString() +var testRegion = "eu01" func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string { flagValues := map[string]string{ - projectIdFlag: testProjectId, - limitFlag: "10", + projectIdFlag: testProjectId, + limitFlag: "10", + globalflags.RegionFlag: testRegion, } for _, mod := range mods { mod(flagValues) @@ -39,6 +41,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { GlobalFlagModel: &globalflags.GlobalFlagModel{ ProjectId: testProjectId, Verbosity: globalflags.VerbosityDefault, + Region: testRegion, }, Limit: utils.Ptr(int64(10)), } @@ -49,7 +52,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *redis.ApiListInstancesRequest)) redis.ApiListInstancesRequest { - request := testClient.ListInstances(testCtx, testProjectId) + request := testClient.DefaultAPI.ListInstances(testCtx, testProjectId, testRegion) for _, mod := range mods { mod(&request) } @@ -137,7 +140,7 @@ func TestBuildRequest(t *testing.T) { request := buildRequest(testCtx, tt.model, testClient) diff := cmp.Diff(request, tt.expectedRequest, - cmp.AllowUnexported(tt.expectedRequest), + cmp.AllowUnexported(tt.expectedRequest, redis.DefaultAPIService{}), cmpopts.EquateComparable(testCtx), ) if diff != "" { diff --git a/internal/cmd/redis/instance/update/update.go b/internal/cmd/redis/instance/update/update.go index ca078eb82..170089ad1 100644 --- a/internal/cmd/redis/instance/update/update.go +++ b/internal/cmd/redis/instance/update/update.go @@ -20,8 +20,8 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/redis" - "github.com/stackitcloud/stackit-sdk-go/services/redis/wait" + redis "github.com/stackitcloud/stackit-sdk-go/services/redis/v2api" + "github.com/stackitcloud/stackit-sdk-go/services/redis/v2api/wait" ) const ( @@ -47,11 +47,11 @@ type inputModel struct { EnableMonitoring *bool Graphite *string - MetricsFrequency *int64 + MetricsFrequency *int32 MetricsPrefix *string MonitoringInstanceId *string SgwAcl *[]string - Syslog *[]string + Syslog []string PlanId *string } @@ -82,7 +82,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return err } - instanceLabel, err := redisUtils.GetInstanceName(ctx, apiClient, model.ProjectId, model.InstanceId) + instanceLabel, err := redisUtils.GetInstanceName(ctx, apiClient.DefaultAPI, model.ProjectId, model.InstanceId, model.Region) if err != nil { params.Printer.Debug(print.ErrorLevel, "get instance name: %v", err) instanceLabel = model.InstanceId @@ -95,7 +95,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } // Call API - req, err := buildRequest(ctx, model, apiClient) + req, err := buildRequest(ctx, model, apiClient.DefaultAPI) if err != nil { var dsaInvalidPlanError *cliErr.DSAInvalidPlanError if !errors.As(err, &dsaInvalidPlanError) { @@ -112,7 +112,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { // Wait for async operation, if async mode not enabled if !model.Async { err := spinner.Run(params.Printer, "Updating instance", func() error { - _, err = wait.PartialUpdateInstanceWaitHandler(ctx, apiClient, model.ProjectId, instanceId).WaitWithContext(ctx) + _, err = wait.PartialUpdateInstanceWaitHandler(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, instanceId).WaitWithContext(ctx) return err }) if err != nil { @@ -135,7 +135,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { func configureFlags(cmd *cobra.Command) { cmd.Flags().Bool(enableMonitoringFlag, false, "Enable monitoring") cmd.Flags().String(graphiteFlag, "", "Graphite host") - cmd.Flags().Int64(metricsFrequencyFlag, 0, "Metrics frequency") + cmd.Flags().Int32(metricsFrequencyFlag, 0, "Metrics frequency") cmd.Flags().String(metricsPrefixFlag, "", "Metrics prefix") cmd.Flags().Var(flags.UUIDFlag(), monitoringInstanceIdFlag, "Monitoring instance ID") cmd.Flags().Var(flags.CIDRSliceFlag(), sgwAclFlag, "List of IP networks in CIDR notation which are allowed to access this instance") @@ -156,10 +156,10 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu enableMonitoring := flags.FlagToBoolPointer(p, cmd, enableMonitoringFlag) monitoringInstanceId := flags.FlagToStringPointer(p, cmd, monitoringInstanceIdFlag) graphite := flags.FlagToStringPointer(p, cmd, graphiteFlag) - metricsFrequency := flags.FlagToInt64Pointer(p, cmd, metricsFrequencyFlag) + metricsFrequency := flags.FlagToInt32Pointer(p, cmd, metricsFrequencyFlag) metricsPrefix := flags.FlagToStringPointer(p, cmd, metricsPrefixFlag) sgwAcl := flags.FlagToStringSlicePointer(p, cmd, sgwAclFlag) - syslog := flags.FlagToStringSlicePointer(p, cmd, syslogFlag) + syslog := flags.FlagToStringSliceValue(p, cmd, syslogFlag) planId := flags.FlagToStringPointer(p, cmd, planIdFlag) planName := flags.FlagToStringValue(p, cmd, planNameFlag) version := flags.FlagToStringValue(p, cmd, versionFlag) @@ -197,18 +197,13 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu return &model, nil } -type redisClient interface { - PartialUpdateInstance(ctx context.Context, projectId, instanceId string) redis.ApiPartialUpdateInstanceRequest - ListOfferingsExecute(ctx context.Context, projectId string) (*redis.ListOfferingsResponse, error) -} - -func buildRequest(ctx context.Context, model *inputModel, apiClient redisClient) (redis.ApiPartialUpdateInstanceRequest, error) { - req := apiClient.PartialUpdateInstance(ctx, model.ProjectId, model.InstanceId) +func buildRequest(ctx context.Context, model *inputModel, apiClient redis.DefaultAPI) (redis.ApiPartialUpdateInstanceRequest, error) { + req := apiClient.PartialUpdateInstance(ctx, model.ProjectId, model.Region, model.InstanceId) var planId *string var err error - offerings, err := apiClient.ListOfferingsExecute(ctx, model.ProjectId) + offerings, err := apiClient.ListOfferings(ctx, model.ProjectId, model.Region).Execute() if err != nil { return req, fmt.Errorf("get Redis offerings: %w", err) } diff --git a/internal/cmd/redis/instance/update/update_test.go b/internal/cmd/redis/instance/update/update_test.go index 140d0d1d9..46ca37dc8 100644 --- a/internal/cmd/redis/instance/update/update_test.go +++ b/internal/cmd/redis/instance/update/update_test.go @@ -12,7 +12,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/redis" + redis "github.com/stackitcloud/stackit-sdk-go/services/redis/v2api" ) var projectIdFlag = globalflags.ProjectIdFlag @@ -20,22 +20,23 @@ var projectIdFlag = globalflags.ProjectIdFlag type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &redis.APIClient{} +var testClient = &redis.APIClient{DefaultAPI: &redis.DefaultAPIService{}} +var testRegion = "eu01" -type redisClientMocked struct { +type mockSettings struct { returnError bool listOfferingsResp *redis.ListOfferingsResponse } -func (c *redisClientMocked) PartialUpdateInstance(ctx context.Context, projectId, instanceId string) redis.ApiPartialUpdateInstanceRequest { - return testClient.PartialUpdateInstance(ctx, projectId, instanceId) -} - -func (c *redisClientMocked) ListOfferingsExecute(_ context.Context, _ string) (*redis.ListOfferingsResponse, error) { - if c.returnError { - return nil, fmt.Errorf("list flavors failed") +func newAPIMock(s mockSettings) redis.DefaultAPI { + return &redis.DefaultAPIServiceMock{ + ListOfferingsExecuteMock: utils.Ptr(func(_ redis.ApiListOfferingsRequest) (*redis.ListOfferingsResponse, error) { + if s.returnError { + return nil, fmt.Errorf("list flavors failed") + } + return s.listOfferingsResp, nil + }), } - return c.listOfferingsResp, nil } var ( @@ -58,6 +59,7 @@ func fixtureArgValues(mods ...func(argValues []string)) []string { func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string { flagValues := map[string]string{ projectIdFlag: testProjectId, + globalflags.RegionFlag: testRegion, enableMonitoringFlag: "true", graphiteFlag: "example-graphite", metricsFrequencyFlag: "100", @@ -78,15 +80,16 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { GlobalFlagModel: &globalflags.GlobalFlagModel{ ProjectId: testProjectId, Verbosity: globalflags.VerbosityDefault, + Region: testRegion, }, InstanceId: testInstanceId, EnableMonitoring: utils.Ptr(true), Graphite: utils.Ptr("example-graphite"), - MetricsFrequency: utils.Ptr(int64(100)), + MetricsFrequency: utils.Ptr(int32(100)), MetricsPrefix: utils.Ptr("example-prefix"), MonitoringInstanceId: utils.Ptr(testMonitoringInstanceId), SgwAcl: utils.Ptr([]string{"198.51.100.14/24"}), - Syslog: utils.Ptr([]string{"example-syslog"}), + Syslog: []string{"example-syslog"}, PlanId: utils.Ptr(testPlanId), } for _, mod := range mods { @@ -96,16 +99,16 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *redis.ApiPartialUpdateInstanceRequest)) redis.ApiPartialUpdateInstanceRequest { - request := testClient.PartialUpdateInstance(testCtx, testProjectId, testInstanceId) + request := testClient.DefaultAPI.PartialUpdateInstance(testCtx, testProjectId, testRegion, testInstanceId) request = request.PartialUpdateInstancePayload(redis.PartialUpdateInstancePayload{ Parameters: &redis.InstanceParameters{ EnableMonitoring: utils.Ptr(true), Graphite: utils.Ptr("example-graphite"), - MetricsFrequency: utils.Ptr(int64(100)), + MetricsFrequency: utils.Ptr(int32(100)), MetricsPrefix: utils.Ptr("example-prefix"), MonitoringInstanceId: utils.Ptr(testMonitoringInstanceId), SgwAcl: utils.Ptr("198.51.100.14/24"), - Syslog: utils.Ptr([]string{"example-syslog"}), + Syslog: []string{"example-syslog"}, }, PlanId: utils.Ptr(testPlanId), }) @@ -186,7 +189,7 @@ func TestParseInput(t *testing.T) { PlanId: utils.Ptr(testPlanId), EnableMonitoring: utils.Ptr(false), Graphite: utils.Ptr(""), - MetricsFrequency: utils.Ptr(int64(0)), + MetricsFrequency: utils.Ptr(int32(0)), MetricsPrefix: utils.Ptr(""), }, }, @@ -268,9 +271,7 @@ func TestParseInput(t *testing.T) { syslogValues: []string{"example-syslog-1", "example-syslog-2"}, isValid: true, expectedModel: fixtureInputModel(func(model *inputModel) { - model.Syslog = utils.Ptr( - append(*model.Syslog, "example-syslog-1", "example-syslog-2"), - ) + model.Syslog = append(model.Syslog, "example-syslog-1", "example-syslog-2") }), }, } @@ -363,13 +364,13 @@ func TestBuildRequest(t *testing.T) { model: fixtureInputModel(), expectedRequest: fixtureRequest(), listOfferingsResp: &redis.ListOfferingsResponse{ - Offerings: &[]redis.Offering{ + Offerings: []redis.Offering{ { - Version: utils.Ptr("example-version"), - Plans: &[]redis.Plan{ + Version: "example-version", + Plans: []redis.Plan{ { - Name: utils.Ptr("example-plan-name"), - Id: utils.Ptr(testPlanId), + Name: "example-plan-name", + Id: testPlanId, }, }, }, @@ -387,13 +388,13 @@ func TestBuildRequest(t *testing.T) { ), expectedRequest: fixtureRequest(), listOfferingsResp: &redis.ListOfferingsResponse{ - Offerings: &[]redis.Offering{ + Offerings: []redis.Offering{ { - Version: utils.Ptr("example-version"), - Plans: &[]redis.Plan{ + Version: "example-version", + Plans: []redis.Plan{ { - Name: utils.Ptr("example-plan-name"), - Id: utils.Ptr(testPlanId), + Name: "example-plan-name", + Id: testPlanId, }, }, }, @@ -422,13 +423,13 @@ func TestBuildRequest(t *testing.T) { }, ), listOfferingsResp: &redis.ListOfferingsResponse{ - Offerings: &[]redis.Offering{ + Offerings: []redis.Offering{ { - Version: utils.Ptr("example-version"), - Plans: &[]redis.Plan{ + Version: "example-version", + Plans: []redis.Plan{ { - Name: utils.Ptr("other-plan-name"), - Id: utils.Ptr(testPlanId), + Name: "other-plan-name", + Id: testPlanId, }, }, }, @@ -442,21 +443,22 @@ func TestBuildRequest(t *testing.T) { GlobalFlagModel: &globalflags.GlobalFlagModel{ ProjectId: testProjectId, Verbosity: globalflags.VerbosityDefault, + Region: testRegion, }, InstanceId: testInstanceId, }, - expectedRequest: testClient.PartialUpdateInstance(testCtx, testProjectId, testInstanceId). + expectedRequest: testClient.DefaultAPI.PartialUpdateInstance(testCtx, testProjectId, testRegion, testInstanceId). PartialUpdateInstancePayload(redis.PartialUpdateInstancePayload{Parameters: &redis.InstanceParameters{}}), }, } for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { - client := &redisClientMocked{ + client := mockSettings{ returnError: tt.getOfferingsFails, listOfferingsResp: tt.listOfferingsResp, } - request, err := buildRequest(testCtx, tt.model, client) + request, err := buildRequest(testCtx, tt.model, newAPIMock(client)) if err != nil { if !tt.isValid { return @@ -465,8 +467,11 @@ func TestBuildRequest(t *testing.T) { } diff := cmp.Diff(request, tt.expectedRequest, - cmp.AllowUnexported(tt.expectedRequest), + cmp.AllowUnexported(tt.expectedRequest, redis.DefaultAPIService{}), cmpopts.EquateComparable(testCtx), + cmp.FilterPath(func(p cmp.Path) bool { + return p.String() == "ApiService" + }, cmp.Ignore()), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/redis/plans/plans.go b/internal/cmd/redis/plans/plans.go index 923006376..ede5f2a76 100644 --- a/internal/cmd/redis/plans/plans.go +++ b/internal/cmd/redis/plans/plans.go @@ -7,7 +7,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/types" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/redis" + redis "github.com/stackitcloud/stackit-sdk-go/services/redis/v2api" "github.com/stackitcloud/stackit-cli/internal/pkg/args" "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -18,7 +18,6 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/projectname" "github.com/stackitcloud/stackit-cli/internal/pkg/services/redis/client" "github.com/stackitcloud/stackit-cli/internal/pkg/tables" - "github.com/stackitcloud/stackit-cli/internal/pkg/utils" ) const ( @@ -66,7 +65,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { if err != nil { return fmt.Errorf("get Redis service plans: %w", err) } - plans := *resp.Offerings + plans := resp.Offerings if len(plans) == 0 { projectLabel, err := projectname.GetProjectName(ctx, params.Printer, params.CliVersion, cmd) if err != nil { @@ -118,7 +117,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, } func buildRequest(ctx context.Context, model *inputModel, apiClient *redis.APIClient) redis.ApiListOfferingsRequest { - req := apiClient.ListOfferings(ctx, model.ProjectId) + req := apiClient.DefaultAPI.ListOfferings(ctx, model.ProjectId, model.Region) return req } @@ -129,14 +128,14 @@ func outputResult(p *print.Printer, outputFormat string, plans []redis.Offering) for i := range plans { o := plans[i] if o.Plans != nil { - for j := range *o.Plans { - plan := (*o.Plans)[j] + for j := range o.Plans { + plan := (o.Plans)[j] table.AddRow( - utils.PtrString(o.Name), - utils.PtrString(o.Version), - utils.PtrString(plan.Id), - utils.PtrString(plan.Name), - utils.PtrString(plan.Description), + o.Name, + o.Version, + plan.Id, + plan.Name, + plan.Description, ) } table.AddSeparator() diff --git a/internal/cmd/redis/plans/plans_test.go b/internal/cmd/redis/plans/plans_test.go index 872bdbac2..17dae4bd3 100644 --- a/internal/cmd/redis/plans/plans_test.go +++ b/internal/cmd/redis/plans/plans_test.go @@ -7,7 +7,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/redis" + redis "github.com/stackitcloud/stackit-sdk-go/services/redis/v2api" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" @@ -20,13 +20,15 @@ var projectIdFlag = globalflags.ProjectIdFlag type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &redis.APIClient{} +var testClient = &redis.APIClient{DefaultAPI: &redis.DefaultAPIService{}} var testProjectId = uuid.NewString() +var testRegion = "eu01" func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string { flagValues := map[string]string{ - projectIdFlag: testProjectId, - limitFlag: "10", + projectIdFlag: testProjectId, + limitFlag: "10", + globalflags.RegionFlag: testRegion, } for _, mod := range mods { mod(flagValues) @@ -39,6 +41,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { GlobalFlagModel: &globalflags.GlobalFlagModel{ ProjectId: testProjectId, Verbosity: globalflags.VerbosityDefault, + Region: testRegion, }, Limit: utils.Ptr(int64(10)), } @@ -49,7 +52,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *redis.ApiListOfferingsRequest)) redis.ApiListOfferingsRequest { - request := testClient.ListOfferings(testCtx, testProjectId) + request := testClient.DefaultAPI.ListOfferings(testCtx, testProjectId, testRegion) for _, mod := range mods { mod(&request) } @@ -137,7 +140,7 @@ func TestBuildRequest(t *testing.T) { request := buildRequest(testCtx, tt.model, testClient) diff := cmp.Diff(request, tt.expectedRequest, - cmp.AllowUnexported(tt.expectedRequest), + cmp.AllowUnexported(tt.expectedRequest, redis.DefaultAPIService{}), cmpopts.EquateComparable(testCtx), ) if diff != "" { diff --git a/internal/pkg/services/redis/client/client.go b/internal/pkg/services/redis/client/client.go index 72c023398..c26718153 100644 --- a/internal/pkg/services/redis/client/client.go +++ b/internal/pkg/services/redis/client/client.go @@ -6,9 +6,9 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/print" "github.com/spf13/viper" - "github.com/stackitcloud/stackit-sdk-go/services/redis" + redis "github.com/stackitcloud/stackit-sdk-go/services/redis/v2api" ) func ConfigureClient(p *print.Printer, cliVersion string) (*redis.APIClient, error) { - return genericclient.ConfigureClientGeneric(p, cliVersion, viper.GetString(config.RedisCustomEndpointKey), true, genericclient.CreateApiClient[*redis.APIClient](redis.NewAPIClient)) + return genericclient.ConfigureClientGeneric(p, cliVersion, viper.GetString(config.RedisCustomEndpointKey), false, genericclient.CreateApiClient[*redis.APIClient](redis.NewAPIClient)) } diff --git a/internal/pkg/services/redis/utils/utils.go b/internal/pkg/services/redis/utils/utils.go index c20444a6c..6a21566c5 100644 --- a/internal/pkg/services/redis/utils/utils.go +++ b/internal/pkg/services/redis/utils/utils.go @@ -7,7 +7,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/errors" - "github.com/stackitcloud/stackit-sdk-go/services/redis" + redis "github.com/stackitcloud/stackit-sdk-go/services/redis/v2api" ) const ( @@ -15,9 +15,9 @@ const ( ) func ValidatePlanId(planId string, offerings *redis.ListOfferingsResponse) error { - for _, offer := range *offerings.Offerings { - for _, plan := range *offer.Plans { - if plan.Id != nil && strings.EqualFold(*plan.Id, planId) { + for _, offer := range offerings.GetOfferings() { + for _, plan := range offer.Plans { + if strings.EqualFold(plan.Id, planId) { return nil } } @@ -33,21 +33,18 @@ func LoadPlanId(planName, version string, offerings *redis.ListOfferingsResponse availableVersions := "" availablePlanNames := "" isValidVersion := false - for _, offer := range *offerings.Offerings { - if !strings.EqualFold(*offer.Version, version) { - availableVersions = fmt.Sprintf("%s\n- %s", availableVersions, *offer.Version) + for _, offer := range offerings.GetOfferings() { + if !strings.EqualFold(offer.Version, version) { + availableVersions = fmt.Sprintf("%s\n- %s", availableVersions, offer.Version) continue } isValidVersion = true - for _, plan := range *offer.Plans { - if plan.Name == nil { - continue + for _, plan := range offer.Plans { + if strings.EqualFold(plan.Name, planName) { + return &plan.Id, nil } - if strings.EqualFold(*plan.Name, planName) && plan.Id != nil { - return plan.Id, nil - } - availablePlanNames = fmt.Sprintf("%s\n- %s", availablePlanNames, *plan.Name) + availablePlanNames = fmt.Sprintf("%s\n- %s", availablePlanNames, plan.Name) } } @@ -65,23 +62,18 @@ func LoadPlanId(planName, version string, offerings *redis.ListOfferingsResponse } } -type RedisClient interface { - GetInstanceExecute(ctx context.Context, projectId, instanceId string) (*redis.Instance, error) - GetCredentialsExecute(ctx context.Context, projectId, instanceId, credentialsId string) (*redis.CredentialsResponse, error) -} - -func GetInstanceName(ctx context.Context, apiClient RedisClient, projectId, instanceId string) (string, error) { - resp, err := apiClient.GetInstanceExecute(ctx, projectId, instanceId) +func GetInstanceName(ctx context.Context, apiClient redis.DefaultAPI, projectId, instanceId, region string) (string, error) { + resp, err := apiClient.GetInstance(ctx, projectId, region, instanceId).Execute() if err != nil { return "", fmt.Errorf("get Redis instance: %w", err) } - return *resp.Name, nil + return resp.Name, nil } -func GetCredentialsUsername(ctx context.Context, apiClient RedisClient, projectId, instanceId, credentialsId string) (string, error) { - resp, err := apiClient.GetCredentialsExecute(ctx, projectId, instanceId, credentialsId) +func GetCredentialsUsername(ctx context.Context, apiClient redis.DefaultAPI, projectId, instanceId, credentialsId, region string) (string, error) { + resp, err := apiClient.GetCredentials(ctx, projectId, region, instanceId, credentialsId).Execute() if err != nil { return "", fmt.Errorf("get Redis credentials: %w", err) } - return *resp.Raw.Credentials.Username, nil + return resp.Raw.Credentials.Username, nil } diff --git a/internal/pkg/services/redis/utils/utils_test.go b/internal/pkg/services/redis/utils/utils_test.go index 83b00eb1a..6b8d3ea7f 100644 --- a/internal/pkg/services/redis/utils/utils_test.go +++ b/internal/pkg/services/redis/utils/utils_test.go @@ -5,10 +5,10 @@ import ( "fmt" "testing" - "github.com/stackitcloud/stackit-cli/internal/pkg/utils" - "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/redis" + redis "github.com/stackitcloud/stackit-sdk-go/services/redis/v2api" + + "github.com/stackitcloud/stackit-cli/internal/pkg/utils" ) var ( @@ -20,27 +20,33 @@ var ( const ( testInstanceName = "instance" testCredentialsUsername = "username" + testRegion = "eu01" ) -type redisClientMocked struct { +type mockSettings struct { getInstanceFails bool getInstanceResp *redis.Instance getCredentialsFails bool getCredentialsResp *redis.CredentialsResponse } -func (m *redisClientMocked) GetInstanceExecute(_ context.Context, _, _ string) (*redis.Instance, error) { - if m.getInstanceFails { - return nil, fmt.Errorf("could not get instance") - } - return m.getInstanceResp, nil -} +func newAPIMock(settings *mockSettings) redis.DefaultAPI { + return &redis.DefaultAPIServiceMock{ + GetInstanceExecuteMock: utils.Ptr(func(_ redis.ApiGetInstanceRequest) (*redis.Instance, error) { + if settings.getInstanceFails { + return nil, fmt.Errorf("could not get instance") + } + + return settings.getInstanceResp, nil + }), + GetCredentialsExecuteMock: utils.Ptr(func(_ redis.ApiGetCredentialsRequest) (*redis.CredentialsResponse, error) { + if settings.getCredentialsFails { + return nil, fmt.Errorf("could not get user") + } -func (m *redisClientMocked) GetCredentialsExecute(_ context.Context, _, _, _ string) (*redis.CredentialsResponse, error) { - if m.getCredentialsFails { - return nil, fmt.Errorf("could not get user") + return settings.getCredentialsResp, nil + }), } - return m.getCredentialsResp, nil } func TestGetInstanceName(t *testing.T) { @@ -54,7 +60,7 @@ func TestGetInstanceName(t *testing.T) { { description: "base", getInstanceResp: &redis.Instance{ - Name: utils.Ptr(testInstanceName), + Name: testInstanceName, }, isValid: true, expectedOutput: testInstanceName, @@ -68,12 +74,12 @@ func TestGetInstanceName(t *testing.T) { for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { - client := &redisClientMocked{ + client := newAPIMock(&mockSettings{ getInstanceFails: tt.getInstanceFails, getInstanceResp: tt.getInstanceResp, - } + }) - output, err := GetInstanceName(context.Background(), client, testProjectId, testInstanceId) + output, err := GetInstanceName(context.Background(), client, testProjectId, testInstanceId, testRegion) if tt.isValid && err != nil { t.Errorf("failed on valid input") @@ -103,8 +109,8 @@ func TestGetCredentialsUsername(t *testing.T) { description: "base", getCredentialsResp: &redis.CredentialsResponse{ Raw: &redis.RawCredentials{ - Credentials: &redis.Credentials{ - Username: utils.Ptr(testCredentialsUsername), + Credentials: redis.Credentials{ + Username: testCredentialsUsername, }, }, }, @@ -120,12 +126,12 @@ func TestGetCredentialsUsername(t *testing.T) { for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { - client := &redisClientMocked{ + client := newAPIMock(&mockSettings{ getCredentialsFails: tt.getCredentialsFails, getCredentialsResp: tt.getCredentialsResp, - } + }) - output, err := GetCredentialsUsername(context.Background(), client, testProjectId, testInstanceId, testCredentialsId) + output, err := GetCredentialsUsername(context.Background(), client, testProjectId, testInstanceId, testCredentialsId, testRegion) if tt.isValid && err != nil { t.Errorf("failed on valid input") From ebff0145f4dc873cb32c8c4ac128921417df801d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 8 Jul 2026 11:16:55 +0200 Subject: [PATCH 23/44] chore(deps): bump golang.org/x/oauth2 from 0.35.0 to 0.36.0 (#1463) --- go.mod | 4 ++-- go.sum | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index d504d6412..6bca65776 100644 --- a/go.mod +++ b/go.mod @@ -40,7 +40,7 @@ require ( github.com/stackitcloud/stackit-sdk-go/services/vpn v0.14.0 github.com/zalando/go-keyring v0.2.6 golang.org/x/mod v0.34.0 - golang.org/x/oauth2 v0.35.0 + golang.org/x/oauth2 v0.36.0 golang.org/x/term v0.42.0 golang.org/x/text v0.36.0 k8s.io/apimachinery v0.35.4 @@ -272,7 +272,7 @@ require ( github.com/stackitcloud/stackit-sdk-go/services/objectstorage v1.7.0 github.com/stackitcloud/stackit-sdk-go/services/observability v0.17.0 github.com/stackitcloud/stackit-sdk-go/services/rabbitmq v1.1.0 - github.com/stackitcloud/stackit-sdk-go/services/redis v1.1.0 + github.com/stackitcloud/stackit-sdk-go/services/redis v1.1.0 github.com/stackitcloud/stackit-sdk-go/services/sfs v0.9.0 github.com/subosito/gotenv v1.6.0 // indirect golang.org/x/sys v0.43.0 // indirect diff --git a/go.sum b/go.sum index 837bae5bf..ebe41d808 100644 --- a/go.sum +++ b/go.sum @@ -841,8 +841,8 @@ golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4Iltr golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.35.0 h1:Mv2mzuHuZuY2+bkyWXIHMfhNdJAdwW3FuWeCPYN5GVQ= -golang.org/x/oauth2 v0.35.0/go.mod h1:lzm5WQJQwKZ3nwavOZ3IS5Aulzxi68dUSgRHujetwEA= +golang.org/x/oauth2 v0.36.0 h1:peZ/1z27fi9hUOFCAZaHyrpWG5lwe0RJEEEeH0ThlIs= +golang.org/x/oauth2 v0.36.0/go.mod h1:YDBUJMTkDnJS+A4BP4eZBjCqtokkg1hODuPjwiGPO7Q= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= From 1b85a24a19e1147815f33e9abfff73d54f0f9dce Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 8 Jul 2026 09:25:32 +0000 Subject: [PATCH 24/44] chore(deps): bump golang.org/x/term from 0.42.0 to 0.44.0 (#1462) --- go.mod | 4 ++-- go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 6bca65776..9b487b850 100644 --- a/go.mod +++ b/go.mod @@ -41,7 +41,7 @@ require ( github.com/zalando/go-keyring v0.2.6 golang.org/x/mod v0.34.0 golang.org/x/oauth2 v0.36.0 - golang.org/x/term v0.42.0 + golang.org/x/term v0.44.0 golang.org/x/text v0.36.0 k8s.io/apimachinery v0.35.4 k8s.io/client-go v0.35.1 @@ -275,7 +275,7 @@ require ( github.com/stackitcloud/stackit-sdk-go/services/redis v1.1.0 github.com/stackitcloud/stackit-sdk-go/services/sfs v0.9.0 github.com/subosito/gotenv v1.6.0 // indirect - golang.org/x/sys v0.43.0 // indirect + golang.org/x/sys v0.46.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect k8s.io/api v0.35.1 // indirect k8s.io/klog/v2 v2.130.1 // indirect diff --git a/go.sum b/go.sum index ebe41d808..80c6f1fe0 100644 --- a/go.sum +++ b/go.sum @@ -909,8 +909,8 @@ golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.43.0 h1:Rlag2XtaFTxp19wS8MXlJwTvoh8ArU6ezoyFsMyCTNI= -golang.org/x/sys v0.43.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw= +golang.org/x/sys v0.46.0 h1:noSf2Fq6F8DBgS+LysIkx7rIExoNHJsxOAtPp4rthXw= +golang.org/x/sys v0.46.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw= golang.org/x/telemetry v0.0.0-20260311193753-579e4da9a98c h1:6a8FdnNk6bTXBjR4AGKFgUKuo+7GnR3FX5L7CbveeZc= golang.org/x/telemetry v0.0.0-20260311193753-579e4da9a98c/go.mod h1:TpUTTEp9frx7rTdLpC9gFG9kdI7zVLFTFFlqaH2Cncw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= @@ -919,8 +919,8 @@ golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU= golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U= -golang.org/x/term v0.42.0 h1:UiKe+zDFmJobeJ5ggPwOshJIVt6/Ft0rcfrXZDLWAWY= -golang.org/x/term v0.42.0/go.mod h1:Dq/D+snpsbazcBG5+F9Q1n2rXV8Ma+71xEjTRufARgY= +golang.org/x/term v0.44.0 h1:0rLvDRCtNj0gZkyIXhCyOb2OAzEhLVqc4B+hrsBhrmc= +golang.org/x/term v0.44.0/go.mod h1:7ze4MdzUzLXpSAoFP1H0bOI9aXDqveSvatT5vKcFh2Y= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= From e52e822de26e7529b94aecfbcf09abccd8415279 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 8 Jul 2026 19:07:12 +0200 Subject: [PATCH 25/44] chore(deps): bump github.com/jedib0t/go-pretty/v6 from 6.7.10 to 6.8.2 (#1466) Bumps [github.com/jedib0t/go-pretty/v6](https://github.com/jedib0t/go-pretty) from 6.7.10 to 6.8.2. - [Release notes](https://github.com/jedib0t/go-pretty/releases) - [Commits](https://github.com/jedib0t/go-pretty/compare/v6.7.10...v6.8.2) --- updated-dependencies: - dependency-name: github.com/jedib0t/go-pretty/v6 dependency-version: 6.8.2 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 9b487b850..98bbfd80f 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/google/go-cmp v0.7.0 github.com/google/uuid v1.6.0 github.com/inhies/go-bytesize v0.0.0-20220417184213-4913239db9cf - github.com/jedib0t/go-pretty/v6 v6.7.10 + github.com/jedib0t/go-pretty/v6 v6.8.2 github.com/lmittmann/tint v1.1.3 github.com/mattn/go-colorable v0.1.14 github.com/spf13/cobra v1.10.2 diff --git a/go.sum b/go.sum index 80c6f1fe0..3129a3e23 100644 --- a/go.sum +++ b/go.sum @@ -371,8 +371,8 @@ github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2 github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/inhies/go-bytesize v0.0.0-20220417184213-4913239db9cf h1:FtEj8sfIcaaBfAKrE1Cwb61YDtYq9JxChK1c7AKce7s= github.com/inhies/go-bytesize v0.0.0-20220417184213-4913239db9cf/go.mod h1:yrqSXGoD/4EKfF26AOGzscPOgTTJcyAwM2rpixWT+t4= -github.com/jedib0t/go-pretty/v6 v6.7.10 h1:B/2qW2Bkv2L6n14PP8o1kx75kWzHOQ3YTluWzg9icac= -github.com/jedib0t/go-pretty/v6 v6.7.10/go.mod h1:YwC5CE4fJ1HFUDeivSV1r//AmANFHyqczZk+U6BDALU= +github.com/jedib0t/go-pretty/v6 v6.8.2 h1:FmKNr1GOyot/zqNQplE8HLhFguJaeHJTCArntnI4uxE= +github.com/jedib0t/go-pretty/v6 v6.8.2/go.mod h1:YwC5CE4fJ1HFUDeivSV1r//AmANFHyqczZk+U6BDALU= github.com/jgautheron/goconst v1.8.2 h1:y0XF7X8CikZ93fSNT6WBTb/NElBu9IjaY7CCYQrCMX4= github.com/jgautheron/goconst v1.8.2/go.mod h1:A0oxgBCHy55NQn6sYpO7UdnA9p+h7cPtoOZUmvNIako= github.com/jingyugao/rowserrcheck v1.1.1 h1:zibz55j/MJtLsjP1OF4bSdgXxwL1b+Vn7Tjzq7gFzUs= From 2aae290858efe4f2dbb520a008c645cfd1b1fa33 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 9 Jul 2026 16:30:28 +0200 Subject: [PATCH 26/44] chore(deps): bump github.com/stackitcloud/stackit-sdk-go/services/objectstorage (#1465) --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 98bbfd80f..d57d0daf9 100644 --- a/go.mod +++ b/go.mod @@ -269,7 +269,7 @@ require ( github.com/stackitcloud/stackit-sdk-go/services/loadbalancer v1.14.0 github.com/stackitcloud/stackit-sdk-go/services/logme v0.30.0 github.com/stackitcloud/stackit-sdk-go/services/mariadb v0.30.0 - github.com/stackitcloud/stackit-sdk-go/services/objectstorage v1.7.0 + github.com/stackitcloud/stackit-sdk-go/services/objectstorage v1.9.0 github.com/stackitcloud/stackit-sdk-go/services/observability v0.17.0 github.com/stackitcloud/stackit-sdk-go/services/rabbitmq v1.1.0 github.com/stackitcloud/stackit-sdk-go/services/redis v1.1.0 diff --git a/go.sum b/go.sum index 3129a3e23..8b296ffbb 100644 --- a/go.sum +++ b/go.sum @@ -624,8 +624,8 @@ github.com/stackitcloud/stackit-sdk-go/services/mariadb v0.30.0 h1:LFIH1wAp633ZA github.com/stackitcloud/stackit-sdk-go/services/mariadb v0.30.0/go.mod h1:joa89Y1dyn0j22FstRcIKfW2ada3FDxNfttxSvq27uY= github.com/stackitcloud/stackit-sdk-go/services/mongodbflex v1.5.8 h1:S7t4wcT6SN8ZzdoY8d6VbF903zFpGjzqrU0FN27rJPg= github.com/stackitcloud/stackit-sdk-go/services/mongodbflex v1.5.8/go.mod h1:CdrhFUsBO7/iJleCc2yQjDChIbG6YaxKNBQRNCjgcF4= -github.com/stackitcloud/stackit-sdk-go/services/objectstorage v1.7.0 h1:UxnbsKm6PQV8Gudw/EhySaEh9q1xSaTG8mzJz1EvhnE= -github.com/stackitcloud/stackit-sdk-go/services/objectstorage v1.7.0/go.mod h1:RFL4h6JZvpsyFYbdJ3+eINEkletzJQTfrPdd+yPT/fU= +github.com/stackitcloud/stackit-sdk-go/services/objectstorage v1.9.0 h1:T+ll3lS0Kn18d8hTOrVAMKcQrXiab+Cuj0cTnAYHmj0= +github.com/stackitcloud/stackit-sdk-go/services/objectstorage v1.9.0/go.mod h1:QsPtoqAYvumyPU6ToX/5j1PbudN+VSTuvh6mp154ecM= github.com/stackitcloud/stackit-sdk-go/services/observability v0.17.0 h1:LGwCvvST0fwUgZ6bOxYIfu45qqTgv421ZS07UhKjZL8= github.com/stackitcloud/stackit-sdk-go/services/observability v0.17.0/go.mod h1:9KdrXC5JS30Ay3mR0adb3vNdhca+qxiy/cPF5P4wehQ= github.com/stackitcloud/stackit-sdk-go/services/opensearch v0.24.6 h1:oTVx1+O177Ojn8OvXIOUbRSwtx7L59jhxDPrZEQFOfQ= From a0cc909ca0467972221172330abe071544d7337e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 9 Jul 2026 14:38:59 +0000 Subject: [PATCH 27/44] chore(deps): bump github.com/zalando/go-keyring from 0.2.6 to 0.2.8 (#1461) --- go.mod | 7 +++---- go.sum | 16 ++++++---------- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/go.mod b/go.mod index d57d0daf9..473543fc0 100644 --- a/go.mod +++ b/go.mod @@ -38,7 +38,7 @@ require ( github.com/stackitcloud/stackit-sdk-go/services/ske v1.11.0 github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex v1.11.0 github.com/stackitcloud/stackit-sdk-go/services/vpn v0.14.0 - github.com/zalando/go-keyring v0.2.6 + github.com/zalando/go-keyring v0.2.8 golang.org/x/mod v0.34.0 golang.org/x/oauth2 v0.36.0 golang.org/x/term v0.44.0 @@ -56,7 +56,6 @@ require ( require ( 4d63.com/gocheckcompilerdirectives v1.3.0 // indirect 4d63.com/gochecknoglobals v0.2.2 // indirect - al.essio.dev/pkg/shellescape v1.5.1 // indirect codeberg.org/chavacava/garif v0.2.0 // indirect codeberg.org/polyfloyd/go-errorlint v1.9.0 // indirect dev.gaijin.team/go/exhaustruct/v4 v4.0.0 // indirect @@ -248,11 +247,11 @@ require ( require ( github.com/cpuguy83/go-md2man/v2 v2.0.6 // indirect - github.com/danieljoos/wincred v1.2.2 // indirect + github.com/danieljoos/wincred v1.2.3 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/fsnotify/fsnotify v1.9.0 // indirect github.com/go-logr/logr v1.4.3 // indirect - github.com/godbus/dbus/v5 v5.1.0 // indirect + github.com/godbus/dbus/v5 v5.2.2 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/mattn/go-runewidth v0.0.16 // indirect diff --git a/go.sum b/go.sum index 8b296ffbb..cfb0e5e67 100644 --- a/go.sum +++ b/go.sum @@ -2,8 +2,6 @@ 4d63.com/gocheckcompilerdirectives v1.3.0/go.mod h1:ofsJ4zx2QAuIP/NO/NAh1ig6R1Fb18/GI7RVMwz7kAY= 4d63.com/gochecknoglobals v0.2.2 h1:H1vdnwnMaZdQW/N+NrkT1SZMTBmcwHe9Vq8lJcYYTtU= 4d63.com/gochecknoglobals v0.2.2/go.mod h1:lLxwTQjL5eIesRbvnzIP3jZtG140FnTdz+AlMa+ogt0= -al.essio.dev/pkg/shellescape v1.5.1 h1:86HrALUujYS/h+GtqoB26SBEdkWfmMI6FubjXlsXyho= -al.essio.dev/pkg/shellescape v1.5.1/go.mod h1:6sIqp7X2P6mThCQ7twERpZTuigpr6KbZWtls1U8I890= cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= @@ -154,8 +152,8 @@ github.com/curioswitch/go-reassign v0.3.0 h1:dh3kpQHuADL3cobV/sSGETA8DOv457dwl+f github.com/curioswitch/go-reassign v0.3.0/go.mod h1:nApPCCTtqLJN/s8HfItCcKV0jIPwluBOvZP+dsJGA88= github.com/daixiang0/gci v0.13.7 h1:+0bG5eK9vlI08J+J/NWGbWPTNiXPG4WhNLJOkSxWITQ= github.com/daixiang0/gci v0.13.7/go.mod h1:812WVN6JLFY9S6Tv76twqmNqevN0pa3SX3nih0brVzQ= -github.com/danieljoos/wincred v1.2.2 h1:774zMFJrqaeYCK2W57BgAem/MLi6mtSE47MB6BOJ0i0= -github.com/danieljoos/wincred v1.2.2/go.mod h1:w7w4Utbrz8lqeMbDAK0lkNJUv5sAOkFi7nd/ogr0Uh8= +github.com/danieljoos/wincred v1.2.3 h1:v7dZC2x32Ut3nEfRH+vhoZGvN72+dQ/snVXo/vMFLdQ= +github.com/danieljoos/wincred v1.2.3/go.mod h1:6qqX0WNrS4RzPZ1tnroDzq9kY3fu1KwE7MRLQK4X0bs= github.com/dave/dst v0.27.3 h1:P1HPoMza3cMEquVf9kKy8yXsFirry4zEnWOdYPOoIzY= github.com/dave/dst v0.27.3/go.mod h1:jHh6EOibnHgcUW3WjKHisiooEkYwqpHLBSX1iOBhEyc= github.com/dave/jennifer v1.7.1 h1:B4jJJDHelWcDhlRQxWeo0Npa/pYKBLrirAQoTN45txo= @@ -243,8 +241,8 @@ github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y= github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8= github.com/goccy/go-yaml v1.19.2 h1:PmFC1S6h8ljIz6gMRBopkjP1TVT7xuwrButHID66PoM= github.com/goccy/go-yaml v1.19.2/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7LkFRi1kA= -github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk= -github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= +github.com/godbus/dbus/v5 v5.2.2 h1:TUR3TgtSVDmjiXOgAAyaZbYmIeP3DPkld3jgKGV8mXQ= +github.com/godbus/dbus/v5 v5.2.2/go.mod h1:3AAv2+hPq5rdnr5txxxRwiGjPXamgoIHgz9FPBfOp3c= github.com/godoc-lint/godoc-lint v0.11.2 h1:Bp0FkJWoSdNsBikdNgIcgtaoo+xz6I/Y9s5WSBQUeeM= github.com/godoc-lint/godoc-lint v0.11.2/go.mod h1:iVpGdL1JCikNH2gGeAn3Hh+AgN5Gx/I/cxV+91L41jo= github.com/gofrs/flock v0.13.0 h1:95JolYOvGMqeH31+FC7D2+uULf6mG61mEZ/A8dRYMzw= @@ -333,8 +331,6 @@ github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hf github.com/google/pprof v0.0.0-20260115054156-294ebfa9ad83 h1:z2ogiKUYzX5Is6zr/vP9vJGqPwcdqsWjOt+V8J7+bTc= github.com/google/pprof v0.0.0-20260115054156-294ebfa9ad83/go.mod h1:MxpfABSjhmINe3F1It9d+8exIHFvUqtLIRCdOGNXqiI= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= -github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4= -github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= @@ -712,8 +708,8 @@ github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9dec github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -github.com/zalando/go-keyring v0.2.6 h1:r7Yc3+H+Ux0+M72zacZoItR3UDxeWfKTcabvkI8ua9s= -github.com/zalando/go-keyring v0.2.6/go.mod h1:2TCrxYrbUNYfNS/Kgy/LSrkSQzZ5UPVH85RwfczwvcI= +github.com/zalando/go-keyring v0.2.8 h1:6sD/Ucpl7jNq10rM2pgqTs0sZ9V3qMrqfIIy5YPccHs= +github.com/zalando/go-keyring v0.2.8/go.mod h1:tsMo+VpRq5NGyKfxoBVjCuMrG47yj8cmakZDO5QGii0= gitlab.com/bosi/decorder v0.4.2 h1:qbQaV3zgwnBZ4zPMhGLW4KZe7A7NwxEhJx39R3shffo= gitlab.com/bosi/decorder v0.4.2/go.mod h1:muuhHoaJkA9QLcYHq4Mj8FJUwDZ+EirSHRiaTcTf6T8= go-simpler.org/assert v0.9.0 h1:PfpmcSvL7yAnWyChSjOz6Sp6m9j5lyK8Ok9pEL31YkQ= From 84945159fc936eeccae275eef6a3ae66c626472c Mon Sep 17 00:00:00 2001 From: cgoetz-inovex Date: Fri, 10 Jul 2026 10:05:57 +0200 Subject: [PATCH 28/44] feat(observability): migrate to multi version SDK (#1453) STACKITCLI-371 --- go.mod | 2 +- go.sum | 2 + .../credentials/create/create.go | 23 +- .../credentials/create/create_test.go | 12 +- .../credentials/delete/delete.go | 8 +- .../credentials/delete/delete_test.go | 10 +- .../observability/credentials/list/list.go | 11 +- .../credentials/list/list_test.go | 10 +- .../grafana/describe/describe.go | 14 +- .../grafana/describe/describe_test.go | 20 +- .../public-read-access/disable/disable.go | 8 +- .../disable/disable_test.go | 49 ++-- .../public-read-access/enable/enable.go | 8 +- .../public-read-access/enable/enable_test.go | 49 ++-- .../grafana/single-sign-on/disable/disable.go | 8 +- .../single-sign-on/disable/disable_test.go | 49 ++-- .../grafana/single-sign-on/enable/enable.go | 8 +- .../single-sign-on/enable/enable_test.go | 49 ++-- .../observability/instance/create/create.go | 26 +- .../instance/create/create_test.go | 41 +-- .../observability/instance/delete/delete.go | 12 +- .../instance/delete/delete_test.go | 10 +- .../instance/describe/describe.go | 41 ++- .../instance/describe/describe_test.go | 10 +- .../cmd/observability/instance/list/list.go | 12 +- .../observability/instance/list/list_test.go | 10 +- .../observability/instance/update/update.go | 27 +- .../instance/update/update_test.go | 46 ++-- internal/cmd/observability/plans/plans.go | 8 +- .../cmd/observability/plans/plans_test.go | 10 +- .../scrape-config/create/create.go | 17 +- .../scrape-config/create/create_test.go | 47 ++-- .../scrape-config/delete/delete.go | 12 +- .../scrape-config/delete/delete_test.go | 10 +- .../scrape-config/describe/describe.go | 26 +- .../scrape-config/describe/describe_test.go | 21 +- .../generate-payload/generate_payload.go | 10 +- .../generate-payload/generate_payload_test.go | 10 +- .../observability/scrape-config/list/list.go | 17 +- .../scrape-config/list/list_test.go | 10 +- .../scrape-config/update/update.go | 6 +- .../scrape-config/update/update_test.go | 40 +-- .../services/observability/client/client.go | 2 +- .../pkg/services/observability/utils/utils.go | 114 ++++---- .../observability/utils/utils_test.go | 252 ++++++++++-------- internal/pkg/utils/utils.go | 11 + internal/pkg/utils/utils_test.go | 56 +++- 47 files changed, 671 insertions(+), 583 deletions(-) diff --git a/go.mod b/go.mod index 473543fc0..af9f8855a 100644 --- a/go.mod +++ b/go.mod @@ -269,7 +269,7 @@ require ( github.com/stackitcloud/stackit-sdk-go/services/logme v0.30.0 github.com/stackitcloud/stackit-sdk-go/services/mariadb v0.30.0 github.com/stackitcloud/stackit-sdk-go/services/objectstorage v1.9.0 - github.com/stackitcloud/stackit-sdk-go/services/observability v0.17.0 + github.com/stackitcloud/stackit-sdk-go/services/observability v0.24.0 github.com/stackitcloud/stackit-sdk-go/services/rabbitmq v1.1.0 github.com/stackitcloud/stackit-sdk-go/services/redis v1.1.0 github.com/stackitcloud/stackit-sdk-go/services/sfs v0.9.0 diff --git a/go.sum b/go.sum index cfb0e5e67..5a15155a2 100644 --- a/go.sum +++ b/go.sum @@ -624,6 +624,8 @@ github.com/stackitcloud/stackit-sdk-go/services/objectstorage v1.9.0 h1:T+ll3lS0 github.com/stackitcloud/stackit-sdk-go/services/objectstorage v1.9.0/go.mod h1:QsPtoqAYvumyPU6ToX/5j1PbudN+VSTuvh6mp154ecM= github.com/stackitcloud/stackit-sdk-go/services/observability v0.17.0 h1:LGwCvvST0fwUgZ6bOxYIfu45qqTgv421ZS07UhKjZL8= github.com/stackitcloud/stackit-sdk-go/services/observability v0.17.0/go.mod h1:9KdrXC5JS30Ay3mR0adb3vNdhca+qxiy/cPF5P4wehQ= +github.com/stackitcloud/stackit-sdk-go/services/observability v0.24.0 h1:KhuWPXr1hl8BFLGLSi6wjxh5o6OQXH9amfquMhYQROU= +github.com/stackitcloud/stackit-sdk-go/services/observability v0.24.0/go.mod h1:0fEZQHm729mBdvg4sNrAhM6KmHROHJSeS2FwCMRk46k= github.com/stackitcloud/stackit-sdk-go/services/opensearch v0.24.6 h1:oTVx1+O177Ojn8OvXIOUbRSwtx7L59jhxDPrZEQFOfQ= github.com/stackitcloud/stackit-sdk-go/services/opensearch v0.24.6/go.mod h1:6ZBeCCY6qG8w1oK7osf61Egyv3mp7Ahv6GDGxiarDGo= github.com/stackitcloud/stackit-sdk-go/services/postgresflex v1.3.5 h1:H67e3KnHQx954yI8fuQmxXwRf/myqAdLg2KvxImp00g= diff --git a/internal/cmd/observability/credentials/create/create.go b/internal/cmd/observability/credentials/create/create.go index 6c2f8289f..d3cd35864 100644 --- a/internal/cmd/observability/credentials/create/create.go +++ b/internal/cmd/observability/credentials/create/create.go @@ -7,7 +7,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/types" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/observability" + observability "github.com/stackitcloud/stackit-sdk-go/services/observability/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/args" cliErr "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -17,7 +17,6 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/print" "github.com/stackitcloud/stackit-cli/internal/pkg/services/observability/client" observabilityUtils "github.com/stackitcloud/stackit-cli/internal/pkg/services/observability/utils" - "github.com/stackitcloud/stackit-cli/internal/pkg/utils" ) const ( @@ -56,7 +55,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return err } - instanceLabel, err := observabilityUtils.GetInstanceName(ctx, apiClient, model.InstanceId, model.ProjectId) + instanceLabel, err := observabilityUtils.GetInstanceName(ctx, apiClient.DefaultAPI, model.InstanceId, model.ProjectId) if err != nil { params.Printer.Debug(print.ErrorLevel, "get instance name: %v", err) instanceLabel = model.InstanceId @@ -69,7 +68,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } // Call API - req := buildRequest(ctx, model, apiClient) + req := buildRequest(ctx, model, apiClient.DefaultAPI) if err != nil { return err } @@ -104,7 +103,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, }, nil } -func buildRequest(ctx context.Context, model *inputModel, apiClient *observability.APIClient) observability.ApiCreateCredentialsRequest { +func buildRequest(ctx context.Context, model *inputModel, apiClient observability.DefaultAPI) observability.ApiCreateCredentialsRequest { req := apiClient.CreateCredentials(ctx, model.InstanceId, model.ProjectId) return req } @@ -117,15 +116,13 @@ func outputResult(p *print.Printer, outputFormat, instanceLabel string, resp *ob return p.OutputResult(outputFormat, resp, func() error { p.Outputf("Created credentials for instance %q.\n\n", instanceLabel) - if resp.Credentials != nil { - // The username field cannot be set by the user, so we only display it if it's not returned empty - username := *resp.Credentials.Username - if username != "" { - p.Outputf("Username: %s\n", username) - } - - p.Outputf("Password: %s\n", utils.PtrString(resp.Credentials.Password)) + // The username field cannot be set by the user, so we only display it if it's not returned empty + username := resp.Credentials.Username + if username != "" { + p.Outputf("Username: %s\n", username) } + + p.Outputf("Password: %s\n", resp.Credentials.Password) return nil }) } diff --git a/internal/cmd/observability/credentials/create/create_test.go b/internal/cmd/observability/credentials/create/create_test.go index d0d2bb324..7f132f9ef 100644 --- a/internal/cmd/observability/credentials/create/create_test.go +++ b/internal/cmd/observability/credentials/create/create_test.go @@ -4,7 +4,7 @@ import ( "context" "testing" - "github.com/stackitcloud/stackit-sdk-go/services/observability" + observability "github.com/stackitcloud/stackit-sdk-go/services/observability/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" @@ -20,7 +20,7 @@ var projectIdFlag = globalflags.ProjectIdFlag type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &observability.APIClient{} +var testClient = &observability.APIClient{DefaultAPI: &observability.DefaultAPIService{}} var testProjectId = uuid.NewString() var testInstanceId = uuid.NewString() @@ -50,7 +50,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *observability.ApiCreateCredentialsRequest)) observability.ApiCreateCredentialsRequest { - request := testClient.CreateCredentials(testCtx, testInstanceId, testProjectId) + request := testClient.DefaultAPI.CreateCredentials(testCtx, testInstanceId, testProjectId) for _, mod := range mods { mod(&request) } @@ -142,10 +142,10 @@ func TestBuildRequest(t *testing.T) { for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { - request := buildRequest(testCtx, tt.model, testClient) + request := buildRequest(testCtx, tt.model, testClient.DefaultAPI) diff := cmp.Diff(request, tt.expectedRequest, - cmp.AllowUnexported(tt.expectedRequest), + cmp.AllowUnexported(tt.expectedRequest, observability.DefaultAPIService{}), cmpopts.EquateComparable(testCtx), ) if diff != "" { @@ -182,7 +182,7 @@ func TestOutputResult(t *testing.T) { name: "set response with credentials", args: args{ resp: &observability.CreateCredentialsResponse{ - Credentials: observability.NewCredentials("dummy-pw", "dummy-user"), + Credentials: *observability.NewCredentials("dummy-pw", "dummy-user"), }, }, wantErr: false, diff --git a/internal/cmd/observability/credentials/delete/delete.go b/internal/cmd/observability/credentials/delete/delete.go index a28888dc9..c2e04ae3c 100644 --- a/internal/cmd/observability/credentials/delete/delete.go +++ b/internal/cmd/observability/credentials/delete/delete.go @@ -16,7 +16,7 @@ import ( observabilityUtils "github.com/stackitcloud/stackit-cli/internal/pkg/services/observability/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/observability" + observability "github.com/stackitcloud/stackit-sdk-go/services/observability/v1api" ) const ( @@ -55,7 +55,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return err } - instanceLabel, err := observabilityUtils.GetInstanceName(ctx, apiClient, model.InstanceId, model.ProjectId) + instanceLabel, err := observabilityUtils.GetInstanceName(ctx, apiClient.DefaultAPI, model.InstanceId, model.ProjectId) if err != nil { params.Printer.Debug(print.ErrorLevel, "get instance name: %v", err) instanceLabel = model.InstanceId @@ -68,7 +68,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } // Call API - req := buildRequest(ctx, model, apiClient) + req := buildRequest(ctx, model, apiClient.DefaultAPI) _, err = req.Execute() if err != nil { return fmt.Errorf("delete Observability credentials: %w", err) @@ -104,7 +104,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu }, nil } -func buildRequest(ctx context.Context, model *inputModel, apiClient *observability.APIClient) observability.ApiDeleteCredentialsRequest { +func buildRequest(ctx context.Context, model *inputModel, apiClient observability.DefaultAPI) observability.ApiDeleteCredentialsRequest { req := apiClient.DeleteCredentials(ctx, model.InstanceId, model.ProjectId, model.Username) return req } diff --git a/internal/cmd/observability/credentials/delete/delete_test.go b/internal/cmd/observability/credentials/delete/delete_test.go index 21965e75c..d1a52f216 100644 --- a/internal/cmd/observability/credentials/delete/delete_test.go +++ b/internal/cmd/observability/credentials/delete/delete_test.go @@ -9,7 +9,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/observability" + observability "github.com/stackitcloud/stackit-sdk-go/services/observability/v1api" ) var projectIdFlag = globalflags.ProjectIdFlag @@ -17,7 +17,7 @@ var projectIdFlag = globalflags.ProjectIdFlag type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &observability.APIClient{} +var testClient = &observability.APIClient{DefaultAPI: &observability.DefaultAPIService{}} var testProjectId = uuid.NewString() var testInstanceId = uuid.NewString() @@ -60,7 +60,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *observability.ApiDeleteCredentialsRequest)) observability.ApiDeleteCredentialsRequest { - request := testClient.DeleteCredentials(testCtx, testInstanceId, testProjectId, testUsername) + request := testClient.DefaultAPI.DeleteCredentials(testCtx, testInstanceId, testProjectId, testUsername) for _, mod := range mods { mod(&request) } @@ -224,10 +224,10 @@ func TestBuildRequest(t *testing.T) { for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { - request := buildRequest(testCtx, tt.model, testClient) + request := buildRequest(testCtx, tt.model, testClient.DefaultAPI) diff := cmp.Diff(request, tt.expectedRequest, - cmp.AllowUnexported(tt.expectedRequest), + cmp.AllowUnexported(tt.expectedRequest, observability.DefaultAPIService{}), cmpopts.EquateComparable(testCtx), ) if diff != "" { diff --git a/internal/cmd/observability/credentials/list/list.go b/internal/cmd/observability/credentials/list/list.go index 94ec66a4d..96d6129cd 100644 --- a/internal/cmd/observability/credentials/list/list.go +++ b/internal/cmd/observability/credentials/list/list.go @@ -15,10 +15,9 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/services/observability/client" observabilityUtils "github.com/stackitcloud/stackit-cli/internal/pkg/services/observability/utils" "github.com/stackitcloud/stackit-cli/internal/pkg/tables" - "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/observability" + observability "github.com/stackitcloud/stackit-sdk-go/services/observability/v1api" ) const ( @@ -63,7 +62,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } // Call API - req := buildRequest(ctx, model, apiClient) + req := buildRequest(ctx, model, apiClient.DefaultAPI) resp, err := req.Execute() if err != nil { return fmt.Errorf("list Observability credentials: %w", err) @@ -71,7 +70,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { credentials := resp.GetCredentials() - instanceLabel, err := observabilityUtils.GetInstanceName(ctx, apiClient, model.InstanceId, model.ProjectId) + instanceLabel, err := observabilityUtils.GetInstanceName(ctx, apiClient.DefaultAPI, model.InstanceId, model.ProjectId) if err != nil { params.Printer.Debug(print.ErrorLevel, "get instance name: %v", err) instanceLabel = model.InstanceId @@ -117,7 +116,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, }, nil } -func buildRequest(ctx context.Context, model *inputModel, apiClient *observability.APIClient) observability.ApiListCredentialsRequest { +func buildRequest(ctx context.Context, model *inputModel, apiClient observability.DefaultAPI) observability.ApiListCredentialsRequest { req := apiClient.ListCredentials(ctx, model.InstanceId, model.ProjectId) return req } @@ -132,7 +131,7 @@ func outputResult(p *print.Printer, outputFormat, instanceLabel string, credenti table.SetHeader("USERNAME") for i := range credentials { c := credentials[i] - table.AddRow(utils.PtrString(c.Name)) + table.AddRow(c.Name) } err := table.Display(p) if err != nil { diff --git a/internal/cmd/observability/credentials/list/list_test.go b/internal/cmd/observability/credentials/list/list_test.go index ee45d8980..01e93cc32 100644 --- a/internal/cmd/observability/credentials/list/list_test.go +++ b/internal/cmd/observability/credentials/list/list_test.go @@ -12,7 +12,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/observability" + observability "github.com/stackitcloud/stackit-sdk-go/services/observability/v1api" ) var projectIdFlag = globalflags.ProjectIdFlag @@ -20,7 +20,7 @@ var projectIdFlag = globalflags.ProjectIdFlag type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &observability.APIClient{} +var testClient = &observability.APIClient{DefaultAPI: &observability.DefaultAPIService{}} var testProjectId = uuid.NewString() var testInstanceId = uuid.NewString() @@ -52,7 +52,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *observability.ApiListCredentialsRequest)) observability.ApiListCredentialsRequest { - request := testClient.ListCredentials(testCtx, testInstanceId, testProjectId) + request := testClient.DefaultAPI.ListCredentials(testCtx, testInstanceId, testProjectId) for _, mod := range mods { mod(&request) } @@ -158,10 +158,10 @@ func TestBuildRequest(t *testing.T) { for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { - request := buildRequest(testCtx, tt.model, testClient) + request := buildRequest(testCtx, tt.model, testClient.DefaultAPI) diff := cmp.Diff(request, tt.expectedRequest, - cmp.AllowUnexported(tt.expectedRequest), + cmp.AllowUnexported(tt.expectedRequest, observability.DefaultAPIService{}), cmpopts.EquateComparable(testCtx), ) if diff != "" { diff --git a/internal/cmd/observability/grafana/describe/describe.go b/internal/cmd/observability/grafana/describe/describe.go index 88b7f70b6..e4e558b35 100644 --- a/internal/cmd/observability/grafana/describe/describe.go +++ b/internal/cmd/observability/grafana/describe/describe.go @@ -17,7 +17,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/observability" + observability "github.com/stackitcloud/stackit-sdk-go/services/observability/v1api" ) const ( @@ -63,12 +63,12 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } // Call API - grafanaConfigsReq := buildGetGrafanaConfigRequest(ctx, model, apiClient) + grafanaConfigsReq := buildGetGrafanaConfigRequest(ctx, model, apiClient.DefaultAPI) grafanaConfigsResp, err := grafanaConfigsReq.Execute() if err != nil { return fmt.Errorf("get Grafana configs: %w", err) } - instanceReq := buildGetInstanceRequest(ctx, model, apiClient) + instanceReq := buildGetInstanceRequest(ctx, model, apiClient.DefaultAPI) instanceResp, err := instanceReq.Execute() if err != nil { return fmt.Errorf("get instance: %w", err) @@ -104,18 +104,18 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu return &model, nil } -func buildGetGrafanaConfigRequest(ctx context.Context, model *inputModel, apiClient *observability.APIClient) observability.ApiGetGrafanaConfigsRequest { +func buildGetGrafanaConfigRequest(ctx context.Context, model *inputModel, apiClient observability.DefaultAPI) observability.ApiGetGrafanaConfigsRequest { req := apiClient.GetGrafanaConfigs(ctx, model.InstanceId, model.ProjectId) return req } -func buildGetInstanceRequest(ctx context.Context, model *inputModel, apiClient *observability.APIClient) observability.ApiGetInstanceRequest { +func buildGetInstanceRequest(ctx context.Context, model *inputModel, apiClient observability.DefaultAPI) observability.ApiGetInstanceRequest { req := apiClient.GetInstance(ctx, model.InstanceId, model.ProjectId) return req } func outputResult(p *print.Printer, outputFormat string, showPassword bool, grafanaConfigs *observability.GrafanaConfigs, instance *observability.GetInstanceResponse) error { - if instance == nil || instance.Instance == nil { + if instance == nil { return fmt.Errorf("instance or instance content is nil") } else if grafanaConfigs == nil { return fmt.Errorf("grafanaConfigs is nil") @@ -130,7 +130,7 @@ func outputResult(p *print.Printer, outputFormat string, showPassword bool, graf } table := tables.NewTable() - table.AddRow("GRAFANA DASHBOARD", utils.PtrString(instance.Instance.GrafanaUrl)) + table.AddRow("GRAFANA DASHBOARD", instance.Instance.GrafanaUrl) table.AddSeparator() table.AddRow("PUBLIC READ ACCESS", utils.PtrString(grafanaConfigs.PublicReadAccess)) table.AddSeparator() diff --git a/internal/cmd/observability/grafana/describe/describe_test.go b/internal/cmd/observability/grafana/describe/describe_test.go index c35d5267c..f9bfad81e 100644 --- a/internal/cmd/observability/grafana/describe/describe_test.go +++ b/internal/cmd/observability/grafana/describe/describe_test.go @@ -7,7 +7,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/observability" + observability "github.com/stackitcloud/stackit-sdk-go/services/observability/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" @@ -19,7 +19,7 @@ var projectIdFlag = globalflags.ProjectIdFlag type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &observability.APIClient{} +var testClient = &observability.APIClient{DefaultAPI: &observability.DefaultAPIService{}} var testProjectId = uuid.NewString() var testInstanceId = uuid.NewString() @@ -58,7 +58,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureGetGrafanaConfigsRequest(mods ...func(request *observability.ApiGetGrafanaConfigsRequest)) observability.ApiGetGrafanaConfigsRequest { - request := testClient.GetGrafanaConfigs(testCtx, testInstanceId, testProjectId) + request := testClient.DefaultAPI.GetGrafanaConfigs(testCtx, testInstanceId, testProjectId) for _, mod := range mods { mod(&request) } @@ -66,7 +66,7 @@ func fixtureGetGrafanaConfigsRequest(mods ...func(request *observability.ApiGetG } func fixtureGetInstanceRequest(mods ...func(request *observability.ApiGetInstanceRequest)) observability.ApiGetInstanceRequest { - request := testClient.GetInstance(testCtx, testInstanceId, testProjectId) + request := testClient.DefaultAPI.GetInstance(testCtx, testInstanceId, testProjectId) for _, mod := range mods { mod(&request) } @@ -237,10 +237,10 @@ func TestBuildGetGrafanaConfigsRequest(t *testing.T) { for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { - request := buildGetGrafanaConfigRequest(testCtx, tt.model, testClient) + request := buildGetGrafanaConfigRequest(testCtx, tt.model, testClient.DefaultAPI) diff := cmp.Diff(request, tt.expectedRequest, - cmp.AllowUnexported(tt.expectedRequest), + cmp.AllowUnexported(tt.expectedRequest, observability.DefaultAPIService{}), cmpopts.EquateComparable(testCtx), ) if diff != "" { @@ -265,10 +265,10 @@ func TestBuildGetInstanceRequest(t *testing.T) { for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { - request := buildGetInstanceRequest(testCtx, tt.model, testClient) + request := buildGetInstanceRequest(testCtx, tt.model, testClient.DefaultAPI) diff := cmp.Diff(request, tt.expectedRequest, - cmp.AllowUnexported(tt.expectedRequest), + cmp.AllowUnexported(tt.expectedRequest, observability.DefaultAPIService{}), cmpopts.EquateComparable(testCtx), ) if diff != "" { @@ -306,7 +306,7 @@ func TestOutputResult(t *testing.T) { name: "set instance but no grafana config", args: args{ instance: &observability.GetInstanceResponse{ - Instance: &observability.InstanceSensitiveData{}, + Instance: observability.InstanceSensitiveData{}, }, }, wantErr: true, @@ -316,7 +316,7 @@ func TestOutputResult(t *testing.T) { args: args{ grafanaConfig: &observability.GrafanaConfigs{}, instance: &observability.GetInstanceResponse{ - Instance: &observability.InstanceSensitiveData{}, + Instance: observability.InstanceSensitiveData{}, }, }, wantErr: false, diff --git a/internal/cmd/observability/grafana/public-read-access/disable/disable.go b/internal/cmd/observability/grafana/public-read-access/disable/disable.go index 0b6b3fcc5..bbc584ef6 100644 --- a/internal/cmd/observability/grafana/public-read-access/disable/disable.go +++ b/internal/cmd/observability/grafana/public-read-access/disable/disable.go @@ -6,7 +6,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/types" - "github.com/stackitcloud/stackit-sdk-go/services/observability" + observability "github.com/stackitcloud/stackit-sdk-go/services/observability/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/args" "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -56,7 +56,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return err } - instanceLabel, err := observabilityUtils.GetInstanceName(ctx, apiClient, model.InstanceId, model.ProjectId) + instanceLabel, err := observabilityUtils.GetInstanceName(ctx, apiClient.DefaultAPI, model.InstanceId, model.ProjectId) if err != nil || instanceLabel == "" { instanceLabel = model.InstanceId } @@ -68,7 +68,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } // Call API - req, err := buildRequest(ctx, model, apiClient) + req, err := buildRequest(ctx, model, apiClient.DefaultAPI) if err != nil { return fmt.Errorf("build request: %w", err) } @@ -101,7 +101,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu return &model, nil } -func buildRequest(ctx context.Context, model *inputModel, apiClient observabilityUtils.ObservabilityClient) (observability.ApiUpdateGrafanaConfigsRequest, error) { +func buildRequest(ctx context.Context, model *inputModel, apiClient observability.DefaultAPI) (observability.ApiUpdateGrafanaConfigsRequest, error) { req := apiClient.UpdateGrafanaConfigs(ctx, model.InstanceId, model.ProjectId) payload, err := observabilityUtils.GetPartialUpdateGrafanaConfigsPayload(ctx, apiClient, model.InstanceId, model.ProjectId, nil, utils.Ptr(false)) if err != nil { diff --git a/internal/cmd/observability/grafana/public-read-access/disable/disable_test.go b/internal/cmd/observability/grafana/public-read-access/disable/disable_test.go index 89cbf05e9..2a8c3b53c 100644 --- a/internal/cmd/observability/grafana/public-read-access/disable/disable_test.go +++ b/internal/cmd/observability/grafana/public-read-access/disable/disable_test.go @@ -12,7 +12,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/observability" + observability "github.com/stackitcloud/stackit-sdk-go/services/observability/v1api" observabilityUtils "github.com/stackitcloud/stackit-cli/internal/pkg/services/observability/utils" ) @@ -22,7 +22,7 @@ var projectIdFlag = globalflags.ProjectIdFlag type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &observability.APIClient{} +var testClient = &observability.APIClient{DefaultAPI: &observability.DefaultAPIService{}} var testProjectId = uuid.NewString() var testInstanceId = uuid.NewString() @@ -31,19 +31,15 @@ type observabilityClientMocked struct { getGrafanaConfigsResp *observability.GrafanaConfigs } -func (c *observabilityClientMocked) GetInstanceExecute(ctx context.Context, instanceId, projectId string) (*observability.GetInstanceResponse, error) { - return testClient.GetInstanceExecute(ctx, instanceId, projectId) -} - -func (c *observabilityClientMocked) UpdateGrafanaConfigs(ctx context.Context, instanceId, projectId string) observability.ApiUpdateGrafanaConfigsRequest { - return testClient.UpdateGrafanaConfigs(ctx, instanceId, projectId) -} - -func (c *observabilityClientMocked) GetGrafanaConfigsExecute(_ context.Context, _, _ string) (*observability.GrafanaConfigs, error) { - if c.getGrafanaConfigsFails { - return nil, fmt.Errorf("get payload failed") +func (c *observabilityClientMocked) newMock() observability.DefaultAPI { + return observability.DefaultAPIServiceMock{ + GetGrafanaConfigsExecuteMock: utils.Ptr(func(_ observability.ApiGetGrafanaConfigsRequest) (*observability.GrafanaConfigs, error) { + if c.getGrafanaConfigsFails { + return nil, fmt.Errorf("get payload failed") + } + return c.getGrafanaConfigsResp, nil + }), } - return c.getGrafanaConfigsResp, nil } func fixtureArgValues(mods ...func(argValues []string)) []string { @@ -82,17 +78,17 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { func fixtureGrafanaConfigs(mods ...func(gc *observability.GrafanaConfigs)) *observability.GrafanaConfigs { gc := observability.GrafanaConfigs{ - GenericOauth: &observability.GrafanaOauth{ - ApiUrl: utils.Ptr("apiUrl"), - AuthUrl: utils.Ptr("authUrl"), - Enabled: utils.Ptr(true), + GenericOauth: &observability.GrafanaOauth{ // nolint:gosec // false positive + ApiUrl: "apiUrl", + AuthUrl: "authUrl", + Enabled: true, Name: utils.Ptr("name"), - OauthClientId: utils.Ptr("oauthClientId"), - OauthClientSecret: utils.Ptr("oauthClientSecret"), - RoleAttributePath: utils.Ptr("roleAttributePath"), + OauthClientId: "oauthClientId", + OauthClientSecret: "oauthClientSecret", + RoleAttributePath: "roleAttributePath", RoleAttributeStrict: utils.Ptr(true), Scopes: utils.Ptr("scopes"), - TokenUrl: utils.Ptr("tokenUrl"), + TokenUrl: "tokenUrl", UsePkce: utils.Ptr(true), }, PublicReadAccess: utils.Ptr(false), @@ -117,7 +113,7 @@ func fixturePayload(mods ...func(payload *observability.UpdateGrafanaConfigsPayl } func fixtureRequest(mods ...func(request *observability.ApiUpdateGrafanaConfigsRequest)) observability.ApiUpdateGrafanaConfigsRequest { - request := testClient.UpdateGrafanaConfigs(testCtx, testInstanceId, testProjectId) + request := testClient.DefaultAPI.UpdateGrafanaConfigs(testCtx, testInstanceId, testProjectId) request = request.UpdateGrafanaConfigsPayload(*fixturePayload()) for _, mod := range mods { mod(&request) @@ -215,7 +211,7 @@ func TestBuildRequest(t *testing.T) { }), isValid: true, expectedRequest: fixtureRequest(func(request *observability.ApiUpdateGrafanaConfigsRequest) { - *request = (*request).UpdateGrafanaConfigsPayload(*fixturePayload(func(payload *observability.UpdateGrafanaConfigsPayload) { + *request = request.UpdateGrafanaConfigsPayload(*fixturePayload(func(payload *observability.UpdateGrafanaConfigsPayload) { payload.GenericOauth = nil })) }), @@ -240,7 +236,7 @@ func TestBuildRequest(t *testing.T) { getGrafanaConfigsFails: tt.getGrafanaConfigsFails, getGrafanaConfigsResp: tt.getGrafanaConfigsResp, } - request, err := buildRequest(testCtx, tt.model, client) + request, err := buildRequest(testCtx, tt.model, client.newMock()) if err != nil { if !tt.isValid { return @@ -251,6 +247,9 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), cmpopts.EquateComparable(testCtx), + cmp.FilterPath(func(p cmp.Path) bool { + return p.String() == "ApiService" + }, cmp.Ignore()), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/observability/grafana/public-read-access/enable/enable.go b/internal/cmd/observability/grafana/public-read-access/enable/enable.go index 88f58227d..934202d1f 100644 --- a/internal/cmd/observability/grafana/public-read-access/enable/enable.go +++ b/internal/cmd/observability/grafana/public-read-access/enable/enable.go @@ -15,7 +15,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/observability" + observability "github.com/stackitcloud/stackit-sdk-go/services/observability/v1api" observabilityUtils "github.com/stackitcloud/stackit-cli/internal/pkg/services/observability/utils" ) @@ -56,7 +56,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return err } - instanceLabel, err := observabilityUtils.GetInstanceName(ctx, apiClient, model.InstanceId, model.ProjectId) + instanceLabel, err := observabilityUtils.GetInstanceName(ctx, apiClient.DefaultAPI, model.InstanceId, model.ProjectId) if err != nil || instanceLabel == "" { instanceLabel = model.InstanceId } @@ -68,7 +68,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } // Call API - req, err := buildRequest(ctx, model, apiClient) + req, err := buildRequest(ctx, model, apiClient.DefaultAPI) if err != nil { return fmt.Errorf("build request: %w", err) } @@ -101,7 +101,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu return &model, nil } -func buildRequest(ctx context.Context, model *inputModel, apiClient observabilityUtils.ObservabilityClient) (observability.ApiUpdateGrafanaConfigsRequest, error) { +func buildRequest(ctx context.Context, model *inputModel, apiClient observability.DefaultAPI) (observability.ApiUpdateGrafanaConfigsRequest, error) { req := apiClient.UpdateGrafanaConfigs(ctx, model.InstanceId, model.ProjectId) payload, err := observabilityUtils.GetPartialUpdateGrafanaConfigsPayload(ctx, apiClient, model.InstanceId, model.ProjectId, nil, utils.Ptr(true)) if err != nil { diff --git a/internal/cmd/observability/grafana/public-read-access/enable/enable_test.go b/internal/cmd/observability/grafana/public-read-access/enable/enable_test.go index e81ed3bc4..5a7c9c4cb 100644 --- a/internal/cmd/observability/grafana/public-read-access/enable/enable_test.go +++ b/internal/cmd/observability/grafana/public-read-access/enable/enable_test.go @@ -12,7 +12,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/observability" + observability "github.com/stackitcloud/stackit-sdk-go/services/observability/v1api" observabilityUtils "github.com/stackitcloud/stackit-cli/internal/pkg/services/observability/utils" ) @@ -22,7 +22,7 @@ var projectIdFlag = globalflags.ProjectIdFlag type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &observability.APIClient{} +var testClient = &observability.APIClient{DefaultAPI: &observability.DefaultAPIService{}} var testProjectId = uuid.NewString() var testInstanceId = uuid.NewString() @@ -31,19 +31,15 @@ type observabilityClientMocked struct { getGrafanaConfigsResp *observability.GrafanaConfigs } -func (c *observabilityClientMocked) GetInstanceExecute(ctx context.Context, instanceId, projectId string) (*observability.GetInstanceResponse, error) { - return testClient.GetInstanceExecute(ctx, instanceId, projectId) -} - -func (c *observabilityClientMocked) UpdateGrafanaConfigs(ctx context.Context, instanceId, projectId string) observability.ApiUpdateGrafanaConfigsRequest { - return testClient.UpdateGrafanaConfigs(ctx, instanceId, projectId) -} - -func (c *observabilityClientMocked) GetGrafanaConfigsExecute(_ context.Context, _, _ string) (*observability.GrafanaConfigs, error) { - if c.getGrafanaConfigsFails { - return nil, fmt.Errorf("get payload failed") +func (c *observabilityClientMocked) newMock() observability.DefaultAPI { + return observability.DefaultAPIServiceMock{ + GetGrafanaConfigsExecuteMock: utils.Ptr(func(_ observability.ApiGetGrafanaConfigsRequest) (*observability.GrafanaConfigs, error) { + if c.getGrafanaConfigsFails { + return nil, fmt.Errorf("get payload failed") + } + return c.getGrafanaConfigsResp, nil + }), } - return c.getGrafanaConfigsResp, nil } func fixtureArgValues(mods ...func(argValues []string)) []string { @@ -82,17 +78,17 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { func fixtureGrafanaConfigs(mods ...func(gc *observability.GrafanaConfigs)) *observability.GrafanaConfigs { gc := observability.GrafanaConfigs{ - GenericOauth: &observability.GrafanaOauth{ - ApiUrl: utils.Ptr("apiUrl"), - AuthUrl: utils.Ptr("authUrl"), - Enabled: utils.Ptr(true), + GenericOauth: &observability.GrafanaOauth{ // nolint:gosec // false positive + ApiUrl: "apiUrl", + AuthUrl: "authUrl", + Enabled: true, Name: utils.Ptr("name"), - OauthClientId: utils.Ptr("oauthClientId"), - OauthClientSecret: utils.Ptr("oauthClientSecret"), - RoleAttributePath: utils.Ptr("roleAttributePath"), + OauthClientId: "oauthClientId", + OauthClientSecret: "oauthClientSecret", + RoleAttributePath: "roleAttributePath", RoleAttributeStrict: utils.Ptr(true), Scopes: utils.Ptr("scopes"), - TokenUrl: utils.Ptr("tokenUrl"), + TokenUrl: "tokenUrl", UsePkce: utils.Ptr(true), }, PublicReadAccess: utils.Ptr(false), @@ -117,7 +113,7 @@ func fixturePayload(mods ...func(payload *observability.UpdateGrafanaConfigsPayl } func fixtureRequest(mods ...func(request *observability.ApiUpdateGrafanaConfigsRequest)) observability.ApiUpdateGrafanaConfigsRequest { - request := testClient.UpdateGrafanaConfigs(testCtx, testInstanceId, testProjectId) + request := testClient.DefaultAPI.UpdateGrafanaConfigs(testCtx, testInstanceId, testProjectId) request = request.UpdateGrafanaConfigsPayload(*fixturePayload()) for _, mod := range mods { mod(&request) @@ -215,7 +211,7 @@ func TestBuildRequest(t *testing.T) { }), isValid: true, expectedRequest: fixtureRequest(func(request *observability.ApiUpdateGrafanaConfigsRequest) { - *request = (*request).UpdateGrafanaConfigsPayload(*fixturePayload(func(payload *observability.UpdateGrafanaConfigsPayload) { + *request = request.UpdateGrafanaConfigsPayload(*fixturePayload(func(payload *observability.UpdateGrafanaConfigsPayload) { payload.GenericOauth = nil })) }), @@ -240,7 +236,7 @@ func TestBuildRequest(t *testing.T) { getGrafanaConfigsFails: tt.getGrafanaConfigsFails, getGrafanaConfigsResp: tt.getGrafanaConfigsResp, } - request, err := buildRequest(testCtx, tt.model, client) + request, err := buildRequest(testCtx, tt.model, client.newMock()) if err != nil { if !tt.isValid { return @@ -251,6 +247,9 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), cmpopts.EquateComparable(testCtx), + cmp.FilterPath(func(p cmp.Path) bool { + return p.String() == "ApiService" + }, cmp.Ignore()), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/observability/grafana/single-sign-on/disable/disable.go b/internal/cmd/observability/grafana/single-sign-on/disable/disable.go index a2023c789..4dc229409 100644 --- a/internal/cmd/observability/grafana/single-sign-on/disable/disable.go +++ b/internal/cmd/observability/grafana/single-sign-on/disable/disable.go @@ -15,7 +15,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/observability" + observability "github.com/stackitcloud/stackit-sdk-go/services/observability/v1api" observabilityUtils "github.com/stackitcloud/stackit-cli/internal/pkg/services/observability/utils" ) @@ -56,7 +56,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return err } - instanceLabel, err := observabilityUtils.GetInstanceName(ctx, apiClient, model.InstanceId, model.ProjectId) + instanceLabel, err := observabilityUtils.GetInstanceName(ctx, apiClient.DefaultAPI, model.InstanceId, model.ProjectId) if err != nil || instanceLabel == "" { instanceLabel = model.InstanceId } @@ -68,7 +68,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } // Call API - req, err := buildRequest(ctx, model, apiClient) + req, err := buildRequest(ctx, model, apiClient.DefaultAPI) if err != nil { return fmt.Errorf("build request: %w", err) } @@ -101,7 +101,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu return &model, nil } -func buildRequest(ctx context.Context, model *inputModel, apiClient observabilityUtils.ObservabilityClient) (observability.ApiUpdateGrafanaConfigsRequest, error) { +func buildRequest(ctx context.Context, model *inputModel, apiClient observability.DefaultAPI) (observability.ApiUpdateGrafanaConfigsRequest, error) { req := apiClient.UpdateGrafanaConfigs(ctx, model.InstanceId, model.ProjectId) payload, err := observabilityUtils.GetPartialUpdateGrafanaConfigsPayload(ctx, apiClient, model.InstanceId, model.ProjectId, utils.Ptr(false), nil) if err != nil { diff --git a/internal/cmd/observability/grafana/single-sign-on/disable/disable_test.go b/internal/cmd/observability/grafana/single-sign-on/disable/disable_test.go index 704b7a199..3de0d5183 100644 --- a/internal/cmd/observability/grafana/single-sign-on/disable/disable_test.go +++ b/internal/cmd/observability/grafana/single-sign-on/disable/disable_test.go @@ -12,7 +12,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/observability" + observability "github.com/stackitcloud/stackit-sdk-go/services/observability/v1api" observabilityUtils "github.com/stackitcloud/stackit-cli/internal/pkg/services/observability/utils" ) @@ -22,7 +22,7 @@ var projectIdFlag = globalflags.ProjectIdFlag type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &observability.APIClient{} +var testClient = &observability.APIClient{DefaultAPI: &observability.DefaultAPIService{}} var testProjectId = uuid.NewString() var testInstanceId = uuid.NewString() @@ -31,19 +31,15 @@ type observabilityClientMocked struct { getGrafanaConfigsResp *observability.GrafanaConfigs } -func (c *observabilityClientMocked) GetInstanceExecute(ctx context.Context, instanceId, projectId string) (*observability.GetInstanceResponse, error) { - return testClient.GetInstanceExecute(ctx, instanceId, projectId) -} - -func (c *observabilityClientMocked) UpdateGrafanaConfigs(ctx context.Context, instanceId, projectId string) observability.ApiUpdateGrafanaConfigsRequest { - return testClient.UpdateGrafanaConfigs(ctx, instanceId, projectId) -} - -func (c *observabilityClientMocked) GetGrafanaConfigsExecute(_ context.Context, _, _ string) (*observability.GrafanaConfigs, error) { - if c.getGrafanaConfigsFails { - return nil, fmt.Errorf("get payload failed") +func (c *observabilityClientMocked) newMock() observability.DefaultAPI { + return observability.DefaultAPIServiceMock{ + GetGrafanaConfigsExecuteMock: utils.Ptr(func(_ observability.ApiGetGrafanaConfigsRequest) (*observability.GrafanaConfigs, error) { + if c.getGrafanaConfigsFails { + return nil, fmt.Errorf("get payload failed") + } + return c.getGrafanaConfigsResp, nil + }), } - return c.getGrafanaConfigsResp, nil } func fixtureArgValues(mods ...func(argValues []string)) []string { @@ -82,17 +78,17 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { func fixtureGrafanaConfigs(mods ...func(gc *observability.GrafanaConfigs)) *observability.GrafanaConfigs { gc := observability.GrafanaConfigs{ - GenericOauth: &observability.GrafanaOauth{ - ApiUrl: utils.Ptr("apiUrl"), - AuthUrl: utils.Ptr("authUrl"), - Enabled: utils.Ptr(true), + GenericOauth: &observability.GrafanaOauth{ // nolint:gosec // false positive + ApiUrl: "apiUrl", + AuthUrl: "authUrl", + Enabled: true, Name: utils.Ptr("name"), - OauthClientId: utils.Ptr("oauthClientId"), - OauthClientSecret: utils.Ptr("oauthClientSecret"), - RoleAttributePath: utils.Ptr("roleAttributePath"), + OauthClientId: "oauthClientId", + OauthClientSecret: "oauthClientSecret", + RoleAttributePath: "roleAttributePath", RoleAttributeStrict: utils.Ptr(true), Scopes: utils.Ptr("scopes"), - TokenUrl: utils.Ptr("tokenUrl"), + TokenUrl: "tokenUrl", UsePkce: utils.Ptr(true), }, PublicReadAccess: utils.Ptr(false), @@ -117,7 +113,7 @@ func fixturePayload(mods ...func(payload *observability.UpdateGrafanaConfigsPayl } func fixtureRequest(mods ...func(request *observability.ApiUpdateGrafanaConfigsRequest)) observability.ApiUpdateGrafanaConfigsRequest { - request := testClient.UpdateGrafanaConfigs(testCtx, testInstanceId, testProjectId) + request := testClient.DefaultAPI.UpdateGrafanaConfigs(testCtx, testInstanceId, testProjectId) request = request.UpdateGrafanaConfigsPayload(*fixturePayload()) for _, mod := range mods { mod(&request) @@ -215,7 +211,7 @@ func TestBuildRequest(t *testing.T) { }), isValid: true, expectedRequest: fixtureRequest(func(request *observability.ApiUpdateGrafanaConfigsRequest) { - *request = (*request).UpdateGrafanaConfigsPayload(*fixturePayload(func(payload *observability.UpdateGrafanaConfigsPayload) { + *request = request.UpdateGrafanaConfigsPayload(*fixturePayload(func(payload *observability.UpdateGrafanaConfigsPayload) { payload.GenericOauth = nil })) }), @@ -240,7 +236,7 @@ func TestBuildRequest(t *testing.T) { getGrafanaConfigsFails: tt.getGrafanaConfigsFails, getGrafanaConfigsResp: tt.getGrafanaConfigsResp, } - request, err := buildRequest(testCtx, tt.model, client) + request, err := buildRequest(testCtx, tt.model, client.newMock()) if err != nil { if !tt.isValid { return @@ -251,6 +247,9 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), cmpopts.EquateComparable(testCtx), + cmp.FilterPath(func(p cmp.Path) bool { + return p.String() == "ApiService" + }, cmp.Ignore()), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/observability/grafana/single-sign-on/enable/enable.go b/internal/cmd/observability/grafana/single-sign-on/enable/enable.go index 3aca5bbe8..a7a8213b6 100644 --- a/internal/cmd/observability/grafana/single-sign-on/enable/enable.go +++ b/internal/cmd/observability/grafana/single-sign-on/enable/enable.go @@ -16,7 +16,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/observability" + observability "github.com/stackitcloud/stackit-sdk-go/services/observability/v1api" ) const ( @@ -55,7 +55,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return err } - instanceLabel, err := observabilityUtils.GetInstanceName(ctx, apiClient, model.InstanceId, model.ProjectId) + instanceLabel, err := observabilityUtils.GetInstanceName(ctx, apiClient.DefaultAPI, model.InstanceId, model.ProjectId) if err != nil || instanceLabel == "" { instanceLabel = model.InstanceId } @@ -67,7 +67,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } // Call API - req, err := buildRequest(ctx, model, apiClient) + req, err := buildRequest(ctx, model, apiClient.DefaultAPI) if err != nil { return fmt.Errorf("build request: %w", err) } @@ -100,7 +100,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu return &model, nil } -func buildRequest(ctx context.Context, model *inputModel, apiClient observabilityUtils.ObservabilityClient) (observability.ApiUpdateGrafanaConfigsRequest, error) { +func buildRequest(ctx context.Context, model *inputModel, apiClient observability.DefaultAPI) (observability.ApiUpdateGrafanaConfigsRequest, error) { req := apiClient.UpdateGrafanaConfigs(ctx, model.InstanceId, model.ProjectId) payload, err := observabilityUtils.GetPartialUpdateGrafanaConfigsPayload(ctx, apiClient, model.InstanceId, model.ProjectId, utils.Ptr(true), nil) if err != nil { diff --git a/internal/cmd/observability/grafana/single-sign-on/enable/enable_test.go b/internal/cmd/observability/grafana/single-sign-on/enable/enable_test.go index f13a2db25..915445ae4 100644 --- a/internal/cmd/observability/grafana/single-sign-on/enable/enable_test.go +++ b/internal/cmd/observability/grafana/single-sign-on/enable/enable_test.go @@ -13,7 +13,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/observability" + observability "github.com/stackitcloud/stackit-sdk-go/services/observability/v1api" ) var projectIdFlag = globalflags.ProjectIdFlag @@ -21,7 +21,7 @@ var projectIdFlag = globalflags.ProjectIdFlag type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &observability.APIClient{} +var testClient = &observability.APIClient{DefaultAPI: &observability.DefaultAPIService{}} var testProjectId = uuid.NewString() var testInstanceId = uuid.NewString() @@ -30,19 +30,15 @@ type observabilityClientMocked struct { getGrafanaConfigsResp *observability.GrafanaConfigs } -func (c *observabilityClientMocked) GetInstanceExecute(ctx context.Context, instanceId, projectId string) (*observability.GetInstanceResponse, error) { - return testClient.GetInstanceExecute(ctx, instanceId, projectId) -} - -func (c *observabilityClientMocked) UpdateGrafanaConfigs(ctx context.Context, instanceId, projectId string) observability.ApiUpdateGrafanaConfigsRequest { - return testClient.UpdateGrafanaConfigs(ctx, instanceId, projectId) -} - -func (c *observabilityClientMocked) GetGrafanaConfigsExecute(_ context.Context, _, _ string) (*observability.GrafanaConfigs, error) { - if c.getGrafanaConfigsFails { - return nil, fmt.Errorf("get payload failed") +func (c *observabilityClientMocked) newMock() observability.DefaultAPI { + return observability.DefaultAPIServiceMock{ + GetGrafanaConfigsExecuteMock: utils.Ptr(func(_ observability.ApiGetGrafanaConfigsRequest) (*observability.GrafanaConfigs, error) { + if c.getGrafanaConfigsFails { + return nil, fmt.Errorf("get payload failed") + } + return c.getGrafanaConfigsResp, nil + }), } - return c.getGrafanaConfigsResp, nil } func fixtureArgValues(mods ...func(argValues []string)) []string { @@ -81,17 +77,17 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { func fixtureGrafanaConfigs(mods ...func(gc *observability.GrafanaConfigs)) *observability.GrafanaConfigs { gc := observability.GrafanaConfigs{ - GenericOauth: &observability.GrafanaOauth{ - ApiUrl: utils.Ptr("apiUrl"), - AuthUrl: utils.Ptr("authUrl"), - Enabled: utils.Ptr(true), + GenericOauth: &observability.GrafanaOauth{ // nolint:gosec // false positive + ApiUrl: "apiUrl", + AuthUrl: "authUrl", + Enabled: true, Name: utils.Ptr("name"), - OauthClientId: utils.Ptr("oauthClientId"), - OauthClientSecret: utils.Ptr("oauthClientSecret"), - RoleAttributePath: utils.Ptr("roleAttributePath"), + OauthClientId: "oauthClientId", + OauthClientSecret: "oauthClientSecret", + RoleAttributePath: "roleAttributePath", RoleAttributeStrict: utils.Ptr(true), Scopes: utils.Ptr("scopes"), - TokenUrl: utils.Ptr("tokenUrl"), + TokenUrl: "tokenUrl", UsePkce: utils.Ptr(true), }, PublicReadAccess: utils.Ptr(false), @@ -116,7 +112,7 @@ func fixturePayload(mods ...func(payload *observability.UpdateGrafanaConfigsPayl } func fixtureRequest(mods ...func(request *observability.ApiUpdateGrafanaConfigsRequest)) observability.ApiUpdateGrafanaConfigsRequest { - request := testClient.UpdateGrafanaConfigs(testCtx, testInstanceId, testProjectId) + request := testClient.DefaultAPI.UpdateGrafanaConfigs(testCtx, testInstanceId, testProjectId) request = request.UpdateGrafanaConfigsPayload(*fixturePayload()) for _, mod := range mods { mod(&request) @@ -214,7 +210,7 @@ func TestBuildRequest(t *testing.T) { }), isValid: true, expectedRequest: fixtureRequest(func(request *observability.ApiUpdateGrafanaConfigsRequest) { - *request = (*request).UpdateGrafanaConfigsPayload(*fixturePayload(func(payload *observability.UpdateGrafanaConfigsPayload) { + *request = request.UpdateGrafanaConfigsPayload(*fixturePayload(func(payload *observability.UpdateGrafanaConfigsPayload) { payload.GenericOauth = nil })) }), @@ -239,7 +235,7 @@ func TestBuildRequest(t *testing.T) { getGrafanaConfigsFails: tt.getGrafanaConfigsFails, getGrafanaConfigsResp: tt.getGrafanaConfigsResp, } - request, err := buildRequest(testCtx, tt.model, client) + request, err := buildRequest(testCtx, tt.model, client.newMock()) if err != nil { if !tt.isValid { return @@ -250,6 +246,9 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), cmpopts.EquateComparable(testCtx), + cmp.FilterPath(func(p cmp.Path) bool { + return p.String() == "ApiService" + }, cmp.Ignore()), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/observability/instance/create/create.go b/internal/cmd/observability/instance/create/create.go index 72d53ebfe..12229c1f6 100644 --- a/internal/cmd/observability/instance/create/create.go +++ b/internal/cmd/observability/instance/create/create.go @@ -16,11 +16,10 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/projectname" "github.com/stackitcloud/stackit-cli/internal/pkg/services/observability/client" "github.com/stackitcloud/stackit-cli/internal/pkg/spinner" - "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/observability" - "github.com/stackitcloud/stackit-sdk-go/services/observability/wait" + observability "github.com/stackitcloud/stackit-sdk-go/services/observability/v1api" + "github.com/stackitcloud/stackit-sdk-go/services/observability/v1api/wait" observabilityUtils "github.com/stackitcloud/stackit-cli/internal/pkg/services/observability/utils" ) @@ -79,7 +78,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } // Call API - req, err := buildRequest(ctx, model, apiClient) + req, err := buildRequest(ctx, model, apiClient.DefaultAPI) if err != nil { var observabilityInvalidPlanError *cliErr.ObservabilityInvalidPlanError if !errors.As(err, &observabilityInvalidPlanError) { @@ -91,12 +90,12 @@ func NewCmd(params *types.CmdParams) *cobra.Command { if err != nil { return fmt.Errorf("create Observability instance: %w", err) } - instanceId := *resp.InstanceId + instanceId := resp.InstanceId // Wait for async operation, if async mode not enabled if !model.Async { err := spinner.Run(params.Printer, "Creating instance", func() error { - _, err = wait.CreateInstanceWaitHandler(ctx, apiClient, instanceId, model.ProjectId).WaitWithContext(ctx) + _, err = wait.CreateInstanceWaitHandler(ctx, apiClient.DefaultAPI, instanceId, model.ProjectId).WaitWithContext(ctx) return err }) if err != nil { @@ -151,18 +150,13 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, return &model, nil } -type observabilityClient interface { - CreateInstance(ctx context.Context, projectId string) observability.ApiCreateInstanceRequest - ListPlansExecute(ctx context.Context, projectId string) (*observability.PlansResponse, error) -} - -func buildRequest(ctx context.Context, model *inputModel, apiClient observabilityClient) (observability.ApiCreateInstanceRequest, error) { +func buildRequest(ctx context.Context, model *inputModel, apiClient observability.DefaultAPI) (observability.ApiCreateInstanceRequest, error) { req := apiClient.CreateInstance(ctx, model.ProjectId) - var planId *string + var planId string var err error - plans, err := apiClient.ListPlansExecute(ctx, model.ProjectId) + plans, err := apiClient.ListPlans(ctx, model.ProjectId).Execute() if err != nil { return req, fmt.Errorf("get Observability plans: %w", err) } @@ -181,7 +175,7 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient observabilit if err != nil { return req, err } - planId = model.PlanId + planId = *model.PlanId } req = req.CreateInstancePayload(observability.CreateInstancePayload{ @@ -201,7 +195,7 @@ func outputResult(p *print.Printer, outputFormat string, async bool, projectLabe if async { operationState = "Triggered creation of" } - p.Outputf("%s instance for project %q. Instance ID: %s\n", operationState, projectLabel, utils.PtrString(resp.InstanceId)) + p.Outputf("%s instance for project %q. Instance ID: %s\n", operationState, projectLabel, resp.InstanceId) return nil }) } diff --git a/internal/cmd/observability/instance/create/create_test.go b/internal/cmd/observability/instance/create/create_test.go index 7ff43cbba..a64925569 100644 --- a/internal/cmd/observability/instance/create/create_test.go +++ b/internal/cmd/observability/instance/create/create_test.go @@ -13,7 +13,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/observability" + observability "github.com/stackitcloud/stackit-sdk-go/services/observability/v1api" ) var projectIdFlag = globalflags.ProjectIdFlag @@ -21,22 +21,22 @@ var projectIdFlag = globalflags.ProjectIdFlag type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &observability.APIClient{} +var testClient = &observability.APIClient{DefaultAPI: &observability.DefaultAPIService{}} type observabilityClientMocked struct { returnError bool listPlansResponse *observability.PlansResponse } -func (c *observabilityClientMocked) CreateInstance(ctx context.Context, projectId string) observability.ApiCreateInstanceRequest { - return testClient.CreateInstance(ctx, projectId) -} - -func (c *observabilityClientMocked) ListPlansExecute(_ context.Context, _ string) (*observability.PlansResponse, error) { - if c.returnError { - return nil, fmt.Errorf("list plans failed") +func (c *observabilityClientMocked) newMock() observability.DefaultAPI { + return observability.DefaultAPIServiceMock{ + ListPlansExecuteMock: utils.Ptr(func(_ observability.ApiListPlansRequest) (*observability.PlansResponse, error) { + if c.returnError { + return nil, fmt.Errorf("list plans failed") + } + return c.listPlansResponse, nil + }), } - return c.listPlansResponse, nil } var testProjectId = uuid.NewString() @@ -70,10 +70,10 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *observability.ApiCreateInstanceRequest)) observability.ApiCreateInstanceRequest { - request := testClient.CreateInstance(testCtx, testProjectId) + request := testClient.DefaultAPI.CreateInstance(testCtx, testProjectId) request = request.CreateInstancePayload(observability.CreateInstancePayload{ Name: utils.Ptr("example-name"), - PlanId: utils.Ptr(testPlanId), + PlanId: testPlanId, }) for _, mod := range mods { mod(&request) @@ -83,10 +83,10 @@ func fixtureRequest(mods ...func(request *observability.ApiCreateInstanceRequest func fixturePlansResponse(mods ...func(response *observability.PlansResponse)) *observability.PlansResponse { response := &observability.PlansResponse{ - Plans: &[]observability.Plan{ + Plans: []observability.Plan{ { Name: utils.Ptr("example-plan-name"), - Id: utils.Ptr(testPlanId), + Id: testPlanId, }, }, } @@ -249,8 +249,8 @@ func TestBuildRequest(t *testing.T) { }, ), getPlansResponse: fixturePlansResponse(), - expectedRequest: testClient.CreateInstance(testCtx, testProjectId). - CreateInstancePayload(observability.CreateInstancePayload{PlanId: utils.Ptr(testPlanId)}), + expectedRequest: testClient.DefaultAPI.CreateInstance(testCtx, testProjectId). + CreateInstancePayload(observability.CreateInstancePayload{PlanId: testPlanId}), isValid: true, }, { @@ -263,8 +263,8 @@ func TestBuildRequest(t *testing.T) { }, ), getPlansResponse: fixturePlansResponse(), - expectedRequest: testClient.CreateInstance(testCtx, testProjectId). - CreateInstancePayload(observability.CreateInstancePayload{PlanId: utils.Ptr(testPlanId)}), + expectedRequest: testClient.DefaultAPI.CreateInstance(testCtx, testProjectId). + CreateInstancePayload(observability.CreateInstancePayload{PlanId: testPlanId}), isValid: true, }, } @@ -275,7 +275,7 @@ func TestBuildRequest(t *testing.T) { returnError: tt.getPlansFails, listPlansResponse: tt.getPlansResponse, } - request, err := buildRequest(testCtx, tt.model, client) + request, err := buildRequest(testCtx, tt.model, client.newMock()) if err != nil { if !tt.isValid { return @@ -290,6 +290,9 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), cmpopts.EquateComparable(testCtx), + cmp.FilterPath(func(p cmp.Path) bool { + return p.String() == "ApiService" + }, cmp.Ignore()), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/observability/instance/delete/delete.go b/internal/cmd/observability/instance/delete/delete.go index d9fc972ab..50e399417 100644 --- a/internal/cmd/observability/instance/delete/delete.go +++ b/internal/cmd/observability/instance/delete/delete.go @@ -17,8 +17,8 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/observability" - "github.com/stackitcloud/stackit-sdk-go/services/observability/wait" + observability "github.com/stackitcloud/stackit-sdk-go/services/observability/v1api" + "github.com/stackitcloud/stackit-sdk-go/services/observability/v1api/wait" ) const ( @@ -54,7 +54,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return err } - instanceLabel, err := observabilityUtils.GetInstanceName(ctx, apiClient, model.InstanceId, model.ProjectId) + instanceLabel, err := observabilityUtils.GetInstanceName(ctx, apiClient.DefaultAPI, model.InstanceId, model.ProjectId) if err != nil { params.Printer.Debug(print.ErrorLevel, "get instance name: %v", err) instanceLabel = model.InstanceId @@ -67,7 +67,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } // Call API - req := buildRequest(ctx, model, apiClient) + req := buildRequest(ctx, model, apiClient.DefaultAPI) _, err = req.Execute() if err != nil { return fmt.Errorf("delete Observability instance: %w", err) @@ -76,7 +76,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { // Wait for async operation, if async mode not enabled if !model.Async { err := spinner.Run(params.Printer, "Deleting instance", func() error { - _, err = wait.DeleteInstanceWaitHandler(ctx, apiClient, model.InstanceId, model.ProjectId).WaitWithContext(ctx) + _, err = wait.DeleteInstanceWaitHandler(ctx, apiClient.DefaultAPI, model.InstanceId, model.ProjectId).WaitWithContext(ctx) return err }) if err != nil { @@ -112,7 +112,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu return &model, nil } -func buildRequest(ctx context.Context, model *inputModel, apiClient *observability.APIClient) observability.ApiDeleteInstanceRequest { +func buildRequest(ctx context.Context, model *inputModel, apiClient observability.DefaultAPI) observability.ApiDeleteInstanceRequest { req := apiClient.DeleteInstance(ctx, model.InstanceId, model.ProjectId) return req } diff --git a/internal/cmd/observability/instance/delete/delete_test.go b/internal/cmd/observability/instance/delete/delete_test.go index 5d6bce774..be1c0f7ff 100644 --- a/internal/cmd/observability/instance/delete/delete_test.go +++ b/internal/cmd/observability/instance/delete/delete_test.go @@ -10,7 +10,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/observability" + observability "github.com/stackitcloud/stackit-sdk-go/services/observability/v1api" ) var projectIdFlag = globalflags.ProjectIdFlag @@ -18,7 +18,7 @@ var projectIdFlag = globalflags.ProjectIdFlag type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &observability.APIClient{} +var testClient = &observability.APIClient{DefaultAPI: &observability.DefaultAPIService{}} var testProjectId = uuid.NewString() var testInstanceId = uuid.NewString() @@ -57,7 +57,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *observability.ApiDeleteInstanceRequest)) observability.ApiDeleteInstanceRequest { - request := testClient.DeleteInstance(testCtx, testInstanceId, testProjectId) + request := testClient.DefaultAPI.DeleteInstance(testCtx, testInstanceId, testProjectId) for _, mod := range mods { mod(&request) } @@ -157,10 +157,10 @@ func TestBuildRequest(t *testing.T) { for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { - request := buildRequest(testCtx, tt.model, testClient) + request := buildRequest(testCtx, tt.model, testClient.DefaultAPI) diff := cmp.Diff(request, tt.expectedRequest, - cmp.AllowUnexported(tt.expectedRequest), + cmp.AllowUnexported(tt.expectedRequest, observability.DefaultAPIService{}), cmpopts.EquateComparable(testCtx), ) if diff != "" { diff --git a/internal/cmd/observability/instance/describe/describe.go b/internal/cmd/observability/instance/describe/describe.go index e9e4a256a..22d6bc6b8 100644 --- a/internal/cmd/observability/instance/describe/describe.go +++ b/internal/cmd/observability/instance/describe/describe.go @@ -16,7 +16,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/observability" + observability "github.com/stackitcloud/stackit-sdk-go/services/observability/v1api" ) const ( @@ -55,7 +55,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } // Call API - req := buildRequest(ctx, model, apiClient) + req := buildRequest(ctx, model, apiClient.DefaultAPI) resp, err := req.Execute() if err != nil { return fmt.Errorf("read Observability instance: %w", err) @@ -84,7 +84,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu return &model, nil } -func buildRequest(ctx context.Context, model *inputModel, apiClient *observability.APIClient) observability.ApiGetInstanceRequest { +func buildRequest(ctx context.Context, model *inputModel, apiClient observability.DefaultAPI) observability.ApiGetInstanceRequest { req := apiClient.GetInstance(ctx, model.InstanceId, model.ProjectId) return req } @@ -96,30 +96,27 @@ func outputResult(p *print.Printer, outputFormat string, instance *observability return p.OutputResult(outputFormat, instance, func() error { table := tables.NewTable() - table.AddRow("ID", utils.PtrString(instance.Id)) + table.AddRow("ID", instance.Id) table.AddSeparator() table.AddRow("NAME", utils.PtrString(instance.Name)) table.AddSeparator() - table.AddRow("STATUS", utils.PtrString(instance.Status)) + table.AddRow("STATUS", instance.Status) table.AddSeparator() - table.AddRow("PLAN NAME", utils.PtrString(instance.PlanName)) + table.AddRow("PLAN NAME", instance.PlanName) + table.AddSeparator() + plan := instance.Instance.Plan + table.AddRow("METRIC SAMPLES (PER MIN)", plan.TotalMetricSamples) + table.AddSeparator() + table.AddRow("LOGS (GB)", plan.LogsStorage) + table.AddSeparator() + table.AddRow("TRACES (GB)", plan.TracesStorage) + table.AddSeparator() + table.AddRow("NOTIFICATION RULES", plan.AlertRules) + table.AddSeparator() + table.AddRow("GRAFANA USERS", plan.GrafanaGlobalUsers) + table.AddSeparator() + table.AddRow("GRAFANA URL", instance.Instance.GrafanaUrl) table.AddSeparator() - if inst := instance.Instance; inst != nil { - if plan := inst.Plan; plan != nil { - table.AddRow("METRIC SAMPLES (PER MIN)", utils.PtrString(plan.TotalMetricSamples)) - table.AddSeparator() - table.AddRow("LOGS (GB)", utils.PtrString(plan.LogsStorage)) - table.AddSeparator() - table.AddRow("TRACES (GB)", utils.PtrString(plan.TracesStorage)) - table.AddSeparator() - table.AddRow("NOTIFICATION RULES", utils.PtrString(plan.AlertRules)) - table.AddSeparator() - table.AddRow("GRAFANA USERS", utils.PtrString(plan.GrafanaGlobalUsers)) - table.AddSeparator() - } - table.AddRow("GRAFANA URL", utils.PtrString(inst.GrafanaUrl)) - table.AddSeparator() - } err := table.Display(p) if err != nil { return fmt.Errorf("render table: %w", err) diff --git a/internal/cmd/observability/instance/describe/describe_test.go b/internal/cmd/observability/instance/describe/describe_test.go index 0cf036a20..853f95d0d 100644 --- a/internal/cmd/observability/instance/describe/describe_test.go +++ b/internal/cmd/observability/instance/describe/describe_test.go @@ -11,7 +11,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/observability" + observability "github.com/stackitcloud/stackit-sdk-go/services/observability/v1api" ) var projectIdFlag = globalflags.ProjectIdFlag @@ -19,7 +19,7 @@ var projectIdFlag = globalflags.ProjectIdFlag type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &observability.APIClient{} +var testClient = &observability.APIClient{DefaultAPI: &observability.DefaultAPIService{}} var testProjectId = uuid.NewString() var testInstanceId = uuid.NewString() @@ -58,7 +58,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *observability.ApiGetInstanceRequest)) observability.ApiGetInstanceRequest { - request := testClient.GetInstance(testCtx, testInstanceId, testProjectId) + request := testClient.DefaultAPI.GetInstance(testCtx, testInstanceId, testProjectId) for _, mod := range mods { mod(&request) } @@ -158,10 +158,10 @@ func TestBuildRequest(t *testing.T) { for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { - request := buildRequest(testCtx, tt.model, testClient) + request := buildRequest(testCtx, tt.model, testClient.DefaultAPI) diff := cmp.Diff(request, tt.expectedRequest, - cmp.AllowUnexported(tt.expectedRequest), + cmp.AllowUnexported(tt.expectedRequest, observability.DefaultAPIService{}), cmpopts.EquateComparable(testCtx), ) if diff != "" { diff --git a/internal/cmd/observability/instance/list/list.go b/internal/cmd/observability/instance/list/list.go index ab0c25959..b77731725 100644 --- a/internal/cmd/observability/instance/list/list.go +++ b/internal/cmd/observability/instance/list/list.go @@ -7,7 +7,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/types" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/observability" + observability "github.com/stackitcloud/stackit-sdk-go/services/observability/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/args" "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -61,7 +61,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } // Call API - req := buildRequest(ctx, model, apiClient) + req := buildRequest(ctx, model, apiClient.DefaultAPI) resp, err := req.Execute() if err != nil { return fmt.Errorf("get Observability instances: %w", err) @@ -115,7 +115,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, return &model, nil } -func buildRequest(ctx context.Context, model *inputModel, apiClient *observability.APIClient) observability.ApiListInstancesRequest { +func buildRequest(ctx context.Context, model *inputModel, apiClient observability.DefaultAPI) observability.ApiListInstancesRequest { req := apiClient.ListInstances(ctx, model.ProjectId) return req } @@ -131,10 +131,10 @@ func outputResult(p *print.Printer, outputFormat, projectLabel string, instances for i := range instances { instance := instances[i] table.AddRow( - utils.PtrString(instance.Id), + instance.Id, utils.PtrString(instance.Name), - utils.PtrString(instance.PlanName), - utils.PtrString(instance.Status), + instance.PlanName, + instance.Status, ) } err := table.Display(p) diff --git a/internal/cmd/observability/instance/list/list_test.go b/internal/cmd/observability/instance/list/list_test.go index a61783fa6..25a4c416d 100644 --- a/internal/cmd/observability/instance/list/list_test.go +++ b/internal/cmd/observability/instance/list/list_test.go @@ -12,7 +12,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/observability" + observability "github.com/stackitcloud/stackit-sdk-go/services/observability/v1api" ) var projectIdFlag = globalflags.ProjectIdFlag @@ -20,7 +20,7 @@ var projectIdFlag = globalflags.ProjectIdFlag type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &observability.APIClient{} +var testClient = &observability.APIClient{DefaultAPI: &observability.DefaultAPIService{}} var testProjectId = uuid.NewString() func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string { @@ -49,7 +49,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *observability.ApiListInstancesRequest)) observability.ApiListInstancesRequest { - request := testClient.ListInstances(testCtx, testProjectId) + request := testClient.DefaultAPI.ListInstances(testCtx, testProjectId) for _, mod := range mods { mod(&request) } @@ -134,10 +134,10 @@ func TestBuildRequest(t *testing.T) { for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { - request := buildRequest(testCtx, tt.model, testClient) + request := buildRequest(testCtx, tt.model, testClient.DefaultAPI) diff := cmp.Diff(request, tt.expectedRequest, - cmp.AllowUnexported(tt.expectedRequest), + cmp.AllowUnexported(tt.expectedRequest, observability.DefaultAPIService{}), cmpopts.EquateComparable(testCtx), ) if diff != "" { diff --git a/internal/cmd/observability/instance/update/update.go b/internal/cmd/observability/instance/update/update.go index 38b2fe693..be02114cc 100644 --- a/internal/cmd/observability/instance/update/update.go +++ b/internal/cmd/observability/instance/update/update.go @@ -19,8 +19,8 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/observability" - "github.com/stackitcloud/stackit-sdk-go/services/observability/wait" + observability "github.com/stackitcloud/stackit-sdk-go/services/observability/v1api" + "github.com/stackitcloud/stackit-sdk-go/services/observability/v1api/wait" ) const ( @@ -70,7 +70,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return err } - instanceLabel, err := observabilityUtils.GetInstanceName(ctx, apiClient, model.InstanceId, model.ProjectId) + instanceLabel, err := observabilityUtils.GetInstanceName(ctx, apiClient.DefaultAPI, model.InstanceId, model.ProjectId) if err != nil || instanceLabel == "" { params.Printer.Debug(print.ErrorLevel, "get instance name: %v", err) instanceLabel = model.InstanceId @@ -83,7 +83,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } // Call API - req, err := buildRequest(ctx, model, apiClient) + req, err := buildRequest(ctx, model, apiClient.DefaultAPI) if err != nil { var observabilityInvalidPlanError *cliErr.ObservabilityInvalidPlanError if !errors.As(err, &observabilityInvalidPlanError) { @@ -101,7 +101,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { // Wait for async operation, if async mode not enabled if !model.Async { err := spinner.Run(params.Printer, "Updating instance", func() error { - _, err = wait.UpdateInstanceWaitHandler(ctx, apiClient, instanceId, model.ProjectId).WaitWithContext(ctx) + _, err = wait.UpdateInstanceWaitHandler(ctx, apiClient.DefaultAPI, instanceId, model.ProjectId).WaitWithContext(ctx) return err }) if err != nil { @@ -161,34 +161,28 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu return &model, nil } -type observabilityClient interface { - UpdateInstance(ctx context.Context, instanceId, projectId string) observability.ApiUpdateInstanceRequest - ListPlansExecute(ctx context.Context, projectId string) (*observability.PlansResponse, error) - GetInstanceExecute(ctx context.Context, instanceId, projectId string) (*observability.GetInstanceResponse, error) -} - -func buildRequest(ctx context.Context, model *inputModel, apiClient observabilityClient) (observability.ApiUpdateInstanceRequest, error) { +func buildRequest(ctx context.Context, model *inputModel, apiClient observability.DefaultAPI) (observability.ApiUpdateInstanceRequest, error) { req := apiClient.UpdateInstance(ctx, model.InstanceId, model.ProjectId) var err error - plans, err := apiClient.ListPlansExecute(ctx, model.ProjectId) + plans, err := apiClient.ListPlans(ctx, model.ProjectId).Execute() if err != nil { return req, fmt.Errorf("get Observability plans: %w", err) } - currentInstance, err := apiClient.GetInstanceExecute(ctx, model.InstanceId, model.ProjectId) + currentInstance, err := apiClient.GetInstance(ctx, model.InstanceId, model.ProjectId).Execute() if err != nil { return req, fmt.Errorf("get Observability instance: %w", err) } payload := observability.UpdateInstancePayload{ - PlanId: currentInstance.PlanId, + PlanId: ¤tInstance.PlanId, Name: currentInstance.Name, } if model.PlanId == nil && model.PlanName != "" { - payload.PlanId, err = observabilityUtils.LoadPlanId(model.PlanName, plans) + planId, err := observabilityUtils.LoadPlanId(model.PlanName, plans) if err != nil { var observabilityInvalidPlanError *cliErr.ObservabilityInvalidPlanError if !errors.As(err, &observabilityInvalidPlanError) { @@ -196,6 +190,7 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient observabilit } return req, err } + payload.PlanId = &planId } else if model.PlanId != nil && model.PlanName == "" { err := observabilityUtils.ValidatePlanId(*model.PlanId, plans) if err != nil { diff --git a/internal/cmd/observability/instance/update/update_test.go b/internal/cmd/observability/instance/update/update_test.go index 6a576ce5d..74ffc17fe 100644 --- a/internal/cmd/observability/instance/update/update_test.go +++ b/internal/cmd/observability/instance/update/update_test.go @@ -12,7 +12,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/observability" + observability "github.com/stackitcloud/stackit-sdk-go/services/observability/v1api" ) var projectIdFlag = globalflags.ProjectIdFlag @@ -20,7 +20,7 @@ var projectIdFlag = globalflags.ProjectIdFlag type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &observability.APIClient{} +var testClient = &observability.APIClient{DefaultAPI: &observability.DefaultAPIService{}} type observabilityClientMocked struct { listPlansError bool @@ -29,22 +29,21 @@ type observabilityClientMocked struct { getInstanceResponse *observability.GetInstanceResponse } -func (c *observabilityClientMocked) UpdateInstance(ctx context.Context, instanceId, projectId string) observability.ApiUpdateInstanceRequest { - return testClient.UpdateInstance(ctx, instanceId, projectId) -} - -func (c *observabilityClientMocked) ListPlansExecute(_ context.Context, _ string) (*observability.PlansResponse, error) { - if c.listPlansError { - return nil, fmt.Errorf("list flavors failed") - } - return c.listPlansResponse, nil -} - -func (c *observabilityClientMocked) GetInstanceExecute(_ context.Context, _, _ string) (*observability.GetInstanceResponse, error) { - if c.getInstanceError { - return nil, fmt.Errorf("get instance failed") +func (c *observabilityClientMocked) newMock() observability.DefaultAPI { + return observability.DefaultAPIServiceMock{ + ListPlansExecuteMock: utils.Ptr(func(_ observability.ApiListPlansRequest) (*observability.PlansResponse, error) { + if c.listPlansError { + return nil, fmt.Errorf("list flavors failed") + } + return c.listPlansResponse, nil + }), + GetInstanceExecuteMock: utils.Ptr(func(_ observability.ApiGetInstanceRequest) (*observability.GetInstanceResponse, error) { + if c.getInstanceError { + return nil, fmt.Errorf("get instance failed") + } + return c.getInstanceResponse, nil + }), } - return c.getInstanceResponse, nil } const ( @@ -95,7 +94,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *observability.ApiUpdateInstanceRequest)) observability.ApiUpdateInstanceRequest { - request := testClient.UpdateInstance(testCtx, testInstanceId, testProjectId) + request := testClient.DefaultAPI.UpdateInstance(testCtx, testInstanceId, testProjectId) request = request.UpdateInstancePayload(observability.UpdateInstancePayload{ PlanId: utils.Ptr(testNewPlanId), Name: utils.Ptr(testInstanceName), @@ -108,10 +107,10 @@ func fixtureRequest(mods ...func(request *observability.ApiUpdateInstanceRequest func fixturePlansResponse(mods ...func(response *observability.PlansResponse)) *observability.PlansResponse { response := &observability.PlansResponse{ - Plans: &[]observability.Plan{ + Plans: []observability.Plan{ { Name: utils.Ptr("example-plan-name"), - Id: utils.Ptr(testNewPlanId), + Id: testNewPlanId, }, }, } @@ -123,7 +122,7 @@ func fixturePlansResponse(mods ...func(response *observability.PlansResponse)) * func fixtureGetInstanceResponse(mods ...func(response *observability.GetInstanceResponse)) *observability.GetInstanceResponse { response := &observability.GetInstanceResponse{ - PlanId: utils.Ptr(testPlanId), + PlanId: testPlanId, Name: utils.Ptr(testInstanceName), } for _, mod := range mods { @@ -375,7 +374,7 @@ func TestBuildRequest(t *testing.T) { getInstanceError: tt.getInstanceFails, getInstanceResponse: tt.getInstanceResponse, } - request, err := buildRequest(testCtx, tt.model, client) + request, err := buildRequest(testCtx, tt.model, client.newMock()) if err != nil { if !tt.isValid { return @@ -390,6 +389,9 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), cmpopts.EquateComparable(testCtx), + cmp.FilterPath(func(p cmp.Path) bool { + return p.String() == "ApiService" + }, cmp.Ignore()), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/observability/plans/plans.go b/internal/cmd/observability/plans/plans.go index ee4fcbb38..386ee26e0 100644 --- a/internal/cmd/observability/plans/plans.go +++ b/internal/cmd/observability/plans/plans.go @@ -18,7 +18,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/observability" + observability "github.com/stackitcloud/stackit-sdk-go/services/observability/v1api" ) const ( @@ -61,7 +61,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } // Call API - req := buildRequest(ctx, model, apiClient) + req := buildRequest(ctx, model, apiClient.DefaultAPI) resp, err := req.Execute() if err != nil { return fmt.Errorf("get Observability service plans: %w", err) @@ -115,7 +115,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, return &model, nil } -func buildRequest(ctx context.Context, model *inputModel, apiClient *observability.APIClient) observability.ApiListPlansRequest { +func buildRequest(ctx context.Context, model *inputModel, apiClient observability.DefaultAPI) observability.ApiListPlansRequest { req := apiClient.ListPlans(ctx, model.ProjectId) return req } @@ -131,7 +131,7 @@ func outputResult(p *print.Printer, outputFormat, projectLabel string, plans []o for i := range plans { o := plans[i] table.AddRow( - utils.PtrString(o.Id), + o.Id, utils.PtrString(o.Name), utils.PtrString(o.Description), ) diff --git a/internal/cmd/observability/plans/plans_test.go b/internal/cmd/observability/plans/plans_test.go index e09caacec..9c9b28b08 100644 --- a/internal/cmd/observability/plans/plans_test.go +++ b/internal/cmd/observability/plans/plans_test.go @@ -12,7 +12,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/observability" + observability "github.com/stackitcloud/stackit-sdk-go/services/observability/v1api" ) var projectIdFlag = globalflags.ProjectIdFlag @@ -20,7 +20,7 @@ var projectIdFlag = globalflags.ProjectIdFlag type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &observability.APIClient{} +var testClient = &observability.APIClient{DefaultAPI: &observability.DefaultAPIService{}} var testProjectId = uuid.NewString() func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string { @@ -49,7 +49,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *observability.ApiListPlansRequest)) observability.ApiListPlansRequest { - request := testClient.ListPlans(testCtx, testProjectId) + request := testClient.DefaultAPI.ListPlans(testCtx, testProjectId) for _, mod := range mods { mod(&request) } @@ -134,10 +134,10 @@ func TestBuildRequest(t *testing.T) { for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { - request := buildRequest(testCtx, tt.model, testClient) + request := buildRequest(testCtx, tt.model, testClient.DefaultAPI) diff := cmp.Diff(request, tt.expectedRequest, - cmp.AllowUnexported(tt.expectedRequest), + cmp.AllowUnexported(tt.expectedRequest, observability.DefaultAPIService{}), cmpopts.EquateComparable(testCtx), ) if diff != "" { diff --git a/internal/cmd/observability/scrape-config/create/create.go b/internal/cmd/observability/scrape-config/create/create.go index 87d206cfe..740166324 100644 --- a/internal/cmd/observability/scrape-config/create/create.go +++ b/internal/cmd/observability/scrape-config/create/create.go @@ -16,11 +16,10 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/services/observability/client" observabilityUtils "github.com/stackitcloud/stackit-cli/internal/pkg/services/observability/utils" "github.com/stackitcloud/stackit-cli/internal/pkg/spinner" - "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/observability" - "github.com/stackitcloud/stackit-sdk-go/services/observability/wait" + observability "github.com/stackitcloud/stackit-sdk-go/services/observability/v1api" + "github.com/stackitcloud/stackit-sdk-go/services/observability/v1api/wait" ) const ( @@ -74,7 +73,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return err } - instanceLabel, err := observabilityUtils.GetInstanceName(ctx, apiClient, model.InstanceId, model.ProjectId) + instanceLabel, err := observabilityUtils.GetInstanceName(ctx, apiClient.DefaultAPI, model.InstanceId, model.ProjectId) if err != nil { params.Printer.Debug(print.ErrorLevel, "get instance name: %v", err) instanceLabel = model.InstanceId @@ -89,14 +88,14 @@ func NewCmd(params *types.CmdParams) *cobra.Command { model.Payload = &defaultPayload } - prompt := fmt.Sprintf("Are you sure you want to create scrape configuration %q on Observability instance %q?", *model.Payload.JobName, instanceLabel) + prompt := fmt.Sprintf("Are you sure you want to create scrape configuration %q on Observability instance %q?", model.Payload.JobName, instanceLabel) err = params.Printer.PromptForConfirmation(prompt) if err != nil { return err } // Call API - req := buildRequest(ctx, model, apiClient) + req := buildRequest(ctx, model, apiClient.DefaultAPI) _, err = req.Execute() if err != nil { return fmt.Errorf("create scrape configuration: %w", err) @@ -107,7 +106,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { // Wait for async operation, if async mode not enabled if !model.Async { err := spinner.Run(params.Printer, "Creating scrape config", func() error { - _, err = wait.CreateScrapeConfigWaitHandler(ctx, apiClient, model.InstanceId, *jobName, model.ProjectId).WaitWithContext(ctx) + _, err = wait.CreateScrapeConfigWaitHandler(ctx, apiClient.DefaultAPI, model.InstanceId, jobName, model.ProjectId).WaitWithContext(ctx) return err }) if err != nil { @@ -119,7 +118,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { if model.Async { operationState = "Triggered creation of" } - params.Printer.Outputf("%s scrape configuration with name %q for Observability instance %q\n", operationState, utils.PtrString(jobName), instanceLabel) + params.Printer.Outputf("%s scrape configuration with name %q for Observability instance %q\n", operationState, jobName, instanceLabel) return nil }, } @@ -158,7 +157,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, }, nil } -func buildRequest(ctx context.Context, model *inputModel, apiClient *observability.APIClient) observability.ApiCreateScrapeConfigRequest { +func buildRequest(ctx context.Context, model *inputModel, apiClient observability.DefaultAPI) observability.ApiCreateScrapeConfigRequest { req := apiClient.CreateScrapeConfig(ctx, model.InstanceId, model.ProjectId) req = req.CreateScrapeConfigPayload(*model.Payload) diff --git a/internal/cmd/observability/scrape-config/create/create_test.go b/internal/cmd/observability/scrape-config/create/create_test.go index 8da9b00a2..2431e1ed9 100644 --- a/internal/cmd/observability/scrape-config/create/create_test.go +++ b/internal/cmd/observability/scrape-config/create/create_test.go @@ -13,7 +13,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/observability" + observability "github.com/stackitcloud/stackit-sdk-go/services/observability/v1api" ) var projectIdFlag = globalflags.ProjectIdFlag @@ -21,12 +21,12 @@ var projectIdFlag = globalflags.ProjectIdFlag type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &observability.APIClient{} +var testClient = &observability.APIClient{DefaultAPI: &observability.DefaultAPIService{}} var testProjectId = uuid.NewString() var testInstanceId = uuid.NewString() var testPayload = &observability.CreateScrapeConfigPayload{ - BasicAuth: &observability.PartialUpdateScrapeConfigsRequestInnerBasicAuth{ + BasicAuth: &observability.CreateScrapeConfigPayloadBasicAuth{ Username: utils.Ptr("username"), Password: utils.Ptr("password"), }, @@ -34,36 +34,36 @@ var testPayload = &observability.CreateScrapeConfigPayload{ HonorLabels: utils.Ptr(true), HonorTimeStamps: utils.Ptr(true), MetricsPath: utils.Ptr("/metrics"), - JobName: utils.Ptr("default-name"), - MetricsRelabelConfigs: &[]observability.PartialUpdateScrapeConfigsRequestInnerMetricsRelabelConfigsInner{ + JobName: "default-name", + MetricsRelabelConfigs: []observability.CreateScrapeConfigPayloadMetricsRelabelConfigsInner{ { - Action: observability.PARTIALUPDATESCRAPECONFIGSREQUESTINNERMETRICSRELABELCONFIGSINNERACTION_REPLACE.Ptr(), - Modulus: utils.Ptr(1.0), + Action: observability.CREATESCRAPECONFIGPAYLOADMETRICSRELABELCONFIGSINNERACTION_REPLACE.Ptr(), + Modulus: utils.Ptr(float32(1.0)), Regex: utils.Ptr("regex"), Replacement: utils.Ptr("replacement"), Separator: utils.Ptr("separator"), - SourceLabels: &[]string{"sourceLabel"}, + SourceLabels: []string{"sourceLabel"}, TargetLabel: utils.Ptr("targetLabel"), }, }, - Params: &map[string]interface{}{ + Params: map[string]interface{}{ "key": []interface{}{string("value1"), string("value2")}, "key2": []interface{}{}, }, - SampleLimit: utils.Ptr(1.0), - Scheme: observability.CREATESCRAPECONFIGPAYLOADSCHEME_HTTPS.Ptr(), - ScrapeInterval: utils.Ptr("interval"), - ScrapeTimeout: utils.Ptr("timeout"), - StaticConfigs: &[]observability.PartialUpdateScrapeConfigsRequestInnerStaticConfigsInner{ + SampleLimit: utils.Ptr(float32(1.0)), + Scheme: observability.CREATESCRAPECONFIGPAYLOADSCHEME_HTTPS, + ScrapeInterval: "interval", + ScrapeTimeout: "timeout", + StaticConfigs: []observability.CreateScrapeConfigPayloadStaticConfigsInner{ { - Labels: &map[string]interface{}{ + Labels: map[string]interface{}{ "label": "value", "label2": "value2", }, - Targets: &[]string{"target"}, + Targets: []string{"target"}, }, }, - TlsConfig: &observability.PartialUpdateScrapeConfigsRequestInnerHttpSdConfigsInnerOauth2TlsConfig{ + TlsConfig: &observability.CreateScrapeConfigPayloadTlsConfig{ InsecureSkipVerify: utils.Ptr(true), }, } @@ -137,7 +137,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *observability.ApiCreateScrapeConfigRequest)) observability.ApiCreateScrapeConfigRequest { - request := testClient.CreateScrapeConfig(testCtx, testInstanceId, testProjectId) + request := testClient.DefaultAPI.CreateScrapeConfig(testCtx, testInstanceId, testProjectId) request = request.CreateScrapeConfigPayload(*testPayload) for _, mod := range mods { mod(&request) @@ -233,7 +233,12 @@ func TestParseInput(t *testing.T) { for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { - testutils.TestParseInput(t, NewCmd, parseInput, tt.expectedModel, tt.argValues, tt.flagValues, tt.isValid) + testutils.TestParseInputWithOptions(t, NewCmd, parseInput, tt.expectedModel, tt.argValues, tt.flagValues, nil, tt.isValid, []testutils.TestingOption{ + testutils.WithCmpOptions(cmp.FilterPath(func(p cmp.Path) bool { + last := p.Last().String() + return last == ".AdditionalProperties" + }, cmp.Ignore())), + }) }) } } @@ -254,10 +259,10 @@ func TestBuildRequest(t *testing.T) { for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { - request := buildRequest(testCtx, tt.model, testClient) + request := buildRequest(testCtx, tt.model, testClient.DefaultAPI) diff := cmp.Diff(request, tt.expectedRequest, - cmp.AllowUnexported(tt.expectedRequest), + cmp.AllowUnexported(tt.expectedRequest, observability.DefaultAPIService{}), cmpopts.EquateComparable(testCtx), ) if diff != "" { diff --git a/internal/cmd/observability/scrape-config/delete/delete.go b/internal/cmd/observability/scrape-config/delete/delete.go index 7ec1e8ccf..c953c4e5e 100644 --- a/internal/cmd/observability/scrape-config/delete/delete.go +++ b/internal/cmd/observability/scrape-config/delete/delete.go @@ -17,8 +17,8 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/spinner" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/observability" - "github.com/stackitcloud/stackit-sdk-go/services/observability/wait" + observability "github.com/stackitcloud/stackit-sdk-go/services/observability/v1api" + "github.com/stackitcloud/stackit-sdk-go/services/observability/v1api/wait" ) const ( @@ -57,7 +57,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return err } - instanceLabel, err := observabilityUtils.GetInstanceName(ctx, apiClient, model.InstanceId, model.ProjectId) + instanceLabel, err := observabilityUtils.GetInstanceName(ctx, apiClient.DefaultAPI, model.InstanceId, model.ProjectId) if err != nil { params.Printer.Debug(print.ErrorLevel, "get instance name: %v", err) instanceLabel = model.InstanceId @@ -70,7 +70,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } // Call API - req := buildRequest(ctx, model, apiClient) + req := buildRequest(ctx, model, apiClient.DefaultAPI) _, err = req.Execute() if err != nil { return fmt.Errorf("delete scrape configuration: %w", err) @@ -79,7 +79,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { // Wait for async operation, if async mode not enabled if !model.Async { err := spinner.Run(params.Printer, "Deleting scrape config", func() error { - _, err = wait.DeleteScrapeConfigWaitHandler(ctx, apiClient, model.InstanceId, model.JobName, model.ProjectId).WaitWithContext(ctx) + _, err = wait.DeleteScrapeConfigWaitHandler(ctx, apiClient.DefaultAPI, model.InstanceId, model.JobName, model.ProjectId).WaitWithContext(ctx) return err }) if err != nil { @@ -121,7 +121,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu }, nil } -func buildRequest(ctx context.Context, model *inputModel, apiClient *observability.APIClient) observability.ApiDeleteScrapeConfigRequest { +func buildRequest(ctx context.Context, model *inputModel, apiClient observability.DefaultAPI) observability.ApiDeleteScrapeConfigRequest { req := apiClient.DeleteScrapeConfig(ctx, model.InstanceId, model.JobName, model.ProjectId) return req } diff --git a/internal/cmd/observability/scrape-config/delete/delete_test.go b/internal/cmd/observability/scrape-config/delete/delete_test.go index c9549964d..be623a878 100644 --- a/internal/cmd/observability/scrape-config/delete/delete_test.go +++ b/internal/cmd/observability/scrape-config/delete/delete_test.go @@ -9,7 +9,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/observability" + observability "github.com/stackitcloud/stackit-sdk-go/services/observability/v1api" ) var projectIdFlag = globalflags.ProjectIdFlag @@ -17,7 +17,7 @@ var projectIdFlag = globalflags.ProjectIdFlag type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &observability.APIClient{} +var testClient = &observability.APIClient{DefaultAPI: &observability.DefaultAPIService{}} var testProjectId = uuid.NewString() var testInstanceId = uuid.NewString() var testJobName = "my-config" @@ -59,7 +59,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *observability.ApiDeleteScrapeConfigRequest)) observability.ApiDeleteScrapeConfigRequest { - request := testClient.DeleteScrapeConfig(testCtx, testInstanceId, testJobName, testProjectId) + request := testClient.DefaultAPI.DeleteScrapeConfig(testCtx, testInstanceId, testJobName, testProjectId) for _, mod := range mods { mod(&request) } @@ -219,10 +219,10 @@ func TestBuildRequest(t *testing.T) { for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { - request := buildRequest(testCtx, tt.model, testClient) + request := buildRequest(testCtx, tt.model, testClient.DefaultAPI) diff := cmp.Diff(request, tt.expectedRequest, - cmp.AllowUnexported(tt.expectedRequest), + cmp.AllowUnexported(tt.expectedRequest, observability.DefaultAPIService{}), cmpopts.EquateComparable(testCtx), ) if diff != "" { diff --git a/internal/cmd/observability/scrape-config/describe/describe.go b/internal/cmd/observability/scrape-config/describe/describe.go index 5dc11a619..edf2427b6 100644 --- a/internal/cmd/observability/scrape-config/describe/describe.go +++ b/internal/cmd/observability/scrape-config/describe/describe.go @@ -8,7 +8,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/types" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/observability" + observability "github.com/stackitcloud/stackit-sdk-go/services/observability/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/args" "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -60,13 +60,13 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } // Call API - req := buildRequest(ctx, model, apiClient) + req := buildRequest(ctx, model, apiClient.DefaultAPI) resp, err := req.Execute() if err != nil { return fmt.Errorf("read scrape configuration: %w", err) } - return outputResult(params.Printer, model.OutputFormat, resp.Data) + return outputResult(params.Printer, model.OutputFormat, &resp.Data) }, } configureFlags(cmd) @@ -95,16 +95,12 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu }, nil } -func buildRequest(ctx context.Context, model *inputModel, apiClient *observability.APIClient) observability.ApiGetScrapeConfigRequest { +func buildRequest(ctx context.Context, model *inputModel, apiClient observability.DefaultAPI) observability.ApiGetScrapeConfigRequest { req := apiClient.GetScrapeConfig(ctx, model.InstanceId, model.JobName, model.ProjectId) return req } func outputResult(p *print.Printer, outputFormat string, config *observability.Job) error { - if config == nil { - return fmt.Errorf(`config is nil`) - } - return p.OutputResult(outputFormat, config, func() error { saml2Enabled := "Enabled" if config.Params != nil { @@ -116,7 +112,7 @@ func outputResult(p *print.Printer, outputFormat string, config *observability.J var targets []string if config.StaticConfigs != nil { - for _, target := range *config.StaticConfigs { + for _, target := range config.StaticConfigs { targetLabels := []string{} targetLabelStr := "N/A" if target.Labels != nil { @@ -130,22 +126,22 @@ func outputResult(p *print.Printer, outputFormat string, config *observability.J } targetUrlsStr := "N/A" if target.Targets != nil { - targetUrlsStr = strings.Join(*target.Targets, ",") + targetUrlsStr = strings.Join(target.Targets, ",") } targets = append(targets, fmt.Sprintf("labels: %s\nurls: %s", targetLabelStr, targetUrlsStr)) } } table := tables.NewTable() - table.AddRow("NAME", utils.PtrString(config.JobName)) + table.AddRow("NAME", config.JobName) table.AddSeparator() table.AddRow("METRICS PATH", utils.PtrString(config.MetricsPath)) table.AddSeparator() table.AddRow("SCHEME", utils.PtrString(config.Scheme)) table.AddSeparator() - table.AddRow("SCRAPE INTERVAL", utils.PtrString(config.ScrapeInterval)) + table.AddRow("SCRAPE INTERVAL", config.ScrapeInterval) table.AddSeparator() - table.AddRow("SCRAPE TIMEOUT", utils.PtrString(config.ScrapeTimeout)) + table.AddRow("SCRAPE TIMEOUT", config.ScrapeTimeout) table.AddSeparator() table.AddRow("SAML2", saml2Enabled) table.AddSeparator() @@ -154,9 +150,9 @@ func outputResult(p *print.Printer, outputFormat string, config *observability.J } else { table.AddRow("AUTHENTICATION", "Basic Auth") table.AddSeparator() - table.AddRow("USERNAME", utils.PtrString(config.BasicAuth.Username)) + table.AddRow("USERNAME", config.BasicAuth.Username) table.AddSeparator() - table.AddRow("PASSWORD", utils.PtrString(config.BasicAuth.Password)) + table.AddRow("PASSWORD", config.BasicAuth.Password) } table.AddSeparator() for i, target := range targets { diff --git a/internal/cmd/observability/scrape-config/describe/describe_test.go b/internal/cmd/observability/scrape-config/describe/describe_test.go index 97083464a..23cbc4c2f 100644 --- a/internal/cmd/observability/scrape-config/describe/describe_test.go +++ b/internal/cmd/observability/scrape-config/describe/describe_test.go @@ -10,7 +10,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/observability" + observability "github.com/stackitcloud/stackit-sdk-go/services/observability/v1api" ) var projectIdFlag = globalflags.ProjectIdFlag @@ -18,7 +18,7 @@ var projectIdFlag = globalflags.ProjectIdFlag type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &observability.APIClient{} +var testClient = &observability.APIClient{DefaultAPI: &observability.DefaultAPIService{}} var testProjectId = uuid.NewString() var testInstanceId = uuid.NewString() var testJobName = "my-config" @@ -60,7 +60,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *observability.ApiGetScrapeConfigRequest)) observability.ApiGetScrapeConfigRequest { - request := testClient.GetScrapeConfig(testCtx, testInstanceId, testJobName, testProjectId) + request := testClient.DefaultAPI.GetScrapeConfig(testCtx, testInstanceId, testJobName, testProjectId) for _, mod := range mods { mod(&request) } @@ -220,10 +220,10 @@ func TestBuildRequest(t *testing.T) { for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { - request := buildRequest(testCtx, tt.model, testClient) + request := buildRequest(testCtx, tt.model, testClient.DefaultAPI) diff := cmp.Diff(request, tt.expectedRequest, - cmp.AllowUnexported(tt.expectedRequest), + cmp.AllowUnexported(tt.expectedRequest, observability.DefaultAPIService{}), cmpopts.EquateComparable(testCtx), ) if diff != "" { @@ -236,7 +236,7 @@ func TestBuildRequest(t *testing.T) { func TestOutputResult(t *testing.T) { type args struct { outputFormat string - config *observability.Job + config observability.Job } tests := []struct { name string @@ -244,14 +244,13 @@ func TestOutputResult(t *testing.T) { wantErr bool }{ { - name: "empty", - args: args{}, - wantErr: true, + name: "empty", + args: args{}, }, { name: "empty config", args: args{ - config: &observability.Job{}, + config: observability.Job{}, }, wantErr: false, }, @@ -259,7 +258,7 @@ func TestOutputResult(t *testing.T) { params := testparams.NewTestParams() for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - if err := outputResult(params.Printer, tt.args.outputFormat, tt.args.config); (err != nil) != tt.wantErr { + if err := outputResult(params.Printer, tt.args.outputFormat, &tt.args.config); (err != nil) != tt.wantErr { t.Errorf("outputResult() error = %v, wantErr %v", err, tt.wantErr) } }) diff --git a/internal/cmd/observability/scrape-config/generate-payload/generate_payload.go b/internal/cmd/observability/scrape-config/generate-payload/generate_payload.go index e891d728e..ab489abe4 100644 --- a/internal/cmd/observability/scrape-config/generate-payload/generate_payload.go +++ b/internal/cmd/observability/scrape-config/generate-payload/generate_payload.go @@ -17,7 +17,7 @@ import ( observabilityUtils "github.com/stackitcloud/stackit-cli/internal/pkg/services/observability/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/observability" + observability "github.com/stackitcloud/stackit-sdk-go/services/observability/v1api" ) const ( @@ -79,7 +79,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return outputCreateResult(params.Printer, model.FilePath, &createPayload) } - req := buildRequest(ctx, model, apiClient) + req := buildRequest(ctx, model, apiClient.DefaultAPI) resp, err := req.Execute() if err != nil { return fmt.Errorf("read Observability scrape config: %w", err) @@ -121,7 +121,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, }, nil } -func buildRequest(ctx context.Context, model *inputModel, apiClient *observability.APIClient) observability.ApiGetScrapeConfigRequest { +func buildRequest(ctx context.Context, model *inputModel, apiClient observability.DefaultAPI) observability.ApiGetScrapeConfigRequest { req := apiClient.GetScrapeConfig(ctx, model.InstanceId, *model.JobName, model.ProjectId) return req } @@ -131,7 +131,7 @@ func outputCreateResult(p *print.Printer, filePath *string, payload *observabili return fmt.Errorf("payload is nil") } - payloadBytes, err := json.MarshalIndent(*payload, "", " ") + payloadBytes, err := json.MarshalIndent(*payload, "", " ") // nolint:gosec // false positive if err != nil { return fmt.Errorf("marshal payload: %w", err) } @@ -153,7 +153,7 @@ func outputUpdateResult(p *print.Printer, filePath *string, payload *observabili return fmt.Errorf("payload is nil") } - payloadBytes, err := json.MarshalIndent(*payload, "", " ") + payloadBytes, err := json.MarshalIndent(*payload, "", " ") // nolint:gosec // false positive if err != nil { return fmt.Errorf("marshal payload: %w", err) } diff --git a/internal/cmd/observability/scrape-config/generate-payload/generate_payload_test.go b/internal/cmd/observability/scrape-config/generate-payload/generate_payload_test.go index 23d437632..f59b3d66b 100644 --- a/internal/cmd/observability/scrape-config/generate-payload/generate_payload_test.go +++ b/internal/cmd/observability/scrape-config/generate-payload/generate_payload_test.go @@ -13,7 +13,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/observability" + observability "github.com/stackitcloud/stackit-sdk-go/services/observability/v1api" ) var projectIdFlag = globalflags.ProjectIdFlag @@ -21,7 +21,7 @@ var projectIdFlag = globalflags.ProjectIdFlag type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &observability.APIClient{} +var testClient = &observability.APIClient{DefaultAPI: &observability.DefaultAPIService{}} var testProjectId = uuid.NewString() var testInstanceId = uuid.NewString() @@ -60,7 +60,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *observability.ApiGetScrapeConfigRequest)) observability.ApiGetScrapeConfigRequest { - request := testClient.GetScrapeConfig(testCtx, testInstanceId, testJobName, testProjectId) + request := testClient.DefaultAPI.GetScrapeConfig(testCtx, testInstanceId, testJobName, testProjectId) for _, mod := range mods { mod(&request) } @@ -194,10 +194,10 @@ func TestBuildRequest(t *testing.T) { for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { - request := buildRequest(testCtx, tt.model, testClient) + request := buildRequest(testCtx, tt.model, testClient.DefaultAPI) diff := cmp.Diff(request, tt.expectedRequest, - cmp.AllowUnexported(tt.expectedRequest), + cmp.AllowUnexported(tt.expectedRequest, observability.DefaultAPIService{}), cmpopts.EquateComparable(testCtx), ) if diff != "" { diff --git a/internal/cmd/observability/scrape-config/list/list.go b/internal/cmd/observability/scrape-config/list/list.go index a5a9ad642..2af2c8d82 100644 --- a/internal/cmd/observability/scrape-config/list/list.go +++ b/internal/cmd/observability/scrape-config/list/list.go @@ -14,12 +14,11 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/print" "github.com/stackitcloud/stackit-cli/internal/pkg/services/observability/client" "github.com/stackitcloud/stackit-cli/internal/pkg/tables" - "github.com/stackitcloud/stackit-cli/internal/pkg/utils" observabilityUtils "github.com/stackitcloud/stackit-cli/internal/pkg/services/observability/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/observability" + observability "github.com/stackitcloud/stackit-sdk-go/services/observability/v1api" ) const ( @@ -64,7 +63,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } // Call API - req := buildRequest(ctx, model, apiClient) + req := buildRequest(ctx, model, apiClient.DefaultAPI) resp, err := req.Execute() if err != nil { return fmt.Errorf("get scrape configurations: %w", err) @@ -72,7 +71,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { configs := resp.GetData() - instanceLabel, err := observabilityUtils.GetInstanceName(ctx, apiClient, model.InstanceId, model.ProjectId) + instanceLabel, err := observabilityUtils.GetInstanceName(ctx, apiClient.DefaultAPI, model.InstanceId, model.ProjectId) if err != nil { params.Printer.Debug(print.ErrorLevel, "get instance name: %v", err) instanceLabel = model.InstanceId @@ -120,7 +119,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, }, nil } -func buildRequest(ctx context.Context, model *inputModel, apiClient *observability.APIClient) observability.ApiListScrapeConfigsRequest { +func buildRequest(ctx context.Context, model *inputModel, apiClient observability.DefaultAPI) observability.ApiListScrapeConfigsRequest { req := apiClient.ListScrapeConfigs(ctx, model.InstanceId, model.ProjectId) return req } @@ -138,18 +137,18 @@ func outputResult(p *print.Printer, outputFormat, instanceLabel string, configs targets := 0 if c.StaticConfigs != nil { - for _, sc := range *c.StaticConfigs { + for _, sc := range c.StaticConfigs { if sc.Targets == nil { continue } - targets += len(*sc.Targets) + targets += len(sc.Targets) } } table.AddRow( - utils.PtrString(c.JobName), + c.JobName, targets, - utils.PtrString(c.ScrapeInterval), + c.ScrapeInterval, ) } err := table.Display(p) diff --git a/internal/cmd/observability/scrape-config/list/list_test.go b/internal/cmd/observability/scrape-config/list/list_test.go index 52d73330f..f993e0a1c 100644 --- a/internal/cmd/observability/scrape-config/list/list_test.go +++ b/internal/cmd/observability/scrape-config/list/list_test.go @@ -13,7 +13,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/observability" + observability "github.com/stackitcloud/stackit-sdk-go/services/observability/v1api" ) var projectIdFlag = globalflags.ProjectIdFlag @@ -21,7 +21,7 @@ var projectIdFlag = globalflags.ProjectIdFlag type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &observability.APIClient{} +var testClient = &observability.APIClient{DefaultAPI: &observability.DefaultAPIService{}} var testProjectId = uuid.NewString() var testInstanceId = uuid.NewString() @@ -53,7 +53,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *observability.ApiListScrapeConfigsRequest)) observability.ApiListScrapeConfigsRequest { - request := testClient.ListScrapeConfigs(testCtx, testInstanceId, testProjectId) + request := testClient.DefaultAPI.ListScrapeConfigs(testCtx, testInstanceId, testProjectId) for _, mod := range mods { mod(&request) } @@ -159,10 +159,10 @@ func TestBuildRequest(t *testing.T) { for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { - request := buildRequest(testCtx, tt.model, testClient) + request := buildRequest(testCtx, tt.model, testClient.DefaultAPI) diff := cmp.Diff(request, tt.expectedRequest, - cmp.AllowUnexported(tt.expectedRequest), + cmp.AllowUnexported(tt.expectedRequest, observability.DefaultAPIService{}), cmpopts.EquateComparable(testCtx), ) if diff != "" { diff --git a/internal/cmd/observability/scrape-config/update/update.go b/internal/cmd/observability/scrape-config/update/update.go index 130199713..e5eb24e06 100644 --- a/internal/cmd/observability/scrape-config/update/update.go +++ b/internal/cmd/observability/scrape-config/update/update.go @@ -16,7 +16,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/services/observability/client" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/observability" + observability "github.com/stackitcloud/stackit-sdk-go/services/observability/v1api" ) const ( @@ -76,7 +76,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } // Call API - req := buildRequest(ctx, model, apiClient) + req := buildRequest(ctx, model, apiClient.DefaultAPI) _, err = req.Execute() if err != nil { return fmt.Errorf("update scrape config: %w", err) @@ -122,7 +122,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu }, nil } -func buildRequest(ctx context.Context, model *inputModel, apiClient *observability.APIClient) observability.ApiUpdateScrapeConfigRequest { +func buildRequest(ctx context.Context, model *inputModel, apiClient observability.DefaultAPI) observability.ApiUpdateScrapeConfigRequest { req := apiClient.UpdateScrapeConfig(ctx, model.InstanceId, model.JobName, model.ProjectId) req = req.UpdateScrapeConfigPayload(model.Payload) diff --git a/internal/cmd/observability/scrape-config/update/update_test.go b/internal/cmd/observability/scrape-config/update/update_test.go index 2f7ce1b13..5a41cfbe9 100644 --- a/internal/cmd/observability/scrape-config/update/update_test.go +++ b/internal/cmd/observability/scrape-config/update/update_test.go @@ -10,7 +10,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/observability" + observability "github.com/stackitcloud/stackit-sdk-go/services/observability/v1api" ) var projectIdFlag = globalflags.ProjectIdFlag @@ -18,35 +18,39 @@ var projectIdFlag = globalflags.ProjectIdFlag type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &observability.APIClient{} +var testClient = &observability.APIClient{DefaultAPI: &observability.DefaultAPIService{}} var testProjectId = uuid.NewString() var testInstanceId = uuid.NewString() var testJobName = "my-config" var testPayload = observability.UpdateScrapeConfigPayload{ - BasicAuth: &observability.PartialUpdateScrapeConfigsRequestInnerBasicAuth{ + BasicAuth: &observability.UpdateScrapeConfigPayloadBasicAuth{ Username: utils.Ptr("username"), Password: utils.Ptr("password"), }, BearerToken: utils.Ptr("bearerToken"), HonorLabels: utils.Ptr(true), HonorTimeStamps: utils.Ptr(true), - MetricsPath: utils.Ptr("/metrics"), - MetricsRelabelConfigs: &[]observability.PartialUpdateScrapeConfigsRequestInnerMetricsRelabelConfigsInner{ + MetricsPath: "/metrics", + MetricsRelabelConfigs: []observability.UpdateScrapeConfigPayloadMetricsRelabelConfigsInner{ { - Action: observability.PARTIALUPDATESCRAPECONFIGSREQUESTINNERMETRICSRELABELCONFIGSINNERACTION_REPLACE.Ptr(), - Modulus: utils.Ptr(1.0), + Action: observability.UPDATESCRAPECONFIGPAYLOADMETRICSRELABELCONFIGSINNERACTION_REPLACE.Ptr(), + Modulus: utils.Ptr(float32(1.0)), Regex: utils.Ptr("regex"), Replacement: utils.Ptr("replacement"), Separator: utils.Ptr("separator"), - SourceLabels: &[]string{"sourceLabel"}, + SourceLabels: []string{"sourceLabel"}, TargetLabel: utils.Ptr("targetLabel"), }, }, - Params: &map[string]interface{}{ - "key": []interface{}{string("value1"), string("value2")}, + Params: map[string]interface{}{ + "key": []interface{}{"value1", "value2"}, "key2": []interface{}{}, }, + ScrapeInterval: "5m", + ScrapeTimeout: "10s", + Scheme: "https", + StaticConfigs: []observability.UpdateScrapeConfigPayloadStaticConfigsInner{}, } func fixtureArgValues(mods ...func(argValues []string)) []string { @@ -86,7 +90,11 @@ func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]st "params": { "key": ["value1", "value2"], "key2": [] - } + }, + "scheme": "https", + "scrapeInterval": "5m", + "scrapeTimeout": "10s", + "staticConfigs": [] }`, } for _, mod := range mods { @@ -112,7 +120,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *observability.ApiUpdateScrapeConfigRequest)) observability.ApiUpdateScrapeConfigRequest { - request := testClient.UpdateScrapeConfig(testCtx, testInstanceId, testJobName, testProjectId) + request := testClient.DefaultAPI.UpdateScrapeConfig(testCtx, testInstanceId, testJobName, testProjectId) request = request.UpdateScrapeConfigPayload(testPayload) for _, mod := range mods { mod(&request) @@ -262,7 +270,9 @@ func TestParseInput(t *testing.T) { if !tt.isValid { t.Fatalf("did not fail on invalid input") } - diff := cmp.Diff(model, tt.expectedModel) + diff := cmp.Diff(model, tt.expectedModel, cmp.FilterPath(func(path cmp.Path) bool { + return path.Last().String() == ".AdditionalProperties" + }, cmp.Ignore())) if diff != "" { t.Fatalf("Data does not match: %s", diff) } @@ -286,10 +296,10 @@ func TestBuildRequest(t *testing.T) { for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { - request := buildRequest(testCtx, tt.model, testClient) + request := buildRequest(testCtx, tt.model, testClient.DefaultAPI) diff := cmp.Diff(request, tt.expectedRequest, - cmp.AllowUnexported(tt.expectedRequest), + cmp.AllowUnexported(tt.expectedRequest, observability.DefaultAPIService{}), cmpopts.EquateComparable(testCtx), ) if diff != "" { diff --git a/internal/pkg/services/observability/client/client.go b/internal/pkg/services/observability/client/client.go index eae8204d7..b8e5a5fbc 100644 --- a/internal/pkg/services/observability/client/client.go +++ b/internal/pkg/services/observability/client/client.go @@ -1,7 +1,7 @@ package client import ( - "github.com/stackitcloud/stackit-sdk-go/services/observability" + observability "github.com/stackitcloud/stackit-sdk-go/services/observability/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/config" genericclient "github.com/stackitcloud/stackit-cli/internal/pkg/generic-client" diff --git a/internal/pkg/services/observability/utils/utils.go b/internal/pkg/services/observability/utils/utils.go index 7a15180c5..c5b2be317 100644 --- a/internal/pkg/services/observability/utils/utils.go +++ b/internal/pkg/services/observability/utils/utils.go @@ -3,9 +3,10 @@ package utils import ( "context" "fmt" + "reflect" "strings" - "github.com/stackitcloud/stackit-sdk-go/services/observability" + observability "github.com/stackitcloud/stackit-sdk-go/services/observability/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/errors" "github.com/stackitcloud/stackit-cli/internal/pkg/utils" @@ -15,27 +16,21 @@ const ( service = "observability" ) -type ObservabilityClient interface { - GetInstanceExecute(ctx context.Context, instanceId, projectId string) (*observability.GetInstanceResponse, error) - GetGrafanaConfigsExecute(ctx context.Context, instanceId, projectId string) (*observability.GrafanaConfigs, error) - UpdateGrafanaConfigs(ctx context.Context, instanceId string, projectId string) observability.ApiUpdateGrafanaConfigsRequest -} - var ( - defaultStaticConfigs = []observability.PartialUpdateScrapeConfigsRequestInnerStaticConfigsInner{ + defaultStaticConfigs = []observability.CreateScrapeConfigPayloadStaticConfigsInner{ { - Targets: utils.Ptr([]string{ + Targets: []string{ "url-target", - }), + }, }, } DefaultCreateScrapeConfigPayload = observability.CreateScrapeConfigPayload{ - JobName: utils.Ptr("default-name"), + JobName: "default-name", MetricsPath: utils.Ptr("/metrics"), - Scheme: observability.CREATESCRAPECONFIGPAYLOADSCHEME_HTTPS.Ptr(), - ScrapeInterval: utils.Ptr("5m"), - ScrapeTimeout: utils.Ptr("2m"), - StaticConfigs: utils.Ptr(defaultStaticConfigs), + Scheme: observability.CREATESCRAPECONFIGPAYLOADSCHEME_HTTPS, + ScrapeInterval: "5m", + ScrapeTimeout: "2m", + StaticConfigs: defaultStaticConfigs, } ) @@ -44,9 +39,9 @@ func ValidatePlanId(planId string, resp *observability.PlansResponse) error { return fmt.Errorf("no Observability plans provided") } - for i := range *resp.Plans { - plan := (*resp.Plans)[i] - if plan.Id != nil && strings.EqualFold(*plan.Id, planId) { + for i := range resp.Plans { + plan := resp.Plans[i] + if strings.EqualFold(plan.Id, planId) { return nil } } @@ -57,32 +52,32 @@ func ValidatePlanId(planId string, resp *observability.PlansResponse) error { } } -func LoadPlanId(planName string, resp *observability.PlansResponse) (*string, error) { +func LoadPlanId(planName string, resp *observability.PlansResponse) (string, error) { availablePlanNames := "" if resp == nil { - return nil, fmt.Errorf("no Observability plans provided") + return "", fmt.Errorf("no Observability plans provided") } - for i := range *resp.Plans { - plan := (*resp.Plans)[i] + for i := range resp.Plans { + plan := resp.Plans[i] if plan.Name == nil { continue } - if strings.EqualFold(*plan.Name, planName) && plan.Id != nil { + if strings.EqualFold(*plan.Name, planName) { return plan.Id, nil } availablePlanNames = fmt.Sprintf("%s\n- %s", availablePlanNames, *plan.Name) } details := fmt.Sprintf("You provided plan name %q, which is invalid. Available plan names are: %s", planName, availablePlanNames) - return nil, &errors.ObservabilityInvalidPlanError{ + return "", &errors.ObservabilityInvalidPlanError{ Service: service, Details: details, } } func MapToUpdateScrapeConfigPayload(resp *observability.GetScrapeConfigResponse) (*observability.UpdateScrapeConfigPayload, error) { - if resp == nil || resp.Data == nil { + if resp == nil { return nil, fmt.Errorf("no Observability scrape config provided") } @@ -93,9 +88,14 @@ func MapToUpdateScrapeConfigPayload(resp *observability.GetScrapeConfigResponse) tlsConfig := mapTlsConfig(data.TlsConfig) metricsRelabelConfigs := mapMetricsRelabelConfig(data.MetricsRelabelConfigs) - var params *map[string]interface{} + var params map[string]interface{} if data.Params != nil { - params = utils.Ptr(mapParams(*data.Params)) + params = mapParams(*data.Params) + } + + var scheme observability.UpdateScrapeConfigPayloadScheme + if data.Scheme != nil { + scheme = observability.UpdateScrapeConfigPayloadScheme(*data.Scheme) } payload := observability.UpdateScrapeConfigPayload{ @@ -103,33 +103,33 @@ func MapToUpdateScrapeConfigPayload(resp *observability.GetScrapeConfigResponse) BearerToken: data.BearerToken, HonorLabels: data.HonorLabels, HonorTimeStamps: data.HonorTimeStamps, - MetricsPath: data.MetricsPath, + MetricsPath: utils.PtrString(data.MetricsPath), MetricsRelabelConfigs: metricsRelabelConfigs, Params: params, - SampleLimit: utils.ConvertInt64PToFloat64P(data.SampleLimit), - Scheme: observability.UpdateScrapeConfigPayloadGetSchemeAttributeType(data.Scheme), + SampleLimit: utils.ConvertInt32PToFloat32P(data.SampleLimit), + Scheme: scheme, ScrapeInterval: data.ScrapeInterval, ScrapeTimeout: data.ScrapeTimeout, StaticConfigs: staticConfigs, TlsConfig: tlsConfig, } - if payload == (observability.UpdateScrapeConfigPayload{}) { + if reflect.DeepEqual(payload, observability.UpdateScrapeConfigPayload{}) { return nil, fmt.Errorf("the provided Observability scrape config payload is empty") } return &payload, nil } -func mapMetricsRelabelConfig(metricsRelabelConfigs *[]observability.MetricsRelabelConfig) *[]observability.PartialUpdateScrapeConfigsRequestInnerMetricsRelabelConfigsInner { +func mapMetricsRelabelConfig(metricsRelabelConfigs []observability.MetricsRelabelConfig) []observability.UpdateScrapeConfigPayloadMetricsRelabelConfigsInner { if metricsRelabelConfigs == nil { return nil } - var mappedConfigs []observability.PartialUpdateScrapeConfigsRequestInnerMetricsRelabelConfigsInner - for _, config := range *metricsRelabelConfigs { - mappedConfig := observability.PartialUpdateScrapeConfigsRequestInnerMetricsRelabelConfigsInner{ - Action: observability.PartialUpdateScrapeConfigsRequestInnerMetricsRelabelConfigsInnerGetActionAttributeType(config.Action), - Modulus: utils.ConvertInt64PToFloat64P(config.Modulus), + var mappedConfigs []observability.UpdateScrapeConfigPayloadMetricsRelabelConfigsInner + for _, config := range metricsRelabelConfigs { + mappedConfig := observability.UpdateScrapeConfigPayloadMetricsRelabelConfigsInner{ + Action: (*observability.UpdateScrapeConfigPayloadMetricsRelabelConfigsInnerAction)(config.Action), + Modulus: utils.ConvertInt32PToFloat32P(config.Modulus), Regex: config.Regex, Replacement: config.Replacement, Separator: config.Separator, @@ -138,18 +138,18 @@ func mapMetricsRelabelConfig(metricsRelabelConfigs *[]observability.MetricsRelab } mappedConfigs = append(mappedConfigs, mappedConfig) } - return &mappedConfigs + return mappedConfigs } -func mapStaticConfig(staticConfigs *[]observability.StaticConfigs) *[]observability.UpdateScrapeConfigPayloadStaticConfigsInner { +func mapStaticConfig(staticConfigs []observability.StaticConfigs) []observability.UpdateScrapeConfigPayloadStaticConfigsInner { if staticConfigs == nil { return nil } var mappedConfigs []observability.UpdateScrapeConfigPayloadStaticConfigsInner - for _, config := range *staticConfigs { - var labels *map[string]interface{} + for _, config := range staticConfigs { + var labels map[string]interface{} if config.Labels != nil { - labels = utils.Ptr(mapStaticConfigLabels(*config.Labels)) + labels = mapStaticConfigLabels(*config.Labels) } mappedConfig := observability.UpdateScrapeConfigPayloadStaticConfigsInner{ Labels: labels, @@ -158,26 +158,34 @@ func mapStaticConfig(staticConfigs *[]observability.StaticConfigs) *[]observabil mappedConfigs = append(mappedConfigs, mappedConfig) } - return &mappedConfigs + return mappedConfigs } -func mapBasicAuth(basicAuth *observability.BasicAuth) *observability.PartialUpdateScrapeConfigsRequestInnerBasicAuth { +func mapBasicAuth(basicAuth *observability.BasicAuth) *observability.UpdateScrapeConfigPayloadBasicAuth { if basicAuth == nil { return nil } - return &observability.PartialUpdateScrapeConfigsRequestInnerBasicAuth{ - Password: basicAuth.Password, - Username: basicAuth.Username, + var password, username *string + if basicAuth.Password != "" { + password = &basicAuth.Password + } + if basicAuth.Username != "" { + username = &basicAuth.Username + } + + return &observability.UpdateScrapeConfigPayloadBasicAuth{ + Password: password, + Username: username, } } -func mapTlsConfig(tlsConfig *observability.TLSConfig) *observability.PartialUpdateScrapeConfigsRequestInnerHttpSdConfigsInnerOauth2TlsConfig { +func mapTlsConfig(tlsConfig *observability.TLSConfig) *observability.UpdateScrapeConfigPayloadTlsConfig { if tlsConfig == nil { return nil } - return &observability.PartialUpdateScrapeConfigsRequestInnerHttpSdConfigsInnerOauth2TlsConfig{ + return &observability.UpdateScrapeConfigPayloadTlsConfig{ InsecureSkipVerify: tlsConfig.InsecureSkipVerify, } } @@ -198,8 +206,8 @@ func mapStaticConfigLabels(labels map[string]string) map[string]interface{} { return labelsMap } -func GetInstanceName(ctx context.Context, apiClient ObservabilityClient, instanceId, projectId string) (string, error) { - resp, err := apiClient.GetInstanceExecute(ctx, instanceId, projectId) +func GetInstanceName(ctx context.Context, apiClient observability.DefaultAPI, instanceId, projectId string) (string, error) { + resp, err := apiClient.GetInstance(ctx, instanceId, projectId).Execute() if err != nil { return "", fmt.Errorf("get Observability instance: %w", err) } @@ -225,8 +233,8 @@ func ToPayloadGenericOAuth(respOAuth *observability.GrafanaOauth) *observability } } -func GetPartialUpdateGrafanaConfigsPayload(ctx context.Context, apiClient ObservabilityClient, instanceId, projectId string, singleSignOn, publicReadAccess *bool) (*observability.UpdateGrafanaConfigsPayload, error) { - currentConfigs, err := apiClient.GetGrafanaConfigsExecute(ctx, instanceId, projectId) +func GetPartialUpdateGrafanaConfigsPayload(ctx context.Context, apiClient observability.DefaultAPI, instanceId, projectId string, singleSignOn, publicReadAccess *bool) (*observability.UpdateGrafanaConfigsPayload, error) { + currentConfigs, err := apiClient.GetGrafanaConfigs(ctx, instanceId, projectId).Execute() if err != nil { return nil, fmt.Errorf("get current Grafana configs: %w", err) } diff --git a/internal/pkg/services/observability/utils/utils_test.go b/internal/pkg/services/observability/utils/utils_test.go index 18919db62..12ffaca07 100644 --- a/internal/pkg/services/observability/utils/utils_test.go +++ b/internal/pkg/services/observability/utils/utils_test.go @@ -10,11 +10,10 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/observability" + observability "github.com/stackitcloud/stackit-sdk-go/services/observability/v1api" ) var ( - testClient = &observability.APIClient{} testProjectId = uuid.NewString() testInstanceId = uuid.NewString() testPlanId = uuid.NewString() @@ -26,34 +25,34 @@ const ( ) var testPlansResponse = observability.PlansResponse{ - Plans: &[]observability.Plan{ + Plans: []observability.Plan{ { - Id: utils.Ptr(testPlanId), + Id: testPlanId, Name: utils.Ptr(testPlanName), }, }, } func fixtureGetScrapeConfigResponse(mods ...func(*observability.GetScrapeConfigResponse)) *observability.GetScrapeConfigResponse { - number := int64(1) + number := int32(1) resp := &observability.GetScrapeConfigResponse{ - Data: &observability.Job{ + Data: observability.Job{ BasicAuth: &observability.BasicAuth{ - Username: utils.Ptr("username"), - Password: utils.Ptr("password"), + Username: "username", + Password: "password", }, BearerToken: utils.Ptr("bearerToken"), HonorLabels: utils.Ptr(true), HonorTimeStamps: utils.Ptr(true), MetricsPath: utils.Ptr("/metrics"), - MetricsRelabelConfigs: &[]observability.MetricsRelabelConfig{ + MetricsRelabelConfigs: []observability.MetricsRelabelConfig{ { - Action: observability.METRICSRELABELCONFIGACTION_REPLACE.Ptr(), + Action: observability.ACTION_REPLACE.Ptr(), Modulus: &number, Regex: utils.Ptr("regex"), Replacement: utils.Ptr("replacement"), Separator: utils.Ptr("separator"), - SourceLabels: &[]string{"sourceLabel"}, + SourceLabels: []string{"sourceLabel"}, TargetLabel: utils.Ptr("targetLabel"), }, }, @@ -62,16 +61,16 @@ func fixtureGetScrapeConfigResponse(mods ...func(*observability.GetScrapeConfigR "key2": {}, }, SampleLimit: &number, - Scheme: observability.JOBSCHEME_HTTP.Ptr(), - ScrapeInterval: utils.Ptr("interval"), - ScrapeTimeout: utils.Ptr("timeout"), - StaticConfigs: &[]observability.StaticConfigs{ + Scheme: observability.SCHEME_HTTP.Ptr(), + ScrapeInterval: "interval", + ScrapeTimeout: "timeout", + StaticConfigs: []observability.StaticConfigs{ { Labels: &map[string]string{ "label": "value", "label2": "value2", }, - Targets: &[]string{"target"}, + Targets: []string{"target"}, }, }, TlsConfig: &observability.TLSConfig{ @@ -89,43 +88,43 @@ func fixtureGetScrapeConfigResponse(mods ...func(*observability.GetScrapeConfigR func fixtureUpdateScrapeConfigPayload(mods ...func(*observability.UpdateScrapeConfigPayload)) *observability.UpdateScrapeConfigPayload { payload := &observability.UpdateScrapeConfigPayload{ - BasicAuth: &observability.PartialUpdateScrapeConfigsRequestInnerBasicAuth{ + BasicAuth: &observability.UpdateScrapeConfigPayloadBasicAuth{ Username: utils.Ptr("username"), Password: utils.Ptr("password"), }, BearerToken: utils.Ptr("bearerToken"), HonorLabels: utils.Ptr(true), HonorTimeStamps: utils.Ptr(true), - MetricsPath: utils.Ptr("/metrics"), - MetricsRelabelConfigs: &[]observability.PartialUpdateScrapeConfigsRequestInnerMetricsRelabelConfigsInner{ + MetricsPath: "/metrics", + MetricsRelabelConfigs: []observability.UpdateScrapeConfigPayloadMetricsRelabelConfigsInner{ { - Action: observability.PartialUpdateScrapeConfigsRequestInnerMetricsRelabelConfigsInnerGetActionAttributeType(utils.Ptr("replace")), - Modulus: utils.Ptr(1.0), + Action: observability.UpdateScrapeConfigPayloadMetricsRelabelConfigsInnerAction("replace").Ptr(), + Modulus: utils.Ptr(float32(1.0)), Regex: utils.Ptr("regex"), Replacement: utils.Ptr("replacement"), Separator: utils.Ptr("separator"), - SourceLabels: &[]string{"sourceLabel"}, + SourceLabels: []string{"sourceLabel"}, TargetLabel: utils.Ptr("targetLabel"), }, }, - Params: &map[string]interface{}{ + Params: map[string]interface{}{ "key": []string{"value1", "value2"}, "key2": []string{}, }, - SampleLimit: utils.Ptr(1.0), - Scheme: observability.UPDATESCRAPECONFIGPAYLOADSCHEME_HTTP.Ptr(), - ScrapeInterval: utils.Ptr("interval"), - ScrapeTimeout: utils.Ptr("timeout"), - StaticConfigs: &[]observability.UpdateScrapeConfigPayloadStaticConfigsInner{ + SampleLimit: utils.Ptr(float32(1.0)), + Scheme: observability.UPDATESCRAPECONFIGPAYLOADSCHEME_HTTP, + ScrapeInterval: "interval", + ScrapeTimeout: "timeout", + StaticConfigs: []observability.UpdateScrapeConfigPayloadStaticConfigsInner{ { - Labels: &map[string]interface{}{ + Labels: map[string]interface{}{ "label": "value", "label2": "value2", }, - Targets: &[]string{"target"}, + Targets: []string{"target"}, }, }, - TlsConfig: &observability.PartialUpdateScrapeConfigsRequestInnerHttpSdConfigsInnerOauth2TlsConfig{ + TlsConfig: &observability.UpdateScrapeConfigPayloadTlsConfig{ InsecureSkipVerify: utils.Ptr(true), }, } @@ -144,37 +143,36 @@ type observabilityClientMocked struct { getGrafanaConfigsResp *observability.GrafanaConfigs } -func (m *observabilityClientMocked) GetInstanceExecute(_ context.Context, _, _ string) (*observability.GetInstanceResponse, error) { - if m.getInstanceFails { - return nil, fmt.Errorf("could not get instance") - } - return m.getInstanceResp, nil -} - -func (m *observabilityClientMocked) GetGrafanaConfigsExecute(_ context.Context, _, _ string) (*observability.GrafanaConfigs, error) { - if m.getGrafanaConfigsFails { - return nil, fmt.Errorf("could not get grafana configs") +func (m *observabilityClientMocked) newMock() observability.DefaultAPI { + return observability.DefaultAPIServiceMock{ + GetInstanceExecuteMock: utils.Ptr(func(_ observability.ApiGetInstanceRequest) (*observability.GetInstanceResponse, error) { + if m.getInstanceFails { + return nil, fmt.Errorf("could not get instance") + } + return m.getInstanceResp, nil + }), + GetGrafanaConfigsExecuteMock: utils.Ptr(func(_ observability.ApiGetGrafanaConfigsRequest) (*observability.GrafanaConfigs, error) { + if m.getGrafanaConfigsFails { + return nil, fmt.Errorf("could not get grafana configs") + } + return m.getGrafanaConfigsResp, nil + }), } - return m.getGrafanaConfigsResp, nil -} - -func (c *observabilityClientMocked) UpdateGrafanaConfigs(ctx context.Context, instanceId, projectId string) observability.ApiUpdateGrafanaConfigsRequest { - return testClient.UpdateGrafanaConfigs(ctx, instanceId, projectId) } func fixtureGrafanaConfigs(mods ...func(gc *observability.GrafanaConfigs)) *observability.GrafanaConfigs { gc := observability.GrafanaConfigs{ - GenericOauth: &observability.GrafanaOauth{ - ApiUrl: utils.Ptr("apiUrl"), - AuthUrl: utils.Ptr("authUrl"), - Enabled: utils.Ptr(true), + GenericOauth: &observability.GrafanaOauth{ // nolint:gosec // false positive + ApiUrl: "apiUrl", + AuthUrl: "authUrl", + Enabled: true, Name: utils.Ptr("name"), - OauthClientId: utils.Ptr("oauthClientId"), - OauthClientSecret: utils.Ptr("oauthClientSecret"), - RoleAttributePath: utils.Ptr("roleAttributePath"), + OauthClientId: "oauthClientId", + OauthClientSecret: "oauthClientSecret", + RoleAttributePath: "roleAttributePath", RoleAttributeStrict: utils.Ptr(true), Scopes: utils.Ptr("scopes"), - TokenUrl: utils.Ptr("tokenUrl"), + TokenUrl: "tokenUrl", UsePkce: utils.Ptr(true), }, PublicReadAccess: utils.Ptr(false), @@ -216,7 +214,7 @@ func TestGetInstanceName(t *testing.T) { getInstanceResp: tt.getInstanceResp, } - output, err := GetInstanceName(context.Background(), client, testInstanceId, testProjectId) + output, err := GetInstanceName(context.Background(), client.newMock(), testInstanceId, testProjectId) if tt.isValid && err != nil { t.Errorf("failed on valid input") @@ -276,7 +274,7 @@ func TestLoadPlanId(t *testing.T) { description: "no available plans", planName: testPlanName, plansResponse: &observability.PlansResponse{ - Plans: &[]observability.Plan{}, + Plans: []observability.Plan{}, }, isValid: false, }, @@ -295,8 +293,8 @@ func TestLoadPlanId(t *testing.T) { if !tt.isValid { return } - if *output != tt.expectedOutput { - t.Errorf("expected output to be %s, got %s", tt.expectedOutput, *output) + if output != tt.expectedOutput { + t.Errorf("expected output to be %s, got %s", tt.expectedOutput, output) } }) } @@ -341,7 +339,7 @@ func TestValidatePlanId(t *testing.T) { description: "no available plans", planId: testPlanId, plansResponse: &observability.PlansResponse{ - Plans: &[]observability.Plan{}, + Plans: []observability.Plan{}, }, isValid: false, }, @@ -382,17 +380,10 @@ func TestMapToUpdateScrapeConfigPayload(t *testing.T) { resp: nil, isValid: false, }, - { - description: "nil data", - resp: &observability.GetScrapeConfigResponse{ - Data: nil, - }, - isValid: false, - }, { description: "empty data", resp: &observability.GetScrapeConfigResponse{ - Data: &observability.Job{}, + Data: observability.Job{}, }, isValid: false, }, @@ -425,37 +416,37 @@ func TestMapToUpdateScrapeConfigPayload(t *testing.T) { func TestMapMetricsRelabelConfig(t *testing.T) { tests := []struct { description string - config *[]observability.MetricsRelabelConfig - expected *[]observability.PartialUpdateScrapeConfigsRequestInnerMetricsRelabelConfigsInner + config []observability.MetricsRelabelConfig + expected *[]observability.UpdateScrapeConfigPayloadMetricsRelabelConfigsInner }{ { description: "base case", - config: &[]observability.MetricsRelabelConfig{ + config: []observability.MetricsRelabelConfig{ { - Action: observability.METRICSRELABELCONFIGACTION_REPLACE.Ptr(), - Modulus: utils.Int64Ptr(1), + Action: observability.ACTION_REPLACE.Ptr(), + Modulus: utils.Ptr(int32(1)), Regex: utils.Ptr("regex"), Replacement: utils.Ptr("replacement"), Separator: utils.Ptr("separator"), - SourceLabels: utils.Ptr([]string{"sourceLabel", "sourceLabel2"}), + SourceLabels: []string{"sourceLabel", "sourceLabel2"}, TargetLabel: utils.Ptr("targetLabel"), }, }, - expected: &[]observability.PartialUpdateScrapeConfigsRequestInnerMetricsRelabelConfigsInner{ + expected: &[]observability.UpdateScrapeConfigPayloadMetricsRelabelConfigsInner{ { - Action: observability.PARTIALUPDATESCRAPECONFIGSREQUESTINNERMETRICSRELABELCONFIGSINNERACTION_REPLACE.Ptr(), - Modulus: utils.Float64Ptr(1.0), + Action: observability.UPDATESCRAPECONFIGPAYLOADMETRICSRELABELCONFIGSINNERACTION_REPLACE.Ptr(), + Modulus: utils.Ptr(float32(1.0)), Regex: utils.Ptr("regex"), Replacement: utils.Ptr("replacement"), Separator: utils.Ptr("separator"), - SourceLabels: utils.Ptr([]string{"sourceLabel", "sourceLabel2"}), + SourceLabels: []string{"sourceLabel", "sourceLabel2"}, TargetLabel: utils.Ptr("targetLabel"), }, }, }, { description: "empty data", - config: &[]observability.MetricsRelabelConfig{}, + config: []observability.MetricsRelabelConfig{}, expected: nil, }, { @@ -469,11 +460,11 @@ func TestMapMetricsRelabelConfig(t *testing.T) { t.Run(tt.description, func(t *testing.T) { output := mapMetricsRelabelConfig(tt.config) - if tt.expected == nil && output == nil || *output == nil { + if tt.expected == nil && output == nil { return } - diff := cmp.Diff(*output, *tt.expected) + diff := cmp.Diff(output, *tt.expected) if diff != "" { t.Fatalf("Data does not match: %s", diff) } @@ -484,33 +475,33 @@ func TestMapMetricsRelabelConfig(t *testing.T) { func TestMapStaticConfig(t *testing.T) { tests := []struct { description string - config *[]observability.StaticConfigs + config []observability.StaticConfigs expected *[]observability.UpdateScrapeConfigPayloadStaticConfigsInner }{ { description: "base case", - config: &[]observability.StaticConfigs{ + config: []observability.StaticConfigs{ { Labels: &map[string]string{ "label": "value", "label2": "value2", }, - Targets: &[]string{"target", "target2"}, + Targets: []string{"target", "target2"}, }, }, expected: &[]observability.UpdateScrapeConfigPayloadStaticConfigsInner{ { - Labels: utils.Ptr(map[string]interface{}{ + Labels: map[string]interface{}{ "label": "value", "label2": "value2", - }), - Targets: utils.Ptr([]string{"target", "target2"}), + }, + Targets: []string{"target", "target2"}, }, }, }, { description: "empty data", - config: &[]observability.StaticConfigs{}, + config: []observability.StaticConfigs{}, expected: nil, }, { @@ -524,11 +515,11 @@ func TestMapStaticConfig(t *testing.T) { t.Run(tt.description, func(t *testing.T) { output := mapStaticConfig(tt.config) - if tt.expected == nil && (output == nil || *output == nil) { + if tt.expected == nil && output == nil { return } - diff := cmp.Diff(*output, *tt.expected) + diff := cmp.Diff(output, *tt.expected) if diff != "" { t.Fatalf("Data does not match: %s", diff) } @@ -540,15 +531,15 @@ func TestMapBasicAuth(t *testing.T) { tests := []struct { description string auth *observability.BasicAuth - expected *observability.PartialUpdateScrapeConfigsRequestInnerBasicAuth + expected *observability.UpdateScrapeConfigPayloadBasicAuth }{ { description: "base case", auth: &observability.BasicAuth{ - Username: utils.Ptr("username"), - Password: utils.Ptr("password"), + Username: "username", + Password: "password", }, - expected: &observability.PartialUpdateScrapeConfigsRequestInnerBasicAuth{ + expected: &observability.UpdateScrapeConfigPayloadBasicAuth{ Username: utils.Ptr("username"), Password: utils.Ptr("password"), }, @@ -556,7 +547,7 @@ func TestMapBasicAuth(t *testing.T) { { description: "empty data", auth: &observability.BasicAuth{}, - expected: &observability.PartialUpdateScrapeConfigsRequestInnerBasicAuth{}, + expected: &observability.UpdateScrapeConfigPayloadBasicAuth{}, }, { description: "nil", @@ -585,21 +576,21 @@ func TestMapTlsConfig(t *testing.T) { tests := []struct { description string config *observability.TLSConfig - expected *observability.PartialUpdateScrapeConfigsRequestInnerHttpSdConfigsInnerOauth2TlsConfig + expected *observability.UpdateScrapeConfigPayloadTlsConfig }{ { description: "base case", config: &observability.TLSConfig{ InsecureSkipVerify: utils.Ptr(true), }, - expected: &observability.PartialUpdateScrapeConfigsRequestInnerHttpSdConfigsInnerOauth2TlsConfig{ + expected: &observability.UpdateScrapeConfigPayloadTlsConfig{ InsecureSkipVerify: utils.Ptr(true), }, }, { description: "empty data", config: &observability.TLSConfig{}, - expected: &observability.PartialUpdateScrapeConfigsRequestInnerHttpSdConfigsInnerOauth2TlsConfig{}, + expected: &observability.UpdateScrapeConfigPayloadTlsConfig{}, }, { description: "nil", @@ -708,30 +699,30 @@ func TestToPayloadGenericOAuth(t *testing.T) { }{ { description: "base", - response: &observability.GrafanaOauth{ - ApiUrl: utils.Ptr("apiUrl"), - AuthUrl: utils.Ptr("authUrl"), - Enabled: utils.Ptr(true), + response: &observability.GrafanaOauth{ // nolint:gosec // false positive + ApiUrl: "apiUrl", + AuthUrl: "authUrl", + Enabled: true, Name: utils.Ptr("name"), - OauthClientId: utils.Ptr("oauthClientId"), - OauthClientSecret: utils.Ptr("oauthClientSecret"), - RoleAttributePath: utils.Ptr("roleAttributePath"), + OauthClientId: "oauthClientId", + OauthClientSecret: "oauthClientSecret", + RoleAttributePath: "roleAttributePath", RoleAttributeStrict: utils.Ptr(true), Scopes: utils.Ptr("scopes"), - TokenUrl: utils.Ptr("tokenUrl"), + TokenUrl: "tokenUrl", UsePkce: utils.Ptr(true), }, - expected: &observability.UpdateGrafanaConfigsPayloadGenericOauth{ - ApiUrl: utils.Ptr("apiUrl"), - AuthUrl: utils.Ptr("authUrl"), - Enabled: utils.Ptr(true), + expected: &observability.UpdateGrafanaConfigsPayloadGenericOauth{ // nolint:gosec // false positive + ApiUrl: "apiUrl", + AuthUrl: "authUrl", + Enabled: true, Name: utils.Ptr("name"), - OauthClientId: utils.Ptr("oauthClientId"), - OauthClientSecret: utils.Ptr("oauthClientSecret"), - RoleAttributePath: utils.Ptr("roleAttributePath"), + OauthClientId: "oauthClientId", + OauthClientSecret: "oauthClientSecret", + RoleAttributePath: "roleAttributePath", RoleAttributeStrict: utils.Ptr(true), Scopes: utils.Ptr("scopes"), - TokenUrl: utils.Ptr("tokenUrl"), + TokenUrl: "tokenUrl", UsePkce: utils.Ptr(true), }, }, @@ -875,7 +866,7 @@ func TestGetPartialUpdateGrafanaConfigsPayload(t *testing.T) { getGrafanaConfigsResp: tt.getGrafanaConfigsResp, } - payload, err := GetPartialUpdateGrafanaConfigsPayload(context.Background(), client, testInstanceId, testProjectId, tt.singleSignOn, tt.publicReadAccess) + payload, err := GetPartialUpdateGrafanaConfigsPayload(context.Background(), client.newMock(), testInstanceId, testProjectId, tt.singleSignOn, tt.publicReadAccess) if tt.isValid && err != nil { t.Errorf("failed on valid input") @@ -894,3 +885,36 @@ func TestGetPartialUpdateGrafanaConfigsPayload(t *testing.T) { }) } } + +// in internal/pkg/services/observability/utils/utils.go#mapMetricsRelabelConfig we cast from one enum to another, esure that both have the same values +func TestUpdateScrapeConfigPayloadMetricsRelabelConfigsInnerActionIsAction(t *testing.T) { + innerKeys := make(map[string]struct{}) + actionKeys := make(map[string]struct{}) + for _, innerEnumVal := range observability.AllowedUpdateScrapeConfigPayloadMetricsRelabelConfigsInnerActionEnumValues { + innerKeys[string(innerEnumVal)] = struct{}{} + } + for _, actionEnumVal := range observability.AllowedActionEnumValues { + actionKeys[string(actionEnumVal)] = struct{}{} + } + onlyInInner := make([]string, 0) + onlyInAction := make([]string, 0) + for innerKey := range innerKeys { + if _, ok := actionKeys[innerKey]; !ok { + onlyInInner = append(onlyInInner, innerKey) + } + } + for actionKey := range actionKeys { + if _, ok := innerKeys[actionKey]; !ok { + onlyInAction = append(onlyInAction, actionKey) + } + } + if len(onlyInInner) > 0 { + t.Logf("the following keys are only in AllowedUpdateScrapeConfigPayloadMetricsRelabelConfigsInnerActionEnumValues: %v", onlyInInner) + } + if len(onlyInAction) > 0 { + t.Logf("the following keys are only in AllowedActionEnumValues: %v", onlyInAction) + } + if len(onlyInInner) > 0 || len(onlyInAction) > 0 { + t.Fail() + } +} diff --git a/internal/pkg/utils/utils.go b/internal/pkg/utils/utils.go index bb2b36561..1326ec122 100644 --- a/internal/pkg/utils/utils.go +++ b/internal/pkg/utils/utils.go @@ -78,6 +78,17 @@ func ConvertInt64PToFloat64P(i *int64) *float64 { return &f } +// ConvertInt32PToFloat32P converts an int32 pointer to a float64 pointer +// This function will return nil if the input is nil +// This is a lossy conversion for i > 2^24 +func ConvertInt32PToFloat32P(i *int32) *float32 { + if i == nil { + return nil + } + f := float32(*i) + return &f +} + func ValidateURLDomain(value string) error { urlStruct, err := url.Parse(value) if err != nil { diff --git a/internal/pkg/utils/utils_test.go b/internal/pkg/utils/utils_test.go index df6a6c414..1fdd5844d 100644 --- a/internal/pkg/utils/utils_test.go +++ b/internal/pkg/utils/utils_test.go @@ -1,12 +1,13 @@ package utils import ( + "fmt" "reflect" "testing" - sdkConfig "github.com/stackitcloud/stackit-sdk-go/core/config" - "github.com/spf13/viper" + sdkConfig "github.com/stackitcloud/stackit-sdk-go/core/config" + "github.com/stackitcloud/stackit-sdk-go/core/utils" "github.com/stackitcloud/stackit-cli/internal/pkg/config" ) @@ -53,6 +54,57 @@ func TestConvertInt64PToFloat64P(t *testing.T) { } } +func TestConvertInt32PToFloat64P(t *testing.T) { + tests := []struct { + name string + input *int32 + expected *float32 + }{ + { + name: "positive", + input: utils.Ptr(int32(1)), + expected: utils.Ptr(float32(1)), + }, + { + name: "negative", + input: utils.Ptr(int32(-1)), + expected: utils.Ptr(float32(-1)), + }, + { + name: "zero", + input: utils.Ptr(int32(0)), + expected: utils.Ptr(float32(0)), + }, + { + name: "nil", + input: nil, + expected: nil, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + expected := ConvertInt32PToFloat32P(tt.input) + + if expected == nil && tt.expected == nil && tt.input == nil { + return + } + + if *expected != *tt.expected { + t.Errorf("ConvertInt64ToFloat64() = %v, want %v", *expected, *tt.expected) + } + }) + } +} + +func TestConvertInt32PToFloat64PLossyConversion(t *testing.T) { + i := int32(900_000_001) + f := ConvertInt32PToFloat32P(&i) + s := fmt.Sprintf("%f", *f) + if s != "900000000.000000" { + t.Errorf("Expected lossy conversion of %d to %f, got %s", i, *f, s) + } +} + func TestValidateURLDomain(t *testing.T) { tests := []struct { name string From 82f6b963adced8566c99359594eb4595008c3092 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 10 Jul 2026 15:20:44 +0200 Subject: [PATCH 29/44] chore(deps): bump github.com/stackitcloud/stackit-sdk-go/services/logme (#1470) --- go.mod | 2 +- go.sum | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/go.mod b/go.mod index af9f8855a..557d358b8 100644 --- a/go.mod +++ b/go.mod @@ -266,7 +266,7 @@ require ( github.com/spf13/cast v1.10.0 // indirect github.com/stackitcloud/stackit-sdk-go/services/kms v1.11.0 github.com/stackitcloud/stackit-sdk-go/services/loadbalancer v1.14.0 - github.com/stackitcloud/stackit-sdk-go/services/logme v0.30.0 + github.com/stackitcloud/stackit-sdk-go/services/logme v1.0.1 github.com/stackitcloud/stackit-sdk-go/services/mariadb v0.30.0 github.com/stackitcloud/stackit-sdk-go/services/objectstorage v1.9.0 github.com/stackitcloud/stackit-sdk-go/services/observability v0.24.0 diff --git a/go.sum b/go.sum index 5a15155a2..c083ea3b5 100644 --- a/go.sum +++ b/go.sum @@ -612,8 +612,8 @@ github.com/stackitcloud/stackit-sdk-go/services/kms v1.11.0 h1:OrUaDypQNr1nOXZfV github.com/stackitcloud/stackit-sdk-go/services/kms v1.11.0/go.mod h1:pVaCmb1ZHAPGVRlSlBlVOjThp9Tb2sX9+nRX0M+d1KU= github.com/stackitcloud/stackit-sdk-go/services/loadbalancer v1.14.0 h1:1dvL7tX91ziklayQmOupniE3jM4D5Nbtc0auNcx2p18= github.com/stackitcloud/stackit-sdk-go/services/loadbalancer v1.14.0/go.mod h1:+Ld3dn648I+YKcBV3fEkYpDSr3fel421+LurJGywSBs= -github.com/stackitcloud/stackit-sdk-go/services/logme v0.30.0 h1:csZlzmvAB+klgUQo7AjoGO+YkpdxRFY3yE5Y7SDeB5w= -github.com/stackitcloud/stackit-sdk-go/services/logme v0.30.0/go.mod h1:JDOOYaGgcBts2x52nKPRMFgSZe7qqOFmfz1xIXCQgRY= +github.com/stackitcloud/stackit-sdk-go/services/logme v1.0.1 h1:iteL61eMMPWT6872nF4Ko/tBU1IXemvS++XR09pj6NA= +github.com/stackitcloud/stackit-sdk-go/services/logme v1.0.1/go.mod h1:JDOOYaGgcBts2x52nKPRMFgSZe7qqOFmfz1xIXCQgRY= github.com/stackitcloud/stackit-sdk-go/services/logs v0.5.2 h1:vr4atxFRT+EL+DqONMT5R44f7AzEMbePa9U7PEE0THU= github.com/stackitcloud/stackit-sdk-go/services/logs v0.5.2/go.mod h1:CAPsiTX7osAImfrG5RnIjaJ/Iz3QpoBKuH2fS346wuQ= github.com/stackitcloud/stackit-sdk-go/services/mariadb v0.30.0 h1:LFIH1wAp633ZAJw/7H3F4nq1DZe0Qu3rlDeXhobZEZA= @@ -622,8 +622,6 @@ github.com/stackitcloud/stackit-sdk-go/services/mongodbflex v1.5.8 h1:S7t4wcT6SN github.com/stackitcloud/stackit-sdk-go/services/mongodbflex v1.5.8/go.mod h1:CdrhFUsBO7/iJleCc2yQjDChIbG6YaxKNBQRNCjgcF4= github.com/stackitcloud/stackit-sdk-go/services/objectstorage v1.9.0 h1:T+ll3lS0Kn18d8hTOrVAMKcQrXiab+Cuj0cTnAYHmj0= github.com/stackitcloud/stackit-sdk-go/services/objectstorage v1.9.0/go.mod h1:QsPtoqAYvumyPU6ToX/5j1PbudN+VSTuvh6mp154ecM= -github.com/stackitcloud/stackit-sdk-go/services/observability v0.17.0 h1:LGwCvvST0fwUgZ6bOxYIfu45qqTgv421ZS07UhKjZL8= -github.com/stackitcloud/stackit-sdk-go/services/observability v0.17.0/go.mod h1:9KdrXC5JS30Ay3mR0adb3vNdhca+qxiy/cPF5P4wehQ= github.com/stackitcloud/stackit-sdk-go/services/observability v0.24.0 h1:KhuWPXr1hl8BFLGLSi6wjxh5o6OQXH9amfquMhYQROU= github.com/stackitcloud/stackit-sdk-go/services/observability v0.24.0/go.mod h1:0fEZQHm729mBdvg4sNrAhM6KmHROHJSeS2FwCMRk46k= github.com/stackitcloud/stackit-sdk-go/services/opensearch v0.24.6 h1:oTVx1+O177Ojn8OvXIOUbRSwtx7L59jhxDPrZEQFOfQ= From f4e58587b1abafd34f57e93d97430b32e00cbaf3 Mon Sep 17 00:00:00 2001 From: Jonas Schlecht <73650029+SerseusWasTaken@users.noreply.github.com> Date: Mon, 13 Jul 2026 14:20:02 +0200 Subject: [PATCH 30/44] feat(mongodbflex): migrate to v2 API (#1467) relates to STACKITCLI-379 --- docs/stackit_mongodbflex_instance_create.md | 4 +- docs/stackit_mongodbflex_instance_update.md | 4 +- go.mod | 2 +- go.sum | 4 +- .../mongodbflex/backup/describe/describe.go | 15 +- .../backup/describe/describe_test.go | 14 +- internal/cmd/mongodbflex/backup/list/list.go | 10 +- .../cmd/mongodbflex/backup/list/list_test.go | 8 +- .../backup/restore-jobs/restore_jobs.go | 21 +- .../backup/restore-jobs/restore_jobs_test.go | 15 +- .../cmd/mongodbflex/backup/restore/restore.go | 20 +- .../backup/restore/restore_test.go | 18 +- .../mongodbflex/backup/schedule/schedule.go | 4 +- .../backup/schedule/schedule_test.go | 8 +- .../backup/update-schedule/update_schedule.go | 59 +-- .../update-schedule/update_schedule_test.go | 42 +-- .../cmd/mongodbflex/instance/create/create.go | 79 ++-- .../instance/create/create_test.go | 350 +++++++++--------- .../cmd/mongodbflex/instance/delete/delete.go | 10 +- .../instance/delete/delete_test.go | 8 +- .../mongodbflex/instance/describe/describe.go | 14 +- .../instance/describe/describe_test.go | 8 +- .../cmd/mongodbflex/instance/list/list.go | 6 +- .../mongodbflex/instance/list/list_test.go | 8 +- .../cmd/mongodbflex/instance/update/update.go | 42 +-- .../instance/update/update_test.go | 113 +++--- internal/cmd/mongodbflex/options/options.go | 41 +- .../cmd/mongodbflex/options/options_test.go | 121 +++--- .../cmd/mongodbflex/user/create/create.go | 12 +- .../mongodbflex/user/create/create_test.go | 16 +- .../cmd/mongodbflex/user/delete/delete.go | 8 +- .../mongodbflex/user/delete/delete_test.go | 8 +- .../cmd/mongodbflex/user/describe/describe.go | 6 +- .../user/describe/describe_test.go | 8 +- internal/cmd/mongodbflex/user/list/list.go | 8 +- .../cmd/mongodbflex/user/list/list_test.go | 8 +- .../user/reset-password/reset_password.go | 8 +- .../reset-password/reset_password_test.go | 8 +- .../cmd/mongodbflex/user/update/update.go | 17 +- .../mongodbflex/user/update/update_test.go | 14 +- .../pkg/services/mongodbflex/client/client.go | 2 +- .../pkg/services/mongodbflex/utils/utils.go | 41 +- .../services/mongodbflex/utils/utils_test.go | 155 ++++---- 43 files changed, 694 insertions(+), 673 deletions(-) diff --git a/docs/stackit_mongodbflex_instance_create.md b/docs/stackit_mongodbflex_instance_create.md index 773482bfb..13b67ea65 100644 --- a/docs/stackit_mongodbflex_instance_create.md +++ b/docs/stackit_mongodbflex_instance_create.md @@ -28,11 +28,11 @@ stackit mongodbflex instance create [flags] ``` --acl strings The access control list (ACL). Must contain at least one valid subnet, for instance '0.0.0.0/0' for open access (discouraged), '1.2.3.0/24 for a public IP range of an organization, '1.2.3.4/32' for a single IP range, etc. (default []) --backup-schedule string Backup schedule (default "0 0/6 * * *") - --cpu int Number of CPUs + --cpu int32 Number of CPUs --flavor-id string ID of the flavor -h, --help Help for "stackit mongodbflex instance create" -n, --name string Instance name - --ram int Amount of RAM (in GB) + --ram int32 Amount of RAM (in GB) --storage-class string Storage class (default "premium-perf2-mongodb") --storage-size int Storage size (in GB) (default 10) --type string Instance type, (one of: [Replica, Sharded, Single]) (default "Replica") diff --git a/docs/stackit_mongodbflex_instance_update.md b/docs/stackit_mongodbflex_instance_update.md index 47c253766..44921ddd8 100644 --- a/docs/stackit_mongodbflex_instance_update.md +++ b/docs/stackit_mongodbflex_instance_update.md @@ -25,11 +25,11 @@ stackit mongodbflex instance update INSTANCE_ID [flags] ``` --acl strings Lists of IP networks in CIDR notation which are allowed to access this instance (default []) --backup-schedule string Backup schedule - --cpu int Number of CPUs + --cpu int32 Number of CPUs --flavor-id string ID of the flavor -h, --help Help for "stackit mongodbflex instance update" -n, --name string Instance name - --ram int Amount of RAM (in GB) + --ram int32 Amount of RAM (in GB) --storage-class string Storage class --storage-size int Storage size (in GB) --type string Instance type, (one of: [Replica, Sharded, Single]) diff --git a/go.mod b/go.mod index 557d358b8..ee06a565d 100644 --- a/go.mod +++ b/go.mod @@ -25,7 +25,7 @@ require ( github.com/stackitcloud/stackit-sdk-go/services/iaas v1.12.0 github.com/stackitcloud/stackit-sdk-go/services/intake v0.7.1 github.com/stackitcloud/stackit-sdk-go/services/logs v0.5.2 - github.com/stackitcloud/stackit-sdk-go/services/mongodbflex v1.5.8 + github.com/stackitcloud/stackit-sdk-go/services/mongodbflex v1.12.0 github.com/stackitcloud/stackit-sdk-go/services/opensearch v0.24.6 github.com/stackitcloud/stackit-sdk-go/services/postgresflex v1.3.5 github.com/stackitcloud/stackit-sdk-go/services/resourcemanager v0.24.0 diff --git a/go.sum b/go.sum index c083ea3b5..5ec138a79 100644 --- a/go.sum +++ b/go.sum @@ -618,8 +618,8 @@ github.com/stackitcloud/stackit-sdk-go/services/logs v0.5.2 h1:vr4atxFRT+EL+DqON github.com/stackitcloud/stackit-sdk-go/services/logs v0.5.2/go.mod h1:CAPsiTX7osAImfrG5RnIjaJ/Iz3QpoBKuH2fS346wuQ= github.com/stackitcloud/stackit-sdk-go/services/mariadb v0.30.0 h1:LFIH1wAp633ZAJw/7H3F4nq1DZe0Qu3rlDeXhobZEZA= github.com/stackitcloud/stackit-sdk-go/services/mariadb v0.30.0/go.mod h1:joa89Y1dyn0j22FstRcIKfW2ada3FDxNfttxSvq27uY= -github.com/stackitcloud/stackit-sdk-go/services/mongodbflex v1.5.8 h1:S7t4wcT6SN8ZzdoY8d6VbF903zFpGjzqrU0FN27rJPg= -github.com/stackitcloud/stackit-sdk-go/services/mongodbflex v1.5.8/go.mod h1:CdrhFUsBO7/iJleCc2yQjDChIbG6YaxKNBQRNCjgcF4= +github.com/stackitcloud/stackit-sdk-go/services/mongodbflex v1.12.0 h1:SVd3WMmLAE0Jxk2SaRuM85DTOOXHycyMpZGx9vzqNkI= +github.com/stackitcloud/stackit-sdk-go/services/mongodbflex v1.12.0/go.mod h1:0hHEPiOEMAA23EzEl42Rm3FlyKIzkW+LWLvDkuFTZ+Q= github.com/stackitcloud/stackit-sdk-go/services/objectstorage v1.9.0 h1:T+ll3lS0Kn18d8hTOrVAMKcQrXiab+Cuj0cTnAYHmj0= github.com/stackitcloud/stackit-sdk-go/services/objectstorage v1.9.0/go.mod h1:QsPtoqAYvumyPU6ToX/5j1PbudN+VSTuvh6mp154ecM= github.com/stackitcloud/stackit-sdk-go/services/observability v0.24.0 h1:KhuWPXr1hl8BFLGLSi6wjxh5o6OQXH9amfquMhYQROU= diff --git a/internal/cmd/mongodbflex/backup/describe/describe.go b/internal/cmd/mongodbflex/backup/describe/describe.go index 1e34a88ee..5897bc04f 100644 --- a/internal/cmd/mongodbflex/backup/describe/describe.go +++ b/internal/cmd/mongodbflex/backup/describe/describe.go @@ -7,7 +7,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/types" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex" + mongodbflex "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex/v2api" "github.com/stackitcloud/stackit-cli/internal/pkg/args" "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -61,7 +61,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return err } - instanceLabel, err := mongoUtils.GetInstanceName(ctx, apiClient, model.ProjectId, model.InstanceId, model.Region) + instanceLabel, err := mongoUtils.GetInstanceName(ctx, apiClient.DefaultAPI, model.ProjectId, model.InstanceId, model.Region) if err != nil { params.Printer.Debug(print.ErrorLevel, "get instance name: %v", err) instanceLabel = model.InstanceId @@ -75,13 +75,13 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return fmt.Errorf("describe backup for MongoDB Flex instance: %w", err) } - restoreJobs, err := apiClient.ListRestoreJobs(ctx, model.ProjectId, model.InstanceId, model.Region).Execute() + restoreJobs, err := apiClient.DefaultAPI.ListRestoreJobs(ctx, model.ProjectId, model.InstanceId, model.Region).Execute() if err != nil { return fmt.Errorf("get restore jobs for MongoDB Flex instance %q: %w", instanceLabel, err) } restoreJobState := mongoUtils.GetRestoreStatus(model.BackupId, restoreJobs) - return outputResult(params.Printer, model.OutputFormat, restoreJobState, *resp.Item) + return outputResult(params.Printer, model.OutputFormat, restoreJobState, resp.Item) }, } configureFlags(cmd) @@ -114,12 +114,15 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *mongodbflex.APIClient) mongodbflex.ApiGetBackupRequest { - req := apiClient.GetBackup(ctx, model.ProjectId, model.InstanceId, model.BackupId, model.Region) + req := apiClient.DefaultAPI.GetBackup(ctx, model.ProjectId, model.InstanceId, model.BackupId, model.Region) return req } -func outputResult(p *print.Printer, outputFormat, restoreStatus string, backup mongodbflex.Backup) error { +func outputResult(p *print.Printer, outputFormat, restoreStatus string, backup *mongodbflex.Backup) error { return p.OutputResult(outputFormat, backup, func() error { + if backup == nil { + return fmt.Errorf("API response is nil") + } table := tables.NewTable() table.AddRow("ID", utils.PtrString(backup.Id)) table.AddSeparator() diff --git a/internal/cmd/mongodbflex/backup/describe/describe_test.go b/internal/cmd/mongodbflex/backup/describe/describe_test.go index efb05f354..cb173a533 100644 --- a/internal/cmd/mongodbflex/backup/describe/describe_test.go +++ b/internal/cmd/mongodbflex/backup/describe/describe_test.go @@ -11,7 +11,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex" + mongodbflex "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex/v2api" ) const ( @@ -22,7 +22,7 @@ const ( type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &mongodbflex.APIClient{} +var testClient = &mongodbflex.APIClient{DefaultAPI: &mongodbflex.DefaultAPIService{}} var testProjectId = uuid.NewString() var testInstanceId = uuid.NewString() @@ -65,7 +65,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *mongodbflex.ApiGetBackupRequest)) mongodbflex.ApiGetBackupRequest { - request := testClient.GetBackup(testCtx, testProjectId, testInstanceId, testBackupId, testRegion) + request := testClient.DefaultAPI.GetBackup(testCtx, testProjectId, testInstanceId, testBackupId, testRegion) for _, mod := range mods { mod(&request) } @@ -187,7 +187,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, mongodbflex.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) @@ -199,7 +199,7 @@ func TestBuildRequest(t *testing.T) { func TestOutputResult(t *testing.T) { type args struct { outputFormat string - backup mongodbflex.Backup + backup *mongodbflex.Backup restoreStatus string } tests := []struct { @@ -210,12 +210,12 @@ func TestOutputResult(t *testing.T) { { name: "empty", args: args{}, - wantErr: false, + wantErr: true, }, { name: "set backup", args: args{ - backup: mongodbflex.Backup{}, + backup: &mongodbflex.Backup{}, }, wantErr: false, }, diff --git a/internal/cmd/mongodbflex/backup/list/list.go b/internal/cmd/mongodbflex/backup/list/list.go index b75955b7a..6678b3f9e 100644 --- a/internal/cmd/mongodbflex/backup/list/list.go +++ b/internal/cmd/mongodbflex/backup/list/list.go @@ -18,7 +18,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex" + mongodbflex "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex/v2api" ) const ( @@ -63,7 +63,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return err } - instanceLabel, err := mongodbflexUtils.GetInstanceName(ctx, apiClient, model.ProjectId, *model.InstanceId, model.Region) + instanceLabel, err := mongodbflexUtils.GetInstanceName(ctx, apiClient.DefaultAPI, model.ProjectId, *model.InstanceId, model.Region) if err != nil { params.Printer.Debug(print.ErrorLevel, "get instance name: %v", err) instanceLabel = *model.InstanceId @@ -75,9 +75,9 @@ func NewCmd(params *types.CmdParams) *cobra.Command { if err != nil { return fmt.Errorf("get backups for MongoDB Flex instance %q: %w", instanceLabel, err) } - backups := utils.GetSliceFromPointer(resp.Items) + backups := resp.Items - restoreJobs, err := apiClient.ListRestoreJobs(ctx, model.ProjectId, *model.InstanceId, model.Region).Execute() + restoreJobs, err := apiClient.DefaultAPI.ListRestoreJobs(ctx, model.ProjectId, *model.InstanceId, model.Region).Execute() if err != nil { return fmt.Errorf("get restore jobs for MongoDB Flex instance %q: %w", instanceLabel, err) } @@ -128,7 +128,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, } func buildRequest(ctx context.Context, model *inputModel, apiClient *mongodbflex.APIClient) mongodbflex.ApiListBackupsRequest { - req := apiClient.ListBackups(ctx, model.ProjectId, *model.InstanceId, model.Region) + req := apiClient.DefaultAPI.ListBackups(ctx, model.ProjectId, *model.InstanceId, model.Region) return req } diff --git a/internal/cmd/mongodbflex/backup/list/list_test.go b/internal/cmd/mongodbflex/backup/list/list_test.go index c0e670d6f..92b4c8e82 100644 --- a/internal/cmd/mongodbflex/backup/list/list_test.go +++ b/internal/cmd/mongodbflex/backup/list/list_test.go @@ -12,7 +12,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex" + mongodbflex "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex/v2api" ) const ( @@ -22,7 +22,7 @@ const ( type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &mongodbflex.APIClient{} +var testClient = &mongodbflex.APIClient{DefaultAPI: &mongodbflex.DefaultAPIService{}} var testProjectId = uuid.NewString() var testInstanceId = uuid.NewString() @@ -56,7 +56,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *mongodbflex.ApiListBackupsRequest)) mongodbflex.ApiListBackupsRequest { - request := testClient.ListBackups(testCtx, testProjectId, testInstanceId, testRegion) + request := testClient.DefaultAPI.ListBackups(testCtx, testProjectId, testInstanceId, testRegion) for _, mod := range mods { mod(&request) } @@ -166,7 +166,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, mongodbflex.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/mongodbflex/backup/restore-jobs/restore_jobs.go b/internal/cmd/mongodbflex/backup/restore-jobs/restore_jobs.go index ad3bf61de..5d0968f2c 100644 --- a/internal/cmd/mongodbflex/backup/restore-jobs/restore_jobs.go +++ b/internal/cmd/mongodbflex/backup/restore-jobs/restore_jobs.go @@ -7,7 +7,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/types" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex" + mongodbflex "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex/v2api" "github.com/stackitcloud/stackit-cli/internal/pkg/args" "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -63,7 +63,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return err } - instanceLabel, err := mongodbflexUtils.GetInstanceName(ctx, apiClient, model.ProjectId, *model.InstanceId, model.Region) + instanceLabel, err := mongodbflexUtils.GetInstanceName(ctx, apiClient.DefaultAPI, model.ProjectId, *model.InstanceId, model.Region) if err != nil { params.Printer.Debug(print.ErrorLevel, "get instance name: %v", err) instanceLabel = *model.InstanceId @@ -75,18 +75,15 @@ func NewCmd(params *types.CmdParams) *cobra.Command { if err != nil { return fmt.Errorf("get restore jobs for MongoDB Flex instance %q: %w", instanceLabel, err) } - if resp.Items == nil || len(*resp.Items) == 0 { - cmd.Printf("No restore jobs found for instance %q\n", instanceLabel) - return nil - } - restoreJobs := *resp.Items + + restoreJobs := resp.GetItems() // Truncate output if model.Limit != nil && len(restoreJobs) > int(*model.Limit) { restoreJobs = restoreJobs[:*model.Limit] } - return outputResult(params.Printer, model.OutputFormat, restoreJobs) + return outputResult(params.Printer, model.OutputFormat, instanceLabel, restoreJobs) }, } @@ -127,12 +124,16 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, } func buildRequest(ctx context.Context, model *inputModel, apiClient *mongodbflex.APIClient) mongodbflex.ApiListRestoreJobsRequest { - req := apiClient.ListRestoreJobs(ctx, model.ProjectId, *model.InstanceId, model.Region) + req := apiClient.DefaultAPI.ListRestoreJobs(ctx, model.ProjectId, *model.InstanceId, model.Region) return req } -func outputResult(p *print.Printer, outputFormat string, restoreJobs []mongodbflex.RestoreInstanceStatus) error { +func outputResult(p *print.Printer, outputFormat, instanceLabel string, restoreJobs []mongodbflex.RestoreInstanceStatus) error { return p.OutputResult(outputFormat, restoreJobs, func() error { + if len(restoreJobs) == 0 { + p.Outputf("No restore jobs found for instance %q\n", instanceLabel) + return nil + } table := tables.NewTable() table.SetHeader("ID", "BACKUP ID", "BACKUP INSTANCE ID", "DATE", "STATUS") for i := range restoreJobs { diff --git a/internal/cmd/mongodbflex/backup/restore-jobs/restore_jobs_test.go b/internal/cmd/mongodbflex/backup/restore-jobs/restore_jobs_test.go index 62ded8e2a..c1f7ec279 100644 --- a/internal/cmd/mongodbflex/backup/restore-jobs/restore_jobs_test.go +++ b/internal/cmd/mongodbflex/backup/restore-jobs/restore_jobs_test.go @@ -12,7 +12,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex" + mongodbflex "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex/v2api" ) const ( @@ -22,7 +22,7 @@ const ( type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &mongodbflex.APIClient{} +var testClient = &mongodbflex.APIClient{DefaultAPI: &mongodbflex.DefaultAPIService{}} var testProjectId = uuid.NewString() var testInstanceId = uuid.NewString() @@ -56,7 +56,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *mongodbflex.ApiListRestoreJobsRequest)) mongodbflex.ApiListRestoreJobsRequest { - request := testClient.ListRestoreJobs(testCtx, testProjectId, testInstanceId, testRegion) + request := testClient.DefaultAPI.ListRestoreJobs(testCtx, testProjectId, testInstanceId, testRegion) for _, mod := range mods { mod(&request) } @@ -166,7 +166,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, mongodbflex.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) @@ -177,8 +177,9 @@ func TestBuildRequest(t *testing.T) { func TestOutputResult(t *testing.T) { type args struct { - outputFormat string - restoreJobs []mongodbflex.RestoreInstanceStatus + outputFormat string + instanceLabel string + restoreJobs []mongodbflex.RestoreInstanceStatus } tests := []struct { name string @@ -208,7 +209,7 @@ func TestOutputResult(t *testing.T) { params := testparams.NewTestParams() for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - if err := outputResult(params.Printer, tt.args.outputFormat, tt.args.restoreJobs); (err != nil) != tt.wantErr { + if err := outputResult(params.Printer, tt.args.outputFormat, tt.args.instanceLabel, tt.args.restoreJobs); (err != nil) != tt.wantErr { t.Errorf("outputResult() error = %v, wantErr %v", err, tt.wantErr) } }) diff --git a/internal/cmd/mongodbflex/backup/restore/restore.go b/internal/cmd/mongodbflex/backup/restore/restore.go index 25171f7cb..9c6768652 100644 --- a/internal/cmd/mongodbflex/backup/restore/restore.go +++ b/internal/cmd/mongodbflex/backup/restore/restore.go @@ -17,8 +17,8 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/spinner" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex" - "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex/wait" + mongodbflex "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex/v2api" + wait "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex/v2api/wait" ) const ( @@ -71,7 +71,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return err } - instanceLabel, err := mongodbUtils.GetInstanceName(ctx, apiClient, model.ProjectId, model.InstanceId, model.Region) + instanceLabel, err := mongodbUtils.GetInstanceName(ctx, apiClient.DefaultAPI, model.ProjectId, model.InstanceId, model.Region) if err != nil { params.Printer.Debug(print.ErrorLevel, "get instance name: %v", err) instanceLabel = model.ProjectId @@ -100,7 +100,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { if !model.Async { err := spinner.Run(params.Printer, "Restoring instance", func() error { - _, err = wait.RestoreInstanceWaitHandler(ctx, apiClient, model.ProjectId, model.InstanceId, model.BackupId, model.Region).WaitWithContext(ctx) + _, err = wait.RestoreInstanceWaitHandler(ctx, apiClient.DefaultAPI, model.ProjectId, model.InstanceId, model.BackupId, model.Region).WaitWithContext(ctx) return err }) if err != nil { @@ -125,7 +125,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { if !model.Async { err := spinner.Run(params.Printer, "Cloning instance", func() error { - _, err = wait.CloneInstanceWaitHandler(ctx, apiClient, model.ProjectId, model.InstanceId, model.Region).WaitWithContext(ctx) + _, err = wait.CloneInstanceWaitHandler(ctx, apiClient.DefaultAPI, model.ProjectId, model.InstanceId, model.Region).WaitWithContext(ctx) return err }) if err != nil { @@ -183,19 +183,19 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, } func buildRestoreRequest(ctx context.Context, model *inputModel, apiClient *mongodbflex.APIClient) mongodbflex.ApiRestoreInstanceRequest { - req := apiClient.RestoreInstance(ctx, model.ProjectId, model.InstanceId, model.Region) + req := apiClient.DefaultAPI.RestoreInstance(ctx, model.ProjectId, model.InstanceId, model.Region) req = req.RestoreInstancePayload(mongodbflex.RestoreInstancePayload{ - BackupId: &model.BackupId, - InstanceId: &model.BackupInstanceId, + BackupId: model.BackupId, + InstanceId: model.BackupInstanceId, }) return req } func buildCloneRequest(ctx context.Context, model *inputModel, apiClient *mongodbflex.APIClient) mongodbflex.ApiCloneInstanceRequest { - req := apiClient.CloneInstance(ctx, model.ProjectId, model.InstanceId, model.Region) + req := apiClient.DefaultAPI.CloneInstance(ctx, model.ProjectId, model.InstanceId, model.Region) req = req.CloneInstancePayload(mongodbflex.CloneInstancePayload{ Timestamp: &model.Timestamp, - InstanceId: &model.BackupInstanceId, + InstanceId: model.BackupInstanceId, }) return req } diff --git a/internal/cmd/mongodbflex/backup/restore/restore_test.go b/internal/cmd/mongodbflex/backup/restore/restore_test.go index 1fed3553f..e1bc0639d 100644 --- a/internal/cmd/mongodbflex/backup/restore/restore_test.go +++ b/internal/cmd/mongodbflex/backup/restore/restore_test.go @@ -11,7 +11,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex" + mongodbflex "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex/v2api" ) type testCtxKey struct{} @@ -23,7 +23,7 @@ const ( ) var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &mongodbflex.APIClient{} +var testClient = &mongodbflex.APIClient{DefaultAPI: &mongodbflex.DefaultAPIService{}} var testProjectId = uuid.NewString() var testInstanceId = uuid.NewString() @@ -61,10 +61,10 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRestoreRequest(mods ...func(request mongodbflex.ApiRestoreInstanceRequest)) mongodbflex.ApiRestoreInstanceRequest { - request := testClient.RestoreInstance(testCtx, testProjectId, testInstanceId, testRegion) + request := testClient.DefaultAPI.RestoreInstance(testCtx, testProjectId, testInstanceId, testRegion) request = request.RestoreInstancePayload(mongodbflex.RestoreInstancePayload{ - BackupId: utils.Ptr(testBackupId), - InstanceId: utils.Ptr(testBackupInstanceId), + BackupId: testBackupId, + InstanceId: testBackupInstanceId, }) for _, mod := range mods { mod(request) @@ -73,10 +73,10 @@ func fixtureRestoreRequest(mods ...func(request mongodbflex.ApiRestoreInstanceRe } func fixtureCloneRequest(mods ...func(request mongodbflex.ApiCloneInstanceRequest)) mongodbflex.ApiCloneInstanceRequest { - request := testClient.CloneInstance(testCtx, testProjectId, testInstanceId, testRegion) + request := testClient.DefaultAPI.CloneInstance(testCtx, testProjectId, testInstanceId, testRegion) request = request.CloneInstancePayload(mongodbflex.CloneInstancePayload{ Timestamp: utils.Ptr(testTimestamp), - InstanceId: utils.Ptr(testBackupInstanceId), + InstanceId: testBackupInstanceId, }) for _, mod := range mods { mod(request) @@ -195,7 +195,7 @@ func TestBuildRestoreRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx)) + cmpopts.EquateComparable(testCtx, mongodbflex.DefaultAPIService{})) if diff != "" { t.Fatalf("Data does not match: %s", diff) } @@ -225,7 +225,7 @@ func TestBuildCloneRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx)) + cmpopts.EquateComparable(testCtx, mongodbflex.DefaultAPIService{})) if diff != "" { t.Fatalf("Data does not match: %s", diff) } diff --git a/internal/cmd/mongodbflex/backup/schedule/schedule.go b/internal/cmd/mongodbflex/backup/schedule/schedule.go index 32d22a094..aff91fc43 100644 --- a/internal/cmd/mongodbflex/backup/schedule/schedule.go +++ b/internal/cmd/mongodbflex/backup/schedule/schedule.go @@ -7,7 +7,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/types" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex" + mongodbflex "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex/v2api" "github.com/stackitcloud/stackit-cli/internal/pkg/args" "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -92,7 +92,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, } func buildRequest(ctx context.Context, model *inputModel, apiClient *mongodbflex.APIClient) mongodbflex.ApiGetInstanceRequest { - req := apiClient.GetInstance(ctx, model.ProjectId, model.InstanceId, model.Region) + req := apiClient.DefaultAPI.GetInstance(ctx, model.ProjectId, model.InstanceId, model.Region) return req } diff --git a/internal/cmd/mongodbflex/backup/schedule/schedule_test.go b/internal/cmd/mongodbflex/backup/schedule/schedule_test.go index 342a31e0f..8b274ed8b 100644 --- a/internal/cmd/mongodbflex/backup/schedule/schedule_test.go +++ b/internal/cmd/mongodbflex/backup/schedule/schedule_test.go @@ -11,7 +11,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex" + mongodbflex "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex/v2api" ) const ( @@ -21,7 +21,7 @@ const ( type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &mongodbflex.APIClient{} +var testClient = &mongodbflex.APIClient{DefaultAPI: &mongodbflex.DefaultAPIService{}} var testProjectId = uuid.NewString() var testInstanceId = uuid.NewString() @@ -53,7 +53,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *mongodbflex.ApiGetInstanceRequest)) mongodbflex.ApiGetInstanceRequest { - request := testClient.GetInstance(testCtx, testProjectId, testInstanceId, testRegion) + request := testClient.DefaultAPI.GetInstance(testCtx, testProjectId, testInstanceId, testRegion) for _, mod := range mods { mod(&request) } @@ -149,7 +149,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, mongodbflex.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/mongodbflex/backup/update-schedule/update_schedule.go b/internal/cmd/mongodbflex/backup/update-schedule/update_schedule.go index 9730a8621..b089c8d48 100644 --- a/internal/cmd/mongodbflex/backup/update-schedule/update_schedule.go +++ b/internal/cmd/mongodbflex/backup/update-schedule/update_schedule.go @@ -8,7 +8,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/types" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex" + mongodbflex "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex/v2api" "github.com/stackitcloud/stackit-cli/internal/pkg/args" cliErr "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -31,11 +31,11 @@ const ( // Default values for the backup schedule options defaultBackupSchedule = "0 0/6 * * *" - defaultSnapshotRetentionDays int64 = 3 - defaultDailySnapshotRetentionDays int64 = 0 - defaultWeeklySnapshotRetentionWeeks int64 = 3 - defaultMonthlySnapshotRetentionMonths int64 = 1 - defaultPointInTimeWindowHours int64 = 30 + defaultSnapshotRetentionDays int32 = 3 + defaultDailySnapshotRetentionDays int32 = 0 + defaultWeeklySnapshotRetentionWeeks int32 = 3 + defaultMonthlySnapshotRetentionMonths int32 = 1 + defaultPointInTimeWindowHours int32 = 30 ) type inputModel struct { @@ -43,10 +43,10 @@ type inputModel struct { InstanceId *string BackupSchedule *string - SnapshotRetentionDays *int64 - DailySnaphotRetentionDays *int64 - WeeklySnapshotRetentionWeeks *int64 - MonthlySnapshotRetentionMonths *int64 + SnapshotRetentionDays *int32 + DailySnaphotRetentionDays *int32 + WeeklySnapshotRetentionWeeks *int32 + MonthlySnapshotRetentionMonths *int32 } func NewCmd(params *types.CmdParams) *cobra.Command { @@ -83,7 +83,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return err } - instanceLabel, err := mongoDBflexUtils.GetInstanceName(ctx, apiClient, model.ProjectId, *model.InstanceId, model.Region) + instanceLabel, err := mongoDBflexUtils.GetInstanceName(ctx, apiClient.DefaultAPI, model.ProjectId, *model.InstanceId, model.Region) if err != nil { params.Printer.Debug(print.ErrorLevel, "get instance name: %v", err) instanceLabel = *model.InstanceId @@ -138,10 +138,10 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, } schedule := flags.FlagToStringPointer(p, cmd, scheduleFlag) - snapshotRetentionDays := flags.FlagToInt64Pointer(p, cmd, snapshotRetentionDaysFlag) - dailySnapshotRetentionDays := flags.FlagToInt64Pointer(p, cmd, dailySnapshotRetentionDaysFlag) - weeklySnapshotRetentionWeeks := flags.FlagToInt64Pointer(p, cmd, weeklySnapshotRetentionWeeksFlag) - monthlySnapshotRetentionMonths := flags.FlagToInt64Pointer(p, cmd, monthlySnapshotRetentionMonthsFlag) + snapshotRetentionDays := flags.FlagToInt32Pointer(p, cmd, snapshotRetentionDaysFlag) + dailySnapshotRetentionDays := flags.FlagToInt32Pointer(p, cmd, dailySnapshotRetentionDaysFlag) + weeklySnapshotRetentionWeeks := flags.FlagToInt32Pointer(p, cmd, weeklySnapshotRetentionWeeksFlag) + monthlySnapshotRetentionMonths := flags.FlagToInt32Pointer(p, cmd, monthlySnapshotRetentionMonthsFlag) if schedule == nil && snapshotRetentionDays == nil && dailySnapshotRetentionDays == nil && weeklySnapshotRetentionWeeks == nil && monthlySnapshotRetentionMonths == nil { return nil, &cliErr.EmptyUpdateError{} @@ -159,7 +159,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, } func buildUpdateBackupScheduleRequest(ctx context.Context, model *inputModel, instance *mongodbflex.Instance, apiClient *mongodbflex.APIClient) mongodbflex.ApiUpdateBackupScheduleRequest { - req := apiClient.UpdateBackupSchedule(ctx, model.ProjectId, *model.InstanceId, model.Region) + req := apiClient.DefaultAPI.UpdateBackupSchedule(ctx, model.ProjectId, *model.InstanceId, model.Region) payload := getUpdateBackupSchedulePayload(instance) @@ -196,25 +196,40 @@ func getUpdateBackupSchedulePayload(instance *mongodbflex.Instance) mongodbflex. if backupSchedule == nil { backupSchedule = utils.Ptr(defaultBackupSchedule) } - dailySnapshotRetentionDays, err := strconv.ParseInt(options["dailySnapshotRetentionDays"], 10, 64) + parsedDailySnapshotRetentionDays, err := strconv.ParseInt(options["dailySnapshotRetentionDays"], 10, 32) + var dailySnapshotRetentionDays int32 if err != nil { dailySnapshotRetentionDays = defaultDailySnapshotRetentionDays + } else { + dailySnapshotRetentionDays = int32(parsedDailySnapshotRetentionDays) } - weeklySnapshotRetentionWeeks, err := strconv.ParseInt(options["weeklySnapshotRetentionWeeks"], 10, 64) + parsedWeeklySnapshotRetentionWeeks, err := strconv.ParseInt(options["weeklySnapshotRetentionWeeks"], 10, 32) + var weeklySnapshotRetentionWeeks int32 if err != nil { weeklySnapshotRetentionWeeks = defaultWeeklySnapshotRetentionWeeks + } else { + weeklySnapshotRetentionWeeks = int32(parsedWeeklySnapshotRetentionWeeks) } - monthlySnapshotRetentionMonths, err := strconv.ParseInt(options["monthlySnapshotRetentionMonths"], 10, 64) + parsedMonthlySnapshotRetentionMonths, err := strconv.ParseInt(options["monthlySnapshotRetentionMonths"], 10, 32) + var monthlySnapshotRetentionMonths int32 if err != nil { monthlySnapshotRetentionMonths = defaultMonthlySnapshotRetentionMonths + } else { + monthlySnapshotRetentionMonths = int32(parsedMonthlySnapshotRetentionMonths) } - pointInTimeWindowHours, err := strconv.ParseInt(options["pointInTimeWindowHours"], 10, 64) + parsedPointInTimeWindowHours, err := strconv.ParseInt(options["pointInTimeWindowHours"], 10, 32) + var pointInTimeWindowHours int32 if err != nil { pointInTimeWindowHours = defaultPointInTimeWindowHours + } else { + pointInTimeWindowHours = int32(parsedPointInTimeWindowHours) } - snapshotRetentionDays, err := strconv.ParseInt(options["snapshotRetentionDays"], 10, 64) + parsedSnapshotRetentionDays, err := strconv.ParseInt(options["snapshotRetentionDays"], 10, 32) + var snapshotRetentionDays int32 if err != nil { snapshotRetentionDays = defaultSnapshotRetentionDays + } else { + snapshotRetentionDays = int32(parsedSnapshotRetentionDays) } defaultPayload := mongodbflex.UpdateBackupSchedulePayload{ @@ -229,6 +244,6 @@ func getUpdateBackupSchedulePayload(instance *mongodbflex.Instance) mongodbflex. } func buildGetInstanceRequest(ctx context.Context, model *inputModel, apiClient *mongodbflex.APIClient) mongodbflex.ApiGetInstanceRequest { - req := apiClient.GetInstance(ctx, model.ProjectId, *model.InstanceId, model.Region) + req := apiClient.DefaultAPI.GetInstance(ctx, model.ProjectId, *model.InstanceId, model.Region) return req } diff --git a/internal/cmd/mongodbflex/backup/update-schedule/update_schedule_test.go b/internal/cmd/mongodbflex/backup/update-schedule/update_schedule_test.go index 649f46738..f4aa91e2b 100644 --- a/internal/cmd/mongodbflex/backup/update-schedule/update_schedule_test.go +++ b/internal/cmd/mongodbflex/backup/update-schedule/update_schedule_test.go @@ -11,7 +11,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex" + mongodbflex "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex/v2api" ) const ( @@ -22,7 +22,7 @@ const ( type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &mongodbflex.APIClient{} +var testClient = &mongodbflex.APIClient{DefaultAPI: &mongodbflex.DefaultAPIService{}} var testProjectId = uuid.NewString() var testInstanceId = uuid.NewString() @@ -58,11 +58,11 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { func fixturePayload(mods ...func(payload *mongodbflex.UpdateBackupSchedulePayload)) mongodbflex.UpdateBackupSchedulePayload { payload := mongodbflex.UpdateBackupSchedulePayload{ BackupSchedule: utils.Ptr(testSchedule), - SnapshotRetentionDays: utils.Ptr(int64(3)), - DailySnapshotRetentionDays: utils.Ptr(int64(0)), - WeeklySnapshotRetentionWeeks: utils.Ptr(int64(3)), - MonthlySnapshotRetentionMonths: utils.Ptr(int64(1)), - PointInTimeWindowHours: utils.Ptr(int64(30)), + SnapshotRetentionDays: utils.Ptr(int32(3)), + DailySnapshotRetentionDays: utils.Ptr(int32(0)), + WeeklySnapshotRetentionWeeks: utils.Ptr(int32(3)), + MonthlySnapshotRetentionMonths: utils.Ptr(int32(1)), + PointInTimeWindowHours: utils.Ptr(int32(30)), } for _, mod := range mods { mod(&payload) @@ -71,7 +71,7 @@ func fixturePayload(mods ...func(payload *mongodbflex.UpdateBackupSchedulePayloa } func fixtureUpdateBackupScheduleRequest(mods ...func(request *mongodbflex.ApiUpdateBackupScheduleRequest)) mongodbflex.ApiUpdateBackupScheduleRequest { - request := testClient.UpdateBackupSchedule(testCtx, testProjectId, testInstanceId, testRegion) + request := testClient.DefaultAPI.UpdateBackupSchedule(testCtx, testProjectId, testInstanceId, testRegion) request = request.UpdateBackupSchedulePayload(fixturePayload()) for _, mod := range mods { mod(&request) @@ -80,7 +80,7 @@ func fixtureUpdateBackupScheduleRequest(mods ...func(request *mongodbflex.ApiUpd } func fixtureGetInstanceRequest(mods ...func(request *mongodbflex.ApiGetInstanceRequest)) mongodbflex.ApiGetInstanceRequest { - request := testClient.GetInstance(testCtx, testProjectId, testInstanceId, testRegion) + request := testClient.DefaultAPI.GetInstance(testCtx, testProjectId, testInstanceId, testRegion) for _, mod := range mods { mod(&request) } @@ -201,7 +201,7 @@ func TestBuildGetInstanceRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, mongodbflex.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) @@ -231,12 +231,12 @@ func TestBuildUpdateBackupScheduleRequest(t *testing.T) { Region: testRegion, }, InstanceId: utils.Ptr(testInstanceId), - DailySnaphotRetentionDays: utils.Ptr(int64(2)), + DailySnaphotRetentionDays: utils.Ptr(int32(2)), }, instance: fixtureInstance(), expectedRequest: fixtureUpdateBackupScheduleRequest().UpdateBackupSchedulePayload( fixturePayload(func(payload *mongodbflex.UpdateBackupSchedulePayload) { - payload.DailySnapshotRetentionDays = utils.Ptr(int64(2)) + payload.DailySnapshotRetentionDays = utils.Ptr(int32(2)) }), ), }, @@ -249,19 +249,19 @@ func TestBuildUpdateBackupScheduleRequest(t *testing.T) { }, InstanceId: utils.Ptr(testInstanceId), BackupSchedule: utils.Ptr("0 0/6 5 2 1"), - DailySnaphotRetentionDays: utils.Ptr(int64(2)), - WeeklySnapshotRetentionWeeks: utils.Ptr(int64(2)), - MonthlySnapshotRetentionMonths: utils.Ptr(int64(2)), - SnapshotRetentionDays: utils.Ptr(int64(2)), + DailySnaphotRetentionDays: utils.Ptr(int32(2)), + WeeklySnapshotRetentionWeeks: utils.Ptr(int32(2)), + MonthlySnapshotRetentionMonths: utils.Ptr(int32(2)), + SnapshotRetentionDays: utils.Ptr(int32(2)), }, instance: fixtureInstance(), expectedRequest: fixtureUpdateBackupScheduleRequest().UpdateBackupSchedulePayload( fixturePayload(func(payload *mongodbflex.UpdateBackupSchedulePayload) { payload.BackupSchedule = utils.Ptr("0 0/6 5 2 1") - payload.DailySnapshotRetentionDays = utils.Ptr(int64(2)) - payload.WeeklySnapshotRetentionWeeks = utils.Ptr(int64(2)) - payload.MonthlySnapshotRetentionMonths = utils.Ptr(int64(2)) - payload.SnapshotRetentionDays = utils.Ptr(int64(2)) + payload.DailySnapshotRetentionDays = utils.Ptr(int32(2)) + payload.WeeklySnapshotRetentionWeeks = utils.Ptr(int32(2)) + payload.MonthlySnapshotRetentionMonths = utils.Ptr(int32(2)) + payload.SnapshotRetentionDays = utils.Ptr(int32(2)) }), ), }, @@ -285,7 +285,7 @@ func TestBuildUpdateBackupScheduleRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, mongodbflex.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/mongodbflex/instance/create/create.go b/internal/cmd/mongodbflex/instance/create/create.go index dbb8455f4..9dcf3b23e 100644 --- a/internal/cmd/mongodbflex/instance/create/create.go +++ b/internal/cmd/mongodbflex/instance/create/create.go @@ -8,8 +8,8 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/types" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex" - "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex/wait" + mongodbflex "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex/v2api" + wait "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex/v2api/wait" "github.com/stackitcloud/stackit-cli/internal/pkg/args" cliErr "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -51,15 +51,15 @@ var typeFlag = flags.StringEnumFlag( type inputModel struct { *globalflags.GlobalFlagModel - InstanceName *string - ACL *[]string - BackupSchedule *string - FlavorId *string - CPU *int64 - RAM *int64 + InstanceName string + ACL []string + BackupSchedule string + FlavorId string + CPU *int32 + RAM *int32 StorageClass *string StorageSize *int64 - Version *string + Version string Type *string } @@ -107,16 +107,16 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } // Fill in version, if needed - if model.Version == nil { - version, err := mongodbflexUtils.GetLatestMongoDBVersion(ctx, apiClient, model.ProjectId, model.Region) + if model.Version == "" { + version, err := mongodbflexUtils.GetLatestMongoDBVersion(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region) if err != nil { return fmt.Errorf("get latest MongoDB version: %w", err) } - model.Version = &version + model.Version = version } // Call API - req, err := buildRequest(ctx, model, apiClient) + req, err := buildRequest(ctx, model, apiClient.DefaultAPI) if err != nil { return err } @@ -129,7 +129,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { // Wait for async operation, if async mode not enabled if !model.Async { err := spinner.Run(params.Printer, "Creating instance", func() error { - _, err = wait.CreateInstanceWaitHandler(ctx, apiClient, model.ProjectId, instanceId, model.Region).WaitWithContext(ctx) + _, err = wait.CreateInstanceWaitHandler(ctx, apiClient.DefaultAPI, model.ProjectId, instanceId, model.Region).WaitWithContext(ctx) return err }) if err != nil { @@ -149,8 +149,8 @@ func configureFlags(cmd *cobra.Command) { cmd.Flags().Var(flags.CIDRSliceFlag(), aclFlag, "The access control list (ACL). Must contain at least one valid subnet, for instance '0.0.0.0/0' for open access (discouraged), '1.2.3.0/24 for a public IP range of an organization, '1.2.3.4/32' for a single IP range, etc.") cmd.Flags().String(backupScheduleFlag, defaultBackupSchedule, "Backup schedule") cmd.Flags().String(flavorIdFlag, "", "ID of the flavor") - cmd.Flags().Int64(cpuFlag, 0, "Number of CPUs") - cmd.Flags().Int64(ramFlag, 0, "Amount of RAM (in GB)") + cmd.Flags().Int32(cpuFlag, 0, "Number of CPUs") + cmd.Flags().Int32(ramFlag, 0, "Amount of RAM (in GB)") cmd.Flags().String(storageClassFlag, defaultStorageClass, "Storage class") cmd.Flags().Int64(storageSizeFlag, defaultStorageSize, "Storage size (in GB)") cmd.Flags().String(versionFlag, "", "MongoDB version. Defaults to the latest version available") @@ -168,16 +168,16 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, storageSize := flags.FlagWithDefaultToInt64Value(p, cmd, storageSizeFlag) - flavorId := flags.FlagToStringPointer(p, cmd, flavorIdFlag) - cpu := flags.FlagToInt64Pointer(p, cmd, cpuFlag) - ram := flags.FlagToInt64Pointer(p, cmd, ramFlag) + flavorId := flags.FlagToStringValue(p, cmd, flavorIdFlag) + cpu := flags.FlagToInt32Pointer(p, cmd, cpuFlag) + ram := flags.FlagToInt32Pointer(p, cmd, ramFlag) - if flavorId == nil && (cpu == nil || ram == nil) { + if flavorId == "" && (cpu == nil || ram == nil) { return nil, &cliErr.DatabaseInputFlavorError{ Cmd: cmd, } } - if flavorId != nil && (cpu != nil || ram != nil) { + if flavorId != "" && (cpu != nil || ram != nil) { return nil, &cliErr.DatabaseInputFlavorError{ Cmd: cmd, } @@ -185,15 +185,15 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, model := inputModel{ GlobalFlagModel: globalFlags, - InstanceName: flags.FlagToStringPointer(p, cmd, instanceNameFlag), - ACL: flags.FlagToStringSlicePointer(p, cmd, aclFlag), - BackupSchedule: utils.Ptr(flags.FlagWithDefaultToStringValue(p, cmd, backupScheduleFlag)), + InstanceName: flags.FlagToStringValue(p, cmd, instanceNameFlag), + ACL: flags.FlagToStringSliceValue(p, cmd, aclFlag), + BackupSchedule: flags.FlagWithDefaultToStringValue(p, cmd, backupScheduleFlag), FlavorId: flavorId, CPU: cpu, RAM: ram, StorageClass: utils.Ptr(flags.FlagWithDefaultToStringValue(p, cmd, storageClassFlag)), StorageSize: &storageSize, - Version: flags.FlagToStringPointer(p, cmd, versionFlag), + Version: flags.FlagToStringValue(p, cmd, versionFlag), Type: typeFlag.Ptr(), } @@ -203,23 +203,23 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, type MongoDBFlexClient interface { CreateInstance(ctx context.Context, projectId, region string) mongodbflex.ApiCreateInstanceRequest - ListFlavorsExecute(ctx context.Context, projectId, region string) (*mongodbflex.ListFlavorsResponse, error) - ListStoragesExecute(ctx context.Context, projectId, flavorId, region string) (*mongodbflex.ListStoragesResponse, error) + ListFlavors(ctx context.Context, projectId, region string) mongodbflex.ApiListFlavorsRequest + ListStorages(ctx context.Context, projectId, flavorId, region string) mongodbflex.ApiListStoragesRequest } func buildRequest(ctx context.Context, model *inputModel, apiClient MongoDBFlexClient) (mongodbflex.ApiCreateInstanceRequest, error) { req := apiClient.CreateInstance(ctx, model.ProjectId, model.Region) - var flavorId *string + var flavorId string var err error - flavors, err := apiClient.ListFlavorsExecute(ctx, model.ProjectId, model.Region) + flavors, err := apiClient.ListFlavors(ctx, model.ProjectId, model.Region).Execute() if err != nil { return req, fmt.Errorf("get MongoDB Flex flavors: %w", err) } - if model.FlavorId == nil { - flavorId, err = mongodbflexUtils.LoadFlavorId(*model.CPU, *model.RAM, flavors.Flavors) + if model.FlavorId == "" { + foundFlavorId, err := mongodbflexUtils.LoadFlavorId(*model.CPU, *model.RAM, &flavors.Flavors) if err != nil { var dsaInvalidPlanError *cliErr.DSAInvalidPlanError if !errors.As(err, &dsaInvalidPlanError) { @@ -227,19 +227,20 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient MongoDBFlexC } return req, err } + flavorId = *foundFlavorId } else { - err := mongodbflexUtils.ValidateFlavorId(*model.FlavorId, flavors.Flavors) + err := mongodbflexUtils.ValidateFlavorId(model.FlavorId, flavors.Flavors) if err != nil { return req, err } flavorId = model.FlavorId } - storages, err := apiClient.ListStoragesExecute(ctx, model.ProjectId, *flavorId, model.Region) + storages, err := apiClient.ListStorages(ctx, model.ProjectId, flavorId, model.Region).Execute() if err != nil { return req, fmt.Errorf("get MongoDB Flex storages: %w", err) } - err = mongodbflexUtils.ValidateStorage(model.StorageClass, model.StorageSize, storages, *flavorId) + err = mongodbflexUtils.ValidateStorage(model.StorageClass, model.StorageSize, storages, flavorId) if err != nil { return req, err } @@ -251,18 +252,18 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient MongoDBFlexC req = req.CreateInstancePayload(mongodbflex.CreateInstancePayload{ Name: model.InstanceName, - Acl: &mongodbflex.CreateInstancePayloadAcl{Items: model.ACL}, + Acl: mongodbflex.ACL{Items: model.ACL}, BackupSchedule: model.BackupSchedule, FlavorId: flavorId, - Replicas: &replicas, - Storage: &mongodbflex.Storage{ + Replicas: replicas, + Storage: mongodbflex.Storage{ Class: model.StorageClass, Size: model.StorageSize, }, Version: model.Version, - Options: utils.Ptr(map[string]string{ + Options: map[string]string{ "type": *model.Type, - }), + }, }) return req, nil } diff --git a/internal/cmd/mongodbflex/instance/create/create_test.go b/internal/cmd/mongodbflex/instance/create/create_test.go index 1b5961008..4f1b88082 100644 --- a/internal/cmd/mongodbflex/instance/create/create_test.go +++ b/internal/cmd/mongodbflex/instance/create/create_test.go @@ -13,7 +13,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex" + mongodbflex "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex/v2api" ) const ( @@ -23,36 +23,34 @@ const ( type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &mongodbflex.APIClient{} +var testClient = &mongodbflex.APIClient{DefaultAPI: &mongodbflex.DefaultAPIService{}} -type mongoDBFlexClientMocked struct { - listFlavorsFails bool - listFlavorsResp *mongodbflex.ListFlavorsResponse - listStoragesFails bool - listStoragesResp *mongodbflex.ListStoragesResponse +type mockSettings struct { + listFlavorsFails bool + listFlavorsResp *mongodbflex.ListFlavorsResponse + listStoragesResp *mongodbflex.ListStoragesResponse } -func (c *mongoDBFlexClientMocked) CreateInstance(ctx context.Context, projectId, region string) mongodbflex.ApiCreateInstanceRequest { - return testClient.CreateInstance(ctx, projectId, region) -} - -func (c *mongoDBFlexClientMocked) ListStoragesExecute(_ context.Context, _, _, _ string) (*mongodbflex.ListStoragesResponse, error) { - if c.listFlavorsFails { - return nil, fmt.Errorf("list storages failed") - } - return c.listStoragesResp, nil -} +var testProjectId = uuid.NewString() +var testFlavorId = uuid.NewString() -func (c *mongoDBFlexClientMocked) ListFlavorsExecute(_ context.Context, _, _ string) (*mongodbflex.ListFlavorsResponse, error) { - if c.listFlavorsFails { - return nil, fmt.Errorf("list flavors failed") +func newAPICLientMock(settings mockSettings) mongodbflex.DefaultAPI { + return mongodbflex.DefaultAPIServiceMock{ + ListStoragesExecuteMock: utils.Ptr(func(_ mongodbflex.ApiListStoragesRequest) (*mongodbflex.ListStoragesResponse, error) { + if settings.listFlavorsFails { + return nil, fmt.Errorf("list storages failed") + } + return settings.listStoragesResp, nil + }), + ListFlavorsExecuteMock: utils.Ptr(func(_ mongodbflex.ApiListFlavorsRequest) (*mongodbflex.ListFlavorsResponse, error) { + if settings.listFlavorsFails { + return nil, fmt.Errorf("list flavors failed") + } + return settings.listFlavorsResp, nil + }), } - return c.listFlavorsResp, nil } -var testProjectId = uuid.NewString() -var testFlavorId = uuid.NewString() - func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string { flagValues := map[string]string{ globalflags.ProjectIdFlag: testProjectId, @@ -79,13 +77,13 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { Region: testRegion, Verbosity: globalflags.VerbosityDefault, }, - InstanceName: utils.Ptr("example-name"), - ACL: utils.Ptr([]string{"0.0.0.0/0"}), - BackupSchedule: utils.Ptr("0 0/6 * * *"), - FlavorId: utils.Ptr(testFlavorId), + InstanceName: "example-name", + ACL: []string{"0.0.0.0/0"}, + BackupSchedule: "0 0/6 * * *", + FlavorId: testFlavorId, StorageClass: utils.Ptr("premium-perf4-mongodb"), StorageSize: utils.Ptr(int64(10)), - Version: utils.Ptr("6.0"), + Version: "6.0", Type: utils.Ptr("Replica"), } for _, mod := range mods { @@ -95,7 +93,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *mongodbflex.ApiCreateInstanceRequest)) mongodbflex.ApiCreateInstanceRequest { - request := testClient.CreateInstance(testCtx, testProjectId, testRegion) + request := testClient.DefaultAPI.CreateInstance(testCtx, testProjectId, testRegion) request = request.CreateInstancePayload(fixturePayload()) for _, mod := range mods { mod(&request) @@ -105,19 +103,19 @@ func fixtureRequest(mods ...func(request *mongodbflex.ApiCreateInstanceRequest)) func fixturePayload(mods ...func(payload *mongodbflex.CreateInstancePayload)) mongodbflex.CreateInstancePayload { payload := mongodbflex.CreateInstancePayload{ - Name: utils.Ptr("example-name"), - Acl: &mongodbflex.CreateInstancePayloadAcl{Items: utils.Ptr([]string{"0.0.0.0/0"})}, - BackupSchedule: utils.Ptr("0 0/6 * * *"), - FlavorId: utils.Ptr(testFlavorId), - Replicas: utils.Ptr(int64(3)), - Storage: &mongodbflex.Storage{ + Name: "example-name", + Acl: mongodbflex.ACL{Items: []string{"0.0.0.0/0"}}, + BackupSchedule: "0 0/6 * * *", + FlavorId: testFlavorId, + Replicas: int32(3), + Storage: mongodbflex.Storage{ Class: utils.Ptr("premium-perf4-mongodb"), Size: utils.Ptr(int64(10)), }, - Version: utils.Ptr("6.0"), - Options: utils.Ptr(map[string]string{ + Version: "6.0", + Options: map[string]string{ "type": "Replica", - }), + }, } for _, mod := range mods { mod(&payload) @@ -158,9 +156,9 @@ func TestParseInput(t *testing.T) { }), isValid: true, expectedModel: fixtureInputModel(func(model *inputModel) { - model.FlavorId = nil - model.CPU = utils.Ptr(int64(2)) - model.RAM = utils.Ptr(int64(4)) + model.FlavorId = "" + model.CPU = utils.Ptr(int32(2)) + model.RAM = utils.Ptr(int32(4)) }), }, { @@ -218,7 +216,7 @@ func TestParseInput(t *testing.T) { }), isValid: true, expectedModel: fixtureInputModel(func(model *inputModel) { - model.Version = nil + model.Version = "" }), }, { @@ -227,9 +225,8 @@ func TestParseInput(t *testing.T) { aclValues: []string{"198.51.100.14/24", "198.51.100.14/32"}, isValid: true, expectedModel: fixtureInputModel(func(model *inputModel) { - model.ACL = utils.Ptr( - append(*model.ACL, "198.51.100.14/24", "198.51.100.14/32"), - ) + model.ACL = + append(model.ACL, "198.51.100.14/24", "198.51.100.14/32") }), }, { @@ -238,9 +235,8 @@ func TestParseInput(t *testing.T) { aclValues: []string{"198.51.100.14/24,198.51.100.14/32"}, isValid: true, expectedModel: fixtureInputModel(func(model *inputModel) { - model.ACL = utils.Ptr( - append(*model.ACL, "198.51.100.14/24", "198.51.100.14/32"), - ) + model.ACL = + append(model.ACL, "198.51.100.14/24", "198.51.100.14/32") }), }, { @@ -264,34 +260,33 @@ func TestParseInput(t *testing.T) { func TestBuildRequest(t *testing.T) { tests := []struct { - description string - model *inputModel - expectedRequest mongodbflex.ApiCreateInstanceRequest - listFlavorsFails bool - listFlavorsResp *mongodbflex.ListFlavorsResponse - listStoragesFails bool - listStoragesResp *mongodbflex.ListStoragesResponse - isValid bool + description string + model *inputModel + expectedRequest mongodbflex.ApiCreateInstanceRequest + mockClientSettings mockSettings + isValid bool }{ { description: "base with flavor ID", model: fixtureInputModel(), isValid: true, expectedRequest: fixtureRequest(), - listFlavorsResp: &mongodbflex.ListFlavorsResponse{ - Flavors: &[]mongodbflex.InstanceFlavor{ - { - Id: utils.Ptr(testFlavorId), - Cpu: utils.Ptr(int64(2)), - Memory: utils.Ptr(int64(4)), + mockClientSettings: mockSettings{ + listFlavorsResp: &mongodbflex.ListFlavorsResponse{ + Flavors: []mongodbflex.InstanceFlavor{ + { + Id: utils.Ptr(testFlavorId), + Cpu: utils.Ptr(int32(2)), + Memory: utils.Ptr(int32(4)), + }, }, }, - }, - listStoragesResp: &mongodbflex.ListStoragesResponse{ - StorageClasses: &[]string{"premium-perf4-mongodb"}, - StorageRange: &mongodbflex.StorageRange{ - Min: utils.Ptr(int64(10)), - Max: utils.Ptr(int64(100)), + listStoragesResp: &mongodbflex.ListStoragesResponse{ + StorageClasses: []string{"premium-perf4-mongodb"}, + StorageRange: &mongodbflex.StorageRange{ + Min: utils.Ptr(int64(10)), + Max: utils.Ptr(int64(100)), + }, }, }, }, @@ -299,32 +294,34 @@ func TestBuildRequest(t *testing.T) { description: "with CPU and RAM", model: fixtureInputModel( func(model *inputModel) { - model.FlavorId = nil - model.CPU = utils.Ptr(int64(2)) - model.RAM = utils.Ptr(int64(4)) + model.FlavorId = "" + model.CPU = utils.Ptr(int32(2)) + model.RAM = utils.Ptr(int32(4)) }, ), isValid: true, expectedRequest: fixtureRequest(), - listFlavorsResp: &mongodbflex.ListFlavorsResponse{ - Flavors: &[]mongodbflex.InstanceFlavor{ - { - Id: utils.Ptr(testFlavorId), - Cpu: utils.Ptr(int64(2)), - Memory: utils.Ptr(int64(4)), - }, - { - Id: utils.Ptr("other-flavor"), - Cpu: utils.Ptr(int64(1)), - Memory: utils.Ptr(int64(8)), + mockClientSettings: mockSettings{ + listFlavorsResp: &mongodbflex.ListFlavorsResponse{ + Flavors: []mongodbflex.InstanceFlavor{ + { + Id: utils.Ptr(testFlavorId), + Cpu: utils.Ptr(int32(2)), + Memory: utils.Ptr(int32(4)), + }, + { + Id: utils.Ptr("other-flavor"), + Cpu: utils.Ptr(int32(1)), + Memory: utils.Ptr(int32(8)), + }, }, }, - }, - listStoragesResp: &mongodbflex.ListStoragesResponse{ - StorageClasses: &[]string{"premium-perf4-mongodb"}, - StorageRange: &mongodbflex.StorageRange{ - Min: utils.Ptr(int64(10)), - Max: utils.Ptr(int64(100)), + listStoragesResp: &mongodbflex.ListStoragesResponse{ + StorageClasses: []string{"premium-perf4-mongodb"}, + StorageRange: &mongodbflex.StorageRange{ + Min: utils.Ptr(int64(10)), + Max: utils.Ptr(int64(100)), + }, }, }, }, @@ -333,23 +330,25 @@ func TestBuildRequest(t *testing.T) { model: fixtureInputModel(func(model *inputModel) { model.Type = utils.Ptr("Single") }), isValid: true, expectedRequest: fixtureRequest().CreateInstancePayload(fixturePayload(func(payload *mongodbflex.CreateInstancePayload) { - payload.Options = utils.Ptr(map[string]string{"type": "Single"}) - payload.Replicas = utils.Ptr(int64(1)) + payload.Options = map[string]string{"type": "Single"} + payload.Replicas = int32(1) })), - listFlavorsResp: &mongodbflex.ListFlavorsResponse{ - Flavors: &[]mongodbflex.InstanceFlavor{ - { - Id: utils.Ptr(testFlavorId), - Cpu: utils.Ptr(int64(2)), - Memory: utils.Ptr(int64(4)), + mockClientSettings: mockSettings{ + listFlavorsResp: &mongodbflex.ListFlavorsResponse{ + Flavors: []mongodbflex.InstanceFlavor{ + { + Id: utils.Ptr(testFlavorId), + Cpu: utils.Ptr(int32(2)), + Memory: utils.Ptr(int32(4)), + }, }, }, - }, - listStoragesResp: &mongodbflex.ListStoragesResponse{ - StorageClasses: &[]string{"premium-perf4-mongodb"}, - StorageRange: &mongodbflex.StorageRange{ - Min: utils.Ptr(int64(10)), - Max: utils.Ptr(int64(100)), + listStoragesResp: &mongodbflex.ListStoragesResponse{ + StorageClasses: []string{"premium-perf4-mongodb"}, + StorageRange: &mongodbflex.StorageRange{ + Min: utils.Ptr(int64(10)), + Max: utils.Ptr(int64(100)), + }, }, }, }, @@ -358,23 +357,25 @@ func TestBuildRequest(t *testing.T) { model: fixtureInputModel(func(model *inputModel) { model.Type = utils.Ptr("Sharded") }), isValid: true, expectedRequest: fixtureRequest().CreateInstancePayload(fixturePayload(func(payload *mongodbflex.CreateInstancePayload) { - payload.Options = utils.Ptr(map[string]string{"type": "Sharded"}) - payload.Replicas = utils.Ptr(int64(9)) + payload.Options = map[string]string{"type": "Sharded"} + payload.Replicas = int32(9) })), - listFlavorsResp: &mongodbflex.ListFlavorsResponse{ - Flavors: &[]mongodbflex.InstanceFlavor{ - { - Id: utils.Ptr(testFlavorId), - Cpu: utils.Ptr(int64(2)), - Memory: utils.Ptr(int64(4)), + mockClientSettings: mockSettings{ + listFlavorsResp: &mongodbflex.ListFlavorsResponse{ + Flavors: []mongodbflex.InstanceFlavor{ + { + Id: utils.Ptr(testFlavorId), + Cpu: utils.Ptr(int32(2)), + Memory: utils.Ptr(int32(4)), + }, }, }, - }, - listStoragesResp: &mongodbflex.ListStoragesResponse{ - StorageClasses: &[]string{"premium-perf4-mongodb"}, - StorageRange: &mongodbflex.StorageRange{ - Min: utils.Ptr(int64(10)), - Max: utils.Ptr(int64(100)), + listStoragesResp: &mongodbflex.ListStoragesResponse{ + StorageClasses: []string{"premium-perf4-mongodb"}, + StorageRange: &mongodbflex.StorageRange{ + Min: utils.Ptr(int64(10)), + Max: utils.Ptr(int64(100)), + }, }, }, }, @@ -382,34 +383,38 @@ func TestBuildRequest(t *testing.T) { description: "get flavors fails", model: fixtureInputModel( func(model *inputModel) { - model.FlavorId = nil - model.CPU = utils.Ptr(int64(2)) - model.RAM = utils.Ptr(int64(4)) + model.FlavorId = "" + model.CPU = utils.Ptr(int32(2)) + model.RAM = utils.Ptr(int32(4)) }, ), - listFlavorsFails: true, - isValid: false, + mockClientSettings: mockSettings{ + listFlavorsFails: true, + }, + isValid: false, }, { description: "flavor id not found", model: fixtureInputModel( func(model *inputModel) { - model.FlavorId = nil - model.CPU = utils.Ptr(int64(5)) - model.RAM = utils.Ptr(int64(9)) + model.FlavorId = "" + model.CPU = utils.Ptr(int32(5)) + model.RAM = utils.Ptr(int32(9)) }, ), - listFlavorsResp: &mongodbflex.ListFlavorsResponse{ - Flavors: &[]mongodbflex.InstanceFlavor{ - { - Id: utils.Ptr(testFlavorId), - Cpu: utils.Ptr(int64(2)), - Memory: utils.Ptr(int64(4)), - }, - { - Id: utils.Ptr("other-flavor"), - Cpu: utils.Ptr(int64(1)), - Memory: utils.Ptr(int64(8)), + mockClientSettings: mockSettings{ + listFlavorsResp: &mongodbflex.ListFlavorsResponse{ + Flavors: []mongodbflex.InstanceFlavor{ + { + Id: utils.Ptr(testFlavorId), + Cpu: utils.Ptr(int32(2)), + Memory: utils.Ptr(int32(4)), + }, + { + Id: utils.Ptr("other-flavor"), + Cpu: utils.Ptr(int32(1)), + Memory: utils.Ptr(int32(8)), + }, }, }, }, @@ -419,13 +424,15 @@ func TestBuildRequest(t *testing.T) { description: "get storages fails", model: fixtureInputModel( func(model *inputModel) { - model.FlavorId = nil - model.CPU = utils.Ptr(int64(2)) - model.RAM = utils.Ptr(int64(4)) + model.FlavorId = "" + model.CPU = utils.Ptr(int32(2)) + model.RAM = utils.Ptr(int32(4)) }, ), - listFlavorsFails: true, - isValid: false, + mockClientSettings: mockSettings{ + listFlavorsFails: true, + }, + isValid: false, }, { description: "invalid storage class", @@ -434,20 +441,22 @@ func TestBuildRequest(t *testing.T) { model.StorageClass = utils.Ptr("non-existing-class") }, ), - listFlavorsResp: &mongodbflex.ListFlavorsResponse{ - Flavors: &[]mongodbflex.InstanceFlavor{ - { - Id: utils.Ptr(testFlavorId), - Cpu: utils.Ptr(int64(2)), - Memory: utils.Ptr(int64(4)), + mockClientSettings: mockSettings{ + listFlavorsResp: &mongodbflex.ListFlavorsResponse{ + Flavors: []mongodbflex.InstanceFlavor{ + { + Id: utils.Ptr(testFlavorId), + Cpu: utils.Ptr(int32(2)), + Memory: utils.Ptr(int32(4)), + }, }, }, - }, - listStoragesResp: &mongodbflex.ListStoragesResponse{ - StorageClasses: &[]string{"premium-perf4-mongodb"}, - StorageRange: &mongodbflex.StorageRange{ - Min: utils.Ptr(int64(10)), - Max: utils.Ptr(int64(100)), + listStoragesResp: &mongodbflex.ListStoragesResponse{ + StorageClasses: []string{"premium-perf4-mongodb"}, + StorageRange: &mongodbflex.StorageRange{ + Min: utils.Ptr(int64(10)), + Max: utils.Ptr(int64(100)), + }, }, }, isValid: false, @@ -459,20 +468,22 @@ func TestBuildRequest(t *testing.T) { model.StorageSize = utils.Ptr(int64(9)) }, ), - listFlavorsResp: &mongodbflex.ListFlavorsResponse{ - Flavors: &[]mongodbflex.InstanceFlavor{ - { - Id: utils.Ptr(testFlavorId), - Cpu: utils.Ptr(int64(2)), - Memory: utils.Ptr(int64(4)), + mockClientSettings: mockSettings{ + listFlavorsResp: &mongodbflex.ListFlavorsResponse{ + Flavors: []mongodbflex.InstanceFlavor{ + { + Id: utils.Ptr(testFlavorId), + Cpu: utils.Ptr(int32(2)), + Memory: utils.Ptr(int32(4)), + }, }, }, - }, - listStoragesResp: &mongodbflex.ListStoragesResponse{ - StorageClasses: &[]string{"premium-perf4-mongodb"}, - StorageRange: &mongodbflex.StorageRange{ - Min: utils.Ptr(int64(10)), - Max: utils.Ptr(int64(100)), + listStoragesResp: &mongodbflex.ListStoragesResponse{ + StorageClasses: []string{"premium-perf4-mongodb"}, + StorageRange: &mongodbflex.StorageRange{ + Min: utils.Ptr(int64(10)), + Max: utils.Ptr(int64(100)), + }, }, }, isValid: false, @@ -481,13 +492,7 @@ func TestBuildRequest(t *testing.T) { for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { - client := &mongoDBFlexClientMocked{ - listFlavorsFails: tt.listFlavorsFails, - listFlavorsResp: tt.listFlavorsResp, - listStoragesFails: tt.listStoragesFails, - listStoragesResp: tt.listStoragesResp, - } - request, err := buildRequest(testCtx, tt.model, client) + request, err := buildRequest(testCtx, tt.model, newAPICLientMock(tt.mockClientSettings)) if err != nil { if !tt.isValid { return @@ -498,6 +503,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), cmpopts.EquateComparable(testCtx), + cmpopts.IgnoreFields(tt.expectedRequest, "ApiService"), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/mongodbflex/instance/delete/delete.go b/internal/cmd/mongodbflex/instance/delete/delete.go index 8c34e1533..a9ca077bd 100644 --- a/internal/cmd/mongodbflex/instance/delete/delete.go +++ b/internal/cmd/mongodbflex/instance/delete/delete.go @@ -17,8 +17,8 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex" - "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex/wait" + mongodbflex "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex/v2api" + wait "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex/v2api/wait" ) const ( @@ -54,7 +54,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return err } - instanceLabel, err := mongodbflexUtils.GetInstanceName(ctx, apiClient, model.ProjectId, model.InstanceId, model.Region) + instanceLabel, err := mongodbflexUtils.GetInstanceName(ctx, apiClient.DefaultAPI, model.ProjectId, model.InstanceId, model.Region) if err != nil { params.Printer.Debug(print.ErrorLevel, "get instance name: %v", err) instanceLabel = model.InstanceId @@ -76,7 +76,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { // Wait for async operation, if async mode not enabled if !model.Async { err := spinner.Run(params.Printer, "Deleting instance", func() error { - _, err = wait.DeleteInstanceWaitHandler(ctx, apiClient, model.ProjectId, model.InstanceId, model.Region).WaitWithContext(ctx) + _, err = wait.DeleteInstanceWaitHandler(ctx, apiClient.DefaultAPI, model.ProjectId, model.InstanceId, model.Region).WaitWithContext(ctx) return err }) if err != nil { @@ -113,6 +113,6 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *mongodbflex.APIClient) mongodbflex.ApiDeleteInstanceRequest { - req := apiClient.DeleteInstance(ctx, model.ProjectId, model.InstanceId, model.Region) + req := apiClient.DefaultAPI.DeleteInstance(ctx, model.ProjectId, model.InstanceId, model.Region) return req } diff --git a/internal/cmd/mongodbflex/instance/delete/delete_test.go b/internal/cmd/mongodbflex/instance/delete/delete_test.go index 52435d690..66753f699 100644 --- a/internal/cmd/mongodbflex/instance/delete/delete_test.go +++ b/internal/cmd/mongodbflex/instance/delete/delete_test.go @@ -10,7 +10,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex" + mongodbflex "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex/v2api" ) const ( @@ -20,7 +20,7 @@ const ( type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &mongodbflex.APIClient{} +var testClient = &mongodbflex.APIClient{DefaultAPI: &mongodbflex.DefaultAPIService{}} var testProjectId = uuid.NewString() var testInstanceId = uuid.NewString() @@ -61,7 +61,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *mongodbflex.ApiDeleteInstanceRequest)) mongodbflex.ApiDeleteInstanceRequest { - request := testClient.DeleteInstance(testCtx, testProjectId, testInstanceId, testRegion) + request := testClient.DefaultAPI.DeleteInstance(testCtx, testProjectId, testInstanceId, testRegion) for _, mod := range mods { mod(&request) } @@ -165,7 +165,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, mongodbflex.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/mongodbflex/instance/describe/describe.go b/internal/cmd/mongodbflex/instance/describe/describe.go index c20de2606..1e6dd2652 100644 --- a/internal/cmd/mongodbflex/instance/describe/describe.go +++ b/internal/cmd/mongodbflex/instance/describe/describe.go @@ -18,7 +18,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex" + mongodbflex "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex/v2api" ) const ( @@ -87,16 +87,15 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *mongodbflex.APIClient) mongodbflex.ApiGetInstanceRequest { - req := apiClient.GetInstance(ctx, model.ProjectId, model.InstanceId, model.Region) + req := apiClient.DefaultAPI.GetInstance(ctx, model.ProjectId, model.InstanceId, model.Region) return req } func outputResult(p *print.Printer, outputFormat string, instance *mongodbflex.Instance) error { - if instance == nil { - return fmt.Errorf("instance is nil") - } - return p.OutputResult(outputFormat, instance, func() error { + if instance == nil { + return fmt.Errorf("instance is nil") + } var instanceType string if instance.HasReplicas() { var err error @@ -121,8 +120,7 @@ func outputResult(p *print.Printer, outputFormat string, instance *mongodbflex.I table.AddRow("VERSION", utils.PtrString(instance.Version)) table.AddSeparator() if instance.HasAcl() { - aclsArray := *instance.Acl.Items - acls := strings.Join(aclsArray, ",") + acls := strings.Join(instance.Acl.Items, ",") table.AddRow("ACL", acls) table.AddSeparator() } diff --git a/internal/cmd/mongodbflex/instance/describe/describe_test.go b/internal/cmd/mongodbflex/instance/describe/describe_test.go index 41af248ca..0a6e0cdf3 100644 --- a/internal/cmd/mongodbflex/instance/describe/describe_test.go +++ b/internal/cmd/mongodbflex/instance/describe/describe_test.go @@ -11,7 +11,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex" + mongodbflex "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex/v2api" ) const ( @@ -21,7 +21,7 @@ const ( type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &mongodbflex.APIClient{} +var testClient = &mongodbflex.APIClient{DefaultAPI: &mongodbflex.DefaultAPIService{}} var testProjectId = uuid.NewString() var testInstanceId = uuid.NewString() @@ -62,7 +62,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *mongodbflex.ApiGetInstanceRequest)) mongodbflex.ApiGetInstanceRequest { - request := testClient.GetInstance(testCtx, testProjectId, testInstanceId, testRegion) + request := testClient.DefaultAPI.GetInstance(testCtx, testProjectId, testInstanceId, testRegion) for _, mod := range mods { mod(&request) } @@ -166,7 +166,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, mongodbflex.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/mongodbflex/instance/list/list.go b/internal/cmd/mongodbflex/instance/list/list.go index 74ac6bcb0..4e362a40c 100644 --- a/internal/cmd/mongodbflex/instance/list/list.go +++ b/internal/cmd/mongodbflex/instance/list/list.go @@ -18,7 +18,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex" + mongodbflex "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex/v2api" ) const ( @@ -66,7 +66,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { if err != nil { return fmt.Errorf("get MongoDB Flex instances: %w", err) } - instances := utils.GetSliceFromPointer(resp.Items) + instances := resp.Items projectLabel, err := projectname.GetProjectName(ctx, params.Printer, params.CliVersion, cmd) if err != nil { @@ -115,7 +115,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, } func buildRequest(ctx context.Context, model *inputModel, apiClient *mongodbflex.APIClient) mongodbflex.ApiListInstancesRequest { - req := apiClient.ListInstances(ctx, model.ProjectId, model.Region).Tag("") + req := apiClient.DefaultAPI.ListInstances(ctx, model.ProjectId, model.Region).Tag("") return req } diff --git a/internal/cmd/mongodbflex/instance/list/list_test.go b/internal/cmd/mongodbflex/instance/list/list_test.go index 9626db143..988be4ae4 100644 --- a/internal/cmd/mongodbflex/instance/list/list_test.go +++ b/internal/cmd/mongodbflex/instance/list/list_test.go @@ -12,7 +12,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex" + mongodbflex "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex/v2api" ) const ( @@ -22,7 +22,7 @@ const ( type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &mongodbflex.APIClient{} +var testClient = &mongodbflex.APIClient{DefaultAPI: &mongodbflex.DefaultAPIService{}} var testProjectId = uuid.NewString() func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string { @@ -53,7 +53,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *mongodbflex.ApiListInstancesRequest)) mongodbflex.ApiListInstancesRequest { - request := testClient.ListInstances(testCtx, testProjectId, testRegion).Tag("") + request := testClient.DefaultAPI.ListInstances(testCtx, testProjectId, testRegion).Tag("") for _, mod := range mods { mod(&request) } @@ -142,7 +142,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, mongodbflex.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/mongodbflex/instance/update/update.go b/internal/cmd/mongodbflex/instance/update/update.go index f255ecb52..22ba42eda 100644 --- a/internal/cmd/mongodbflex/instance/update/update.go +++ b/internal/cmd/mongodbflex/instance/update/update.go @@ -19,8 +19,8 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex" - "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex/wait" + mongodbflex "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex/v2api" + wait "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex/v2api/wait" ) const ( @@ -51,8 +51,8 @@ type inputModel struct { ACL *[]string BackupSchedule *string FlavorId *string - CPU *int64 - RAM *int64 + CPU *int32 + RAM *int32 StorageClass *string StorageSize *int64 Version *string @@ -87,7 +87,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return err } - instanceLabel, err := mongodbflexUtils.GetInstanceName(ctx, apiClient, model.ProjectId, model.InstanceId, model.Region) + instanceLabel, err := mongodbflexUtils.GetInstanceName(ctx, apiClient.DefaultAPI, model.ProjectId, model.InstanceId, model.Region) if err != nil { params.Printer.Debug(print.ErrorLevel, "get instance name: %v", err) instanceLabel = model.InstanceId @@ -100,7 +100,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } // Call API - req, err := buildRequest(ctx, model, apiClient) + req, err := buildRequest(ctx, model, apiClient.DefaultAPI) if err != nil { return err } @@ -113,7 +113,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { // Wait for async operation, if async mode not enabled if !model.Async { err := spinner.Run(params.Printer, "Updating instance", func() error { - _, err = wait.PartialUpdateInstanceWaitHandler(ctx, apiClient, model.ProjectId, instanceId, model.Region).WaitWithContext(ctx) + _, err = wait.PartialUpdateInstanceWaitHandler(ctx, apiClient.DefaultAPI, model.ProjectId, instanceId, model.Region).WaitWithContext(ctx) return err }) if err != nil { @@ -133,8 +133,8 @@ func configureFlags(cmd *cobra.Command) { cmd.Flags().Var(flags.CIDRSliceFlag(), aclFlag, "Lists of IP networks in CIDR notation which are allowed to access this instance") cmd.Flags().String(backupScheduleFlag, "", "Backup schedule") cmd.Flags().String(flavorIdFlag, "", "ID of the flavor") - cmd.Flags().Int64(cpuFlag, 0, "Number of CPUs") - cmd.Flags().Int64(ramFlag, 0, "Amount of RAM (in GB)") + cmd.Flags().Int32(cpuFlag, 0, "Number of CPUs") + cmd.Flags().Int32(ramFlag, 0, "Amount of RAM (in GB)") cmd.Flags().String(storageClassFlag, "", "Storage class") cmd.Flags().Int64(storageSizeFlag, 0, "Storage size (in GB)") cmd.Flags().String(versionFlag, "", "Version") @@ -151,8 +151,8 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu instanceName := flags.FlagToStringPointer(p, cmd, instanceNameFlag) flavorId := flags.FlagToStringPointer(p, cmd, flavorIdFlag) - cpu := flags.FlagToInt64Pointer(p, cmd, cpuFlag) - ram := flags.FlagToInt64Pointer(p, cmd, ramFlag) + cpu := flags.FlagToInt32Pointer(p, cmd, cpuFlag) + ram := flags.FlagToInt32Pointer(p, cmd, ramFlag) acl := flags.FlagToStringSlicePointer(p, cmd, aclFlag) backupSchedule := flags.FlagToStringPointer(p, cmd, backupScheduleFlag) storageClass := flags.FlagToStringPointer(p, cmd, storageClassFlag) @@ -193,9 +193,9 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu type MongoDBFlexClient interface { PartialUpdateInstance(ctx context.Context, projectId, instanceId, region string) mongodbflex.ApiPartialUpdateInstanceRequest - GetInstanceExecute(ctx context.Context, projectId, instanceId, region string) (*mongodbflex.InstanceResponse, error) - ListFlavorsExecute(ctx context.Context, projectId, region string) (*mongodbflex.ListFlavorsResponse, error) - ListStoragesExecute(ctx context.Context, projectId, flavorId, region string) (*mongodbflex.ListStoragesResponse, error) + GetInstance(ctx context.Context, projectId, instanceId, region string) mongodbflex.ApiGetInstanceRequest + ListFlavors(ctx context.Context, projectId, region string) mongodbflex.ApiListFlavorsRequest + ListStorages(ctx context.Context, projectId, flavorId, region string) mongodbflex.ApiListStoragesRequest } func buildRequest(ctx context.Context, model *inputModel, apiClient MongoDBFlexClient) (mongodbflex.ApiPartialUpdateInstanceRequest, error) { @@ -204,7 +204,7 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient MongoDBFlexC var flavorId *string var err error - flavors, err := apiClient.ListFlavorsExecute(ctx, model.ProjectId, model.Region) + flavors, err := apiClient.ListFlavors(ctx, model.ProjectId, model.Region).Execute() if err != nil { return req, fmt.Errorf("get MongoDB Flex flavors: %w", err) } @@ -213,7 +213,7 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient MongoDBFlexC ram := model.RAM cpu := model.CPU if model.RAM == nil || model.CPU == nil { - currentInstance, err := apiClient.GetInstanceExecute(ctx, model.ProjectId, model.InstanceId, model.Region) + currentInstance, err := apiClient.GetInstance(ctx, model.ProjectId, model.InstanceId, model.Region).Execute() if err != nil { return req, fmt.Errorf("get MongoDB Flex instance: %w", err) } @@ -224,7 +224,7 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient MongoDBFlexC cpu = currentInstance.Item.Flavor.Cpu } } - flavorId, err = mongodbflexUtils.LoadFlavorId(*cpu, *ram, flavors.Flavors) + flavorId, err = mongodbflexUtils.LoadFlavorId(*cpu, *ram, &flavors.Flavors) if err != nil { var dsaInvalidPlanError *cliErr.DSAInvalidPlanError if !errors.As(err, &dsaInvalidPlanError) { @@ -244,13 +244,13 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient MongoDBFlexC if model.StorageClass != nil || model.StorageSize != nil { validationFlavorId := flavorId if validationFlavorId == nil { - currentInstance, err := apiClient.GetInstanceExecute(ctx, model.ProjectId, model.InstanceId, model.Region) + currentInstance, err := apiClient.GetInstance(ctx, model.ProjectId, model.InstanceId, model.Region).Execute() if err != nil { return req, fmt.Errorf("get MongoDB Flex instance: %w", err) } validationFlavorId = currentInstance.Item.Flavor.Id } - storages, err = apiClient.ListStoragesExecute(ctx, model.ProjectId, *validationFlavorId, model.Region) + storages, err = apiClient.ListStorages(ctx, model.ProjectId, *validationFlavorId, model.Region).Execute() if err != nil { return req, fmt.Errorf("get MongoDB Flex storages: %w", err) } @@ -262,7 +262,7 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient MongoDBFlexC var payloadAcl *mongodbflex.ACL if model.ACL != nil { - payloadAcl = &mongodbflex.ACL{Items: model.ACL} + payloadAcl = &mongodbflex.ACL{Items: *model.ACL} } var payloadStorage *mongodbflex.Storage @@ -273,7 +273,7 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient MongoDBFlexC } } - var replicas *int64 + var replicas *int32 var payloadOptions *map[string]string if model.Type != nil { replicasInt, err := mongodbflexUtils.GetInstanceReplicas(*model.Type) diff --git a/internal/cmd/mongodbflex/instance/update/update_test.go b/internal/cmd/mongodbflex/instance/update/update_test.go index 0a12cf79d..5b34c94f0 100644 --- a/internal/cmd/mongodbflex/instance/update/update_test.go +++ b/internal/cmd/mongodbflex/instance/update/update_test.go @@ -12,7 +12,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex" + mongodbflex "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex/v2api" ) const ( @@ -22,9 +22,9 @@ const ( type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &mongodbflex.APIClient{} +var testClient = &mongodbflex.APIClient{DefaultAPI: &mongodbflex.DefaultAPIService{}} -type mongoDBFlexClientMocked struct { +type mockClientSettings struct { listFlavorsFails bool listFlavorsResp *mongodbflex.ListFlavorsResponse listStoragesFails bool @@ -33,29 +33,27 @@ type mongoDBFlexClientMocked struct { getInstanceResp *mongodbflex.InstanceResponse } -func (c *mongoDBFlexClientMocked) PartialUpdateInstance(ctx context.Context, projectId, instanceId, region string) mongodbflex.ApiPartialUpdateInstanceRequest { - return testClient.PartialUpdateInstance(ctx, projectId, instanceId, region) -} - -func (c *mongoDBFlexClientMocked) GetInstanceExecute(_ context.Context, _, _, _ string) (*mongodbflex.InstanceResponse, error) { - if c.getInstanceFails { - return nil, fmt.Errorf("get instance failed") - } - return c.getInstanceResp, nil -} - -func (c *mongoDBFlexClientMocked) ListStoragesExecute(_ context.Context, _, _, _ string) (*mongodbflex.ListStoragesResponse, error) { - if c.listFlavorsFails { - return nil, fmt.Errorf("list storages failed") - } - return c.listStoragesResp, nil -} - -func (c *mongoDBFlexClientMocked) ListFlavorsExecute(_ context.Context, _, _ string) (*mongodbflex.ListFlavorsResponse, error) { - if c.listFlavorsFails { - return nil, fmt.Errorf("list flavors failed") +func newAPIClientMock(c mockClientSettings) mongodbflex.DefaultAPI { + return mongodbflex.DefaultAPIServiceMock{ + GetInstanceExecuteMock: utils.Ptr(func(_ mongodbflex.ApiGetInstanceRequest) (*mongodbflex.InstanceResponse, error) { + if c.getInstanceFails { + return nil, fmt.Errorf("get instance failed") + } + return c.getInstanceResp, nil + }), + ListStoragesExecuteMock: utils.Ptr(func(_ mongodbflex.ApiListStoragesRequest) (*mongodbflex.ListStoragesResponse, error) { + if c.listFlavorsFails { + return nil, fmt.Errorf("list storages failed") + } + return c.listStoragesResp, nil + }), + ListFlavorsExecuteMock: utils.Ptr(func(_ mongodbflex.ApiListFlavorsRequest) (*mongodbflex.ListFlavorsResponse, error) { + if c.listFlavorsFails { + return nil, fmt.Errorf("list flavors failed") + } + return c.listFlavorsResp, nil + }), } - return c.listFlavorsResp, nil } var testProjectId = uuid.NewString() @@ -141,7 +139,7 @@ func fixtureStandardInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *mongodbflex.ApiPartialUpdateInstanceRequest)) mongodbflex.ApiPartialUpdateInstanceRequest { - request := testClient.PartialUpdateInstance(testCtx, testProjectId, testInstanceId, testRegion) + request := testClient.DefaultAPI.PartialUpdateInstance(testCtx, testProjectId, testInstanceId, testRegion) request = request.PartialUpdateInstancePayload(mongodbflex.PartialUpdateInstancePayload{}) for _, mod := range mods { mod(&request) @@ -201,8 +199,8 @@ func TestParseInput(t *testing.T) { isValid: true, expectedModel: fixtureStandardInputModel(func(model *inputModel) { model.FlavorId = nil - model.CPU = utils.Ptr(int64(2)) - model.RAM = utils.Ptr(int64(4)) + model.CPU = utils.Ptr(int32(2)) + model.RAM = utils.Ptr(int32(4)) }), }, { @@ -374,15 +372,15 @@ func TestBuildRequest(t *testing.T) { }), isValid: true, listFlavorsResp: &mongodbflex.ListFlavorsResponse{ - Flavors: &[]mongodbflex.InstanceFlavor{ + Flavors: []mongodbflex.InstanceFlavor{ { Id: utils.Ptr(testFlavorId), - Cpu: utils.Ptr(int64(2)), - Memory: utils.Ptr(int64(4)), + Cpu: utils.Ptr(int32(2)), + Memory: utils.Ptr(int32(4)), }, }, }, - expectedRequest: testClient.PartialUpdateInstance(testCtx, testProjectId, testInstanceId, testRegion). + expectedRequest: testClient.DefaultAPI.PartialUpdateInstance(testCtx, testProjectId, testInstanceId, testRegion). PartialUpdateInstancePayload(mongodbflex.PartialUpdateInstancePayload{ FlavorId: utils.Ptr(testFlavorId), }), @@ -390,20 +388,20 @@ func TestBuildRequest(t *testing.T) { { description: "update flavor from cpu and ram", model: fixtureRequiredInputModel(func(model *inputModel) { - model.CPU = utils.Ptr(int64(2)) - model.RAM = utils.Ptr(int64(4)) + model.CPU = utils.Ptr(int32(2)) + model.RAM = utils.Ptr(int32(4)) }), isValid: true, listFlavorsResp: &mongodbflex.ListFlavorsResponse{ - Flavors: &[]mongodbflex.InstanceFlavor{ + Flavors: []mongodbflex.InstanceFlavor{ { Id: utils.Ptr(testFlavorId), - Cpu: utils.Ptr(int64(2)), - Memory: utils.Ptr(int64(4)), + Cpu: utils.Ptr(int32(2)), + Memory: utils.Ptr(int32(4)), }, }, }, - expectedRequest: testClient.PartialUpdateInstance(testCtx, testProjectId, testInstanceId, testRegion). + expectedRequest: testClient.DefaultAPI.PartialUpdateInstance(testCtx, testProjectId, testInstanceId, testRegion). PartialUpdateInstancePayload(mongodbflex.PartialUpdateInstancePayload{ FlavorId: utils.Ptr(testFlavorId), }), @@ -422,13 +420,13 @@ func TestBuildRequest(t *testing.T) { }, }, listStoragesResp: &mongodbflex.ListStoragesResponse{ - StorageClasses: &[]string{"class"}, + StorageClasses: []string{"class"}, StorageRange: &mongodbflex.StorageRange{ Min: utils.Ptr(int64(10)), Max: utils.Ptr(int64(100)), }, }, - expectedRequest: testClient.PartialUpdateInstance(testCtx, testProjectId, testInstanceId, testRegion). + expectedRequest: testClient.DefaultAPI.PartialUpdateInstance(testCtx, testProjectId, testInstanceId, testRegion). PartialUpdateInstancePayload(mongodbflex.PartialUpdateInstancePayload{ Storage: &mongodbflex.Storage{ Class: utils.Ptr("class"), @@ -450,13 +448,13 @@ func TestBuildRequest(t *testing.T) { }, }, listStoragesResp: &mongodbflex.ListStoragesResponse{ - StorageClasses: &[]string{"class"}, + StorageClasses: []string{"class"}, StorageRange: &mongodbflex.StorageRange{ Min: utils.Ptr(int64(10)), Max: utils.Ptr(int64(100)), }, }, - expectedRequest: testClient.PartialUpdateInstance(testCtx, testProjectId, testInstanceId, testRegion). + expectedRequest: testClient.DefaultAPI.PartialUpdateInstance(testCtx, testProjectId, testInstanceId, testRegion). PartialUpdateInstancePayload(mongodbflex.PartialUpdateInstancePayload{ Storage: &mongodbflex.Storage{ Class: utils.Ptr("class"), @@ -468,8 +466,8 @@ func TestBuildRequest(t *testing.T) { description: "get flavors fails", model: fixtureRequiredInputModel( func(model *inputModel) { - model.CPU = utils.Ptr(int64(2)) - model.RAM = utils.Ptr(int64(4)) + model.CPU = utils.Ptr(int32(2)) + model.RAM = utils.Ptr(int32(4)) }, ), listFlavorsFails: true, @@ -479,21 +477,21 @@ func TestBuildRequest(t *testing.T) { description: "flavor id not found", model: fixtureRequiredInputModel( func(model *inputModel) { - model.CPU = utils.Ptr(int64(5)) - model.RAM = utils.Ptr(int64(9)) + model.CPU = utils.Ptr(int32(5)) + model.RAM = utils.Ptr(int32(9)) }, ), listFlavorsResp: &mongodbflex.ListFlavorsResponse{ - Flavors: &[]mongodbflex.InstanceFlavor{ + Flavors: []mongodbflex.InstanceFlavor{ { Id: utils.Ptr(testFlavorId), - Cpu: utils.Ptr(int64(2)), - Memory: utils.Ptr(int64(4)), + Cpu: utils.Ptr(int32(2)), + Memory: utils.Ptr(int32(4)), }, { Id: utils.Ptr("other-flavor"), - Cpu: utils.Ptr(int64(1)), - Memory: utils.Ptr(int64(8)), + Cpu: utils.Ptr(int32(1)), + Memory: utils.Ptr(int32(8)), }, }, }, @@ -514,8 +512,8 @@ func TestBuildRequest(t *testing.T) { model: fixtureRequiredInputModel( func(model *inputModel) { model.FlavorId = nil - model.CPU = utils.Ptr(int64(2)) - model.RAM = utils.Ptr(int64(4)) + model.CPU = utils.Ptr(int32(2)) + model.RAM = utils.Ptr(int32(4)) }, ), listFlavorsFails: true, @@ -536,7 +534,7 @@ func TestBuildRequest(t *testing.T) { }, }, listStoragesResp: &mongodbflex.ListStoragesResponse{ - StorageClasses: &[]string{"class"}, + StorageClasses: []string{"class"}, StorageRange: &mongodbflex.StorageRange{ Min: utils.Ptr(int64(10)), Max: utils.Ptr(int64(100)), @@ -559,7 +557,7 @@ func TestBuildRequest(t *testing.T) { }, }, listStoragesResp: &mongodbflex.ListStoragesResponse{ - StorageClasses: &[]string{"class"}, + StorageClasses: []string{"class"}, StorageRange: &mongodbflex.StorageRange{ Min: utils.Ptr(int64(10)), Max: utils.Ptr(int64(100)), @@ -571,7 +569,7 @@ func TestBuildRequest(t *testing.T) { for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { - client := &mongoDBFlexClientMocked{ + settings := mockClientSettings{ getInstanceFails: tt.getInstanceFails, getInstanceResp: tt.getInstanceResp, listFlavorsFails: tt.listFlavorsFails, @@ -579,7 +577,7 @@ func TestBuildRequest(t *testing.T) { listStoragesFails: tt.listStoragesFails, listStoragesResp: tt.listStoragesResp, } - request, err := buildRequest(testCtx, tt.model, client) + request, err := buildRequest(testCtx, tt.model, newAPIClientMock(settings)) if err != nil { if !tt.isValid { return @@ -590,6 +588,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), cmpopts.EquateComparable(testCtx), + cmpopts.IgnoreFields(tt.expectedRequest, "ApiService"), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/mongodbflex/options/options.go b/internal/cmd/mongodbflex/options/options.go index a49d3bc84..1941ffbc1 100644 --- a/internal/cmd/mongodbflex/options/options.go +++ b/internal/cmd/mongodbflex/options/options.go @@ -7,7 +7,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/types" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex" + mongodbflex "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex/v2api" "github.com/stackitcloud/stackit-cli/internal/pkg/args" "github.com/stackitcloud/stackit-cli/internal/pkg/examples" @@ -36,9 +36,9 @@ type inputModel struct { } type options struct { - Flavors *[]mongodbflex.InstanceFlavor `json:"flavors,omitempty"` - Versions *[]string `json:"versions,omitempty"` - Storages *flavorStorages `json:"flavorStorages,omitempty"` + Flavors []mongodbflex.InstanceFlavor `json:"flavors,omitempty"` + Versions []string `json:"versions,omitempty"` + Storages *flavorStorages `json:"flavorStorages,omitempty"` } type flavorStorages struct { @@ -77,7 +77,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } // Call API - err = buildAndExecuteRequest(ctx, params.Printer, model, apiClient) + err = buildAndExecuteRequest(ctx, params.Printer, model, apiClient.DefaultAPI) if err != nil { return fmt.Errorf("get MongoDB Flex options: %w", err) } @@ -129,9 +129,9 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, } type mongoDBFlexOptionsClient interface { - ListFlavorsExecute(ctx context.Context, projectId, region string) (*mongodbflex.ListFlavorsResponse, error) - ListVersionsExecute(ctx context.Context, projectId, region string) (*mongodbflex.ListVersionsResponse, error) - ListStoragesExecute(ctx context.Context, projectId, flavorId, region string) (*mongodbflex.ListStoragesResponse, error) + ListFlavors(ctx context.Context, projectId, region string) mongodbflex.ApiListFlavorsRequest + ListVersions(ctx context.Context, projectId, region string) mongodbflex.ApiListVersionsRequest + ListStorages(ctx context.Context, projectId, flavorId, region string) mongodbflex.ApiListStoragesRequest } func buildAndExecuteRequest(ctx context.Context, p *print.Printer, model *inputModel, apiClient mongoDBFlexOptionsClient) error { @@ -141,19 +141,19 @@ func buildAndExecuteRequest(ctx context.Context, p *print.Printer, model *inputM var err error if model.Flavors { - flavors, err = apiClient.ListFlavorsExecute(ctx, model.ProjectId, model.Region) + flavors, err = apiClient.ListFlavors(ctx, model.ProjectId, model.Region).Execute() if err != nil { return fmt.Errorf("get MongoDB Flex flavors: %w", err) } } if model.Versions { - versions, err = apiClient.ListVersionsExecute(ctx, model.ProjectId, model.Region) + versions, err = apiClient.ListVersions(ctx, model.ProjectId, model.Region).Execute() if err != nil { return fmt.Errorf("get MongoDB Flex versions: %w", err) } } if model.Storages { - storages, err = apiClient.ListStoragesExecute(ctx, model.ProjectId, *model.FlavorId, model.Region) + storages, err = apiClient.ListStorages(ctx, model.ProjectId, *model.FlavorId, model.Region).Execute() if err != nil { return fmt.Errorf("get MongoDB Flex storages: %w", err) } @@ -194,13 +194,13 @@ func outputResultAsTable(p *print.Printer, model *inputModel, options *options) } content := []tables.Table{} - if model.Flavors && len(*options.Flavors) != 0 { - content = append(content, buildFlavorsTable(*options.Flavors)) + if model.Flavors && len(options.Flavors) != 0 { + content = append(content, buildFlavorsTable(options.Flavors)) } - if model.Versions && len(*options.Versions) != 0 { - content = append(content, buildVersionsTable(*options.Versions)) + if model.Versions && len(options.Versions) != 0 { + content = append(content, buildVersionsTable(options.Versions)) } - if model.Storages && options.Storages.Storages != nil && len(*options.Storages.Storages.StorageClasses) > 0 { + if model.Storages && options.Storages.Storages != nil && len(options.Storages.Storages.StorageClasses) > 0 { content = append(content, buildStoragesTable(*options.Storages.Storages)) } @@ -223,7 +223,7 @@ func buildFlavorsTable(flavors []mongodbflex.InstanceFlavor) tables.Table { utils.PtrString(f.Cpu), utils.PtrString(f.Memory), utils.PtrString(f.Description), - utils.PtrString(f.Categories), + f.Categories, ) } return table @@ -241,16 +241,15 @@ func buildVersionsTable(versions []string) tables.Table { } func buildStoragesTable(storagesResp mongodbflex.ListStoragesResponse) tables.Table { - storages := *storagesResp.StorageClasses + storages := storagesResp.StorageClasses table := tables.NewTable() table.SetTitle("Storages") table.SetHeader("MINIMUM", "MAXIMUM", "STORAGE CLASS") - for i := range storages { - sc := storages[i] + for _, storageClass := range storages { table.AddRow( utils.PtrString(storagesResp.StorageRange.Min), utils.PtrString(storagesResp.StorageRange.Max), - sc, + storageClass, ) } table.EnableAutoMergeOnColumns(1, 2, 3) diff --git a/internal/cmd/mongodbflex/options/options_test.go b/internal/cmd/mongodbflex/options/options_test.go index cf5b3a154..667db24b9 100644 --- a/internal/cmd/mongodbflex/options/options_test.go +++ b/internal/cmd/mongodbflex/options/options_test.go @@ -10,14 +10,14 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/testutils" "github.com/stackitcloud/stackit-cli/internal/pkg/utils" - "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex" + mongodbflex "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex/v2api" ) type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -type mongoDBFlexClientMocked struct { +type mockSettings struct { listFlavorsFails bool listVersionsFails bool listStoragesFails bool @@ -27,38 +27,40 @@ type mongoDBFlexClientMocked struct { listStoragesCalled bool } -func (c *mongoDBFlexClientMocked) ListFlavorsExecute(_ context.Context, _, _ string) (*mongodbflex.ListFlavorsResponse, error) { - c.listFlavorsCalled = true - if c.listFlavorsFails { - return nil, fmt.Errorf("list flavors failed") - } - return utils.Ptr(mongodbflex.ListFlavorsResponse{ - Flavors: utils.Ptr([]mongodbflex.InstanceFlavor{}), - }), nil -} - -func (c *mongoDBFlexClientMocked) ListVersionsExecute(_ context.Context, _, _ string) (*mongodbflex.ListVersionsResponse, error) { - c.listVersionsCalled = true - if c.listVersionsFails { - return nil, fmt.Errorf("list versions failed") - } - return utils.Ptr(mongodbflex.ListVersionsResponse{ - Versions: utils.Ptr([]string{}), - }), nil -} - -func (c *mongoDBFlexClientMocked) ListStoragesExecute(_ context.Context, _, _, _ string) (*mongodbflex.ListStoragesResponse, error) { - c.listStoragesCalled = true - if c.listStoragesFails { - return nil, fmt.Errorf("list storages failed") +func newAPIClientMock(c *mockSettings) mongodbflex.DefaultAPI { + return mongodbflex.DefaultAPIServiceMock{ + ListFlavorsExecuteMock: utils.Ptr(func(_ mongodbflex.ApiListFlavorsRequest) (*mongodbflex.ListFlavorsResponse, error) { + c.listFlavorsCalled = true + if c.listFlavorsFails { + return nil, fmt.Errorf("list flavors failed") + } + return utils.Ptr(mongodbflex.ListFlavorsResponse{ + Flavors: []mongodbflex.InstanceFlavor{}, + }), nil + }), + ListVersionsExecuteMock: utils.Ptr(func(_ mongodbflex.ApiListVersionsRequest) (*mongodbflex.ListVersionsResponse, error) { + c.listVersionsCalled = true + if c.listVersionsFails { + return nil, fmt.Errorf("list versions failed") + } + return utils.Ptr(mongodbflex.ListVersionsResponse{ + Versions: []string{}, + }), nil + }), + ListStoragesExecuteMock: utils.Ptr(func(_ mongodbflex.ApiListStoragesRequest) (*mongodbflex.ListStoragesResponse, error) { + c.listStoragesCalled = true + if c.listStoragesFails { + return nil, fmt.Errorf("list storages failed") + } + return utils.Ptr(mongodbflex.ListStoragesResponse{ + StorageClasses: []string{}, + StorageRange: &mongodbflex.StorageRange{ + Min: utils.Ptr(int64(10)), + Max: utils.Ptr(int64(100)), + }, + }), nil + }), } - return utils.Ptr(mongodbflex.ListStoragesResponse{ - StorageClasses: utils.Ptr([]string{}), - StorageRange: &mongodbflex.StorageRange{ - Min: utils.Ptr(int64(10)), - Max: utils.Ptr(int64(100)), - }, - }), nil } func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string { @@ -177,9 +179,7 @@ func TestBuildAndExecuteRequest(t *testing.T) { description string model *inputModel isValid bool - listFlavorsFails bool - listVersionsFails bool - listStoragesFails bool + mockClientSettings mockSettings expectListFlavorsCalled bool expectListVersionsCalled bool expectListStoragesCalled bool @@ -222,28 +222,34 @@ func TestBuildAndExecuteRequest(t *testing.T) { expectListStoragesCalled: true, }, { - description: "list flavors fails", - model: fixtureInputModelAllTrue(), - isValid: false, - listFlavorsFails: true, + description: "list flavors fails", + model: fixtureInputModelAllTrue(), + isValid: false, + mockClientSettings: mockSettings{ + listFlavorsFails: true, + }, expectListFlavorsCalled: true, expectListVersionsCalled: false, expectListStoragesCalled: false, }, { - description: "list versions fails", - model: fixtureInputModelAllTrue(), - isValid: false, - listVersionsFails: true, + description: "list versions fails", + model: fixtureInputModelAllTrue(), + isValid: false, + mockClientSettings: mockSettings{ + listVersionsFails: true, + }, expectListFlavorsCalled: true, expectListVersionsCalled: true, expectListStoragesCalled: false, }, { - description: "list storages fails", - model: fixtureInputModelAllTrue(), - isValid: false, - listStoragesFails: true, + description: "list storages fails", + model: fixtureInputModelAllTrue(), + isValid: false, + mockClientSettings: mockSettings{ + listStoragesFails: true, + }, expectListFlavorsCalled: true, expectListVersionsCalled: true, expectListStoragesCalled: true, @@ -253,13 +259,8 @@ func TestBuildAndExecuteRequest(t *testing.T) { for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { params := testparams.NewTestParams() - client := &mongoDBFlexClientMocked{ - listFlavorsFails: tt.listFlavorsFails, - listVersionsFails: tt.listVersionsFails, - listStoragesFails: tt.listStoragesFails, - } - err := buildAndExecuteRequest(testCtx, params.Printer, tt.model, client) + err := buildAndExecuteRequest(testCtx, params.Printer, tt.model, newAPIClientMock(&tt.mockClientSettings)) if err != nil && tt.isValid { t.Fatalf("error building and executing request: %v", err) } @@ -270,14 +271,14 @@ func TestBuildAndExecuteRequest(t *testing.T) { return } - if tt.expectListFlavorsCalled != client.listFlavorsCalled { - t.Fatalf("expected listFlavorsCalled to be %v, got %v", tt.expectListFlavorsCalled, client.listFlavorsCalled) + if tt.expectListFlavorsCalled != (tt.mockClientSettings).listFlavorsCalled { + t.Fatalf("expected listFlavorsCalled to be %v, got %v", tt.expectListFlavorsCalled, (tt.mockClientSettings).listFlavorsCalled) } - if tt.expectListVersionsCalled != client.listVersionsCalled { - t.Fatalf("expected listVersionsCalled to be %v, got %v", tt.expectListVersionsCalled, client.listVersionsCalled) + if tt.expectListVersionsCalled != (tt.mockClientSettings).listVersionsCalled { + t.Fatalf("expected listVersionsCalled to be %v, got %v", tt.expectListVersionsCalled, (tt.mockClientSettings).listVersionsCalled) } - if tt.expectListStoragesCalled != client.listStoragesCalled { - t.Fatalf("expected listStoragesCalled to be %v, got %v", tt.expectListStoragesCalled, client.listStoragesCalled) + if tt.expectListStoragesCalled != (tt.mockClientSettings).listStoragesCalled { + t.Fatalf("expected listStoragesCalled to be %v, got %v", tt.expectListStoragesCalled, (tt.mockClientSettings).listStoragesCalled) } }) } diff --git a/internal/cmd/mongodbflex/user/create/create.go b/internal/cmd/mongodbflex/user/create/create.go index 886027376..692e7abb8 100644 --- a/internal/cmd/mongodbflex/user/create/create.go +++ b/internal/cmd/mongodbflex/user/create/create.go @@ -7,7 +7,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/types" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex" + mongodbflex "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex/v2api" "github.com/stackitcloud/stackit-cli/internal/pkg/args" "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -77,7 +77,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return err } - instanceLabel, err := mongodbflexUtils.GetInstanceName(ctx, apiClient, model.ProjectId, model.InstanceId, model.Region) + instanceLabel, err := mongodbflexUtils.GetInstanceName(ctx, apiClient.DefaultAPI, model.ProjectId, model.InstanceId, model.Region) if err != nil { params.Printer.Debug(print.ErrorLevel, "get instance name: %v", err) instanceLabel = model.InstanceId @@ -134,11 +134,11 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, } func buildRequest(ctx context.Context, model *inputModel, apiClient *mongodbflex.APIClient) mongodbflex.ApiCreateUserRequest { - req := apiClient.CreateUser(ctx, model.ProjectId, model.InstanceId, model.Region) + req := apiClient.DefaultAPI.CreateUser(ctx, model.ProjectId, model.InstanceId, model.Region) req = req.CreateUserPayload(mongodbflex.CreateUserPayload{ Username: model.Username, - Database: model.Database, - Roles: model.Roles, + Database: *model.Database, + Roles: *model.Roles, }) return req } @@ -152,7 +152,7 @@ func outputResult(p *print.Printer, outputFormat, instanceLabel string, user *mo p.Outputf("Created user for instance %q. User ID: %s\n\n", instanceLabel, utils.PtrString(user.Id)) p.Outputf("Username: %s\n", utils.PtrString(user.Username)) p.Outputf("Password: %s\n", utils.PtrString(user.Password)) - p.Outputf("Roles: %v\n", utils.PtrString(user.Roles)) + p.Outputf("Roles: %v\n", user.Roles) p.Outputf("Database: %s\n", utils.PtrString(user.Database)) p.Outputf("Host: %s\n", utils.PtrString(user.Host)) p.Outputf("Port: %s\n", utils.PtrString(user.Port)) diff --git a/internal/cmd/mongodbflex/user/create/create_test.go b/internal/cmd/mongodbflex/user/create/create_test.go index b290fb3a4..937b32344 100644 --- a/internal/cmd/mongodbflex/user/create/create_test.go +++ b/internal/cmd/mongodbflex/user/create/create_test.go @@ -12,7 +12,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex" + mongodbflex "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex/v2api" ) const ( @@ -22,7 +22,7 @@ const ( type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &mongodbflex.APIClient{} +var testClient = &mongodbflex.APIClient{DefaultAPI: &mongodbflex.DefaultAPIService{}} var testProjectId = uuid.NewString() var testInstanceId = uuid.NewString() @@ -59,11 +59,11 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *mongodbflex.ApiCreateUserRequest)) mongodbflex.ApiCreateUserRequest { - request := testClient.CreateUser(testCtx, testProjectId, testInstanceId, testRegion) + request := testClient.DefaultAPI.CreateUser(testCtx, testProjectId, testInstanceId, testRegion) request = request.CreateUserPayload(mongodbflex.CreateUserPayload{ Username: utils.Ptr("johndoe"), - Database: utils.Ptr("default"), - Roles: utils.Ptr([]string{"read"}), + Database: "default", + Roles: []string{"read"}, }) for _, mod := range mods { @@ -187,8 +187,8 @@ func TestBuildRequest(t *testing.T) { model.Username = nil }), expectedRequest: fixtureRequest().CreateUserPayload(mongodbflex.CreateUserPayload{ - Database: utils.Ptr("default"), - Roles: utils.Ptr([]string{"read"}), + Database: "default", + Roles: []string{"read"}, }), }, } @@ -199,7 +199,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, mongodbflex.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/mongodbflex/user/delete/delete.go b/internal/cmd/mongodbflex/user/delete/delete.go index 823f43d65..75477948b 100644 --- a/internal/cmd/mongodbflex/user/delete/delete.go +++ b/internal/cmd/mongodbflex/user/delete/delete.go @@ -17,7 +17,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex" + mongodbflex "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex/v2api" ) const ( @@ -60,13 +60,13 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return err } - instanceLabel, err := mongodbflexUtils.GetInstanceName(ctx, apiClient, model.ProjectId, model.InstanceId, model.Region) + instanceLabel, err := mongodbflexUtils.GetInstanceName(ctx, apiClient.DefaultAPI, model.ProjectId, model.InstanceId, model.Region) if err != nil { params.Printer.Debug(print.ErrorLevel, "get instance name: %v", err) instanceLabel = model.InstanceId } - userLabel, err := mongodbflexUtils.GetUserName(ctx, apiClient, model.ProjectId, model.InstanceId, model.UserId, model.Region) + userLabel, err := mongodbflexUtils.GetUserName(ctx, apiClient.DefaultAPI, model.ProjectId, model.InstanceId, model.UserId, model.Region) if err != nil { params.Printer.Debug(print.ErrorLevel, "get user name: %v", err) userLabel = model.UserId @@ -119,6 +119,6 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *mongodbflex.APIClient) mongodbflex.ApiDeleteUserRequest { - req := apiClient.DeleteUser(ctx, model.ProjectId, model.InstanceId, model.UserId, model.Region) + req := apiClient.DefaultAPI.DeleteUser(ctx, model.ProjectId, model.InstanceId, model.UserId, model.Region) return req } diff --git a/internal/cmd/mongodbflex/user/delete/delete_test.go b/internal/cmd/mongodbflex/user/delete/delete_test.go index e324f0010..d14df20cc 100644 --- a/internal/cmd/mongodbflex/user/delete/delete_test.go +++ b/internal/cmd/mongodbflex/user/delete/delete_test.go @@ -10,7 +10,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex" + mongodbflex "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex/v2api" ) const ( @@ -20,7 +20,7 @@ const ( type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &mongodbflex.APIClient{} +var testClient = &mongodbflex.APIClient{DefaultAPI: &mongodbflex.DefaultAPIService{}} var testProjectId = uuid.NewString() var testInstanceId = uuid.NewString() var testUserId = uuid.NewString() @@ -64,7 +64,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *mongodbflex.ApiDeleteUserRequest)) mongodbflex.ApiDeleteUserRequest { - request := testClient.DeleteUser(testCtx, testProjectId, testInstanceId, testUserId, testRegion) + request := testClient.DefaultAPI.DeleteUser(testCtx, testProjectId, testInstanceId, testUserId, testRegion) for _, mod := range mods { mod(&request) } @@ -192,7 +192,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, mongodbflex.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/mongodbflex/user/describe/describe.go b/internal/cmd/mongodbflex/user/describe/describe.go index 038894cfc..f6d85cbb3 100644 --- a/internal/cmd/mongodbflex/user/describe/describe.go +++ b/internal/cmd/mongodbflex/user/describe/describe.go @@ -17,7 +17,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex" + mongodbflex "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex/v2api" ) const ( @@ -105,7 +105,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *mongodbflex.APIClient) mongodbflex.ApiGetUserRequest { - req := apiClient.GetUser(ctx, model.ProjectId, model.InstanceId, model.UserId, model.Region) + req := apiClient.DefaultAPI.GetUser(ctx, model.ProjectId, model.InstanceId, model.UserId, model.Region) return req } @@ -116,7 +116,7 @@ func outputResult(p *print.Printer, outputFormat string, user mongodbflex.Instan table.AddSeparator() table.AddRow("USERNAME", utils.PtrString(user.Username)) table.AddSeparator() - table.AddRow("ROLES", utils.PtrString(user.Roles)) + table.AddRow("ROLES", user.Roles) table.AddSeparator() table.AddRow("DATABASE", utils.PtrString(user.Database)) table.AddSeparator() diff --git a/internal/cmd/mongodbflex/user/describe/describe_test.go b/internal/cmd/mongodbflex/user/describe/describe_test.go index 4609ba120..8a67beda2 100644 --- a/internal/cmd/mongodbflex/user/describe/describe_test.go +++ b/internal/cmd/mongodbflex/user/describe/describe_test.go @@ -11,7 +11,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex" + mongodbflex "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex/v2api" ) const ( @@ -21,7 +21,7 @@ const ( type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &mongodbflex.APIClient{} +var testClient = &mongodbflex.APIClient{DefaultAPI: &mongodbflex.DefaultAPIService{}} var testProjectId = uuid.NewString() var testInstanceId = uuid.NewString() var testUserId = uuid.NewString() @@ -65,7 +65,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *mongodbflex.ApiGetUserRequest)) mongodbflex.ApiGetUserRequest { - request := testClient.GetUser(testCtx, testProjectId, testInstanceId, testUserId, testRegion) + request := testClient.DefaultAPI.GetUser(testCtx, testProjectId, testInstanceId, testUserId, testRegion) for _, mod := range mods { mod(&request) } @@ -193,7 +193,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, mongodbflex.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/mongodbflex/user/list/list.go b/internal/cmd/mongodbflex/user/list/list.go index 57d8530b1..47c482ca3 100644 --- a/internal/cmd/mongodbflex/user/list/list.go +++ b/internal/cmd/mongodbflex/user/list/list.go @@ -18,7 +18,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex" + mongodbflex "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex/v2api" ) const ( @@ -69,9 +69,9 @@ func NewCmd(params *types.CmdParams) *cobra.Command { if err != nil { return fmt.Errorf("get MongoDB Flex users: %w", err) } - users := utils.GetSliceFromPointer(resp.Items) + users := resp.Items - instanceLabel, err := mongodbflexUtils.GetInstanceName(ctx, apiClient, model.ProjectId, *model.InstanceId, model.Region) + instanceLabel, err := mongodbflexUtils.GetInstanceName(ctx, apiClient.DefaultAPI, model.ProjectId, *model.InstanceId, model.Region) if err != nil { params.Printer.Debug(print.ErrorLevel, "get instance name: %v", err) instanceLabel = *model.InstanceId @@ -123,7 +123,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, } func buildRequest(ctx context.Context, model *inputModel, apiClient *mongodbflex.APIClient) mongodbflex.ApiListUsersRequest { - req := apiClient.ListUsers(ctx, model.ProjectId, *model.InstanceId, model.Region) + req := apiClient.DefaultAPI.ListUsers(ctx, model.ProjectId, *model.InstanceId, model.Region) return req } diff --git a/internal/cmd/mongodbflex/user/list/list_test.go b/internal/cmd/mongodbflex/user/list/list_test.go index 26579a06e..d249268b3 100644 --- a/internal/cmd/mongodbflex/user/list/list_test.go +++ b/internal/cmd/mongodbflex/user/list/list_test.go @@ -12,7 +12,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex" + mongodbflex "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex/v2api" ) const ( @@ -22,7 +22,7 @@ const ( type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &mongodbflex.APIClient{} +var testClient = &mongodbflex.APIClient{DefaultAPI: &mongodbflex.DefaultAPIService{}} var testProjectId = uuid.NewString() var testInstanceId = uuid.NewString() @@ -56,7 +56,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *mongodbflex.ApiListUsersRequest)) mongodbflex.ApiListUsersRequest { - request := testClient.ListUsers(testCtx, testProjectId, testInstanceId, testRegion) + request := testClient.DefaultAPI.ListUsers(testCtx, testProjectId, testInstanceId, testRegion) for _, mod := range mods { mod(&request) } @@ -159,7 +159,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, mongodbflex.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/mongodbflex/user/reset-password/reset_password.go b/internal/cmd/mongodbflex/user/reset-password/reset_password.go index 749b8f9d0..8c21e3f6d 100644 --- a/internal/cmd/mongodbflex/user/reset-password/reset_password.go +++ b/internal/cmd/mongodbflex/user/reset-password/reset_password.go @@ -17,7 +17,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex" + mongodbflex "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex/v2api" ) const ( @@ -60,13 +60,13 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return err } - instanceLabel, err := mongodbflexUtils.GetInstanceName(ctx, apiClient, model.ProjectId, model.InstanceId, model.Region) + instanceLabel, err := mongodbflexUtils.GetInstanceName(ctx, apiClient.DefaultAPI, model.ProjectId, model.InstanceId, model.Region) if err != nil { params.Printer.Debug(print.ErrorLevel, "get instance name: %v", err) instanceLabel = model.InstanceId } - userLabel, err := mongodbflexUtils.GetUserName(ctx, apiClient, model.ProjectId, model.InstanceId, model.UserId, model.Region) + userLabel, err := mongodbflexUtils.GetUserName(ctx, apiClient.DefaultAPI, model.ProjectId, model.InstanceId, model.UserId, model.Region) if err != nil { params.Printer.Debug(print.ErrorLevel, "get user name: %v", err) userLabel = model.UserId @@ -119,7 +119,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *mongodbflex.APIClient) mongodbflex.ApiResetUserRequest { - req := apiClient.ResetUser(ctx, model.ProjectId, model.InstanceId, model.UserId, model.Region) + req := apiClient.DefaultAPI.ResetUser(ctx, model.ProjectId, model.InstanceId, model.UserId, model.Region) return req } diff --git a/internal/cmd/mongodbflex/user/reset-password/reset_password_test.go b/internal/cmd/mongodbflex/user/reset-password/reset_password_test.go index 21753d115..6843186b0 100644 --- a/internal/cmd/mongodbflex/user/reset-password/reset_password_test.go +++ b/internal/cmd/mongodbflex/user/reset-password/reset_password_test.go @@ -11,7 +11,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex" + mongodbflex "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex/v2api" ) const ( @@ -21,7 +21,7 @@ const ( type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &mongodbflex.APIClient{} +var testClient = &mongodbflex.APIClient{DefaultAPI: &mongodbflex.DefaultAPIService{}} var testProjectId = uuid.NewString() var testInstanceId = uuid.NewString() var testUserId = uuid.NewString() @@ -65,7 +65,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *mongodbflex.ApiResetUserRequest)) mongodbflex.ApiResetUserRequest { - request := testClient.ResetUser(testCtx, testProjectId, testInstanceId, testUserId, testRegion) + request := testClient.DefaultAPI.ResetUser(testCtx, testProjectId, testInstanceId, testUserId, testRegion) for _, mod := range mods { mod(&request) } @@ -193,7 +193,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, mongodbflex.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/mongodbflex/user/update/update.go b/internal/cmd/mongodbflex/user/update/update.go index bd107bafa..d8e67fc32 100644 --- a/internal/cmd/mongodbflex/user/update/update.go +++ b/internal/cmd/mongodbflex/user/update/update.go @@ -17,7 +17,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex" + mongodbflex "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex/v2api" ) const ( @@ -39,7 +39,7 @@ type inputModel struct { InstanceId string UserId string Database *string - Roles *[]string + Roles []string } func NewCmd(params *types.CmdParams) *cobra.Command { @@ -66,13 +66,13 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return err } - instanceLabel, err := mongodbflexUtils.GetInstanceName(ctx, apiClient, model.ProjectId, model.InstanceId, model.Region) + instanceLabel, err := mongodbflexUtils.GetInstanceName(ctx, apiClient.DefaultAPI, model.ProjectId, model.InstanceId, model.Region) if err != nil { params.Printer.Debug(print.ErrorLevel, "get instance name: %v", err) instanceLabel = model.InstanceId } - userLabel, err := mongodbflexUtils.GetUserName(ctx, apiClient, model.ProjectId, model.InstanceId, model.UserId, model.Region) + userLabel, err := mongodbflexUtils.GetUserName(ctx, apiClient.DefaultAPI, model.ProjectId, model.InstanceId, model.UserId, model.Region) if err != nil { params.Printer.Debug(print.ErrorLevel, "get user name: %v", err) userLabel = model.UserId @@ -105,6 +105,7 @@ func configureFlags(cmd *cobra.Command) { cmd.Flags().String(databaseFlag, "", "The database inside the MongoDB instance that the user has access to. If it does not exist, it will be created once the user writes to it") roleFlag.Register(cmd) + cmd.MarkFlagsOneRequired(databaseFlag, roleFlag.Name()) err := flags.MarkFlagsRequired(cmd, instanceIdFlag) cobra.CheckErr(err) } @@ -118,11 +119,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } database := flags.FlagToStringPointer(p, cmd, databaseFlag) - roles := roleFlag.Ptr() - - if database == nil && roles == nil { - return nil, &errors.EmptyUpdateError{} - } + roles := roleFlag.Get() model := inputModel{ GlobalFlagModel: globalFlags, @@ -137,7 +134,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *mongodbflex.APIClient) mongodbflex.ApiPartialUpdateUserRequest { - req := apiClient.PartialUpdateUser(ctx, model.ProjectId, model.InstanceId, model.UserId, model.Region) + req := apiClient.DefaultAPI.PartialUpdateUser(ctx, model.ProjectId, model.InstanceId, model.UserId, model.Region) req = req.PartialUpdateUserPayload(mongodbflex.PartialUpdateUserPayload{ Database: model.Database, Roles: model.Roles, diff --git a/internal/cmd/mongodbflex/user/update/update_test.go b/internal/cmd/mongodbflex/user/update/update_test.go index dc8451036..6457e38c8 100644 --- a/internal/cmd/mongodbflex/user/update/update_test.go +++ b/internal/cmd/mongodbflex/user/update/update_test.go @@ -11,7 +11,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex" + mongodbflex "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex/v2api" ) const ( @@ -21,7 +21,7 @@ const ( type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &mongodbflex.APIClient{} +var testClient = &mongodbflex.APIClient{DefaultAPI: &mongodbflex.DefaultAPIService{}} var testProjectId = uuid.NewString() var testInstanceId = uuid.NewString() var testUserId = uuid.NewString() @@ -67,7 +67,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *mongodbflex.ApiPartialUpdateUserRequest)) mongodbflex.ApiPartialUpdateUserRequest { - request := testClient.PartialUpdateUser(testCtx, testProjectId, testInstanceId, testUserId, testRegion) + request := testClient.DefaultAPI.PartialUpdateUser(testCtx, testProjectId, testInstanceId, testUserId, testRegion) request = request.PartialUpdateUserPayload(mongodbflex.PartialUpdateUserPayload{ Database: utils.Ptr("default"), }) @@ -113,7 +113,7 @@ func TestParseInput(t *testing.T) { }), isValid: true, expectedModel: fixtureInputModel(func(model *inputModel) { - model.Roles = utils.Ptr([]string{"read"}) + model.Roles = []string{"read"} }), }, { @@ -220,10 +220,10 @@ func TestBuildRequest(t *testing.T) { description: "update roles only", model: fixtureInputModel(func(model *inputModel) { model.Database = nil - model.Roles = &[]string{"default"} + model.Roles = []string{"default"} }), expectedRequest: fixtureRequest().PartialUpdateUserPayload(mongodbflex.PartialUpdateUserPayload{ - Roles: &[]string{"default"}, + Roles: []string{"default"}, }), }, } @@ -234,7 +234,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, mongodbflex.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/pkg/services/mongodbflex/client/client.go b/internal/pkg/services/mongodbflex/client/client.go index 7bb81905e..edde69f90 100644 --- a/internal/pkg/services/mongodbflex/client/client.go +++ b/internal/pkg/services/mongodbflex/client/client.go @@ -2,7 +2,7 @@ package client import ( "github.com/spf13/viper" - "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex" + mongodbflex "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex/v2api" "github.com/stackitcloud/stackit-cli/internal/pkg/config" genericclient "github.com/stackitcloud/stackit-cli/internal/pkg/generic-client" diff --git a/internal/pkg/services/mongodbflex/utils/utils.go b/internal/pkg/services/mongodbflex/utils/utils.go index 352cdc948..8ee805f89 100644 --- a/internal/pkg/services/mongodbflex/utils/utils.go +++ b/internal/pkg/services/mongodbflex/utils/utils.go @@ -11,21 +11,21 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/errors" - "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex" + mongodbflex "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex/v2api" ) // The number of replicas is enforced by the API according to the instance type -var instanceTypeToReplicas = map[string]int64{ +var instanceTypeToReplicas = map[string]int32{ "Single": 1, "Replica": 3, "Sharded": 9, } type MongoDBFlexClient interface { - ListVersionsExecute(ctx context.Context, projectId, region string) (*mongodbflex.ListVersionsResponse, error) - GetInstanceExecute(ctx context.Context, projectId, instanceId, region string) (*mongodbflex.InstanceResponse, error) - GetUserExecute(ctx context.Context, projectId, instanceId, userId, region string) (*mongodbflex.GetUserResponse, error) - ListRestoreJobsExecute(ctx context.Context, projectId string, instanceId, region string) (*mongodbflex.ListRestoreJobsResponse, error) + ListVersions(ctx context.Context, projectId, region string) mongodbflex.ApiListVersionsRequest + GetInstance(ctx context.Context, projectId, instanceId, region string) mongodbflex.ApiGetInstanceRequest + GetUser(ctx context.Context, projectId, instanceId, userId, region string) mongodbflex.ApiGetUserRequest + ListRestoreJobs(ctx context.Context, projectId string, instanceId, region string) mongodbflex.ApiListRestoreJobsRequest } func AvailableInstanceTypes() []string { @@ -41,7 +41,7 @@ func AvailableInstanceTypes() []string { return instanceTypes } -func GetInstanceReplicas(instanceType string) (int64, error) { +func GetInstanceReplicas(instanceType string) (int32, error) { numReplicas, ok := instanceTypeToReplicas[instanceType] if !ok { return 0, fmt.Errorf("invalid instance type: %v", instanceType) @@ -49,7 +49,7 @@ func GetInstanceReplicas(instanceType string) (int64, error) { return numReplicas, nil } -func GetInstanceType(numReplicas int64) (string, error) { +func GetInstanceType(numReplicas int32) (string, error) { for k, v := range instanceTypeToReplicas { if v == numReplicas { return k, nil @@ -58,12 +58,12 @@ func GetInstanceType(numReplicas int64) (string, error) { return "", fmt.Errorf("invalid number of replicas: %v", numReplicas) } -func ValidateFlavorId(flavorId string, flavors *[]mongodbflex.InstanceFlavor) error { +func ValidateFlavorId(flavorId string, flavors []mongodbflex.InstanceFlavor) error { if flavors == nil { return fmt.Errorf("nil flavors") } - for _, f := range *flavors { + for _, f := range flavors { if f.Id != nil && strings.EqualFold(*f.Id, flavorId) { return nil } @@ -90,7 +90,7 @@ func ValidateStorage(storageClass *string, storageSize *int64, storages *mongodb return nil } - for _, sc := range *storages.StorageClasses { + for _, sc := range storages.StorageClasses { if strings.EqualFold(*storageClass, sc) { return nil } @@ -102,7 +102,7 @@ func ValidateStorage(storageClass *string, storageSize *int64, storages *mongodb } } -func LoadFlavorId(cpu, ram int64, flavors *[]mongodbflex.InstanceFlavor) (*string, error) { +func LoadFlavorId(cpu, ram int32, flavors *[]mongodbflex.InstanceFlavor) (*string, error) { if flavors == nil { return nil, fmt.Errorf("nil flavors") } @@ -124,20 +124,19 @@ func LoadFlavorId(cpu, ram int64, flavors *[]mongodbflex.InstanceFlavor) (*strin } func GetLatestMongoDBVersion(ctx context.Context, apiClient MongoDBFlexClient, projectId, region string) (string, error) { - resp, err := apiClient.ListVersionsExecute(ctx, projectId, region) + resp, err := apiClient.ListVersions(ctx, projectId, region).Execute() if err != nil { return "", fmt.Errorf("get MongoDB versions: %w", err) } - versions := *resp.Versions latestVersion := "0" - for i := range versions { + for i := range resp.Versions { oldSemVer := fmt.Sprintf("v%s", latestVersion) - newSemVer := fmt.Sprintf("v%s", versions[i]) + newSemVer := fmt.Sprintf("v%s", resp.Versions[i]) if semver.Compare(newSemVer, oldSemVer) != 1 { continue } - latestVersion = versions[i] + latestVersion = resp.Versions[i] } if latestVersion == "0" { return "", fmt.Errorf("no MongoDB versions found") @@ -146,7 +145,7 @@ func GetLatestMongoDBVersion(ctx context.Context, apiClient MongoDBFlexClient, p } func GetInstanceName(ctx context.Context, apiClient MongoDBFlexClient, projectId, instanceId, region string) (string, error) { - resp, err := apiClient.GetInstanceExecute(ctx, projectId, instanceId, region) + resp, err := apiClient.GetInstance(ctx, projectId, instanceId, region).Execute() if err != nil { return "", fmt.Errorf("get MongoDB Flex instance: %w", err) } @@ -154,7 +153,7 @@ func GetInstanceName(ctx context.Context, apiClient MongoDBFlexClient, projectId } func GetUserName(ctx context.Context, apiClient MongoDBFlexClient, projectId, instanceId, userId, region string) (string, error) { - resp, err := apiClient.GetUserExecute(ctx, projectId, instanceId, userId, region) + resp, err := apiClient.GetUser(ctx, projectId, instanceId, userId, region).Execute() if err != nil { return "", fmt.Errorf("get MongoDB Flex user: %w", err) } @@ -167,7 +166,7 @@ func GetRestoreStatus(backupId string, restoreJobs *mongodbflex.ListRestoreJobsR return state } - restoreJobsSlice := *restoreJobs.Items + restoreJobsSlice := restoreJobs.Items // sort array by descending date slices.SortFunc(restoreJobsSlice, func(i, j mongodbflex.RestoreInstanceStatus) int { @@ -175,7 +174,7 @@ func GetRestoreStatus(backupId string, restoreJobs *mongodbflex.ListRestoreJobsR return cmp.Compare(*j.Date, *i.Date) }) - for _, restoreJob := range *restoreJobs.Items { + for _, restoreJob := range restoreJobs.Items { if *restoreJob.BackupID == backupId { state = *restoreJob.Status break diff --git a/internal/pkg/services/mongodbflex/utils/utils_test.go b/internal/pkg/services/mongodbflex/utils/utils_test.go index 157bc2803..7960bf501 100644 --- a/internal/pkg/services/mongodbflex/utils/utils_test.go +++ b/internal/pkg/services/mongodbflex/utils/utils_test.go @@ -9,7 +9,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex" + mongodbflex "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex/v2api" ) var ( @@ -25,7 +25,36 @@ const ( testUserName = "user" ) -type mongoDBFlexClientMocked struct { +func newAPIClientMock(m clientMockSettings) mongodbflex.DefaultAPI { + return mongodbflex.DefaultAPIServiceMock{ + ListVersionsExecuteMock: utils.Ptr(func(_ mongodbflex.ApiListVersionsRequest) (*mongodbflex.ListVersionsResponse, error) { + if m.listVersionsFails { + return nil, fmt.Errorf("could not list versions") + } + return m.listVersionsResp, nil + }), + ListRestoreJobsExecuteMock: utils.Ptr(func(_ mongodbflex.ApiListRestoreJobsRequest) (*mongodbflex.ListRestoreJobsResponse, error) { + if m.listRestoreJobsFails { + return nil, fmt.Errorf("could not list versions") + } + return m.listRestoreJobsResp, nil + }), + GetInstanceExecuteMock: utils.Ptr(func(_ mongodbflex.ApiGetInstanceRequest) (*mongodbflex.InstanceResponse, error) { + if m.getInstanceFails { + return nil, fmt.Errorf("could not get instance") + } + return m.getInstanceResp, nil + }), + GetUserExecuteMock: utils.Ptr(func(_ mongodbflex.ApiGetUserRequest) (*mongodbflex.GetUserResponse, error) { + if m.getUserFails { + return nil, fmt.Errorf("could not get user") + } + return m.getUserResp, nil + }), + } +} + +type clientMockSettings struct { listVersionsFails bool listVersionsResp *mongodbflex.ListVersionsResponse getInstanceFails bool @@ -36,34 +65,6 @@ type mongoDBFlexClientMocked struct { listRestoreJobsResp *mongodbflex.ListRestoreJobsResponse } -func (m *mongoDBFlexClientMocked) ListVersionsExecute(_ context.Context, _, _ string) (*mongodbflex.ListVersionsResponse, error) { - if m.listVersionsFails { - return nil, fmt.Errorf("could not list versions") - } - return m.listVersionsResp, nil -} - -func (m *mongoDBFlexClientMocked) ListRestoreJobsExecute(_ context.Context, _, _, _ string) (*mongodbflex.ListRestoreJobsResponse, error) { - if m.listRestoreJobsFails { - return nil, fmt.Errorf("could not list versions") - } - return m.listRestoreJobsResp, nil -} - -func (m *mongoDBFlexClientMocked) GetInstanceExecute(_ context.Context, _, _, _ string) (*mongodbflex.InstanceResponse, error) { - if m.getInstanceFails { - return nil, fmt.Errorf("could not get instance") - } - return m.getInstanceResp, nil -} - -func (m *mongoDBFlexClientMocked) GetUserExecute(_ context.Context, _, _, _, _ string) (*mongodbflex.GetUserResponse, error) { - if m.getUserFails { - return nil, fmt.Errorf("could not get user") - } - return m.getUserResp, nil -} - func TestValidateStorage(t *testing.T) { tests := []struct { description string @@ -77,7 +78,7 @@ func TestValidateStorage(t *testing.T) { storageClass: utils.Ptr("foo"), storageSize: utils.Ptr(int64(10)), storages: &mongodbflex.ListStoragesResponse{ - StorageClasses: &[]string{"bar-1", "bar-2", "foo"}, + StorageClasses: []string{"bar-1", "bar-2", "foo"}, StorageRange: &mongodbflex.StorageRange{ Min: utils.Ptr(int64(5)), Max: utils.Ptr(int64(20)), @@ -97,7 +98,7 @@ func TestValidateStorage(t *testing.T) { storageClass: utils.Ptr("foo"), storageSize: utils.Ptr(int64(1)), storages: &mongodbflex.ListStoragesResponse{ - StorageClasses: &[]string{"bar-1", "bar-2", "foo"}, + StorageClasses: []string{"bar-1", "bar-2", "foo"}, StorageRange: &mongodbflex.StorageRange{ Min: utils.Ptr(int64(5)), Max: utils.Ptr(int64(20)), @@ -110,7 +111,7 @@ func TestValidateStorage(t *testing.T) { storageClass: utils.Ptr("foo"), storageSize: utils.Ptr(int64(200)), storages: &mongodbflex.ListStoragesResponse{ - StorageClasses: &[]string{"bar-1", "bar-2", "foo"}, + StorageClasses: []string{"bar-1", "bar-2", "foo"}, StorageRange: &mongodbflex.StorageRange{ Min: utils.Ptr(int64(5)), Max: utils.Ptr(int64(20)), @@ -123,7 +124,7 @@ func TestValidateStorage(t *testing.T) { storageClass: utils.Ptr("foo"), storageSize: utils.Ptr(int64(5)), storages: &mongodbflex.ListStoragesResponse{ - StorageClasses: &[]string{"bar-1", "bar-2", "foo"}, + StorageClasses: []string{"bar-1", "bar-2", "foo"}, StorageRange: &mongodbflex.StorageRange{ Min: utils.Ptr(int64(5)), Max: utils.Ptr(int64(20)), @@ -136,7 +137,7 @@ func TestValidateStorage(t *testing.T) { storageClass: utils.Ptr("foo"), storageSize: utils.Ptr(int64(20)), storages: &mongodbflex.ListStoragesResponse{ - StorageClasses: &[]string{"bar-1", "bar-2", "foo"}, + StorageClasses: []string{"bar-1", "bar-2", "foo"}, StorageRange: &mongodbflex.StorageRange{ Min: utils.Ptr(int64(5)), Max: utils.Ptr(int64(20)), @@ -149,7 +150,7 @@ func TestValidateStorage(t *testing.T) { storageClass: utils.Ptr("foo"), storageSize: utils.Ptr(int64(10)), storages: &mongodbflex.ListStoragesResponse{ - StorageClasses: &[]string{"bar-1", "bar-2", "bar-3"}, + StorageClasses: []string{"bar-1", "bar-2", "bar-3"}, StorageRange: &mongodbflex.StorageRange{ Min: utils.Ptr(int64(5)), Max: utils.Ptr(int64(20)), @@ -176,13 +177,13 @@ func TestValidateFlavorId(t *testing.T) { tests := []struct { description string flavorId string - flavors *[]mongodbflex.InstanceFlavor + flavors []mongodbflex.InstanceFlavor isValid bool }{ { description: "base", flavorId: "foo", - flavors: &[]mongodbflex.InstanceFlavor{ + flavors: []mongodbflex.InstanceFlavor{ {Id: utils.Ptr("bar-1")}, {Id: utils.Ptr("bar-2")}, {Id: utils.Ptr("foo")}, @@ -198,13 +199,13 @@ func TestValidateFlavorId(t *testing.T) { { description: "no flavors", flavorId: "foo", - flavors: &[]mongodbflex.InstanceFlavor{}, + flavors: []mongodbflex.InstanceFlavor{}, isValid: false, }, { description: "nil flavor id", flavorId: "foo", - flavors: &[]mongodbflex.InstanceFlavor{ + flavors: []mongodbflex.InstanceFlavor{ {Id: utils.Ptr("bar-1")}, {Id: nil}, {Id: utils.Ptr("foo")}, @@ -214,7 +215,7 @@ func TestValidateFlavorId(t *testing.T) { { description: "invalid flavor", flavorId: "foo", - flavors: &[]mongodbflex.InstanceFlavor{ + flavors: []mongodbflex.InstanceFlavor{ {Id: utils.Ptr("bar-1")}, {Id: utils.Ptr("bar-2")}, {Id: utils.Ptr("bar-3")}, @@ -239,8 +240,8 @@ func TestValidateFlavorId(t *testing.T) { func TestLoadFlavorId(t *testing.T) { tests := []struct { description string - cpu int64 - ram int64 + cpu int32 + ram int32 flavors *[]mongodbflex.InstanceFlavor isValid bool expectedOutput *string @@ -252,18 +253,18 @@ func TestLoadFlavorId(t *testing.T) { flavors: &[]mongodbflex.InstanceFlavor{ { Id: utils.Ptr("bar-1"), - Cpu: utils.Ptr(int64(2)), - Memory: utils.Ptr(int64(2)), + Cpu: utils.Ptr(int32(2)), + Memory: utils.Ptr(int32(2)), }, { Id: utils.Ptr("bar-2"), - Cpu: utils.Ptr(int64(4)), - Memory: utils.Ptr(int64(4)), + Cpu: utils.Ptr(int32(4)), + Memory: utils.Ptr(int32(4)), }, { Id: utils.Ptr("foo"), - Cpu: utils.Ptr(int64(2)), - Memory: utils.Ptr(int64(4)), + Cpu: utils.Ptr(int32(2)), + Memory: utils.Ptr(int32(4)), }, }, isValid: true, @@ -295,13 +296,13 @@ func TestLoadFlavorId(t *testing.T) { }, { Id: utils.Ptr("bar-2"), - Cpu: utils.Ptr(int64(4)), - Memory: utils.Ptr(int64(4)), + Cpu: utils.Ptr(int32(4)), + Memory: utils.Ptr(int32(4)), }, { Id: utils.Ptr("foo"), - Cpu: utils.Ptr(int64(2)), - Memory: utils.Ptr(int64(4)), + Cpu: utils.Ptr(int32(2)), + Memory: utils.Ptr(int32(4)), }, }, isValid: true, @@ -314,18 +315,18 @@ func TestLoadFlavorId(t *testing.T) { flavors: &[]mongodbflex.InstanceFlavor{ { Id: utils.Ptr("bar-1"), - Cpu: utils.Ptr(int64(2)), - Memory: utils.Ptr(int64(2)), + Cpu: utils.Ptr(int32(2)), + Memory: utils.Ptr(int32(2)), }, { Id: utils.Ptr("bar-2"), - Cpu: utils.Ptr(int64(4)), - Memory: utils.Ptr(int64(4)), + Cpu: utils.Ptr(int32(4)), + Memory: utils.Ptr(int32(4)), }, { Id: nil, - Cpu: utils.Ptr(int64(2)), - Memory: utils.Ptr(int64(4)), + Cpu: utils.Ptr(int32(2)), + Memory: utils.Ptr(int32(4)), }, }, isValid: false, @@ -337,13 +338,13 @@ func TestLoadFlavorId(t *testing.T) { flavors: &[]mongodbflex.InstanceFlavor{ { Id: utils.Ptr("bar-1"), - Cpu: utils.Ptr(int64(2)), - Memory: utils.Ptr(int64(2)), + Cpu: utils.Ptr(int32(2)), + Memory: utils.Ptr(int32(2)), }, { Id: utils.Ptr("bar-2"), - Cpu: utils.Ptr(int64(4)), - Memory: utils.Ptr(int64(4)), + Cpu: utils.Ptr(int32(4)), + Memory: utils.Ptr(int32(4)), }, }, isValid: false, @@ -386,7 +387,7 @@ func TestGetLatestMongoDBFlexVersion(t *testing.T) { { description: "base", listVersionsResp: &mongodbflex.ListVersionsResponse{ - Versions: &[]string{"8", "10", "9"}, + Versions: []string{"8", "10", "9"}, }, isValid: true, expectedOutput: "10", @@ -399,7 +400,7 @@ func TestGetLatestMongoDBFlexVersion(t *testing.T) { { description: "no versions", listVersionsResp: &mongodbflex.ListVersionsResponse{ - Versions: &[]string{}, + Versions: []string{}, }, isValid: false, }, @@ -407,12 +408,12 @@ func TestGetLatestMongoDBFlexVersion(t *testing.T) { for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { - client := &mongoDBFlexClientMocked{ + settings := clientMockSettings{ listVersionsFails: tt.listVersionsFails, listVersionsResp: tt.listVersionsResp, } - output, err := GetLatestMongoDBVersion(context.Background(), client, testProjectId, testRegion) + output, err := GetLatestMongoDBVersion(context.Background(), newAPIClientMock(settings), testProjectId, testRegion) if tt.isValid && err != nil { t.Errorf("failed on valid input") @@ -457,12 +458,12 @@ func TestGetInstanceName(t *testing.T) { for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { - client := &mongoDBFlexClientMocked{ + settings := clientMockSettings{ getInstanceFails: tt.getInstanceFails, getInstanceResp: tt.getInstanceResp, } - output, err := GetInstanceName(context.Background(), client, testProjectId, testInstanceId, testRegion) + output, err := GetInstanceName(context.Background(), newAPIClientMock(settings), testProjectId, testInstanceId, testRegion) if tt.isValid && err != nil { t.Errorf("failed on valid input") @@ -507,12 +508,12 @@ func TestGetUserName(t *testing.T) { for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { - client := &mongoDBFlexClientMocked{ + settings := clientMockSettings{ getUserFails: tt.getUserFails, getUserResp: tt.getUserResp, } - output, err := GetUserName(context.Background(), client, testProjectId, testInstanceId, testUserId, testRegion) + output, err := GetUserName(context.Background(), newAPIClientMock(settings), testProjectId, testInstanceId, testUserId, testRegion) if tt.isValid && err != nil { t.Errorf("failed on valid input") @@ -539,7 +540,7 @@ func TestGetRestoreStatus(t *testing.T) { { description: "base", listRestoreJobsResp: &mongodbflex.ListRestoreJobsResponse{ - Items: &[]mongodbflex.RestoreInstanceStatus{ + Items: []mongodbflex.RestoreInstanceStatus{ { BackupID: utils.Ptr(testBackupId), Date: utils.Ptr("2024-05-14T12:01:11Z"), @@ -557,7 +558,7 @@ func TestGetRestoreStatus(t *testing.T) { { description: "get latest restore, ordered array", listRestoreJobsResp: &mongodbflex.ListRestoreJobsResponse{ - Items: &[]mongodbflex.RestoreInstanceStatus{ + Items: []mongodbflex.RestoreInstanceStatus{ { BackupID: utils.Ptr(testBackupId), Date: utils.Ptr("2024-05-14T12:01:11Z"), @@ -575,7 +576,7 @@ func TestGetRestoreStatus(t *testing.T) { { description: "get latest restore, unordered array", listRestoreJobsResp: &mongodbflex.ListRestoreJobsResponse{ - Items: &[]mongodbflex.RestoreInstanceStatus{ + Items: []mongodbflex.RestoreInstanceStatus{ { BackupID: utils.Ptr(testBackupId), Date: utils.Ptr("2024-05-13T12:01:11Z"), @@ -593,7 +594,7 @@ func TestGetRestoreStatus(t *testing.T) { { description: "get latest restore, another date format", listRestoreJobsResp: &mongodbflex.ListRestoreJobsResponse{ - Items: &[]mongodbflex.RestoreInstanceStatus{ + Items: []mongodbflex.RestoreInstanceStatus{ { BackupID: utils.Ptr(testBackupId), Date: utils.Ptr("2009-11-10 23:00:00 +0000 UTC m=+0.000000001"), @@ -611,7 +612,7 @@ func TestGetRestoreStatus(t *testing.T) { { description: "no restore job for that backup", listRestoreJobsResp: &mongodbflex.ListRestoreJobsResponse{ - Items: &[]mongodbflex.RestoreInstanceStatus{ + Items: []mongodbflex.RestoreInstanceStatus{ { BackupID: utils.Ptr("bar"), Date: utils.Ptr("2024-05-13T12:01:11Z"), @@ -649,7 +650,7 @@ func TestGetRestoreStatus(t *testing.T) { func TestGetInstanceType(t *testing.T) { tests := []struct { description string - numReplicas int64 + numReplicas int32 expectedOutput string isValid bool }{ From 8c9edfa66974a266a4b13f1d9460205ea4e2b1bd Mon Sep 17 00:00:00 2001 From: Jonas Schlecht <73650029+SerseusWasTaken@users.noreply.github.com> Date: Tue, 14 Jul 2026 15:43:57 +0200 Subject: [PATCH 31/44] feat(opensearch): region adjustments and migration to new SDK structure (#1474) relates to STACKITTCLI-372 --- docs/stackit_opensearch_instance_create.md | 4 +- docs/stackit_opensearch_instance_update.md | 4 +- go.mod | 2 +- go.sum | 4 +- .../opensearch/credentials/create/create.go | 40 ++-- .../credentials/create/create_test.go | 64 ++--- .../opensearch/credentials/delete/delete.go | 8 +- .../credentials/delete/delete_test.go | 21 +- .../credentials/describe/describe.go | 27 +-- .../credentials/describe/describe_test.go | 35 +-- .../cmd/opensearch/credentials/list/list.go | 9 +- .../opensearch/credentials/list/list_test.go | 19 +- .../cmd/opensearch/instance/create/create.go | 56 ++--- .../opensearch/instance/create/create_test.go | 192 +++++++-------- .../cmd/opensearch/instance/delete/delete.go | 10 +- .../opensearch/instance/delete/delete_test.go | 19 +- .../opensearch/instance/describe/describe.go | 27 +-- .../instance/describe/describe_test.go | 19 +- internal/cmd/opensearch/instance/list/list.go | 10 +- .../cmd/opensearch/instance/list/list_test.go | 17 +- .../cmd/opensearch/instance/update/update.go | 56 +++-- .../opensearch/instance/update/update_test.go | 223 ++++++------------ internal/cmd/opensearch/plans/plans.go | 19 +- internal/cmd/opensearch/plans/plans_test.go | 17 +- .../pkg/services/opensearch/client/client.go | 4 +- .../pkg/services/opensearch/utils/utils.go | 46 ++-- .../services/opensearch/utils/utils_test.go | 98 ++++---- 27 files changed, 501 insertions(+), 549 deletions(-) diff --git a/docs/stackit_opensearch_instance_create.md b/docs/stackit_opensearch_instance_create.md index ba979af69..8e3534d0a 100644 --- a/docs/stackit_opensearch_instance_create.md +++ b/docs/stackit_opensearch_instance_create.md @@ -30,13 +30,13 @@ stackit opensearch instance create [flags] --enable-monitoring Enable monitoring --graphite string Graphite host -h, --help Help for "stackit opensearch instance create" - --metrics-frequency int Metrics frequency + --metrics-frequency int32 Metrics frequency --metrics-prefix string Metrics prefix --monitoring-instance-id string Monitoring instance ID -n, --name string Instance name --plan-id string Plan ID --plan-name string Plan name - --plugin strings Plugin + --plugin strings Plugins (multiple of: [repository-s3, repository-azure, analysis-phonetic]) (default []) --syslog strings Syslog --version string Instance OpenSearch version ``` diff --git a/docs/stackit_opensearch_instance_update.md b/docs/stackit_opensearch_instance_update.md index 33b2b817b..508f46a05 100644 --- a/docs/stackit_opensearch_instance_update.md +++ b/docs/stackit_opensearch_instance_update.md @@ -27,12 +27,12 @@ stackit opensearch instance update INSTANCE_ID [flags] --enable-monitoring Enable monitoring --graphite string Graphite host -h, --help Help for "stackit opensearch instance update" - --metrics-frequency int Metrics frequency + --metrics-frequency int32 Metrics frequency --metrics-prefix string Metrics prefix --monitoring-instance-id string Monitoring instance ID --plan-id string Plan ID --plan-name string Plan name - --plugin strings Plugin + --plugin strings Plugins (multiple of: [repository-s3, repository-azure, analysis-phonetic]) (default []) --syslog strings Syslog --version string Instance OpenSearch version ``` diff --git a/go.mod b/go.mod index ee06a565d..2353b9927 100644 --- a/go.mod +++ b/go.mod @@ -26,7 +26,7 @@ require ( github.com/stackitcloud/stackit-sdk-go/services/intake v0.7.1 github.com/stackitcloud/stackit-sdk-go/services/logs v0.5.2 github.com/stackitcloud/stackit-sdk-go/services/mongodbflex v1.12.0 - github.com/stackitcloud/stackit-sdk-go/services/opensearch v0.24.6 + github.com/stackitcloud/stackit-sdk-go/services/opensearch v1.1.0 github.com/stackitcloud/stackit-sdk-go/services/postgresflex v1.3.5 github.com/stackitcloud/stackit-sdk-go/services/resourcemanager v0.24.0 github.com/stackitcloud/stackit-sdk-go/services/runcommand v1.4.3 diff --git a/go.sum b/go.sum index 5ec138a79..5ec24b922 100644 --- a/go.sum +++ b/go.sum @@ -624,8 +624,8 @@ github.com/stackitcloud/stackit-sdk-go/services/objectstorage v1.9.0 h1:T+ll3lS0 github.com/stackitcloud/stackit-sdk-go/services/objectstorage v1.9.0/go.mod h1:QsPtoqAYvumyPU6ToX/5j1PbudN+VSTuvh6mp154ecM= github.com/stackitcloud/stackit-sdk-go/services/observability v0.24.0 h1:KhuWPXr1hl8BFLGLSi6wjxh5o6OQXH9amfquMhYQROU= github.com/stackitcloud/stackit-sdk-go/services/observability v0.24.0/go.mod h1:0fEZQHm729mBdvg4sNrAhM6KmHROHJSeS2FwCMRk46k= -github.com/stackitcloud/stackit-sdk-go/services/opensearch v0.24.6 h1:oTVx1+O177Ojn8OvXIOUbRSwtx7L59jhxDPrZEQFOfQ= -github.com/stackitcloud/stackit-sdk-go/services/opensearch v0.24.6/go.mod h1:6ZBeCCY6qG8w1oK7osf61Egyv3mp7Ahv6GDGxiarDGo= +github.com/stackitcloud/stackit-sdk-go/services/opensearch v1.1.0 h1:hooc/E9Qabn8xno1NUd3uJQfUbW5KoY6mgURlnd776c= +github.com/stackitcloud/stackit-sdk-go/services/opensearch v1.1.0/go.mod h1:L+NlfC1hilLOqlLLukCj/UDnxlnNrc/oMikcw3Ansyw= github.com/stackitcloud/stackit-sdk-go/services/postgresflex v1.3.5 h1:H67e3KnHQx954yI8fuQmxXwRf/myqAdLg2KvxImp00g= github.com/stackitcloud/stackit-sdk-go/services/postgresflex v1.3.5/go.mod h1:xmAWk9eom8wznvLuLfm0F4xyeiBX8LaggXsKFmos+dw= github.com/stackitcloud/stackit-sdk-go/services/rabbitmq v1.1.0 h1:HRJwodJX4aOn/487zaqJIKw13yIj4T6dn7/kEHLxeTg= diff --git a/internal/cmd/opensearch/credentials/create/create.go b/internal/cmd/opensearch/credentials/create/create.go index cfc9bd5f3..7e9eb5ee7 100644 --- a/internal/cmd/opensearch/credentials/create/create.go +++ b/internal/cmd/opensearch/credentials/create/create.go @@ -7,7 +7,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/types" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/opensearch" + opensearch "github.com/stackitcloud/stackit-sdk-go/services/opensearch/v2api" "github.com/stackitcloud/stackit-cli/internal/pkg/args" "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -17,7 +17,6 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/print" "github.com/stackitcloud/stackit-cli/internal/pkg/services/opensearch/client" opensearchUtils "github.com/stackitcloud/stackit-cli/internal/pkg/services/opensearch/utils" - "github.com/stackitcloud/stackit-cli/internal/pkg/utils" ) const ( @@ -58,7 +57,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return err } - instanceLabel, err := opensearchUtils.GetInstanceName(ctx, apiClient, model.ProjectId, model.InstanceId) + instanceLabel, err := opensearchUtils.GetInstanceName(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, model.InstanceId) if err != nil { params.Printer.Debug(print.ErrorLevel, "get instance name: %v", err) instanceLabel = model.InstanceId @@ -77,7 +76,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return fmt.Errorf("create OpenSearch credentials: %w", err) } - return outputResult(params.Printer, model.OutputFormat, model.ShowPassword, instanceLabel, resp) + return outputResult(params.Printer, *model, instanceLabel, resp) }, } configureFlags(cmd) @@ -109,35 +108,38 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, } func buildRequest(ctx context.Context, model *inputModel, apiClient *opensearch.APIClient) opensearch.ApiCreateCredentialsRequest { - req := apiClient.CreateCredentials(ctx, model.ProjectId, model.InstanceId) + req := apiClient.DefaultAPI.CreateCredentials(ctx, model.ProjectId, model.Region, model.InstanceId) return req } -func outputResult(p *print.Printer, outputFormat string, showPassword bool, instanceLabel string, resp *opensearch.CredentialsResponse) error { - if resp == nil || resp.Raw == nil || resp.Raw.Credentials == nil || resp.Uri == nil { +func outputResult(p *print.Printer, model inputModel, instanceLabel string, resp *opensearch.CredentialsResponse) error { + if model.GlobalFlagModel == nil { + return fmt.Errorf("no global flags defined") + } + if resp == nil || resp.Raw == nil { return fmt.Errorf("response or response content is nil") } - if !showPassword { - resp.Raw.Credentials.Password = utils.Ptr("hidden") + if !model.ShowPassword { + resp.Raw.Credentials.Password = "hidden" } - return p.OutputResult(outputFormat, resp, func() error { - p.Outputf("Created credentials for instance %q. Credentials ID: %s\n\n", instanceLabel, utils.PtrString(resp.Id)) + return p.OutputResult(model.OutputFormat, resp, func() error { + p.Outputf("Created credentials for instance %q. Credentials ID: %s\n\n", instanceLabel, resp.Id) // The username field cannot be set by the user so we only display it if it's not returned empty - if resp.HasRaw() && resp.Raw.Credentials != nil { - if username := resp.Raw.Credentials.Username; username != nil && *username != "" { - p.Outputf("Username: %s\n", *username) + if resp.HasRaw() { + if username := resp.Raw.Credentials.Username; username != "" { + p.Outputf("Username: %s\n", username) } - if !showPassword { + if !model.ShowPassword { p.Outputf("Password: \n") } else { - p.Outputf("Password: %s\n", utils.PtrString(resp.Raw.Credentials.Password)) + p.Outputf("Password: %s\n", resp.Raw.Credentials.Password) } - p.Outputf("Host: %s\n", utils.PtrString(resp.Raw.Credentials.Host)) - p.Outputf("Port: %s\n", utils.PtrString(resp.Raw.Credentials.Port)) + p.Outputf("Host: %s\n", resp.Raw.Credentials.Host) + p.Outputf("Port: %d\n", resp.Raw.Credentials.Port) } - p.Outputf("URI: %s\n", *resp.Uri) + p.Outputf("URI: %s\n", resp.Uri) return nil }) } diff --git a/internal/cmd/opensearch/credentials/create/create_test.go b/internal/cmd/opensearch/credentials/create/create_test.go index 309291ed3..f6cd78b76 100644 --- a/internal/cmd/opensearch/credentials/create/create_test.go +++ b/internal/cmd/opensearch/credentials/create/create_test.go @@ -7,24 +7,27 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/opensearch" + opensearch "github.com/stackitcloud/stackit-sdk-go/services/opensearch/v2api" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" "github.com/stackitcloud/stackit-cli/internal/pkg/testutils" - "github.com/stackitcloud/stackit-cli/internal/pkg/utils" ) type testCtxKey struct{} -var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &opensearch.APIClient{} -var testProjectId = uuid.NewString() -var testInstanceId = uuid.NewString() +var ( + testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") + testClient = &opensearch.APIClient{DefaultAPI: &opensearch.DefaultAPIService{}} + testProjectId = uuid.NewString() + testRegion = "eu01" + testInstanceId = uuid.NewString() +) func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string { flagValues := map[string]string{ globalflags.ProjectIdFlag: testProjectId, + globalflags.RegionFlag: testRegion, instanceIdFlag: testInstanceId, } for _, mod := range mods { @@ -37,6 +40,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { model := &inputModel{ GlobalFlagModel: &globalflags.GlobalFlagModel{ ProjectId: testProjectId, + Region: testRegion, Verbosity: globalflags.VerbosityDefault, }, InstanceId: testInstanceId, @@ -48,7 +52,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *opensearch.ApiCreateCredentialsRequest)) opensearch.ApiCreateCredentialsRequest { - request := testClient.CreateCredentials(testCtx, testProjectId, testInstanceId) + request := testClient.DefaultAPI.CreateCredentials(testCtx, testProjectId, testRegion, testInstanceId) for _, mod := range mods { mod(&request) } @@ -154,7 +158,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, opensearch.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) @@ -165,8 +169,7 @@ func TestBuildRequest(t *testing.T) { func TestOutputResult(t *testing.T) { type args struct { - outputFormat string - showPassword bool + model inputModel instanceLabel string resp *opensearch.CredentialsResponse } @@ -181,40 +184,20 @@ func TestOutputResult(t *testing.T) { wantErr: true, }, { - name: "set no raw in response", - args: args{ - resp: &opensearch.CredentialsResponse{ - Uri: utils.Ptr("https://opensearch.example.com"), - }, - }, - wantErr: true, - }, - { - name: "set empty raw in response", - args: args{ - resp: &opensearch.CredentialsResponse{ - Raw: &opensearch.RawCredentials{}, - Uri: utils.Ptr("https://opensearch.example.com"), - }, - }, - wantErr: true, - }, - { - name: "set raw but no uri in response", + name: "set uri but no raw in response", args: args{ resp: &opensearch.CredentialsResponse{ - Raw: &opensearch.RawCredentials{ - Credentials: &opensearch.Credentials{}, - }, + Uri: "https://opensearch.example.com", }, }, wantErr: true, }, { - name: "set uri but no raw in response", + name: "empty response should not cause panic when password should be hidden", args: args{ - resp: &opensearch.CredentialsResponse{ - Uri: utils.Ptr("https://opensearch.example.com"), + model: inputModel{ + GlobalFlagModel: &globalflags.GlobalFlagModel{}, + ShowPassword: false, }, }, wantErr: true, @@ -224,9 +207,12 @@ func TestOutputResult(t *testing.T) { args: args{ resp: &opensearch.CredentialsResponse{ Raw: &opensearch.RawCredentials{ - Credentials: &opensearch.Credentials{}, + Credentials: opensearch.Credentials{}, }, - Uri: utils.Ptr("https://opensearch.example.com"), + Uri: "https://opensearch.example.com", + }, + model: inputModel{ + GlobalFlagModel: &globalflags.GlobalFlagModel{}, }, }, wantErr: false, @@ -235,7 +221,7 @@ func TestOutputResult(t *testing.T) { params := testparams.NewTestParams() for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - if err := outputResult(params.Printer, tt.args.outputFormat, tt.args.showPassword, tt.args.instanceLabel, tt.args.resp); (err != nil) != tt.wantErr { + if err := outputResult(params.Printer, tt.args.model, tt.args.instanceLabel, tt.args.resp); (err != nil) != tt.wantErr { t.Errorf("outputResult() error = %v, wantErr %v", err, tt.wantErr) } }) diff --git a/internal/cmd/opensearch/credentials/delete/delete.go b/internal/cmd/opensearch/credentials/delete/delete.go index 236b9c626..15661c6cf 100644 --- a/internal/cmd/opensearch/credentials/delete/delete.go +++ b/internal/cmd/opensearch/credentials/delete/delete.go @@ -17,7 +17,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/opensearch" + opensearch "github.com/stackitcloud/stackit-sdk-go/services/opensearch/v2api" ) const ( @@ -56,13 +56,13 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return err } - instanceLabel, err := opensearchUtils.GetInstanceName(ctx, apiClient, model.ProjectId, model.InstanceId) + instanceLabel, err := opensearchUtils.GetInstanceName(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, model.InstanceId) if err != nil { params.Printer.Debug(print.ErrorLevel, "get instance name: %v", err) instanceLabel = model.InstanceId } - credentialsLabel, err := opensearchUtils.GetCredentialsUsername(ctx, apiClient, model.ProjectId, model.InstanceId, model.CredentialsId) + credentialsLabel, err := opensearchUtils.GetCredentialsUsername(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, model.InstanceId, model.CredentialsId) if err != nil { params.Printer.Debug(print.ErrorLevel, "get credentials user name: %v", err) credentialsLabel = model.CredentialsId @@ -115,6 +115,6 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *opensearch.APIClient) opensearch.ApiDeleteCredentialsRequest { - req := apiClient.DeleteCredentials(ctx, model.ProjectId, model.InstanceId, model.CredentialsId) + req := apiClient.DefaultAPI.DeleteCredentials(ctx, model.ProjectId, model.Region, model.InstanceId, model.CredentialsId) return req } diff --git a/internal/cmd/opensearch/credentials/delete/delete_test.go b/internal/cmd/opensearch/credentials/delete/delete_test.go index dcaa66ee1..1f236627a 100644 --- a/internal/cmd/opensearch/credentials/delete/delete_test.go +++ b/internal/cmd/opensearch/credentials/delete/delete_test.go @@ -10,16 +10,19 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/opensearch" + opensearch "github.com/stackitcloud/stackit-sdk-go/services/opensearch/v2api" ) type testCtxKey struct{} -var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &opensearch.APIClient{} -var testProjectId = uuid.NewString() -var testInstanceId = uuid.NewString() -var testCredentialsId = uuid.NewString() +var ( + testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") + testClient = &opensearch.APIClient{DefaultAPI: &opensearch.DefaultAPIService{}} + testProjectId = uuid.NewString() + testRegion = "eu01" + testInstanceId = uuid.NewString() + testCredentialsId = uuid.NewString() +) func fixtureArgValues(mods ...func(argValues []string)) []string { argValues := []string{ @@ -34,6 +37,7 @@ func fixtureArgValues(mods ...func(argValues []string)) []string { func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string { flagValues := map[string]string{ globalflags.ProjectIdFlag: testProjectId, + globalflags.RegionFlag: testRegion, instanceIdFlag: testInstanceId, } for _, mod := range mods { @@ -46,6 +50,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { model := &inputModel{ GlobalFlagModel: &globalflags.GlobalFlagModel{ ProjectId: testProjectId, + Region: testRegion, Verbosity: globalflags.VerbosityDefault, }, InstanceId: testInstanceId, @@ -58,7 +63,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *opensearch.ApiDeleteCredentialsRequest)) opensearch.ApiDeleteCredentialsRequest { - request := testClient.DeleteCredentials(testCtx, testProjectId, testInstanceId, testCredentialsId) + request := testClient.DefaultAPI.DeleteCredentials(testCtx, testProjectId, testRegion, testInstanceId, testCredentialsId) for _, mod := range mods { mod(&request) } @@ -186,7 +191,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, opensearch.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/opensearch/credentials/describe/describe.go b/internal/cmd/opensearch/credentials/describe/describe.go index 50a495940..3d37ed7c1 100644 --- a/internal/cmd/opensearch/credentials/describe/describe.go +++ b/internal/cmd/opensearch/credentials/describe/describe.go @@ -18,7 +18,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/opensearch" + opensearch "github.com/stackitcloud/stackit-sdk-go/services/opensearch/v2api" ) const ( @@ -100,34 +100,33 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *opensearch.APIClient) opensearch.ApiGetCredentialsRequest { - req := apiClient.GetCredentials(ctx, model.ProjectId, model.InstanceId, model.CredentialsId) + req := apiClient.DefaultAPI.GetCredentials(ctx, model.ProjectId, model.Region, model.InstanceId, model.CredentialsId) return req } func outputResult(p *print.Printer, outputFormat string, credentials *opensearch.CredentialsResponse) error { - if credentials == nil { - return fmt.Errorf("credentials is nil") - } - return p.OutputResult(outputFormat, credentials, func() error { + if credentials == nil { + return fmt.Errorf("credentials is nil") + } table := tables.NewTable() - table.AddRow("ID", utils.PtrString(credentials.Id)) + table.AddRow("ID", credentials.Id) table.AddSeparator() // The username field cannot be set by the user so we only display it if it's not returned empty - if credentials.HasRaw() && credentials.Raw.Credentials != nil { - if username := credentials.Raw.Credentials.Username; username != nil && *username != "" { - table.AddRow("USERNAME", *username) + if credentials.HasRaw() { + if username := credentials.Raw.Credentials.Username; username != "" { + table.AddRow("USERNAME", username) table.AddSeparator() } - table.AddRow("PASSWORD", utils.PtrString(credentials.Raw.Credentials.Password)) + table.AddRow("PASSWORD", credentials.Raw.Credentials.Password) table.AddSeparator() table.AddRow("URI", utils.PtrString(credentials.Raw.Credentials.Uri)) table.AddSeparator() - table.AddRow("HOST", utils.PtrString(credentials.Raw.Credentials.Host)) + table.AddRow("HOST", credentials.Raw.Credentials.Host) hosts := credentials.Raw.Credentials.Hosts - if hosts != nil && len(*hosts) > 0 { + if len(hosts) > 0 { table.AddSeparator() - table.AddRow("HOSTS", strings.Join(*hosts, "\n")) + table.AddRow("HOSTS", strings.Join(hosts, "\n")) } } err := table.Display(p) diff --git a/internal/cmd/opensearch/credentials/describe/describe_test.go b/internal/cmd/opensearch/credentials/describe/describe_test.go index 61b5bb2c6..7ac6737c3 100644 --- a/internal/cmd/opensearch/credentials/describe/describe_test.go +++ b/internal/cmd/opensearch/credentials/describe/describe_test.go @@ -5,7 +5,6 @@ import ( "testing" "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" - "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/testutils" @@ -13,16 +12,19 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/opensearch" + opensearch "github.com/stackitcloud/stackit-sdk-go/services/opensearch/v2api" ) type testCtxKey struct{} -var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &opensearch.APIClient{} -var testProjectId = uuid.NewString() -var testInstanceId = uuid.NewString() -var testCredentialsId = uuid.NewString() +var ( + testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") + testClient = &opensearch.APIClient{DefaultAPI: &opensearch.DefaultAPIService{}} + testProjectId = uuid.NewString() + testRegion = "eu01" + testInstanceId = uuid.NewString() + testCredentialsId = uuid.NewString() +) func fixtureArgValues(mods ...func(argValues []string)) []string { argValues := []string{ @@ -37,6 +39,7 @@ func fixtureArgValues(mods ...func(argValues []string)) []string { func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string { flagValues := map[string]string{ globalflags.ProjectIdFlag: testProjectId, + globalflags.RegionFlag: testRegion, instanceIdFlag: testInstanceId, } for _, mod := range mods { @@ -49,6 +52,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { model := &inputModel{ GlobalFlagModel: &globalflags.GlobalFlagModel{ ProjectId: testProjectId, + Region: testRegion, Verbosity: globalflags.VerbosityDefault, }, InstanceId: testInstanceId, @@ -61,7 +65,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *opensearch.ApiGetCredentialsRequest)) opensearch.ApiGetCredentialsRequest { - request := testClient.GetCredentials(testCtx, testProjectId, testInstanceId, testCredentialsId) + request := testClient.DefaultAPI.GetCredentials(testCtx, testProjectId, testRegion, testInstanceId, testCredentialsId) for _, mod := range mods { mod(&request) } @@ -189,7 +193,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, opensearch.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) @@ -225,24 +229,23 @@ func TestOutputResult(t *testing.T) { args: args{ credentials: &opensearch.CredentialsResponse{ Raw: &opensearch.RawCredentials{ - Credentials: &opensearch.Credentials{ - Host: utils.Ptr("host"), - Hosts: utils.Ptr([]string{ + Credentials: opensearch.Credentials{ + Host: "host", + Hosts: []string{ "hosts-a", "hosts-b", - }), + }, }, }, }, }, }, { - name: "raw credentials nil host & hosts", + name: "raw credentials and nil hosts", args: args{ credentials: &opensearch.CredentialsResponse{ Raw: &opensearch.RawCredentials{ - Credentials: &opensearch.Credentials{ - Host: nil, + Credentials: opensearch.Credentials{ Hosts: nil, }, }, diff --git a/internal/cmd/opensearch/credentials/list/list.go b/internal/cmd/opensearch/credentials/list/list.go index 05f4e8ef8..85a083e71 100644 --- a/internal/cmd/opensearch/credentials/list/list.go +++ b/internal/cmd/opensearch/credentials/list/list.go @@ -15,10 +15,9 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/services/opensearch/client" opensearchUtils "github.com/stackitcloud/stackit-cli/internal/pkg/services/opensearch/utils" "github.com/stackitcloud/stackit-cli/internal/pkg/tables" - "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/opensearch" + opensearch "github.com/stackitcloud/stackit-sdk-go/services/opensearch/v2api" ) const ( @@ -70,7 +69,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } credentials := resp.GetCredentialsList() - instanceLabel, err := opensearchUtils.GetInstanceName(ctx, apiClient, model.ProjectId, model.InstanceId) + instanceLabel, err := opensearchUtils.GetInstanceName(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, model.InstanceId) if err != nil { params.Printer.Debug(print.ErrorLevel, "get instance name: %v", err) instanceLabel = model.InstanceId @@ -121,7 +120,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, } func buildRequest(ctx context.Context, model *inputModel, apiClient *opensearch.APIClient) opensearch.ApiListCredentialsRequest { - req := apiClient.ListCredentials(ctx, model.ProjectId, model.InstanceId) + req := apiClient.DefaultAPI.ListCredentials(ctx, model.ProjectId, model.Region, model.InstanceId) return req } @@ -136,7 +135,7 @@ func outputResult(p *print.Printer, outputFormat, instanceLabel string, credenti table.SetHeader("ID") for i := range credentials { c := credentials[i] - table.AddRow(utils.PtrString(c.Id)) + table.AddRow(c.Id) } err := table.Display(p) if err != nil { diff --git a/internal/cmd/opensearch/credentials/list/list_test.go b/internal/cmd/opensearch/credentials/list/list_test.go index 14fc8cf40..d965e574a 100644 --- a/internal/cmd/opensearch/credentials/list/list_test.go +++ b/internal/cmd/opensearch/credentials/list/list_test.go @@ -12,19 +12,23 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/opensearch" + opensearch "github.com/stackitcloud/stackit-sdk-go/services/opensearch/v2api" ) type testCtxKey struct{} -var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &opensearch.APIClient{} -var testProjectId = uuid.NewString() -var testInstanceId = uuid.NewString() +var ( + testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") + testClient = &opensearch.APIClient{DefaultAPI: &opensearch.DefaultAPIService{}} + testProjectId = uuid.NewString() + testRegion = "eu01" + testInstanceId = uuid.NewString() +) func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string { flagValues := map[string]string{ globalflags.ProjectIdFlag: testProjectId, + globalflags.RegionFlag: testRegion, instanceIdFlag: testInstanceId, limitFlag: "10", } @@ -38,6 +42,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { model := &inputModel{ GlobalFlagModel: &globalflags.GlobalFlagModel{ ProjectId: testProjectId, + Region: testRegion, Verbosity: globalflags.VerbosityDefault, }, InstanceId: testInstanceId, @@ -50,7 +55,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *opensearch.ApiListCredentialsRequest)) opensearch.ApiListCredentialsRequest { - request := testClient.ListCredentials(testCtx, testProjectId, testInstanceId) + request := testClient.DefaultAPI.ListCredentials(testCtx, testProjectId, testRegion, testInstanceId) for _, mod := range mods { mod(&request) } @@ -160,7 +165,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, opensearch.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/opensearch/instance/create/create.go b/internal/cmd/opensearch/instance/create/create.go index 776e6b86f..b7694de96 100644 --- a/internal/cmd/opensearch/instance/create/create.go +++ b/internal/cmd/opensearch/instance/create/create.go @@ -21,8 +21,8 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/opensearch" - "github.com/stackitcloud/stackit-sdk-go/services/opensearch/wait" + opensearch "github.com/stackitcloud/stackit-sdk-go/services/opensearch/v2api" + wait "github.com/stackitcloud/stackit-sdk-go/services/opensearch/v2api/wait" ) const ( @@ -32,7 +32,6 @@ const ( metricsFrequencyFlag = "metrics-frequency" metricsPrefixFlag = "metrics-prefix" monitoringInstanceIdFlag = "monitoring-instance-id" - pluginFlag = "plugin" sgwAclFlag = "acl" syslogFlag = "syslog" planIdFlag = "plan-id" @@ -40,21 +39,23 @@ const ( versionFlag = "version" ) +var flagPlugins = flags.StringEnumSliceFlag("plugin", opensearch.AllowedInstanceParametersPluginsInnerEnumValues, "Plugins") + type inputModel struct { *globalflags.GlobalFlagModel PlanName string Version string - InstanceName *string + InstanceName string EnableMonitoring *bool Graphite *string - MetricsFrequency *int64 + MetricsFrequency *int32 MetricsPrefix *string MonitoringInstanceId *string - Plugin *[]string + Plugin []opensearch.InstanceParametersPluginsInner SgwAcl *[]string - Syslog *[]string - PlanId *string + Syslog []string + PlanId string } func NewCmd(params *types.CmdParams) *cobra.Command { @@ -100,7 +101,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } // Call API - req, err := buildRequest(ctx, model, apiClient) + req, err := buildRequest(ctx, model, apiClient.DefaultAPI) if err != nil { var dsaInvalidPlanError *cliErr.DSAInvalidPlanError if !errors.As(err, &dsaInvalidPlanError) { @@ -112,12 +113,11 @@ func NewCmd(params *types.CmdParams) *cobra.Command { if err != nil { return fmt.Errorf("create OpenSearch instance: %w", err) } - instanceId := *resp.InstanceId // Wait for async operation, if async mode not enabled if !model.Async { err := spinner.Run(params.Printer, "Creating instance", func() error { - _, err = wait.CreateInstanceWaitHandler(ctx, apiClient, model.ProjectId, instanceId).WaitWithContext(ctx) + _, err = wait.CreateInstanceWaitHandler(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, resp.InstanceId).WaitWithContext(ctx) return err }) if err != nil { @@ -125,7 +125,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } } - return outputResult(params.Printer, model.OutputFormat, model.Async, projectLabel, instanceId, resp) + return outputResult(params.Printer, model.OutputFormat, model.Async, projectLabel, resp.InstanceId, resp) }, } configureFlags(cmd) @@ -136,10 +136,10 @@ func configureFlags(cmd *cobra.Command) { cmd.Flags().StringP(instanceNameFlag, "n", "", "Instance name") cmd.Flags().Bool(enableMonitoringFlag, false, "Enable monitoring") cmd.Flags().String(graphiteFlag, "", "Graphite host") - cmd.Flags().Int64(metricsFrequencyFlag, 0, "Metrics frequency") + cmd.Flags().Int32(metricsFrequencyFlag, 0, "Metrics frequency") cmd.Flags().String(metricsPrefixFlag, "", "Metrics prefix") cmd.Flags().Var(flags.UUIDFlag(), monitoringInstanceIdFlag, "Monitoring instance ID") - cmd.Flags().StringSlice(pluginFlag, []string{}, "Plugin") + flagPlugins.Register(cmd) cmd.Flags().Var(flags.CIDRSliceFlag(), sgwAclFlag, "List of IP networks in CIDR notation which are allowed to access this instance") cmd.Flags().StringSlice(syslogFlag, []string{}, "Syslog") cmd.Flags().Var(flags.UUIDFlag(), planIdFlag, "Plan ID") @@ -156,16 +156,16 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, return nil, &cliErr.ProjectIdError{} } - planId := flags.FlagToStringPointer(p, cmd, planIdFlag) + planId := flags.FlagToStringValue(p, cmd, planIdFlag) planName := flags.FlagToStringValue(p, cmd, planNameFlag) version := flags.FlagToStringValue(p, cmd, versionFlag) - if planId == nil && (planName == "" || version == "") { + if planId == "" && (planName == "" || version == "") { return nil, &cliErr.DSAInputPlanError{ Cmd: cmd, } } - if planId != nil && (planName != "" || version != "") { + if planId != "" && (planName != "" || version != "") { return nil, &cliErr.DSAInputPlanError{ Cmd: cmd, } @@ -173,15 +173,15 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, model := inputModel{ GlobalFlagModel: globalFlags, - InstanceName: flags.FlagToStringPointer(p, cmd, instanceNameFlag), + InstanceName: flags.FlagToStringValue(p, cmd, instanceNameFlag), EnableMonitoring: flags.FlagToBoolPointer(p, cmd, enableMonitoringFlag), MonitoringInstanceId: flags.FlagToStringPointer(p, cmd, monitoringInstanceIdFlag), Graphite: flags.FlagToStringPointer(p, cmd, graphiteFlag), - MetricsFrequency: flags.FlagToInt64Pointer(p, cmd, metricsFrequencyFlag), + MetricsFrequency: flags.FlagToInt32Pointer(p, cmd, metricsFrequencyFlag), MetricsPrefix: flags.FlagToStringPointer(p, cmd, metricsPrefixFlag), - Plugin: flags.FlagToStringSlicePointer(p, cmd, pluginFlag), + Plugin: flagPlugins.Get(), SgwAcl: flags.FlagToStringSlicePointer(p, cmd, sgwAclFlag), - Syslog: flags.FlagToStringSlicePointer(p, cmd, syslogFlag), + Syslog: flags.FlagToStringSliceValue(p, cmd, syslogFlag), PlanId: planId, PlanName: planName, Version: version, @@ -192,22 +192,22 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, } type openSearchClient interface { - CreateInstance(ctx context.Context, projectId string) opensearch.ApiCreateInstanceRequest - ListOfferingsExecute(ctx context.Context, projectId string) (*opensearch.ListOfferingsResponse, error) + CreateInstance(ctx context.Context, projectId, region string) opensearch.ApiCreateInstanceRequest + ListOfferings(ctx context.Context, projectId, region string) opensearch.ApiListOfferingsRequest } func buildRequest(ctx context.Context, model *inputModel, apiClient openSearchClient) (opensearch.ApiCreateInstanceRequest, error) { - req := apiClient.CreateInstance(ctx, model.ProjectId) + req := apiClient.CreateInstance(ctx, model.ProjectId, model.Region) - var planId *string + var planId string var err error - offerings, err := apiClient.ListOfferingsExecute(ctx, model.ProjectId) + offerings, err := apiClient.ListOfferings(ctx, model.ProjectId, model.Region).Execute() if err != nil { return req, fmt.Errorf("get OpenSearch offerings: %w", err) } - if model.PlanId == nil { + if model.PlanId == "" { planId, err = opensearchUtils.LoadPlanId(model.PlanName, model.Version, offerings) if err != nil { var dsaInvalidPlanError *cliErr.DSAInvalidPlanError @@ -217,7 +217,7 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient openSearchCl return req, err } } else { - err := opensearchUtils.ValidatePlanId(*model.PlanId, offerings) + err := opensearchUtils.ValidatePlanId(model.PlanId, offerings) if err != nil { return req, err } diff --git a/internal/cmd/opensearch/instance/create/create_test.go b/internal/cmd/opensearch/instance/create/create_test.go index 5341b00af..ba50a359e 100644 --- a/internal/cmd/opensearch/instance/create/create_test.go +++ b/internal/cmd/opensearch/instance/create/create_test.go @@ -14,44 +14,46 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/opensearch" + opensearch "github.com/stackitcloud/stackit-sdk-go/services/opensearch/v2api" ) type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &opensearch.APIClient{} +var testClient = &opensearch.APIClient{DefaultAPI: &opensearch.DefaultAPIService{}} -type openSearchClientMocked struct { - returnError bool - listOfferingsResp *opensearch.ListOfferingsResponse +type mockSettings struct { + getOfferingsFails bool + getOfferingsResp *opensearch.ListOfferingsResponse } -func (c *openSearchClientMocked) CreateInstance(ctx context.Context, projectId string) opensearch.ApiCreateInstanceRequest { - return testClient.CreateInstance(ctx, projectId) -} - -func (c *openSearchClientMocked) ListOfferingsExecute(_ context.Context, _ string) (*opensearch.ListOfferingsResponse, error) { - if c.returnError { - return nil, fmt.Errorf("list flavors failed") +func newAPIClientMock(c mockSettings) opensearch.DefaultAPI { + return opensearch.DefaultAPIServiceMock{ + ListOfferingsExecuteMock: utils.Ptr(func(_ opensearch.ApiListOfferingsRequest) (*opensearch.ListOfferingsResponse, error) { + if c.getOfferingsFails { + return nil, fmt.Errorf("list flavors failed") + } + return c.getOfferingsResp, nil + }), } - return c.listOfferingsResp, nil } var testProjectId = uuid.NewString() +var testRegion = "eu01" var testPlanId = uuid.NewString() var testMonitoringInstanceId = uuid.NewString() func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string { flagValues := map[string]string{ globalflags.ProjectIdFlag: testProjectId, + globalflags.RegionFlag: testRegion, instanceNameFlag: "example-name", enableMonitoringFlag: "true", graphiteFlag: "example-graphite", metricsFrequencyFlag: "100", metricsPrefixFlag: "example-prefix", monitoringInstanceIdFlag: testMonitoringInstanceId, - pluginFlag: "example-plugin", + flagPlugins.Name(): string(opensearch.INSTANCEPARAMETERSPLUGINSINNER_REPOSITORY_AZURE), sgwAclFlag: "198.51.100.14/24", syslogFlag: "example-syslog", planIdFlag: testPlanId, @@ -66,18 +68,19 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { model := &inputModel{ GlobalFlagModel: &globalflags.GlobalFlagModel{ ProjectId: testProjectId, + Region: testRegion, Verbosity: globalflags.VerbosityDefault, }, - InstanceName: utils.Ptr("example-name"), + InstanceName: "example-name", EnableMonitoring: utils.Ptr(true), Graphite: utils.Ptr("example-graphite"), - MetricsFrequency: utils.Ptr(int64(100)), + MetricsFrequency: utils.Ptr(int32(100)), MetricsPrefix: utils.Ptr("example-prefix"), MonitoringInstanceId: utils.Ptr(testMonitoringInstanceId), - Plugin: utils.Ptr([]string{"example-plugin"}), + Plugin: []opensearch.InstanceParametersPluginsInner{opensearch.INSTANCEPARAMETERSPLUGINSINNER_REPOSITORY_AZURE}, SgwAcl: utils.Ptr([]string{"198.51.100.14/24"}), - Syslog: utils.Ptr([]string{"example-syslog"}), - PlanId: utils.Ptr(testPlanId), + Syslog: []string{"example-syslog"}, + PlanId: testPlanId, } for _, mod := range mods { mod(model) @@ -86,20 +89,20 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *opensearch.ApiCreateInstanceRequest)) opensearch.ApiCreateInstanceRequest { - request := testClient.CreateInstance(testCtx, testProjectId) + request := testClient.DefaultAPI.CreateInstance(testCtx, testProjectId, testRegion) request = request.CreateInstancePayload(opensearch.CreateInstancePayload{ - InstanceName: utils.Ptr("example-name"), + InstanceName: "example-name", Parameters: &opensearch.InstanceParameters{ EnableMonitoring: utils.Ptr(true), Graphite: utils.Ptr("example-graphite"), - MetricsFrequency: utils.Ptr(int64(100)), + MetricsFrequency: utils.Ptr(int32(100)), MetricsPrefix: utils.Ptr("example-prefix"), MonitoringInstanceId: utils.Ptr(testMonitoringInstanceId), - Plugins: utils.Ptr([]string{"example-plugin"}), + Plugins: []opensearch.InstanceParametersPluginsInner{opensearch.INSTANCEPARAMETERSPLUGINSINNER_REPOSITORY_AZURE}, SgwAcl: utils.Ptr("198.51.100.14/24"), - Syslog: utils.Ptr([]string{"example-syslog"}), + Syslog: []string{"example-syslog"}, }, - PlanId: utils.Ptr(testPlanId), + PlanId: testPlanId, }) for _, mod := range mods { mod(&request) @@ -133,7 +136,7 @@ func TestParseInput(t *testing.T) { }), isValid: true, expectedModel: fixtureInputModel(func(model *inputModel) { - model.PlanId = nil + model.PlanId = "" model.PlanName = "plan-name" model.Version = "6" }), @@ -156,8 +159,8 @@ func TestParseInput(t *testing.T) { ProjectId: testProjectId, Verbosity: globalflags.VerbosityDefault, }, - InstanceName: utils.Ptr("example-name"), - PlanId: utils.Ptr(testPlanId), + InstanceName: "example-name", + PlanId: testPlanId, }, }, { @@ -177,11 +180,11 @@ func TestParseInput(t *testing.T) { ProjectId: testProjectId, Verbosity: globalflags.VerbosityDefault, }, - PlanId: utils.Ptr(testPlanId), - InstanceName: utils.Ptr(""), + PlanId: testPlanId, + InstanceName: "", EnableMonitoring: utils.Ptr(false), Graphite: utils.Ptr(""), - MetricsFrequency: utils.Ptr(int64(0)), + MetricsFrequency: utils.Ptr(int32(0)), MetricsPrefix: utils.Ptr(""), }, }, @@ -254,12 +257,11 @@ func TestParseInput(t *testing.T) { { description: "repeated plugin flags", flagValues: fixtureFlagValues(), - pluginValues: []string{"example-plugin-1", "example-plugin-2"}, + pluginValues: []string{string(opensearch.INSTANCEPARAMETERSPLUGINSINNER_REPOSITORY_AZURE), string(opensearch.INSTANCEPARAMETERSPLUGINSINNER_ANALYSIS_PHONETIC)}, isValid: true, expectedModel: fixtureInputModel(func(model *inputModel) { - model.Plugin = utils.Ptr( - append(*model.Plugin, "example-plugin-1", "example-plugin-2"), - ) + model.Plugin = + append(model.Plugin, opensearch.INSTANCEPARAMETERSPLUGINSINNER_REPOSITORY_AZURE, opensearch.INSTANCEPARAMETERSPLUGINSINNER_ANALYSIS_PHONETIC) }), }, { @@ -268,9 +270,8 @@ func TestParseInput(t *testing.T) { syslogValues: []string{"example-syslog-1", "example-syslog-2"}, isValid: true, expectedModel: fixtureInputModel(func(model *inputModel) { - model.Syslog = utils.Ptr( - append(*model.Syslog, "example-syslog-1", "example-syslog-2"), - ) + model.Syslog = + append(model.Syslog, "example-syslog-1", "example-syslog-2") }), }, } @@ -278,9 +279,9 @@ func TestParseInput(t *testing.T) { for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { testutils.TestParseInputWithAdditionalFlags(t, NewCmd, parseInput, tt.expectedModel, tt.argValues, tt.flagValues, map[string][]string{ - sgwAclFlag: tt.sgwAclValues, - pluginFlag: tt.pluginValues, - syslogFlag: tt.syslogValues, + sgwAclFlag: tt.sgwAclValues, + flagPlugins.Name(): tt.pluginValues, + syslogFlag: tt.syslogValues, }, tt.isValid) }) } @@ -288,25 +289,26 @@ func TestParseInput(t *testing.T) { func TestBuildRequest(t *testing.T) { tests := []struct { - description string - model *inputModel - expectedRequest opensearch.ApiCreateInstanceRequest - getOfferingsFails bool - getOfferingsResp *opensearch.ListOfferingsResponse - isValid bool + description string + model *inputModel + expectedRequest opensearch.ApiCreateInstanceRequest + mockClientSettings mockSettings + isValid bool }{ { description: "base", model: fixtureInputModel(), expectedRequest: fixtureRequest(), - getOfferingsResp: &opensearch.ListOfferingsResponse{ - Offerings: &[]opensearch.Offering{ - { - Version: utils.Ptr("example-version"), - Plans: &[]opensearch.Plan{ - { - Name: utils.Ptr("example-plan-name"), - Id: utils.Ptr(testPlanId), + mockClientSettings: mockSettings{ + getOfferingsResp: &opensearch.ListOfferingsResponse{ + Offerings: []opensearch.Offering{ + { + Version: "example-version", + Plans: []opensearch.Plan{ + { + Name: "example-plan-name", + Id: testPlanId, + }, }, }, }, @@ -317,20 +319,22 @@ func TestBuildRequest(t *testing.T) { description: "use plan name and version", model: fixtureInputModel( func(model *inputModel) { - model.PlanId = nil + model.PlanId = "" model.PlanName = "example-plan-name" model.Version = "example-version" }, ), expectedRequest: fixtureRequest(), - getOfferingsResp: &opensearch.ListOfferingsResponse{ - Offerings: &[]opensearch.Offering{ - { - Version: utils.Ptr("example-version"), - Plans: &[]opensearch.Plan{ - { - Name: utils.Ptr("example-plan-name"), - Id: utils.Ptr(testPlanId), + mockClientSettings: mockSettings{ + getOfferingsResp: &opensearch.ListOfferingsResponse{ + Offerings: []opensearch.Offering{ + { + Version: "example-version", + Plans: []opensearch.Plan{ + { + Name: "example-plan-name", + Id: testPlanId, + }, }, }, }, @@ -341,31 +345,35 @@ func TestBuildRequest(t *testing.T) { description: "get offering fails", model: fixtureInputModel( func(model *inputModel) { - model.PlanId = nil + model.PlanId = "" model.PlanName = "example-plan-name" model.Version = "example-version" }, ), - getOfferingsFails: true, - isValid: false, + mockClientSettings: mockSettings{ + getOfferingsFails: true, + }, + isValid: false, }, { description: "plan name not found", model: fixtureInputModel( func(model *inputModel) { - model.PlanId = nil + model.PlanId = "" model.PlanName = "example-plan-name" model.Version = "example-version" }, ), - getOfferingsResp: &opensearch.ListOfferingsResponse{ - Offerings: &[]opensearch.Offering{ - { - Version: utils.Ptr("example-version"), - Plans: &[]opensearch.Plan{ - { - Name: utils.Ptr("other-plan-name"), - Id: utils.Ptr(testPlanId), + mockClientSettings: mockSettings{ + getOfferingsResp: &opensearch.ListOfferingsResponse{ + Offerings: []opensearch.Offering{ + { + Version: "example-version", + Plans: []opensearch.Plan{ + { + Name: "other-plan-name", + Id: testPlanId, + }, }, }, }, @@ -378,35 +386,34 @@ func TestBuildRequest(t *testing.T) { model: &inputModel{ GlobalFlagModel: &globalflags.GlobalFlagModel{ ProjectId: testProjectId, + Region: testRegion, Verbosity: globalflags.VerbosityDefault, }, - PlanId: utils.Ptr(testPlanId), + PlanId: testPlanId, }, - getOfferingsResp: &opensearch.ListOfferingsResponse{ - Offerings: &[]opensearch.Offering{ - { - Version: utils.Ptr("example-version"), - Plans: &[]opensearch.Plan{ - { - Name: utils.Ptr("example-plan-name"), - Id: utils.Ptr(testPlanId), + mockClientSettings: mockSettings{ + getOfferingsResp: &opensearch.ListOfferingsResponse{ + Offerings: []opensearch.Offering{ + { + Version: "example-version", + Plans: []opensearch.Plan{ + { + Name: "example-plan-name", + Id: testPlanId, + }, }, }, }, }, }, - expectedRequest: testClient.CreateInstance(testCtx, testProjectId). - CreateInstancePayload(opensearch.CreateInstancePayload{PlanId: utils.Ptr(testPlanId), Parameters: &opensearch.InstanceParameters{}}), + expectedRequest: testClient.DefaultAPI.CreateInstance(testCtx, testProjectId, testRegion). + CreateInstancePayload(opensearch.CreateInstancePayload{PlanId: testPlanId, Parameters: &opensearch.InstanceParameters{}}), }, } for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { - client := &openSearchClientMocked{ - returnError: tt.getOfferingsFails, - listOfferingsResp: tt.getOfferingsResp, - } - request, err := buildRequest(testCtx, tt.model, client) + request, err := buildRequest(testCtx, tt.model, newAPIClientMock(tt.mockClientSettings)) if err != nil { if !tt.isValid { return @@ -417,6 +424,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), cmpopts.EquateComparable(testCtx), + cmpopts.IgnoreFields(tt.expectedRequest, "ApiService"), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/opensearch/instance/delete/delete.go b/internal/cmd/opensearch/instance/delete/delete.go index 58f4f59d1..34463c499 100644 --- a/internal/cmd/opensearch/instance/delete/delete.go +++ b/internal/cmd/opensearch/instance/delete/delete.go @@ -17,8 +17,8 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/opensearch" - "github.com/stackitcloud/stackit-sdk-go/services/opensearch/wait" + opensearch "github.com/stackitcloud/stackit-sdk-go/services/opensearch/v2api" + wait "github.com/stackitcloud/stackit-sdk-go/services/opensearch/v2api/wait" ) const ( @@ -54,7 +54,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return err } - instanceLabel, err := opensearchUtils.GetInstanceName(ctx, apiClient, model.ProjectId, model.InstanceId) + instanceLabel, err := opensearchUtils.GetInstanceName(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, model.InstanceId) if err != nil { params.Printer.Debug(print.ErrorLevel, "get instance name: %v", err) instanceLabel = model.InstanceId @@ -76,7 +76,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { // Wait for async operation, if async mode not enabled if !model.Async { err := spinner.Run(params.Printer, "Deleting instance", func() error { - _, err = wait.DeleteInstanceWaitHandler(ctx, apiClient, model.ProjectId, model.InstanceId).WaitWithContext(ctx) + _, err = wait.DeleteInstanceWaitHandler(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, model.InstanceId).WaitWithContext(ctx) return err }) if err != nil { @@ -113,6 +113,6 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *opensearch.APIClient) opensearch.ApiDeleteInstanceRequest { - req := apiClient.DeleteInstance(ctx, model.ProjectId, model.InstanceId) + req := apiClient.DefaultAPI.DeleteInstance(ctx, model.ProjectId, model.Region, model.InstanceId) return req } diff --git a/internal/cmd/opensearch/instance/delete/delete_test.go b/internal/cmd/opensearch/instance/delete/delete_test.go index f9943acf7..29d85b31b 100644 --- a/internal/cmd/opensearch/instance/delete/delete_test.go +++ b/internal/cmd/opensearch/instance/delete/delete_test.go @@ -10,15 +10,18 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/opensearch" + opensearch "github.com/stackitcloud/stackit-sdk-go/services/opensearch/v2api" ) type testCtxKey struct{} -var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &opensearch.APIClient{} -var testProjectId = uuid.NewString() -var testInstanceId = uuid.NewString() +var ( + testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") + testClient = &opensearch.APIClient{DefaultAPI: &opensearch.DefaultAPIService{}} + testProjectId = uuid.NewString() + testRegion = "eu01" + testInstanceId = uuid.NewString() +) func fixtureArgValues(mods ...func(argValues []string)) []string { argValues := []string{ @@ -33,6 +36,7 @@ func fixtureArgValues(mods ...func(argValues []string)) []string { func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string { flagValues := map[string]string{ globalflags.ProjectIdFlag: testProjectId, + globalflags.RegionFlag: testRegion, } for _, mod := range mods { mod(flagValues) @@ -44,6 +48,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { model := &inputModel{ GlobalFlagModel: &globalflags.GlobalFlagModel{ ProjectId: testProjectId, + Region: testRegion, Verbosity: globalflags.VerbosityDefault, }, InstanceId: testInstanceId, @@ -55,7 +60,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *opensearch.ApiDeleteInstanceRequest)) opensearch.ApiDeleteInstanceRequest { - request := testClient.DeleteInstance(testCtx, testProjectId, testInstanceId) + request := testClient.DefaultAPI.DeleteInstance(testCtx, testProjectId, testRegion, testInstanceId) for _, mod := range mods { mod(&request) } @@ -159,7 +164,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, opensearch.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/opensearch/instance/describe/describe.go b/internal/cmd/opensearch/instance/describe/describe.go index 663ce82de..0bc1345b2 100644 --- a/internal/cmd/opensearch/instance/describe/describe.go +++ b/internal/cmd/opensearch/instance/describe/describe.go @@ -16,7 +16,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/opensearch" + opensearch "github.com/stackitcloud/stackit-sdk-go/services/opensearch/v2api" ) const ( @@ -87,31 +87,28 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *opensearch.APIClient) opensearch.ApiGetInstanceRequest { - req := apiClient.GetInstance(ctx, model.ProjectId, model.InstanceId) + req := apiClient.DefaultAPI.GetInstance(ctx, model.ProjectId, model.Region, model.InstanceId) return req } func outputResult(p *print.Printer, outputFormat string, instance *opensearch.Instance) error { - if instance == nil { - return fmt.Errorf("instance is nil") - } - return p.OutputResult(outputFormat, instance, func() error { + if instance == nil { + return fmt.Errorf("instance is nil") + } table := tables.NewTable() table.AddRow("ID", utils.PtrString(instance.InstanceId)) table.AddSeparator() - table.AddRow("NAME", utils.PtrString(instance.Name)) + table.AddRow("NAME", instance.Name) table.AddSeparator() - if instance.LastOperation != nil { - table.AddRow("LAST OPERATION TYPE", utils.PtrString(instance.LastOperation.Type)) - table.AddSeparator() - table.AddRow("LAST OPERATION STATE", utils.PtrString(instance.LastOperation.State)) - table.AddSeparator() - } - table.AddRow("PLAN ID", utils.PtrString(instance.PlanId)) + table.AddRow("LAST OPERATION TYPE", instance.LastOperation.Type) + table.AddSeparator() + table.AddRow("LAST OPERATION STATE", instance.LastOperation.State) + table.AddSeparator() + table.AddRow("PLAN ID", instance.PlanId) // Only show ACL if it's present and not empty if instance.Parameters != nil { - acl := (*instance.Parameters)[aclParameterKey] + acl := instance.Parameters[aclParameterKey] aclStr, ok := acl.(string) if ok { if aclStr != "" { diff --git a/internal/cmd/opensearch/instance/describe/describe_test.go b/internal/cmd/opensearch/instance/describe/describe_test.go index cbbd064b2..dd5c0619a 100644 --- a/internal/cmd/opensearch/instance/describe/describe_test.go +++ b/internal/cmd/opensearch/instance/describe/describe_test.go @@ -11,15 +11,18 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/opensearch" + opensearch "github.com/stackitcloud/stackit-sdk-go/services/opensearch/v2api" ) type testCtxKey struct{} -var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &opensearch.APIClient{} -var testProjectId = uuid.NewString() -var testInstanceId = uuid.NewString() +var ( + testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") + testClient = &opensearch.APIClient{DefaultAPI: &opensearch.DefaultAPIService{}} + testProjectId = uuid.NewString() + testRegion = "eu01" + testInstanceId = uuid.NewString() +) func fixtureArgValues(mods ...func(argValues []string)) []string { argValues := []string{ @@ -34,6 +37,7 @@ func fixtureArgValues(mods ...func(argValues []string)) []string { func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string { flagValues := map[string]string{ globalflags.ProjectIdFlag: testProjectId, + globalflags.RegionFlag: testRegion, } for _, mod := range mods { mod(flagValues) @@ -45,6 +49,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { model := &inputModel{ GlobalFlagModel: &globalflags.GlobalFlagModel{ ProjectId: testProjectId, + Region: testRegion, Verbosity: globalflags.VerbosityDefault, }, InstanceId: testInstanceId, @@ -56,7 +61,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *opensearch.ApiGetInstanceRequest)) opensearch.ApiGetInstanceRequest { - request := testClient.GetInstance(testCtx, testProjectId, testInstanceId) + request := testClient.DefaultAPI.GetInstance(testCtx, testProjectId, testRegion, testInstanceId) for _, mod := range mods { mod(&request) } @@ -160,7 +165,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, opensearch.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/opensearch/instance/list/list.go b/internal/cmd/opensearch/instance/list/list.go index 48f7e986b..48ce861df 100644 --- a/internal/cmd/opensearch/instance/list/list.go +++ b/internal/cmd/opensearch/instance/list/list.go @@ -7,7 +7,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/types" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/opensearch" + opensearch "github.com/stackitcloud/stackit-sdk-go/services/opensearch/v2api" "github.com/stackitcloud/stackit-cli/internal/pkg/args" "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -115,7 +115,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, } func buildRequest(ctx context.Context, model *inputModel, apiClient *opensearch.APIClient) opensearch.ApiListInstancesRequest { - req := apiClient.ListInstances(ctx, model.ProjectId) + req := apiClient.DefaultAPI.ListInstances(ctx, model.ProjectId, model.Region) return req } @@ -132,9 +132,9 @@ func outputResult(p *print.Printer, outputFormat, projectLabel string, instances instance := instances[i] table.AddRow( utils.PtrString(instance.InstanceId), - utils.PtrString(instance.Name), - utils.PtrString(instance.LastOperation.Type), - utils.PtrString(instance.LastOperation.State), + instance.Name, + instance.LastOperation.Type, + instance.LastOperation.State, ) } err := table.Display(p) diff --git a/internal/cmd/opensearch/instance/list/list_test.go b/internal/cmd/opensearch/instance/list/list_test.go index ad5ea76eb..c7d53f585 100644 --- a/internal/cmd/opensearch/instance/list/list_test.go +++ b/internal/cmd/opensearch/instance/list/list_test.go @@ -12,18 +12,22 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/opensearch" + opensearch "github.com/stackitcloud/stackit-sdk-go/services/opensearch/v2api" ) type testCtxKey struct{} -var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &opensearch.APIClient{} -var testProjectId = uuid.NewString() +var ( + testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") + testClient = &opensearch.APIClient{DefaultAPI: &opensearch.DefaultAPIService{}} + testProjectId = uuid.NewString() + testRegion = "eu01" +) func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string { flagValues := map[string]string{ globalflags.ProjectIdFlag: testProjectId, + globalflags.RegionFlag: testRegion, limitFlag: "10", } for _, mod := range mods { @@ -36,6 +40,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { model := &inputModel{ GlobalFlagModel: &globalflags.GlobalFlagModel{ ProjectId: testProjectId, + Region: testRegion, Verbosity: globalflags.VerbosityDefault, }, Limit: utils.Ptr(int64(10)), @@ -47,7 +52,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *opensearch.ApiListInstancesRequest)) opensearch.ApiListInstancesRequest { - request := testClient.ListInstances(testCtx, testProjectId) + request := testClient.DefaultAPI.ListInstances(testCtx, testProjectId, testRegion) for _, mod := range mods { mod(&request) } @@ -136,7 +141,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, opensearch.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/opensearch/instance/update/update.go b/internal/cmd/opensearch/instance/update/update.go index 557fb1712..e5772dc63 100644 --- a/internal/cmd/opensearch/instance/update/update.go +++ b/internal/cmd/opensearch/instance/update/update.go @@ -20,8 +20,8 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/opensearch" - "github.com/stackitcloud/stackit-sdk-go/services/opensearch/wait" + opensearch "github.com/stackitcloud/stackit-sdk-go/services/opensearch/v2api" + wait "github.com/stackitcloud/stackit-sdk-go/services/opensearch/v2api/wait" ) const ( @@ -33,7 +33,6 @@ const ( metricsFrequencyFlag = "metrics-frequency" metricsPrefixFlag = "metrics-prefix" monitoringInstanceIdFlag = "monitoring-instance-id" - pluginFlag = "plugin" sgwAclFlag = "acl" syslogFlag = "syslog" planIdFlag = "plan-id" @@ -41,6 +40,12 @@ const ( versionFlag = "version" ) +var flagPlugins = flags.StringEnumSliceFlag( + "plugin", + opensearch.AllowedInstanceParametersPluginsInnerEnumValues, + "Plugins", +) + type inputModel struct { *globalflags.GlobalFlagModel InstanceId string @@ -49,12 +54,12 @@ type inputModel struct { EnableMonitoring *bool Graphite *string - MetricsFrequency *int64 + MetricsFrequency *int32 MetricsPrefix *string MonitoringInstanceId *string - Plugin *[]string + Plugin []opensearch.InstanceParametersPluginsInner SgwAcl *[]string - Syslog *[]string + Syslog []string PlanId *string } @@ -85,7 +90,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return err } - instanceLabel, err := opensearchUtils.GetInstanceName(ctx, apiClient, model.ProjectId, model.InstanceId) + instanceLabel, err := opensearchUtils.GetInstanceName(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, model.InstanceId) if err != nil { params.Printer.Debug(print.ErrorLevel, "get instance name: %v", err) instanceLabel = model.InstanceId @@ -98,7 +103,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } // Call API - req, err := buildRequest(ctx, model, apiClient) + req, err := buildRequest(ctx, model, apiClient.DefaultAPI) if err != nil { var dsaInvalidPlanError *cliErr.DSAInvalidPlanError if !errors.As(err, &dsaInvalidPlanError) { @@ -115,7 +120,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { // Wait for async operation, if async mode not enabled if !model.Async { err := spinner.Run(params.Printer, "Updating instance", func() error { - _, err = wait.PartialUpdateInstanceWaitHandler(ctx, apiClient, model.ProjectId, instanceId).WaitWithContext(ctx) + _, err = wait.PartialUpdateInstanceWaitHandler(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, instanceId).WaitWithContext(ctx) return err }) if err != nil { @@ -138,10 +143,10 @@ func NewCmd(params *types.CmdParams) *cobra.Command { func configureFlags(cmd *cobra.Command) { cmd.Flags().Bool(enableMonitoringFlag, false, "Enable monitoring") cmd.Flags().String(graphiteFlag, "", "Graphite host") - cmd.Flags().Int64(metricsFrequencyFlag, 0, "Metrics frequency") + cmd.Flags().Int32(metricsFrequencyFlag, 0, "Metrics frequency") cmd.Flags().String(metricsPrefixFlag, "", "Metrics prefix") cmd.Flags().Var(flags.UUIDFlag(), monitoringInstanceIdFlag, "Monitoring instance ID") - cmd.Flags().StringSlice(pluginFlag, []string{}, "Plugin") + flagPlugins.Register(cmd) cmd.Flags().Var(flags.CIDRSliceFlag(), sgwAclFlag, "List of IP networks in CIDR notation which are allowed to access this instance") cmd.Flags().StringSlice(syslogFlag, []string{}, "Syslog") cmd.Flags().Var(flags.UUIDFlag(), planIdFlag, "Plan ID") @@ -160,11 +165,11 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu enableMonitoring := flags.FlagToBoolPointer(p, cmd, enableMonitoringFlag) monitoringInstanceId := flags.FlagToStringPointer(p, cmd, monitoringInstanceIdFlag) graphite := flags.FlagToStringPointer(p, cmd, graphiteFlag) - metricsFrequency := flags.FlagToInt64Pointer(p, cmd, metricsFrequencyFlag) + metricsFrequency := flags.FlagToInt32Pointer(p, cmd, metricsFrequencyFlag) metricsPrefix := flags.FlagToStringPointer(p, cmd, metricsPrefixFlag) - plugin := flags.FlagToStringSlicePointer(p, cmd, pluginFlag) + plugin := flagPlugins.Get() sgwAcl := flags.FlagToStringSlicePointer(p, cmd, sgwAclFlag) - syslog := flags.FlagToStringSlicePointer(p, cmd, syslogFlag) + syslog := flags.FlagToStringSliceValue(p, cmd, syslogFlag) planId := flags.FlagToStringPointer(p, cmd, planIdFlag) planName := flags.FlagToStringValue(p, cmd, planNameFlag) version := flags.FlagToStringValue(p, cmd, versionFlag) @@ -178,7 +183,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu if enableMonitoring == nil && monitoringInstanceId == nil && graphite == nil && metricsFrequency == nil && metricsPrefix == nil && plugin == nil && - sgwAcl == nil && syslog == nil && planId == nil && + sgwAcl == nil && planId == nil && planName == "" && version == "" { return nil, &cliErr.EmptyUpdateError{} } @@ -204,23 +209,23 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } type openSearchClient interface { - PartialUpdateInstance(ctx context.Context, projectId, instanceId string) opensearch.ApiPartialUpdateInstanceRequest - ListOfferingsExecute(ctx context.Context, projectId string) (*opensearch.ListOfferingsResponse, error) + PartialUpdateInstance(ctx context.Context, projectId, region, instanceId string) opensearch.ApiPartialUpdateInstanceRequest + ListOfferings(ctx context.Context, projectId, region string) opensearch.ApiListOfferingsRequest } func buildRequest(ctx context.Context, model *inputModel, apiClient openSearchClient) (opensearch.ApiPartialUpdateInstanceRequest, error) { - req := apiClient.PartialUpdateInstance(ctx, model.ProjectId, model.InstanceId) + req := apiClient.PartialUpdateInstance(ctx, model.ProjectId, model.Region, model.InstanceId) var planId *string var err error - offerings, err := apiClient.ListOfferingsExecute(ctx, model.ProjectId) + offerings, err := apiClient.ListOfferings(ctx, model.ProjectId, model.Region).Execute() if err != nil { return req, fmt.Errorf("get OpenSearch offerings: %w", err) } if model.PlanId == nil && model.PlanName != "" && model.Version != "" { - planId, err = opensearchUtils.LoadPlanId(model.PlanName, model.Version, offerings) + foundPlanId, err := opensearchUtils.LoadPlanId(model.PlanName, model.Version, offerings) if err != nil { var dsaInvalidPlanError *cliErr.DSAInvalidPlanError if !errors.As(err, &dsaInvalidPlanError) { @@ -228,13 +233,12 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient openSearchCl } return req, err } - } else { + planId = &foundPlanId + } else if model.PlanId != nil { // planId is not required for update operation - if model.PlanId != nil { - err := opensearchUtils.ValidatePlanId(*model.PlanId, offerings) - if err != nil { - return req, err - } + err := opensearchUtils.ValidatePlanId(*model.PlanId, offerings) + if err != nil { + return req, err } planId = model.PlanId } diff --git a/internal/cmd/opensearch/instance/update/update_test.go b/internal/cmd/opensearch/instance/update/update_test.go index 433927c8d..4124a1af0 100644 --- a/internal/cmd/opensearch/instance/update/update_test.go +++ b/internal/cmd/opensearch/instance/update/update_test.go @@ -6,38 +6,39 @@ import ( "testing" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" - "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" + "github.com/stackitcloud/stackit-cli/internal/pkg/testutils" "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/opensearch" + opensearch "github.com/stackitcloud/stackit-sdk-go/services/opensearch/v2api" ) type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &opensearch.APIClient{} +var testClient = &opensearch.APIClient{DefaultAPI: &opensearch.DefaultAPIService{}} -type openSearchClientMocked struct { - returnError bool +type mockSettings struct { + getOfferingsFails bool listOfferingsResp *opensearch.ListOfferingsResponse } -func (c *openSearchClientMocked) PartialUpdateInstance(ctx context.Context, projectId, instanceId string) opensearch.ApiPartialUpdateInstanceRequest { - return testClient.PartialUpdateInstance(ctx, projectId, instanceId) -} - -func (c *openSearchClientMocked) ListOfferingsExecute(_ context.Context, _ string) (*opensearch.ListOfferingsResponse, error) { - if c.returnError { - return nil, fmt.Errorf("list flavors failed") +func newAPIClientMock(c mockSettings) opensearch.DefaultAPI { + return opensearch.DefaultAPIServiceMock{ + ListOfferingsExecuteMock: utils.Ptr(func(_ opensearch.ApiListOfferingsRequest) (*opensearch.ListOfferingsResponse, error) { + if c.getOfferingsFails { + return nil, fmt.Errorf("list flavors failed") + } + return c.listOfferingsResp, nil + }), } - return c.listOfferingsResp, nil } var ( testProjectId = uuid.NewString() + testRegion = "eu01" testInstanceId = uuid.NewString() testPlanId = uuid.NewString() testMonitoringInstanceId = uuid.NewString() @@ -56,12 +57,13 @@ func fixtureArgValues(mods ...func(argValues []string)) []string { func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string { flagValues := map[string]string{ globalflags.ProjectIdFlag: testProjectId, + globalflags.RegionFlag: testRegion, enableMonitoringFlag: "true", graphiteFlag: "example-graphite", metricsFrequencyFlag: "100", metricsPrefixFlag: "example-prefix", monitoringInstanceIdFlag: testMonitoringInstanceId, - pluginFlag: "example-plugin", + flagPlugins.Name(): string(opensearch.INSTANCEPARAMETERSPLUGINSINNER_REPOSITORY_AZURE), sgwAclFlag: "198.51.100.14/24", syslogFlag: "example-syslog", planIdFlag: testPlanId, @@ -76,17 +78,18 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { model := &inputModel{ GlobalFlagModel: &globalflags.GlobalFlagModel{ ProjectId: testProjectId, + Region: testRegion, Verbosity: globalflags.VerbosityDefault, }, InstanceId: testInstanceId, EnableMonitoring: utils.Ptr(true), Graphite: utils.Ptr("example-graphite"), - MetricsFrequency: utils.Ptr(int64(100)), + MetricsFrequency: utils.Ptr(int32(100)), MetricsPrefix: utils.Ptr("example-prefix"), MonitoringInstanceId: utils.Ptr(testMonitoringInstanceId), - Plugin: utils.Ptr([]string{"example-plugin"}), + Plugin: []opensearch.InstanceParametersPluginsInner{opensearch.INSTANCEPARAMETERSPLUGINSINNER_REPOSITORY_AZURE}, SgwAcl: utils.Ptr([]string{"198.51.100.14/24"}), - Syslog: utils.Ptr([]string{"example-syslog"}), + Syslog: []string{"example-syslog"}, PlanId: utils.Ptr(testPlanId), } for _, mod := range mods { @@ -96,17 +99,17 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *opensearch.ApiPartialUpdateInstanceRequest)) opensearch.ApiPartialUpdateInstanceRequest { - request := testClient.PartialUpdateInstance(testCtx, testProjectId, testInstanceId) + request := testClient.DefaultAPI.PartialUpdateInstance(testCtx, testProjectId, testRegion, testInstanceId) request = request.PartialUpdateInstancePayload(opensearch.PartialUpdateInstancePayload{ Parameters: &opensearch.InstanceParameters{ EnableMonitoring: utils.Ptr(true), Graphite: utils.Ptr("example-graphite"), - MetricsFrequency: utils.Ptr(int64(100)), + MetricsFrequency: utils.Ptr(int32(100)), MetricsPrefix: utils.Ptr("example-prefix"), MonitoringInstanceId: utils.Ptr(testMonitoringInstanceId), - Plugins: utils.Ptr([]string{"example-plugin"}), + Plugins: []opensearch.InstanceParametersPluginsInner{opensearch.INSTANCEPARAMETERSPLUGINSINNER_REPOSITORY_AZURE}, SgwAcl: utils.Ptr("198.51.100.14/24"), - Syslog: utils.Ptr([]string{"example-syslog"}), + Syslog: []string{"example-syslog"}, }, PlanId: utils.Ptr(testPlanId), }) @@ -188,7 +191,7 @@ func TestParseInput(t *testing.T) { PlanId: utils.Ptr(testPlanId), EnableMonitoring: utils.Ptr(false), Graphite: utils.Ptr(""), - MetricsFrequency: utils.Ptr(int64(0)), + MetricsFrequency: utils.Ptr(int32(0)), MetricsPrefix: utils.Ptr(""), }, }, @@ -267,12 +270,11 @@ func TestParseInput(t *testing.T) { description: "repeated plugin flags", argValues: fixtureArgValues(), flagValues: fixtureFlagValues(), - pluginValues: []string{"example-plugin-1", "example-plugin-2"}, + pluginValues: []string{string(opensearch.INSTANCEPARAMETERSPLUGINSINNER_REPOSITORY_AZURE), string(opensearch.INSTANCEPARAMETERSPLUGINSINNER_ANALYSIS_PHONETIC)}, isValid: true, expectedModel: fixtureInputModel(func(model *inputModel) { - model.Plugin = utils.Ptr( - append(*model.Plugin, "example-plugin-1", "example-plugin-2"), - ) + model.Plugin = + append(model.Plugin, opensearch.INSTANCEPARAMETERSPLUGINSINNER_REPOSITORY_AZURE, opensearch.INSTANCEPARAMETERSPLUGINSINNER_ANALYSIS_PHONETIC) }), }, { @@ -282,118 +284,45 @@ func TestParseInput(t *testing.T) { syslogValues: []string{"example-syslog-1", "example-syslog-2"}, isValid: true, expectedModel: fixtureInputModel(func(model *inputModel) { - model.Syslog = utils.Ptr( - append(*model.Syslog, "example-syslog-1", "example-syslog-2"), - ) + model.Syslog = + append(model.Syslog, "example-syslog-1", "example-syslog-2") }), }, } for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { - params := testparams.NewTestParams() - cmd := NewCmd(params.CmdParams) - err := globalflags.Configure(cmd.Flags()) - if err != nil { - t.Fatalf("configure global flags: %v", err) - } - - for flag, value := range tt.flagValues { - err := cmd.Flags().Set(flag, value) - if err != nil { - if !tt.isValid { - return - } - t.Fatalf("setting flag --%s=%s: %v", flag, value, err) - } - } - - for _, value := range tt.sgwAclValues { - err := cmd.Flags().Set(sgwAclFlag, value) - if err != nil { - if !tt.isValid { - return - } - t.Fatalf("setting flag --%s=%s: %v", sgwAclFlag, value, err) - } - } - - for _, value := range tt.pluginValues { - err := cmd.Flags().Set(pluginFlag, value) - if err != nil { - if !tt.isValid { - return - } - t.Fatalf("setting flag --%s=%s: %v", pluginFlag, value, err) - } - } - - for _, value := range tt.syslogValues { - err := cmd.Flags().Set(syslogFlag, value) - if err != nil { - if !tt.isValid { - return - } - t.Fatalf("setting flag --%s=%s: %v", syslogFlag, value, err) - } - } - - err = cmd.ValidateArgs(tt.argValues) - if err != nil { - if !tt.isValid { - return - } - t.Fatalf("error validating args: %v", err) - } - - err = cmd.ValidateRequiredFlags() - if err != nil { - if !tt.isValid { - return - } - t.Fatalf("error validating flags: %v", err) - } - - model, err := parseInput(params.Printer, cmd, tt.argValues) - if err != nil { - if !tt.isValid { - return - } - t.Fatalf("error parsing flags: %v", err) - } - - if !tt.isValid { - t.Fatalf("did not fail on invalid input") - } - diff := cmp.Diff(model, tt.expectedModel) - if diff != "" { - t.Fatalf("Data does not match: %s", diff) - } + testutils.TestParseInputWithAdditionalFlags(t, NewCmd, parseInput, tt.expectedModel, tt.argValues, tt.flagValues, map[string][]string{ + sgwAclFlag: tt.sgwAclValues, + flagPlugins.Name(): tt.pluginValues, + syslogFlag: tt.syslogValues, + }, tt.isValid) }) } } func TestBuildRequest(t *testing.T) { tests := []struct { - description string - model *inputModel - expectedRequest opensearch.ApiPartialUpdateInstanceRequest - getOfferingsFails bool - listOfferingsResp *opensearch.ListOfferingsResponse - isValid bool + description string + model *inputModel + expectedRequest opensearch.ApiPartialUpdateInstanceRequest + mockClientSettings mockSettings + isValid bool }{ { description: "base", model: fixtureInputModel(), expectedRequest: fixtureRequest(), - listOfferingsResp: &opensearch.ListOfferingsResponse{ - Offerings: &[]opensearch.Offering{ - { - Version: utils.Ptr("example-version"), - Plans: &[]opensearch.Plan{ - { - Name: utils.Ptr("example-plan-name"), - Id: utils.Ptr(testPlanId), + mockClientSettings: mockSettings{ + listOfferingsResp: &opensearch.ListOfferingsResponse{ + Offerings: []opensearch.Offering{ + { + Version: "example-version", + Plans: []opensearch.Plan{ + { + Name: "example-plan-name", + Id: testPlanId, + }, }, }, }, @@ -410,14 +339,16 @@ func TestBuildRequest(t *testing.T) { }, ), expectedRequest: fixtureRequest(), - listOfferingsResp: &opensearch.ListOfferingsResponse{ - Offerings: &[]opensearch.Offering{ - { - Version: utils.Ptr("example-version"), - Plans: &[]opensearch.Plan{ - { - Name: utils.Ptr("example-plan-name"), - Id: utils.Ptr(testPlanId), + mockClientSettings: mockSettings{ + listOfferingsResp: &opensearch.ListOfferingsResponse{ + Offerings: []opensearch.Offering{ + { + Version: "example-version", + Plans: []opensearch.Plan{ + { + Name: "example-plan-name", + Id: testPlanId, + }, }, }, }, @@ -433,8 +364,10 @@ func TestBuildRequest(t *testing.T) { model.Version = "example-version" }, ), - getOfferingsFails: true, - isValid: false, + mockClientSettings: mockSettings{ + getOfferingsFails: true, + }, + isValid: false, }, { description: "plan name not found", @@ -445,14 +378,16 @@ func TestBuildRequest(t *testing.T) { model.Version = "example-version" }, ), - listOfferingsResp: &opensearch.ListOfferingsResponse{ - Offerings: &[]opensearch.Offering{ - { - Version: utils.Ptr("example-version"), - Plans: &[]opensearch.Plan{ - { - Name: utils.Ptr("other-plan-name"), - Id: utils.Ptr(testPlanId), + mockClientSettings: mockSettings{ + listOfferingsResp: &opensearch.ListOfferingsResponse{ + Offerings: []opensearch.Offering{ + { + Version: "example-version", + Plans: []opensearch.Plan{ + { + Name: "other-plan-name", + Id: testPlanId, + }, }, }, }, @@ -465,22 +400,19 @@ func TestBuildRequest(t *testing.T) { model: &inputModel{ GlobalFlagModel: &globalflags.GlobalFlagModel{ ProjectId: testProjectId, + Region: testRegion, Verbosity: globalflags.VerbosityDefault, }, InstanceId: testInstanceId, }, - expectedRequest: testClient.PartialUpdateInstance(testCtx, testProjectId, testInstanceId). + expectedRequest: testClient.DefaultAPI.PartialUpdateInstance(testCtx, testProjectId, testRegion, testInstanceId). PartialUpdateInstancePayload(opensearch.PartialUpdateInstancePayload{Parameters: &opensearch.InstanceParameters{}}), }, } for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { - client := &openSearchClientMocked{ - returnError: tt.getOfferingsFails, - listOfferingsResp: tt.listOfferingsResp, - } - request, err := buildRequest(testCtx, tt.model, client) + request, err := buildRequest(testCtx, tt.model, newAPIClientMock(tt.mockClientSettings)) if err != nil { if !tt.isValid { return @@ -491,6 +423,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), cmpopts.EquateComparable(testCtx), + cmpopts.IgnoreFields(tt.expectedRequest, "ApiService"), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/opensearch/plans/plans.go b/internal/cmd/opensearch/plans/plans.go index f5705879e..b8fbce408 100644 --- a/internal/cmd/opensearch/plans/plans.go +++ b/internal/cmd/opensearch/plans/plans.go @@ -7,7 +7,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/types" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/opensearch" + opensearch "github.com/stackitcloud/stackit-sdk-go/services/opensearch/v2api" "github.com/stackitcloud/stackit-cli/internal/pkg/args" "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -18,7 +18,6 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/projectname" "github.com/stackitcloud/stackit-cli/internal/pkg/services/opensearch/client" "github.com/stackitcloud/stackit-cli/internal/pkg/tables" - "github.com/stackitcloud/stackit-cli/internal/pkg/utils" ) const ( @@ -115,7 +114,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, } func buildRequest(ctx context.Context, model *inputModel, apiClient *opensearch.APIClient) opensearch.ApiListOfferingsRequest { - req := apiClient.ListOfferings(ctx, model.ProjectId) + req := apiClient.DefaultAPI.ListOfferings(ctx, model.ProjectId, model.Region) return req } @@ -131,14 +130,14 @@ func outputResult(p *print.Printer, outputFormat, projectLabel string, plans []o for i := range plans { o := plans[i] if o.Plans != nil { - for j := range *o.Plans { - plan := (*o.Plans)[j] + for j := range o.Plans { + plan := o.Plans[j] table.AddRow( - utils.PtrString(o.Name), - utils.PtrString(o.Version), - utils.PtrString(plan.Id), - utils.PtrString(plan.Name), - utils.PtrString(plan.Description), + o.Name, + o.Version, + plan.Id, + plan.Name, + plan.Description, ) } } diff --git a/internal/cmd/opensearch/plans/plans_test.go b/internal/cmd/opensearch/plans/plans_test.go index 7a44e1335..349c30754 100644 --- a/internal/cmd/opensearch/plans/plans_test.go +++ b/internal/cmd/opensearch/plans/plans_test.go @@ -12,18 +12,22 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/opensearch" + opensearch "github.com/stackitcloud/stackit-sdk-go/services/opensearch/v2api" ) type testCtxKey struct{} -var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &opensearch.APIClient{} -var testProjectId = uuid.NewString() +var ( + testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") + testClient = &opensearch.APIClient{DefaultAPI: &opensearch.DefaultAPIService{}} + testProjectId = uuid.NewString() + testRegion = "eu01" +) func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string { flagValues := map[string]string{ globalflags.ProjectIdFlag: testProjectId, + globalflags.RegionFlag: testRegion, limitFlag: "10", } for _, mod := range mods { @@ -36,6 +40,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { model := &inputModel{ GlobalFlagModel: &globalflags.GlobalFlagModel{ ProjectId: testProjectId, + Region: testRegion, Verbosity: globalflags.VerbosityDefault, }, Limit: utils.Ptr(int64(10)), @@ -47,7 +52,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *opensearch.ApiListOfferingsRequest)) opensearch.ApiListOfferingsRequest { - request := testClient.ListOfferings(testCtx, testProjectId) + request := testClient.DefaultAPI.ListOfferings(testCtx, testProjectId, testRegion) for _, mod := range mods { mod(&request) } @@ -136,7 +141,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, opensearch.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/pkg/services/opensearch/client/client.go b/internal/pkg/services/opensearch/client/client.go index fb7d218a3..f151d34e6 100644 --- a/internal/pkg/services/opensearch/client/client.go +++ b/internal/pkg/services/opensearch/client/client.go @@ -6,9 +6,9 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/print" "github.com/spf13/viper" - "github.com/stackitcloud/stackit-sdk-go/services/opensearch" + opensearch "github.com/stackitcloud/stackit-sdk-go/services/opensearch/v2api" ) func ConfigureClient(p *print.Printer, cliVersion string) (*opensearch.APIClient, error) { - return genericclient.ConfigureClientGeneric(p, cliVersion, viper.GetString(config.OpenSearchCustomEndpointKey), true, genericclient.CreateApiClient[*opensearch.APIClient](opensearch.NewAPIClient)) + return genericclient.ConfigureClientGeneric(p, cliVersion, viper.GetString(config.OpenSearchCustomEndpointKey), false, genericclient.CreateApiClient[*opensearch.APIClient](opensearch.NewAPIClient)) } diff --git a/internal/pkg/services/opensearch/utils/utils.go b/internal/pkg/services/opensearch/utils/utils.go index 58219f52c..9bc51b92b 100644 --- a/internal/pkg/services/opensearch/utils/utils.go +++ b/internal/pkg/services/opensearch/utils/utils.go @@ -7,7 +7,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/errors" - "github.com/stackitcloud/stackit-sdk-go/services/opensearch" + opensearch "github.com/stackitcloud/stackit-sdk-go/services/opensearch/v2api" ) const ( @@ -15,9 +15,9 @@ const ( ) func ValidatePlanId(planId string, offerings *opensearch.ListOfferingsResponse) error { - for _, offer := range *offerings.Offerings { - for _, plan := range *offer.Plans { - if plan.Id != nil && strings.EqualFold(*plan.Id, planId) { + for _, offer := range offerings.Offerings { + for _, plan := range offer.Plans { + if strings.EqualFold(plan.Id, planId) { return nil } } @@ -29,59 +29,51 @@ func ValidatePlanId(planId string, offerings *opensearch.ListOfferingsResponse) } } -func LoadPlanId(planName, version string, offerings *opensearch.ListOfferingsResponse) (*string, error) { +func LoadPlanId(planName, version string, offerings *opensearch.ListOfferingsResponse) (string, error) { availableVersions := "" availablePlanNames := "" isValidVersion := false - for _, offer := range *offerings.Offerings { - if !strings.EqualFold(*offer.Version, version) { - availableVersions = fmt.Sprintf("%s\n- %s", availableVersions, *offer.Version) + for _, offer := range offerings.Offerings { + if !strings.EqualFold(offer.Version, version) { + availableVersions = fmt.Sprintf("%s\n- %s", availableVersions, offer.Version) continue } isValidVersion = true - for _, plan := range *offer.Plans { - if plan.Name == nil { - continue - } - if strings.EqualFold(*plan.Name, planName) && plan.Id != nil { + for _, plan := range offer.Plans { + if strings.EqualFold(plan.Name, planName) { return plan.Id, nil } - availablePlanNames = fmt.Sprintf("%s\n- %s", availablePlanNames, *plan.Name) + availablePlanNames = fmt.Sprintf("%s\n- %s", availablePlanNames, plan.Name) } } if !isValidVersion { details := fmt.Sprintf("You provided version %q, which is invalid. Available versions are: %s", version, availableVersions) - return nil, &errors.DSAInvalidPlanError{ + return "", &errors.DSAInvalidPlanError{ Service: service, Details: details, } } details := fmt.Sprintf("You provided plan_name %q for version %s, which is invalid. Available plan names for that version are: %s", planName, version, availablePlanNames) - return nil, &errors.DSAInvalidPlanError{ + return "", &errors.DSAInvalidPlanError{ Service: service, Details: details, } } -type OpenSearchClient interface { - GetInstanceExecute(ctx context.Context, projectId, instanceId string) (*opensearch.Instance, error) - GetCredentialsExecute(ctx context.Context, projectId, instanceId, credentialsId string) (*opensearch.CredentialsResponse, error) -} - -func GetInstanceName(ctx context.Context, apiClient OpenSearchClient, projectId, instanceId string) (string, error) { - resp, err := apiClient.GetInstanceExecute(ctx, projectId, instanceId) +func GetInstanceName(ctx context.Context, apiClient opensearch.DefaultAPI, projectId, region, instanceId string) (string, error) { + resp, err := apiClient.GetInstance(ctx, projectId, region, instanceId).Execute() if err != nil { return "", fmt.Errorf("get OpenSearch instance: %w", err) } - return *resp.Name, nil + return resp.Name, nil } -func GetCredentialsUsername(ctx context.Context, apiClient OpenSearchClient, projectId, instanceId, credentialsId string) (string, error) { - resp, err := apiClient.GetCredentialsExecute(ctx, projectId, instanceId, credentialsId) +func GetCredentialsUsername(ctx context.Context, apiClient opensearch.DefaultAPI, projectId, region, instanceId, credentialsId string) (string, error) { + resp, err := apiClient.GetCredentials(ctx, projectId, region, instanceId, credentialsId).Execute() if err != nil { return "", fmt.Errorf("get OpenSearch credentials: %w", err) } - return *resp.Raw.Credentials.Username, nil + return resp.Raw.Credentials.Username, nil } diff --git a/internal/pkg/services/opensearch/utils/utils_test.go b/internal/pkg/services/opensearch/utils/utils_test.go index 8ebe3391b..114e8230b 100644 --- a/internal/pkg/services/opensearch/utils/utils_test.go +++ b/internal/pkg/services/opensearch/utils/utils_test.go @@ -5,10 +5,10 @@ import ( "fmt" "testing" - "github.com/stackitcloud/stackit-cli/internal/pkg/utils" - "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/opensearch" + opensearch "github.com/stackitcloud/stackit-sdk-go/services/opensearch/v2api" + + "github.com/stackitcloud/stackit-cli/internal/pkg/utils" ) var ( @@ -18,62 +18,64 @@ var ( ) const ( + testRegion = "eu01" testInstanceName = "instance" testCredentialsUsername = "username" ) -type openSearchClientMocked struct { +type mockSettings struct { getInstanceFails bool getInstanceResp *opensearch.Instance getCredentialsFails bool getCredentialsResp *opensearch.CredentialsResponse } -func (m *openSearchClientMocked) GetInstanceExecute(_ context.Context, _, _ string) (*opensearch.Instance, error) { - if m.getInstanceFails { - return nil, fmt.Errorf("could not get instance") - } - return m.getInstanceResp, nil -} - -func (m *openSearchClientMocked) GetCredentialsExecute(_ context.Context, _, _, _ string) (*opensearch.CredentialsResponse, error) { - if m.getCredentialsFails { - return nil, fmt.Errorf("could not get user") +func newAPIClientMock(m mockSettings) opensearch.DefaultAPI { + return opensearch.DefaultAPIServiceMock{ + GetInstanceExecuteMock: utils.Ptr(func(_ opensearch.ApiGetInstanceRequest) (*opensearch.Instance, error) { + if m.getInstanceFails { + return nil, fmt.Errorf("could not get instance") + } + return m.getInstanceResp, nil + }), + GetCredentialsExecuteMock: utils.Ptr(func(_ opensearch.ApiGetCredentialsRequest) (*opensearch.CredentialsResponse, error) { + if m.getCredentialsFails { + return nil, fmt.Errorf("could not get user") + } + return m.getCredentialsResp, nil + }), } - return m.getCredentialsResp, nil } func TestGetInstanceName(t *testing.T) { tests := []struct { - description string - getInstanceFails bool - getInstanceResp *opensearch.Instance - isValid bool - expectedOutput string + description string + mockClientSettings mockSettings + isValid bool + expectedOutput string }{ { description: "base", - getInstanceResp: &opensearch.Instance{ - Name: utils.Ptr(testInstanceName), + mockClientSettings: mockSettings{ + getInstanceResp: &opensearch.Instance{ + Name: testInstanceName, + }, }, isValid: true, expectedOutput: testInstanceName, }, { - description: "get instance fails", - getInstanceFails: true, - isValid: false, + description: "get instance fails", + mockClientSettings: mockSettings{ + getInstanceFails: true, + }, + isValid: false, }, } for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { - client := &openSearchClientMocked{ - getInstanceFails: tt.getInstanceFails, - getInstanceResp: tt.getInstanceResp, - } - - output, err := GetInstanceName(context.Background(), client, testProjectId, testInstanceId) + output, err := GetInstanceName(context.Background(), newAPIClientMock(tt.mockClientSettings), testProjectId, testRegion, testInstanceId) if tt.isValid && err != nil { t.Errorf("failed on valid input") @@ -93,18 +95,19 @@ func TestGetInstanceName(t *testing.T) { func TestGetCredentialsUsername(t *testing.T) { tests := []struct { - description string - getCredentialsFails bool - getCredentialsResp *opensearch.CredentialsResponse - isValid bool - expectedOutput string + description string + mockClientSettings mockSettings + isValid bool + expectedOutput string }{ { description: "base", - getCredentialsResp: &opensearch.CredentialsResponse{ - Raw: &opensearch.RawCredentials{ - Credentials: &opensearch.Credentials{ - Username: utils.Ptr(testCredentialsUsername), + mockClientSettings: mockSettings{ + getCredentialsResp: &opensearch.CredentialsResponse{ + Raw: &opensearch.RawCredentials{ + Credentials: opensearch.Credentials{ + Username: testCredentialsUsername, + }, }, }, }, @@ -112,20 +115,17 @@ func TestGetCredentialsUsername(t *testing.T) { expectedOutput: testCredentialsUsername, }, { - description: "get credentials fails", - getCredentialsFails: true, - isValid: false, + description: "get credentials fails", + mockClientSettings: mockSettings{ + getCredentialsFails: true, + }, + isValid: false, }, } for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { - client := &openSearchClientMocked{ - getCredentialsFails: tt.getCredentialsFails, - getCredentialsResp: tt.getCredentialsResp, - } - - output, err := GetCredentialsUsername(context.Background(), client, testProjectId, testInstanceId, testCredentialsId) + output, err := GetCredentialsUsername(context.Background(), newAPIClientMock(tt.mockClientSettings), testProjectId, testRegion, testInstanceId, testCredentialsId) if tt.isValid && err != nil { t.Errorf("failed on valid input") From 632876ff0d2b9393f83ead06454029c958f48339 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 17 Jul 2026 07:50:15 +0200 Subject: [PATCH 32/44] chore(deps): bump actions/stale from 10.3.0 to 10.4.0 (#1480) Bumps [actions/stale](https://github.com/actions/stale) from 10.3.0 to 10.4.0. - [Release notes](https://github.com/actions/stale/releases) - [Changelog](https://github.com/actions/stale/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/stale/compare/v10.3.0...v10.4.0) --- updated-dependencies: - dependency-name: actions/stale dependency-version: 10.4.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/stale.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/stale.yaml b/.github/workflows/stale.yaml index eecf81410..814490cfb 100644 --- a/.github/workflows/stale.yaml +++ b/.github/workflows/stale.yaml @@ -24,7 +24,7 @@ jobs: timeout-minutes: 10 steps: - name: "Mark old PRs as stale" - uses: actions/stale@v10.3.0 + uses: actions/stale@v10.4.0 with: repo-token: ${{ secrets.GITHUB_TOKEN }} stale-pr-message: "This PR was marked as stale after ${{ env.DAYS_BEFORE_PR_STALE }} days of inactivity and will be closed after another ${{ env.DAYS_BEFORE_PR_CLOSE }} days of further inactivity. If this PR should be kept open, just add a comment, remove the stale label or push new commits to it." From c46e1b26461d8b15618bbda2b582d20fdfb77801 Mon Sep 17 00:00:00 2001 From: Jonas Schlecht <73650029+SerseusWasTaken@users.noreply.github.com> Date: Mon, 20 Jul 2026 15:09:39 +0200 Subject: [PATCH 33/44] feat(postgresflex): migrate to V2 api (#1476) relates to STACKITCLI-374 --- go.mod | 2 +- go.sum | 4 +- .../postgresflex/backup/describe/describe.go | 11 +- .../backup/describe/describe_test.go | 55 +++- internal/cmd/postgresflex/backup/list/list.go | 20 +- .../cmd/postgresflex/backup/list/list_test.go | 24 +- .../backup/update-schedule/update_schedule.go | 16 +- .../update-schedule/update_schedule_test.go | 19 +- .../cmd/postgresflex/instance/clone/clone.go | 29 +- .../postgresflex/instance/clone/clone_test.go | 189 ++++++------ .../postgresflex/instance/create/create.go | 75 +++-- .../instance/create/create_test.go | 281 +++++++++--------- .../postgresflex/instance/delete/delete.go | 24 +- .../instance/delete/delete_test.go | 89 +++--- .../instance/describe/describe.go | 12 +- .../instance/describe/describe_test.go | 12 +- .../cmd/postgresflex/instance/list/list.go | 29 +- .../postgresflex/instance/list/list_test.go | 15 +- .../postgresflex/instance/update/update.go | 33 +- .../instance/update/update_test.go | 257 ++++++++-------- internal/cmd/postgresflex/options/options.go | 38 +-- .../cmd/postgresflex/options/options_test.go | 127 ++++---- .../cmd/postgresflex/user/create/create.go | 12 +- .../postgresflex/user/create/create_test.go | 18 +- .../cmd/postgresflex/user/delete/delete.go | 8 +- .../postgresflex/user/delete/delete_test.go | 8 +- .../postgresflex/user/describe/describe.go | 6 +- .../user/describe/describe_test.go | 10 +- internal/cmd/postgresflex/user/list/list.go | 32 +- .../cmd/postgresflex/user/list/list_test.go | 19 +- .../user/reset-password/reset_password.go | 14 +- .../reset-password/reset_password_test.go | 8 +- .../cmd/postgresflex/user/update/update.go | 14 +- .../postgresflex/user/update/update_test.go | 13 +- .../services/postgresflex/client/client.go | 4 +- .../pkg/services/postgresflex/utils/utils.go | 39 ++- .../services/postgresflex/utils/utils_test.go | 210 +++++++------ 37 files changed, 889 insertions(+), 887 deletions(-) diff --git a/go.mod b/go.mod index 2353b9927..160310ab2 100644 --- a/go.mod +++ b/go.mod @@ -27,7 +27,7 @@ require ( github.com/stackitcloud/stackit-sdk-go/services/logs v0.5.2 github.com/stackitcloud/stackit-sdk-go/services/mongodbflex v1.12.0 github.com/stackitcloud/stackit-sdk-go/services/opensearch v1.1.0 - github.com/stackitcloud/stackit-sdk-go/services/postgresflex v1.3.5 + github.com/stackitcloud/stackit-sdk-go/services/postgresflex v1.11.0 github.com/stackitcloud/stackit-sdk-go/services/resourcemanager v0.24.0 github.com/stackitcloud/stackit-sdk-go/services/runcommand v1.4.3 github.com/stackitcloud/stackit-sdk-go/services/secretsmanager v0.18.1 diff --git a/go.sum b/go.sum index 5ec24b922..a00946832 100644 --- a/go.sum +++ b/go.sum @@ -626,8 +626,8 @@ github.com/stackitcloud/stackit-sdk-go/services/observability v0.24.0 h1:KhuWPXr github.com/stackitcloud/stackit-sdk-go/services/observability v0.24.0/go.mod h1:0fEZQHm729mBdvg4sNrAhM6KmHROHJSeS2FwCMRk46k= github.com/stackitcloud/stackit-sdk-go/services/opensearch v1.1.0 h1:hooc/E9Qabn8xno1NUd3uJQfUbW5KoY6mgURlnd776c= github.com/stackitcloud/stackit-sdk-go/services/opensearch v1.1.0/go.mod h1:L+NlfC1hilLOqlLLukCj/UDnxlnNrc/oMikcw3Ansyw= -github.com/stackitcloud/stackit-sdk-go/services/postgresflex v1.3.5 h1:H67e3KnHQx954yI8fuQmxXwRf/myqAdLg2KvxImp00g= -github.com/stackitcloud/stackit-sdk-go/services/postgresflex v1.3.5/go.mod h1:xmAWk9eom8wznvLuLfm0F4xyeiBX8LaggXsKFmos+dw= +github.com/stackitcloud/stackit-sdk-go/services/postgresflex v1.11.0 h1:cuI4NhuFhaZ3tTkBpUM7nt2odKFJkyCcphT/3gGb9CE= +github.com/stackitcloud/stackit-sdk-go/services/postgresflex v1.11.0/go.mod h1:yzlakB+f8ur4yAHR6lyCABO+HcEtZG3G2Faj6m5/uW8= github.com/stackitcloud/stackit-sdk-go/services/rabbitmq v1.1.0 h1:HRJwodJX4aOn/487zaqJIKw13yIj4T6dn7/kEHLxeTg= github.com/stackitcloud/stackit-sdk-go/services/rabbitmq v1.1.0/go.mod h1:TwfVVynB/+AKbccSOLk2qZpPL1tdK43BBAiACP6EtSg= github.com/stackitcloud/stackit-sdk-go/services/redis v1.1.0 h1:ckYMRXAGE2/vaxPeNGEuun9AGcFn/8xuu0ytfsiqfWU= diff --git a/internal/cmd/postgresflex/backup/describe/describe.go b/internal/cmd/postgresflex/backup/describe/describe.go index ee3e3753e..effe99ea0 100644 --- a/internal/cmd/postgresflex/backup/describe/describe.go +++ b/internal/cmd/postgresflex/backup/describe/describe.go @@ -8,7 +8,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/types" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/postgresflex" + postgresflex "github.com/stackitcloud/stackit-sdk-go/services/postgresflex/v2api" "github.com/stackitcloud/stackit-cli/internal/pkg/args" "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -73,7 +73,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return fmt.Errorf("describe backup for PostgreSQL Flex instance: %w", err) } - return outputResult(params.Printer, model.OutputFormat, *resp.Item) + return outputResult(params.Printer, model.OutputFormat, resp.Item) }, } configureFlags(cmd) @@ -103,11 +103,14 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *postgresflex.APIClient) postgresflex.ApiGetBackupRequest { - req := apiClient.GetBackup(ctx, model.ProjectId, model.Region, model.InstanceId, model.BackupId) + req := apiClient.DefaultAPI.GetBackup(ctx, model.ProjectId, model.Region, model.InstanceId, model.BackupId) return req } -func outputResult(p *print.Printer, outputFormat string, backup postgresflex.Backup) error { +func outputResult(p *print.Printer, outputFormat string, backup *postgresflex.Backup) error { + if backup == nil { + return fmt.Errorf("backup is nil") + } if backup.StartTime == nil || *backup.StartTime == "" { return fmt.Errorf("start time not defined") } diff --git a/internal/cmd/postgresflex/backup/describe/describe_test.go b/internal/cmd/postgresflex/backup/describe/describe_test.go index 79588d715..a77f0fed5 100644 --- a/internal/cmd/postgresflex/backup/describe/describe_test.go +++ b/internal/cmd/postgresflex/backup/describe/describe_test.go @@ -8,7 +8,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/postgresflex" + postgresflex "github.com/stackitcloud/stackit-sdk-go/services/postgresflex/v2api" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" @@ -18,7 +18,7 @@ import ( type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &postgresflex.APIClient{} +var testClient = &postgresflex.APIClient{DefaultAPI: &postgresflex.DefaultAPIService{}} var testProjectId = uuid.NewString() var testInstanceId = uuid.NewString() var testBackupId = "backupID" @@ -63,7 +63,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *postgresflex.ApiGetBackupRequest)) postgresflex.ApiGetBackupRequest { - request := testClient.GetBackup(testCtx, testProjectId, testRegion, testInstanceId, testBackupId) + request := testClient.DefaultAPI.GetBackup(testCtx, testProjectId, testRegion, testInstanceId, testBackupId) for _, mod := range mods { mod(&request) } @@ -231,7 +231,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, postgresflex.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) @@ -243,24 +243,47 @@ func TestBuildRequest(t *testing.T) { func Test_outputResult(t *testing.T) { type args struct { outputFormat string - backup postgresflex.Backup + backup *postgresflex.Backup } tests := []struct { name string args args wantErr bool }{ - {"empty", args{}, true}, - {"standard", args{outputFormat: "", backup: postgresflex.Backup{StartTime: utils.Ptr(time.Now().Format(time.RFC3339))}}, false}, - {"complete", args{outputFormat: "", backup: postgresflex.Backup{ - EndTime: utils.Ptr(time.Now().Format(time.RFC3339)), - Id: utils.Ptr("id"), - Labels: &[]string{"foo", "bar", "baz"}, - Name: utils.Ptr("name"), - Options: &map[string]string{"test1": "test1", "test2": "test2"}, - Size: utils.Ptr(int64(42)), - StartTime: utils.Ptr(time.Now().Format(time.RFC3339)), - }}, false}, + { + name: "empty", + args: args{}, + wantErr: true, + }, + { + name: "standard", + args: args{ + outputFormat: "", + backup: &postgresflex.Backup{ + StartTime: utils.Ptr(time.Now().Format(time.RFC3339)), + }, + }, + wantErr: false, + }, + { + name: "complete", + args: args{ + outputFormat: "", + backup: &postgresflex.Backup{ + EndTime: utils.Ptr(time.Now().Format(time.RFC3339)), + Id: utils.Ptr("id"), + Labels: []string{"foo", + "bar", + "baz", + }, + Name: utils.Ptr("name"), + Options: &map[string]string{"test1": "test1", "test2": "test2"}, + Size: utils.Ptr(int64(42)), + StartTime: utils.Ptr(time.Now().Format(time.RFC3339)), + }, + }, + wantErr: false, + }, } params := testparams.NewTestParams() for _, tt := range tests { diff --git a/internal/cmd/postgresflex/backup/list/list.go b/internal/cmd/postgresflex/backup/list/list.go index 004159b2b..0b4d763e9 100644 --- a/internal/cmd/postgresflex/backup/list/list.go +++ b/internal/cmd/postgresflex/backup/list/list.go @@ -20,7 +20,7 @@ import ( "time" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/postgresflex" + postgresflex "github.com/stackitcloud/stackit-sdk-go/services/postgresflex/v2api" ) const ( @@ -68,7 +68,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return err } - instanceLabel, err := postgresflexUtils.GetInstanceName(ctx, apiClient, model.ProjectId, model.Region, *model.InstanceId) + instanceLabel, err := postgresflexUtils.GetInstanceName(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, *model.InstanceId) if err != nil { params.Printer.Debug(print.ErrorLevel, "get instance name: %v", err) instanceLabel = *model.InstanceId @@ -80,18 +80,14 @@ func NewCmd(params *types.CmdParams) *cobra.Command { if err != nil { return fmt.Errorf("get backups for PostgreSQL Flex instance %q: %w", instanceLabel, err) } - if resp.Items == nil || len(*resp.Items) == 0 { - params.Printer.Outputf("No backups found for instance %q", instanceLabel) - return nil - } - backups := *resp.Items + backups := resp.Items // Truncate output if model.Limit != nil && len(backups) > int(*model.Limit) { backups = backups[:*model.Limit] } - return outputResult(params.Printer, model.OutputFormat, backups) + return outputResult(params.Printer, model.OutputFormat, instanceLabel, backups) }, } @@ -129,12 +125,16 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, } func buildRequest(ctx context.Context, model *inputModel, apiClient *postgresflex.APIClient) postgresflex.ApiListBackupsRequest { - req := apiClient.ListBackups(ctx, model.ProjectId, model.Region, *model.InstanceId) + req := apiClient.DefaultAPI.ListBackups(ctx, model.ProjectId, model.Region, *model.InstanceId) return req } -func outputResult(p *print.Printer, outputFormat string, backups []postgresflex.Backup) error { +func outputResult(p *print.Printer, outputFormat, instanceLabel string, backups []postgresflex.Backup) error { return p.OutputResult(outputFormat, backups, func() error { + if len(backups) == 0 { + p.Outputf("No backups found for instance %q", instanceLabel) + return nil + } table := tables.NewTable() table.SetHeader("ID", "CREATED AT", "EXPIRES AT", "BACKUP SIZE") for i := range backups { diff --git a/internal/cmd/postgresflex/backup/list/list_test.go b/internal/cmd/postgresflex/backup/list/list_test.go index 1ac29b6dd..34177acb8 100644 --- a/internal/cmd/postgresflex/backup/list/list_test.go +++ b/internal/cmd/postgresflex/backup/list/list_test.go @@ -6,12 +6,13 @@ import ( "time" "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" + "github.com/stackitcloud/stackit-cli/internal/pkg/testutils" "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/postgresflex" + postgresflex "github.com/stackitcloud/stackit-sdk-go/services/postgresflex/v2api" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/utils" @@ -20,7 +21,7 @@ import ( type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &postgresflex.APIClient{} +var testClient = &postgresflex.APIClient{DefaultAPI: &postgresflex.DefaultAPIService{}} var testProjectId = uuid.NewString() var testInstanceId = uuid.NewString() var testRegion = "eu01" @@ -55,7 +56,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *postgresflex.ApiListBackupsRequest)) postgresflex.ApiListBackupsRequest { - request := testClient.ListBackups(testCtx, testProjectId, testRegion, testInstanceId) + request := testClient.DefaultAPI.ListBackups(testCtx, testProjectId, testRegion, testInstanceId) for _, mod := range mods { mod(&request) } @@ -165,7 +166,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, postgresflex.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) @@ -176,8 +177,9 @@ func TestBuildRequest(t *testing.T) { func Test_outputResult(t *testing.T) { type args struct { - outputFormat string - backups []postgresflex.Backup + outputFormat string + instanceLabel string + backups []postgresflex.Backup } tests := []struct { name string @@ -185,12 +187,12 @@ func Test_outputResult(t *testing.T) { wantErr bool }{ {"empty", args{}, false}, - {"standard", args{outputFormat: "", backups: []postgresflex.Backup{}}, false}, - {"complete", args{outputFormat: "", backups: []postgresflex.Backup{ + {"standard", args{outputFormat: "", instanceLabel: "label", backups: []postgresflex.Backup{}}, false}, + {"complete", args{outputFormat: "", instanceLabel: "label", backups: []postgresflex.Backup{ { EndTime: utils.Ptr(time.Now().Format(time.RFC3339)), Id: utils.Ptr("id"), - Labels: &[]string{"foo", "bar", "baz"}, + Labels: []string{"foo", "bar", "baz"}, Name: utils.Ptr("name"), Options: &map[string]string{"test1": "test1", "test2": "test2"}, Size: utils.Ptr(int64(42)), @@ -199,7 +201,7 @@ func Test_outputResult(t *testing.T) { { EndTime: utils.Ptr(time.Now().Format(time.RFC3339)), Id: utils.Ptr("id"), - Labels: &[]string{"foo", "bar", "baz"}, + Labels: []string{"foo", "bar", "baz"}, Name: utils.Ptr("name"), Options: &map[string]string{"test1": "test1", "test2": "test2"}, Size: utils.Ptr(int64(42)), @@ -211,7 +213,7 @@ func Test_outputResult(t *testing.T) { params := testparams.NewTestParams() for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - if err := outputResult(params.Printer, tt.args.outputFormat, tt.args.backups); (err != nil) != tt.wantErr { + if err := outputResult(params.Printer, tt.args.outputFormat, tt.args.instanceLabel, tt.args.backups); (err != nil) != tt.wantErr { t.Errorf("outputResult() error = %v, wantErr %v", err, tt.wantErr) } }) diff --git a/internal/cmd/postgresflex/backup/update-schedule/update_schedule.go b/internal/cmd/postgresflex/backup/update-schedule/update_schedule.go index 447fe0864..8b200f83a 100644 --- a/internal/cmd/postgresflex/backup/update-schedule/update_schedule.go +++ b/internal/cmd/postgresflex/backup/update-schedule/update_schedule.go @@ -7,7 +7,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/types" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/postgresflex" + postgresflex "github.com/stackitcloud/stackit-sdk-go/services/postgresflex/v2api" "github.com/stackitcloud/stackit-cli/internal/pkg/args" cliErr "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -27,8 +27,8 @@ const ( type inputModel struct { *globalflags.GlobalFlagModel - InstanceId *string - BackupSchedule *string + InstanceId string + BackupSchedule string } func NewCmd(params *types.CmdParams) *cobra.Command { @@ -57,10 +57,10 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return err } - instanceLabel, err := postgresflexUtils.GetInstanceName(ctx, apiClient, model.ProjectId, model.Region, *model.InstanceId) + instanceLabel, err := postgresflexUtils.GetInstanceName(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, model.InstanceId) if err != nil { params.Printer.Debug(print.ErrorLevel, "get instance name: %v", err) - instanceLabel = *model.InstanceId + instanceLabel = model.InstanceId } prompt := fmt.Sprintf("Are you sure you want to update backup schedule of instance %q?", instanceLabel) @@ -100,13 +100,13 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, return &inputModel{ GlobalFlagModel: globalFlags, - InstanceId: flags.FlagToStringPointer(p, cmd, instanceIdFlag), - BackupSchedule: flags.FlagToStringPointer(p, cmd, scheduleFlag), + InstanceId: flags.FlagToStringValue(p, cmd, instanceIdFlag), + BackupSchedule: flags.FlagToStringValue(p, cmd, scheduleFlag), }, nil } func buildRequest(ctx context.Context, model *inputModel, apiClient *postgresflex.APIClient) postgresflex.ApiUpdateBackupScheduleRequest { - req := apiClient.UpdateBackupSchedule(ctx, model.ProjectId, model.Region, *model.InstanceId) + req := apiClient.DefaultAPI.UpdateBackupSchedule(ctx, model.ProjectId, model.Region, model.InstanceId) req = req.UpdateBackupSchedulePayload(postgresflex.UpdateBackupSchedulePayload{ BackupSchedule: model.BackupSchedule, }) diff --git a/internal/cmd/postgresflex/backup/update-schedule/update_schedule_test.go b/internal/cmd/postgresflex/backup/update-schedule/update_schedule_test.go index 18ed95ae6..93ef49667 100644 --- a/internal/cmd/postgresflex/backup/update-schedule/update_schedule_test.go +++ b/internal/cmd/postgresflex/backup/update-schedule/update_schedule_test.go @@ -6,18 +6,17 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/testutils" - "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/postgresflex" + postgresflex "github.com/stackitcloud/stackit-sdk-go/services/postgresflex/v2api" ) type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &postgresflex.APIClient{} +var testClient = &postgresflex.APIClient{DefaultAPI: &postgresflex.DefaultAPIService{}} var testProjectId = uuid.NewString() var testInstanceId = uuid.NewString() var testSchedule = "0 0 * * *" @@ -43,8 +42,8 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { Region: testRegion, Verbosity: globalflags.VerbosityDefault, }, - InstanceId: utils.Ptr(testInstanceId), - BackupSchedule: &testSchedule, + InstanceId: testInstanceId, + BackupSchedule: testSchedule, } for _, mod := range mods { mod(model) @@ -54,7 +53,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { func fixturePayload(mods ...func(payload *postgresflex.UpdateBackupSchedulePayload)) postgresflex.UpdateBackupSchedulePayload { payload := postgresflex.UpdateBackupSchedulePayload{ - BackupSchedule: utils.Ptr(testSchedule), + BackupSchedule: testSchedule, } for _, mod := range mods { mod(&payload) @@ -63,7 +62,7 @@ func fixturePayload(mods ...func(payload *postgresflex.UpdateBackupSchedulePaylo } func fixtureRequest(mods ...func(request *postgresflex.ApiUpdateBackupScheduleRequest)) postgresflex.ApiUpdateBackupScheduleRequest { - request := testClient.UpdateBackupSchedule(testCtx, testProjectId, testRegion, testInstanceId) + request := testClient.DefaultAPI.UpdateBackupSchedule(testCtx, testProjectId, testRegion, testInstanceId) request = request.UpdateBackupSchedulePayload(fixturePayload()) for _, mod := range mods { mod(&request) @@ -167,9 +166,9 @@ func TestBuildRequest(t *testing.T) { ProjectId: testProjectId, Region: testRegion, }, - InstanceId: utils.Ptr(testInstanceId), + InstanceId: testInstanceId, }, - expectedRequest: testClient.UpdateBackupSchedule(testCtx, testProjectId, testRegion, testInstanceId). + expectedRequest: testClient.DefaultAPI.UpdateBackupSchedule(testCtx, testProjectId, testRegion, testInstanceId). UpdateBackupSchedulePayload(postgresflex.UpdateBackupSchedulePayload{}), }, } @@ -180,7 +179,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, postgresflex.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/postgresflex/instance/clone/clone.go b/internal/cmd/postgresflex/instance/clone/clone.go index facfdf105..b5bea934c 100644 --- a/internal/cmd/postgresflex/instance/clone/clone.go +++ b/internal/cmd/postgresflex/instance/clone/clone.go @@ -18,8 +18,8 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/postgresflex" - "github.com/stackitcloud/stackit-sdk-go/services/postgresflex/wait" + postgresflex "github.com/stackitcloud/stackit-sdk-go/services/postgresflex/v2api" + wait "github.com/stackitcloud/stackit-sdk-go/services/postgresflex/v2api/wait" ) const ( @@ -72,7 +72,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return err } - instanceLabel, err := postgresflexUtils.GetInstanceName(ctx, apiClient, model.ProjectId, model.Region, model.InstanceId) + instanceLabel, err := postgresflexUtils.GetInstanceName(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, model.InstanceId) if err != nil { params.Printer.Debug(print.ErrorLevel, "get instance name: %v", err) instanceLabel = model.InstanceId @@ -85,7 +85,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } // Call API - req, err := buildRequest(ctx, model, apiClient) + req, err := buildRequest(ctx, model, apiClient.DefaultAPI) if err != nil { return err } @@ -98,7 +98,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { // Wait for async operation, if async mode not enabled if !model.Async { err := spinner.Run(params.Printer, "Cloning instance", func() error { - _, err = wait.CreateInstanceWaitHandler(ctx, apiClient, model.ProjectId, model.Region, instanceId).WaitWithContext(ctx) + _, err = wait.CreateInstanceWaitHandler(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, instanceId).WaitWithContext(ctx) return err }) if err != nil { @@ -151,18 +151,12 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu return &model, nil } -type PostgreSQLFlexClient interface { - CloneInstance(ctx context.Context, projectId, region, instanceId string) postgresflex.ApiCloneInstanceRequest - GetInstanceExecute(ctx context.Context, projectId, region, instanceId string) (*postgresflex.InstanceResponse, error) - ListStoragesExecute(ctx context.Context, projectId, region, flavorId string) (*postgresflex.ListStoragesResponse, error) -} - -func buildRequest(ctx context.Context, model *inputModel, apiClient PostgreSQLFlexClient) (postgresflex.ApiCloneInstanceRequest, error) { +func buildRequest(ctx context.Context, model *inputModel, apiClient postgresflex.DefaultAPI) (postgresflex.ApiCloneInstanceRequest, error) { req := apiClient.CloneInstance(ctx, model.ProjectId, model.Region, model.InstanceId) var storages *postgresflex.ListStoragesResponse if model.StorageClass != nil || model.StorageSize != nil { - currentInstance, err := apiClient.GetInstanceExecute(ctx, model.ProjectId, model.Region, model.InstanceId) + currentInstance, err := apiClient.GetInstance(ctx, model.ProjectId, model.Region, model.InstanceId).Execute() if err != nil { return req, fmt.Errorf("get PostgreSQL Flex instance: %w", err) } @@ -170,7 +164,7 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient PostgreSQLFl currentInstanceStorageClass := currentInstance.Item.Storage.Class currentInstanceStorageSize := currentInstance.Item.Storage.Size - storages, err = apiClient.ListStoragesExecute(ctx, model.ProjectId, model.Region, *validationFlavorId) + storages, err = apiClient.ListStorages(ctx, model.ProjectId, model.Region, *validationFlavorId).Execute() if err != nil { return req, fmt.Errorf("get PostgreSQL Flex storages: %w", err) } @@ -196,11 +190,10 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient PostgreSQLFl } func outputResult(p *print.Printer, outputFormat string, async bool, instanceLabel, instanceId string, resp *postgresflex.CloneInstanceResponse) error { - if resp == nil { - return fmt.Errorf("response not set") - } - return p.OutputResult(outputFormat, resp, func() error { + if resp == nil { + return fmt.Errorf("response not set") + } operationState := "Cloned" if async { operationState = "Triggered cloning of" diff --git a/internal/cmd/postgresflex/instance/clone/clone_test.go b/internal/cmd/postgresflex/instance/clone/clone_test.go index f123caf15..4e99f08e7 100644 --- a/internal/cmd/postgresflex/instance/clone/clone_test.go +++ b/internal/cmd/postgresflex/instance/clone/clone_test.go @@ -9,7 +9,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/postgresflex" + postgresflex "github.com/stackitcloud/stackit-sdk-go/services/postgresflex/v2api" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" @@ -20,31 +20,30 @@ import ( type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &postgresflex.APIClient{} +var testClient = &postgresflex.APIClient{DefaultAPI: &postgresflex.DefaultAPIService{}} -type postgresFlexClientMocked struct { +type mockSettings struct { listStoragesFails bool listStoragesResp *postgresflex.ListStoragesResponse getInstanceFails bool getInstanceResp *postgresflex.InstanceResponse } -func (c *postgresFlexClientMocked) CloneInstance(ctx context.Context, projectId, region, instanceId string) postgresflex.ApiCloneInstanceRequest { - return testClient.CloneInstance(ctx, projectId, region, instanceId) -} - -func (c *postgresFlexClientMocked) GetInstanceExecute(_ context.Context, _, _, _ string) (*postgresflex.InstanceResponse, error) { - if c.getInstanceFails { - return nil, fmt.Errorf("get instance failed") - } - return c.getInstanceResp, nil -} - -func (c *postgresFlexClientMocked) ListStoragesExecute(_ context.Context, _, _, _ string) (*postgresflex.ListStoragesResponse, error) { - if c.listStoragesFails { - return nil, fmt.Errorf("list storages failed") +func newAPIMockClient(c mockSettings) postgresflex.DefaultAPI { + return &postgresflex.DefaultAPIServiceMock{ + GetInstanceExecuteMock: utils.Ptr(func(_ postgresflex.ApiGetInstanceRequest) (*postgresflex.InstanceResponse, error) { + if c.getInstanceFails { + return nil, fmt.Errorf("get instance failed") + } + return c.getInstanceResp, nil + }), + ListStoragesExecuteMock: utils.Ptr(func(_ postgresflex.ApiListStoragesRequest) (*postgresflex.ListStoragesResponse, error) { + if c.listStoragesFails { + return nil, fmt.Errorf("list storages failed") + } + return c.listStoragesResp, nil + }), } - return c.listStoragesResp, nil } var testProjectId = uuid.NewString() @@ -138,7 +137,7 @@ func fixtureStandardInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *postgresflex.ApiCloneInstanceRequest)) postgresflex.ApiCloneInstanceRequest { - request := testClient.CloneInstance(testCtx, testProjectId, testRegion, testInstanceId) + request := testClient.DefaultAPI.CloneInstance(testCtx, testProjectId, testRegion, testInstanceId) request = request.CloneInstancePayload(fixturePayload()) for _, mod := range mods { mod(&request) @@ -316,14 +315,11 @@ func TestBuildRequest(t *testing.T) { recoveryTimestampString := testRecoveryTimestamp.Format(recoveryDateFormat) tests := []struct { - description string - model *inputModel - expectedRequest postgresflex.ApiCloneInstanceRequest - getInstanceFails bool - getInstanceResp *postgresflex.InstanceResponse - listStoragesFails bool - listStoragesResp *postgresflex.ListStoragesResponse - isValid bool + description string + model *inputModel + expectedRequest postgresflex.ApiCloneInstanceRequest + mockClientSettings mockSettings + isValid bool }{ { description: "base", @@ -337,25 +333,27 @@ func TestBuildRequest(t *testing.T) { model.StorageClass = utils.Ptr("class") }), isValid: true, - getInstanceResp: &postgresflex.InstanceResponse{ - Item: &postgresflex.Instance{ - Flavor: &postgresflex.Flavor{ - Id: utils.Ptr(testFlavorId), - }, - Storage: &postgresflex.Storage{ - Class: utils.Ptr(testStorageClass), - Size: utils.Ptr(testStorageSize), + mockClientSettings: mockSettings{ + getInstanceResp: &postgresflex.InstanceResponse{ + Item: &postgresflex.Instance{ + Flavor: &postgresflex.Flavor{ + Id: utils.Ptr(testFlavorId), + }, + Storage: &postgresflex.Storage{ + Class: utils.Ptr(testStorageClass), + Size: utils.Ptr(testStorageSize), + }, }, }, - }, - listStoragesResp: &postgresflex.ListStoragesResponse{ - StorageClasses: &[]string{"class"}, - StorageRange: &postgresflex.StorageRange{ - Min: utils.Ptr(int64(10)), - Max: utils.Ptr(int64(100)), + listStoragesResp: &postgresflex.ListStoragesResponse{ + StorageClasses: []string{"class"}, + StorageRange: &postgresflex.StorageRange{ + Min: utils.Ptr(int64(10)), + Max: utils.Ptr(int64(100)), + }, }, }, - expectedRequest: testClient.CloneInstance(testCtx, testProjectId, testRegion, testInstanceId). + expectedRequest: testClient.DefaultAPI.CloneInstance(testCtx, testProjectId, testRegion, testInstanceId). CloneInstancePayload(postgresflex.CloneInstancePayload{ Class: utils.Ptr("class"), Timestamp: utils.Ptr(recoveryTimestampString), @@ -368,25 +366,27 @@ func TestBuildRequest(t *testing.T) { model.StorageSize = utils.Ptr(int64(10)) }), isValid: true, - getInstanceResp: &postgresflex.InstanceResponse{ - Item: &postgresflex.Instance{ - Flavor: &postgresflex.Flavor{ - Id: utils.Ptr(testFlavorId), - }, - Storage: &postgresflex.Storage{ - Class: utils.Ptr(testStorageClass), - Size: utils.Ptr(testStorageSize), + mockClientSettings: mockSettings{ + getInstanceResp: &postgresflex.InstanceResponse{ + Item: &postgresflex.Instance{ + Flavor: &postgresflex.Flavor{ + Id: utils.Ptr(testFlavorId), + }, + Storage: &postgresflex.Storage{ + Class: utils.Ptr(testStorageClass), + Size: utils.Ptr(testStorageSize), + }, }, }, - }, - listStoragesResp: &postgresflex.ListStoragesResponse{ - StorageClasses: &[]string{"class"}, - StorageRange: &postgresflex.StorageRange{ - Min: utils.Ptr(int64(10)), - Max: utils.Ptr(int64(100)), + listStoragesResp: &postgresflex.ListStoragesResponse{ + StorageClasses: []string{"class"}, + StorageRange: &postgresflex.StorageRange{ + Min: utils.Ptr(int64(10)), + Max: utils.Ptr(int64(100)), + }, }, }, - expectedRequest: testClient.CloneInstance(testCtx, testProjectId, testRegion, testInstanceId). + expectedRequest: testClient.DefaultAPI.CloneInstance(testCtx, testProjectId, testRegion, testInstanceId). CloneInstancePayload(postgresflex.CloneInstancePayload{ Class: utils.Ptr("class"), Size: utils.Ptr(int64(10)), @@ -401,8 +401,10 @@ func TestBuildRequest(t *testing.T) { model.RecoveryDate = utils.Ptr(recoveryTimestampString) }, ), - getInstanceFails: true, - isValid: false, + mockClientSettings: mockSettings{ + getInstanceFails: true, + }, + isValid: false, }, { description: "invalid storage class", @@ -411,22 +413,24 @@ func TestBuildRequest(t *testing.T) { model.StorageClass = utils.Ptr("non-existing-class") }, ), - getInstanceResp: &postgresflex.InstanceResponse{ - Item: &postgresflex.Instance{ - Flavor: &postgresflex.Flavor{ - Id: utils.Ptr(testFlavorId), - }, - Storage: &postgresflex.Storage{ - Class: utils.Ptr(testStorageClass), - Size: utils.Ptr(testStorageSize), + mockClientSettings: mockSettings{ + getInstanceResp: &postgresflex.InstanceResponse{ + Item: &postgresflex.Instance{ + Flavor: &postgresflex.Flavor{ + Id: utils.Ptr(testFlavorId), + }, + Storage: &postgresflex.Storage{ + Class: utils.Ptr(testStorageClass), + Size: utils.Ptr(testStorageSize), + }, }, }, - }, - listStoragesResp: &postgresflex.ListStoragesResponse{ - StorageClasses: &[]string{"class"}, - StorageRange: &postgresflex.StorageRange{ - Min: utils.Ptr(int64(10)), - Max: utils.Ptr(int64(100)), + listStoragesResp: &postgresflex.ListStoragesResponse{ + StorageClasses: []string{"class"}, + StorageRange: &postgresflex.StorageRange{ + Min: utils.Ptr(int64(10)), + Max: utils.Ptr(int64(100)), + }, }, }, isValid: false, @@ -438,22 +442,24 @@ func TestBuildRequest(t *testing.T) { model.StorageSize = utils.Ptr(int64(9)) }, ), - getInstanceResp: &postgresflex.InstanceResponse{ - Item: &postgresflex.Instance{ - Flavor: &postgresflex.Flavor{ - Id: utils.Ptr(testFlavorId), - }, - Storage: &postgresflex.Storage{ - Class: utils.Ptr(testStorageClass), - Size: utils.Ptr(testStorageSize), + mockClientSettings: mockSettings{ + getInstanceResp: &postgresflex.InstanceResponse{ + Item: &postgresflex.Instance{ + Flavor: &postgresflex.Flavor{ + Id: utils.Ptr(testFlavorId), + }, + Storage: &postgresflex.Storage{ + Class: utils.Ptr(testStorageClass), + Size: utils.Ptr(testStorageSize), + }, }, }, - }, - listStoragesResp: &postgresflex.ListStoragesResponse{ - StorageClasses: &[]string{"class"}, - StorageRange: &postgresflex.StorageRange{ - Min: utils.Ptr(int64(10)), - Max: utils.Ptr(int64(100)), + listStoragesResp: &postgresflex.ListStoragesResponse{ + StorageClasses: []string{"class"}, + StorageRange: &postgresflex.StorageRange{ + Min: utils.Ptr(int64(10)), + Max: utils.Ptr(int64(100)), + }, }, }, isValid: false, @@ -462,13 +468,7 @@ func TestBuildRequest(t *testing.T) { for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { - client := &postgresFlexClientMocked{ - getInstanceFails: tt.getInstanceFails, - getInstanceResp: tt.getInstanceResp, - listStoragesFails: tt.listStoragesFails, - listStoragesResp: tt.listStoragesResp, - } - request, err := buildRequest(testCtx, tt.model, client) + request, err := buildRequest(testCtx, tt.model, newAPIMockClient(tt.mockClientSettings)) if err != nil { if !tt.isValid { return @@ -479,6 +479,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), cmpopts.EquateComparable(testCtx), + cmpopts.IgnoreFields(tt.expectedRequest, "ApiService"), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/postgresflex/instance/create/create.go b/internal/cmd/postgresflex/instance/create/create.go index d3530b87e..5537cc370 100644 --- a/internal/cmd/postgresflex/instance/create/create.go +++ b/internal/cmd/postgresflex/instance/create/create.go @@ -20,8 +20,8 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/postgresflex" - "github.com/stackitcloud/stackit-sdk-go/services/postgresflex/wait" + postgresflex "github.com/stackitcloud/stackit-sdk-go/services/postgresflex/v2api" + wait "github.com/stackitcloud/stackit-sdk-go/services/postgresflex/v2api/wait" ) const ( @@ -53,16 +53,16 @@ var ( type inputModel struct { *globalflags.GlobalFlagModel - InstanceName *string - ACL *[]string - BackupSchedule *string + InstanceName string + ACL []string + BackupSchedule string FlavorId *string CPU *int64 RAM *int64 StorageClass *string StorageSize *int64 - Version *string - Type *string + Version string + Type string } func NewCmd(params *types.CmdParams) *cobra.Command { @@ -109,16 +109,16 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } // Fill in version, if needed - if model.Version == nil { - version, err := postgresflexUtils.GetLatestPostgreSQLVersion(ctx, apiClient, model.ProjectId, model.Region) + if model.Version == "" { + version, err := postgresflexUtils.GetLatestPostgreSQLVersion(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region) if err != nil { return fmt.Errorf("get latest PostgreSQL version: %w", err) } - model.Version = &version + model.Version = version } // Call API - req, err := buildRequest(ctx, model, apiClient) + req, err := buildRequest(ctx, model, apiClient.DefaultAPI) if err != nil { return err } @@ -131,7 +131,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { // Wait for async operation, if async mode not enabled if !model.Async { err := spinner.Run(params.Printer, "Creating instance", func() error { - _, err = wait.CreateInstanceWaitHandler(ctx, apiClient, model.ProjectId, model.Region, instanceId).WaitWithContext(ctx) + _, err = wait.CreateInstanceWaitHandler(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, instanceId).WaitWithContext(ctx) return err }) if err != nil { @@ -187,41 +187,35 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, model := inputModel{ GlobalFlagModel: globalFlags, - InstanceName: flags.FlagToStringPointer(p, cmd, instanceNameFlag), - ACL: flags.FlagToStringSlicePointer(p, cmd, aclFlag), - BackupSchedule: utils.Ptr(flags.FlagWithDefaultToStringValue(p, cmd, backupScheduleFlag)), + InstanceName: flags.FlagToStringValue(p, cmd, instanceNameFlag), + ACL: flags.FlagToStringSliceValue(p, cmd, aclFlag), + BackupSchedule: flags.FlagWithDefaultToStringValue(p, cmd, backupScheduleFlag), FlavorId: flavorId, CPU: cpu, RAM: ram, StorageClass: utils.Ptr(flags.FlagWithDefaultToStringValue(p, cmd, storageClassFlag)), StorageSize: &storageSize, - Version: flags.FlagToStringPointer(p, cmd, versionFlag), - Type: typeFlag.Ptr(), + Version: flags.FlagToStringValue(p, cmd, versionFlag), + Type: typeFlag.Get(), } p.DebugInputModel(model) return &model, nil } -type PostgreSQLFlexClient interface { - CreateInstance(ctx context.Context, projectId, region string) postgresflex.ApiCreateInstanceRequest - ListFlavorsExecute(ctx context.Context, projectId, region string) (*postgresflex.ListFlavorsResponse, error) - ListStoragesExecute(ctx context.Context, projectId, region, flavorId string) (*postgresflex.ListStoragesResponse, error) -} - -func buildRequest(ctx context.Context, model *inputModel, apiClient PostgreSQLFlexClient) (postgresflex.ApiCreateInstanceRequest, error) { +func buildRequest(ctx context.Context, model *inputModel, apiClient postgresflex.DefaultAPI) (postgresflex.ApiCreateInstanceRequest, error) { req := apiClient.CreateInstance(ctx, model.ProjectId, model.Region) - var flavorId *string + var flavorId string var err error - flavors, err := apiClient.ListFlavorsExecute(ctx, model.ProjectId, model.Region) + flavors, err := apiClient.ListFlavors(ctx, model.ProjectId, model.Region).Execute() if err != nil { return req, fmt.Errorf("get PostgreSQL Flex flavors: %w", err) } if model.FlavorId == nil { - flavorId, err = postgresflexUtils.LoadFlavorId(*model.CPU, *model.RAM, flavors.Flavors) + foundFlavorId, err := postgresflexUtils.LoadFlavorId(*model.CPU, *model.RAM, flavors.Flavors) if err != nil { var dsaInvalidPlanError *cliErr.DSAInvalidPlanError if !errors.As(err, &dsaInvalidPlanError) { @@ -229,51 +223,52 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient PostgreSQLFl } return req, err } + flavorId = *foundFlavorId } else { err := postgresflexUtils.ValidateFlavorId(*model.FlavorId, flavors.Flavors) if err != nil { return req, err } - flavorId = model.FlavorId + flavorId = *model.FlavorId } - storages, err := apiClient.ListStoragesExecute(ctx, model.ProjectId, model.Region, *flavorId) + storages, err := apiClient.ListStorages(ctx, model.ProjectId, model.Region, flavorId).Execute() if err != nil { return req, fmt.Errorf("get PostgreSQL Flex storages: %w", err) } - err = postgresflexUtils.ValidateStorage(model.StorageClass, model.StorageSize, storages, *flavorId) + err = postgresflexUtils.ValidateStorage(model.StorageClass, model.StorageSize, storages, flavorId) if err != nil { return req, err } - replicas, err := postgresflexUtils.GetInstanceReplicas(*model.Type) + replicas, err := postgresflexUtils.GetInstanceReplicas(model.Type) if err != nil { return req, fmt.Errorf("get PostgreSQL Flex instance type: %w", err) } req = req.CreateInstancePayload(postgresflex.CreateInstancePayload{ Name: model.InstanceName, - Acl: &postgresflex.ACL{Items: model.ACL}, + Acl: postgresflex.ACL{Items: model.ACL}, BackupSchedule: model.BackupSchedule, FlavorId: flavorId, - Replicas: &replicas, - Storage: &postgresflex.Storage{ + Replicas: replicas, + Storage: postgresflex.Storage{ Class: model.StorageClass, Size: model.StorageSize, }, Version: model.Version, - Options: utils.Ptr(map[string]string{ - "type": *model.Type, - }), + Options: map[string]string{ + "type": model.Type, + }, }) return req, nil } func outputResult(p *print.Printer, outputFormat string, async bool, projectLabel, instanceId string, resp *postgresflex.CreateInstanceResponse) error { - if resp == nil { - return fmt.Errorf("no response passed") - } return p.OutputResult(outputFormat, resp, func() error { + if resp == nil { + return fmt.Errorf("no response passed") + } operationState := "Created" if async { operationState = "Triggered creation of" diff --git a/internal/cmd/postgresflex/instance/create/create_test.go b/internal/cmd/postgresflex/instance/create/create_test.go index 54f1b3087..d0f86d364 100644 --- a/internal/cmd/postgresflex/instance/create/create_test.go +++ b/internal/cmd/postgresflex/instance/create/create_test.go @@ -8,7 +8,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/postgresflex" + postgresflex "github.com/stackitcloud/stackit-sdk-go/services/postgresflex/v2api" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" @@ -19,32 +19,31 @@ import ( type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &postgresflex.APIClient{} +var testClient = &postgresflex.APIClient{DefaultAPI: &postgresflex.DefaultAPIService{}} var testRegion = "eu01" -type postgresFlexClientMocked struct { +type mockSettings struct { listFlavorsFails bool listFlavorsResp *postgresflex.ListFlavorsResponse listStoragesFails bool listStoragesResp *postgresflex.ListStoragesResponse } -func (c *postgresFlexClientMocked) CreateInstance(ctx context.Context, projectId, region string) postgresflex.ApiCreateInstanceRequest { - return testClient.CreateInstance(ctx, projectId, region) -} - -func (c *postgresFlexClientMocked) ListStoragesExecute(_ context.Context, _, _, _ string) (*postgresflex.ListStoragesResponse, error) { - if c.listFlavorsFails { - return nil, fmt.Errorf("list storages failed") - } - return c.listStoragesResp, nil -} - -func (c *postgresFlexClientMocked) ListFlavorsExecute(_ context.Context, _, _ string) (*postgresflex.ListFlavorsResponse, error) { - if c.listFlavorsFails { - return nil, fmt.Errorf("list flavors failed") +func newAPIClientMock(c mockSettings) postgresflex.DefaultAPI { + return postgresflex.DefaultAPIServiceMock{ + ListStoragesExecuteMock: utils.Ptr(func(_ postgresflex.ApiListStoragesRequest) (*postgresflex.ListStoragesResponse, error) { + if c.listStoragesFails { + return nil, fmt.Errorf("list storages failed") + } + return c.listStoragesResp, nil + }), + ListFlavorsExecuteMock: utils.Ptr(func(_ postgresflex.ApiListFlavorsRequest) (*postgresflex.ListFlavorsResponse, error) { + if c.listFlavorsFails { + return nil, fmt.Errorf("list flavors failed") + } + return c.listFlavorsResp, nil + }), } - return c.listFlavorsResp, nil } var testProjectId = uuid.NewString() @@ -76,14 +75,14 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { Region: testRegion, Verbosity: globalflags.VerbosityDefault, }, - InstanceName: utils.Ptr("example-name"), - ACL: utils.Ptr([]string{"0.0.0.0/0"}), - BackupSchedule: utils.Ptr("0 0 * * *"), + InstanceName: "example-name", + ACL: []string{"0.0.0.0/0"}, + BackupSchedule: "0 0 * * *", FlavorId: utils.Ptr(testFlavorId), StorageClass: utils.Ptr("premium-perf4-stackit"), StorageSize: utils.Ptr(int64(10)), - Version: utils.Ptr("6.0"), - Type: utils.Ptr("Replica"), + Version: "6.0", + Type: "Replica", } for _, mod := range mods { mod(model) @@ -92,7 +91,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *postgresflex.ApiCreateInstanceRequest)) postgresflex.ApiCreateInstanceRequest { - request := testClient.CreateInstance(testCtx, testProjectId, testRegion) + request := testClient.DefaultAPI.CreateInstance(testCtx, testProjectId, testRegion) request = request.CreateInstancePayload(fixturePayload()) for _, mod := range mods { mod(&request) @@ -102,19 +101,19 @@ func fixtureRequest(mods ...func(request *postgresflex.ApiCreateInstanceRequest) func fixturePayload(mods ...func(payload *postgresflex.CreateInstancePayload)) postgresflex.CreateInstancePayload { payload := postgresflex.CreateInstancePayload{ - Name: utils.Ptr("example-name"), - Acl: &postgresflex.ACL{Items: utils.Ptr([]string{"0.0.0.0/0"})}, - BackupSchedule: utils.Ptr("0 0 * * *"), - FlavorId: utils.Ptr(testFlavorId), - Replicas: utils.Ptr(int64(3)), - Storage: &postgresflex.Storage{ + Name: "example-name", + Acl: postgresflex.ACL{Items: []string{"0.0.0.0/0"}}, + BackupSchedule: "0 0 * * *", + FlavorId: testFlavorId, + Replicas: int32(3), + Storage: postgresflex.Storage{ Class: utils.Ptr("premium-perf4-stackit"), Size: utils.Ptr(int64(10)), }, - Version: utils.Ptr("6.0"), - Options: utils.Ptr(map[string]string{ + Version: "6.0", + Options: map[string]string{ "type": "Replica", - }), + }, } for _, mod := range mods { mod(&payload) @@ -215,7 +214,7 @@ func TestParseInput(t *testing.T) { }), isValid: true, expectedModel: fixtureInputModel(func(model *inputModel) { - model.Version = nil + model.Version = "" }), }, { @@ -224,9 +223,8 @@ func TestParseInput(t *testing.T) { aclValues: []string{"198.51.100.14/24", "198.51.100.14/32"}, isValid: true, expectedModel: fixtureInputModel(func(model *inputModel) { - model.ACL = utils.Ptr( - append(*model.ACL, "198.51.100.14/24", "198.51.100.14/32"), - ) + model.ACL = + append(model.ACL, "198.51.100.14/24", "198.51.100.14/32") }), }, { @@ -235,9 +233,8 @@ func TestParseInput(t *testing.T) { aclValues: []string{"198.51.100.14/24,198.51.100.14/32"}, isValid: true, expectedModel: fixtureInputModel(func(model *inputModel) { - model.ACL = utils.Ptr( - append(*model.ACL, "198.51.100.14/24", "198.51.100.14/32"), - ) + model.ACL = + append(model.ACL, "198.51.100.14/24", "198.51.100.14/32") }), }, { @@ -261,34 +258,33 @@ func TestParseInput(t *testing.T) { func TestBuildRequest(t *testing.T) { tests := []struct { - description string - model *inputModel - expectedRequest postgresflex.ApiCreateInstanceRequest - listFlavorsFails bool - listFlavorsResp *postgresflex.ListFlavorsResponse - listStoragesFails bool - listStoragesResp *postgresflex.ListStoragesResponse - isValid bool + description string + model *inputModel + expectedRequest postgresflex.ApiCreateInstanceRequest + mockClientSettings mockSettings + isValid bool }{ { description: "base with flavor ID", model: fixtureInputModel(), isValid: true, expectedRequest: fixtureRequest(), - listFlavorsResp: &postgresflex.ListFlavorsResponse{ - Flavors: &[]postgresflex.Flavor{ - { - Id: utils.Ptr(testFlavorId), - Cpu: utils.Ptr(int64(2)), - Memory: utils.Ptr(int64(4)), + mockClientSettings: mockSettings{ + listFlavorsResp: &postgresflex.ListFlavorsResponse{ + Flavors: []postgresflex.Flavor{ + { + Id: utils.Ptr(testFlavorId), + Cpu: utils.Ptr(int64(2)), + Memory: utils.Ptr(int64(4)), + }, }, }, - }, - listStoragesResp: &postgresflex.ListStoragesResponse{ - StorageClasses: &[]string{"premium-perf4-stackit"}, - StorageRange: &postgresflex.StorageRange{ - Min: utils.Ptr(int64(10)), - Max: utils.Ptr(int64(100)), + listStoragesResp: &postgresflex.ListStoragesResponse{ + StorageClasses: []string{"premium-perf4-stackit"}, + StorageRange: &postgresflex.StorageRange{ + Min: utils.Ptr(int64(10)), + Max: utils.Ptr(int64(100)), + }, }, }, }, @@ -303,50 +299,54 @@ func TestBuildRequest(t *testing.T) { ), isValid: true, expectedRequest: fixtureRequest(), - listFlavorsResp: &postgresflex.ListFlavorsResponse{ - Flavors: &[]postgresflex.Flavor{ - { - Id: utils.Ptr(testFlavorId), - Cpu: utils.Ptr(int64(2)), - Memory: utils.Ptr(int64(4)), - }, - { - Id: utils.Ptr("other-flavor"), - Cpu: utils.Ptr(int64(1)), - Memory: utils.Ptr(int64(8)), + mockClientSettings: mockSettings{ + listFlavorsResp: &postgresflex.ListFlavorsResponse{ + Flavors: []postgresflex.Flavor{ + { + Id: utils.Ptr(testFlavorId), + Cpu: utils.Ptr(int64(2)), + Memory: utils.Ptr(int64(4)), + }, + { + Id: utils.Ptr("other-flavor"), + Cpu: utils.Ptr(int64(1)), + Memory: utils.Ptr(int64(8)), + }, }, }, - }, - listStoragesResp: &postgresflex.ListStoragesResponse{ - StorageClasses: &[]string{"premium-perf4-stackit"}, - StorageRange: &postgresflex.StorageRange{ - Min: utils.Ptr(int64(10)), - Max: utils.Ptr(int64(100)), + listStoragesResp: &postgresflex.ListStoragesResponse{ + StorageClasses: []string{"premium-perf4-stackit"}, + StorageRange: &postgresflex.StorageRange{ + Min: utils.Ptr(int64(10)), + Max: utils.Ptr(int64(100)), + }, }, }, }, { description: "single instance type", - model: fixtureInputModel(func(model *inputModel) { model.Type = utils.Ptr("Single") }), + model: fixtureInputModel(func(model *inputModel) { model.Type = "Single" }), isValid: true, expectedRequest: fixtureRequest().CreateInstancePayload(fixturePayload(func(payload *postgresflex.CreateInstancePayload) { - payload.Options = utils.Ptr(map[string]string{"type": "Single"}) - payload.Replicas = utils.Ptr(int64(1)) + payload.Options = map[string]string{"type": "Single"} + payload.Replicas = int32(1) })), - listFlavorsResp: &postgresflex.ListFlavorsResponse{ - Flavors: &[]postgresflex.Flavor{ - { - Id: utils.Ptr(testFlavorId), - Cpu: utils.Ptr(int64(2)), - Memory: utils.Ptr(int64(4)), + mockClientSettings: mockSettings{ + listFlavorsResp: &postgresflex.ListFlavorsResponse{ + Flavors: []postgresflex.Flavor{ + { + Id: utils.Ptr(testFlavorId), + Cpu: utils.Ptr(int64(2)), + Memory: utils.Ptr(int64(4)), + }, }, }, - }, - listStoragesResp: &postgresflex.ListStoragesResponse{ - StorageClasses: &[]string{"premium-perf4-stackit"}, - StorageRange: &postgresflex.StorageRange{ - Min: utils.Ptr(int64(10)), - Max: utils.Ptr(int64(100)), + listStoragesResp: &postgresflex.ListStoragesResponse{ + StorageClasses: []string{"premium-perf4-stackit"}, + StorageRange: &postgresflex.StorageRange{ + Min: utils.Ptr(int64(10)), + Max: utils.Ptr(int64(100)), + }, }, }, }, @@ -359,8 +359,10 @@ func TestBuildRequest(t *testing.T) { model.RAM = utils.Ptr(int64(4)) }, ), - listFlavorsFails: true, - isValid: false, + mockClientSettings: mockSettings{ + listFlavorsFails: true, + }, + isValid: false, }, { description: "flavor id not found", @@ -371,17 +373,19 @@ func TestBuildRequest(t *testing.T) { model.RAM = utils.Ptr(int64(9)) }, ), - listFlavorsResp: &postgresflex.ListFlavorsResponse{ - Flavors: &[]postgresflex.Flavor{ - { - Id: utils.Ptr(testFlavorId), - Cpu: utils.Ptr(int64(2)), - Memory: utils.Ptr(int64(4)), - }, - { - Id: utils.Ptr("other-flavor"), - Cpu: utils.Ptr(int64(1)), - Memory: utils.Ptr(int64(8)), + mockClientSettings: mockSettings{ + listFlavorsResp: &postgresflex.ListFlavorsResponse{ + Flavors: []postgresflex.Flavor{ + { + Id: utils.Ptr(testFlavorId), + Cpu: utils.Ptr(int64(2)), + Memory: utils.Ptr(int64(4)), + }, + { + Id: utils.Ptr("other-flavor"), + Cpu: utils.Ptr(int64(1)), + Memory: utils.Ptr(int64(8)), + }, }, }, }, @@ -396,8 +400,10 @@ func TestBuildRequest(t *testing.T) { model.RAM = utils.Ptr(int64(4)) }, ), - listFlavorsFails: true, - isValid: false, + mockClientSettings: mockSettings{ + listFlavorsFails: true, + }, + isValid: false, }, { description: "invalid storage class", @@ -406,20 +412,22 @@ func TestBuildRequest(t *testing.T) { model.StorageClass = utils.Ptr("non-existing-class") }, ), - listFlavorsResp: &postgresflex.ListFlavorsResponse{ - Flavors: &[]postgresflex.Flavor{ - { - Id: utils.Ptr(testFlavorId), - Cpu: utils.Ptr(int64(2)), - Memory: utils.Ptr(int64(4)), + mockClientSettings: mockSettings{ + listFlavorsResp: &postgresflex.ListFlavorsResponse{ + Flavors: []postgresflex.Flavor{ + { + Id: utils.Ptr(testFlavorId), + Cpu: utils.Ptr(int64(2)), + Memory: utils.Ptr(int64(4)), + }, }, }, - }, - listStoragesResp: &postgresflex.ListStoragesResponse{ - StorageClasses: &[]string{"premium-perf4-stackit"}, - StorageRange: &postgresflex.StorageRange{ - Min: utils.Ptr(int64(10)), - Max: utils.Ptr(int64(100)), + listStoragesResp: &postgresflex.ListStoragesResponse{ + StorageClasses: []string{"premium-perf4-stackit"}, + StorageRange: &postgresflex.StorageRange{ + Min: utils.Ptr(int64(10)), + Max: utils.Ptr(int64(100)), + }, }, }, isValid: false, @@ -431,20 +439,22 @@ func TestBuildRequest(t *testing.T) { model.StorageSize = utils.Ptr(int64(9)) }, ), - listFlavorsResp: &postgresflex.ListFlavorsResponse{ - Flavors: &[]postgresflex.Flavor{ - { - Id: utils.Ptr(testFlavorId), - Cpu: utils.Ptr(int64(2)), - Memory: utils.Ptr(int64(4)), + mockClientSettings: mockSettings{ + listFlavorsResp: &postgresflex.ListFlavorsResponse{ + Flavors: []postgresflex.Flavor{ + { + Id: utils.Ptr(testFlavorId), + Cpu: utils.Ptr(int64(2)), + Memory: utils.Ptr(int64(4)), + }, }, }, - }, - listStoragesResp: &postgresflex.ListStoragesResponse{ - StorageClasses: &[]string{"premium-perf4-stackit"}, - StorageRange: &postgresflex.StorageRange{ - Min: utils.Ptr(int64(10)), - Max: utils.Ptr(int64(100)), + listStoragesResp: &postgresflex.ListStoragesResponse{ + StorageClasses: []string{"premium-perf4-stackit"}, + StorageRange: &postgresflex.StorageRange{ + Min: utils.Ptr(int64(10)), + Max: utils.Ptr(int64(100)), + }, }, }, isValid: false, @@ -453,13 +463,7 @@ func TestBuildRequest(t *testing.T) { for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { - client := &postgresFlexClientMocked{ - listFlavorsFails: tt.listFlavorsFails, - listFlavorsResp: tt.listFlavorsResp, - listStoragesFails: tt.listStoragesFails, - listStoragesResp: tt.listStoragesResp, - } - request, err := buildRequest(testCtx, tt.model, client) + request, err := buildRequest(testCtx, tt.model, newAPIClientMock(tt.mockClientSettings)) if err != nil { if !tt.isValid { return @@ -470,6 +474,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), cmpopts.EquateComparable(testCtx), + cmpopts.IgnoreFields(tt.expectedRequest, "ApiService"), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/postgresflex/instance/delete/delete.go b/internal/cmd/postgresflex/instance/delete/delete.go index 3a8aa4cfe..c26787a42 100644 --- a/internal/cmd/postgresflex/instance/delete/delete.go +++ b/internal/cmd/postgresflex/instance/delete/delete.go @@ -18,8 +18,8 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/postgresflex" - "github.com/stackitcloud/stackit-sdk-go/services/postgresflex/wait" + postgresflex "github.com/stackitcloud/stackit-sdk-go/services/postgresflex/v2api" + wait "github.com/stackitcloud/stackit-sdk-go/services/postgresflex/v2api/wait" ) const ( @@ -65,7 +65,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return err } - instanceLabel, err := postgresflexUtils.GetInstanceName(ctx, apiClient, model.ProjectId, model.Region, model.InstanceId) + instanceLabel, err := postgresflexUtils.GetInstanceName(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, model.InstanceId) if err != nil { params.Printer.Debug(print.ErrorLevel, "get instance name: %v", err) instanceLabel = model.InstanceId @@ -77,7 +77,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return err } - toDelete, toForceDelete, err := getNextOperations(ctx, model, apiClient) + toDelete, toForceDelete, err := getNextOperations(ctx, model, apiClient.DefaultAPI) if err != nil { return err } @@ -93,7 +93,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { // Wait for async operation, if async mode not enabled if !model.Async { err := spinner.Run(params.Printer, "Deleting instance", func() error { - _, err = wait.DeleteInstanceWaitHandler(ctx, apiClient, model.ProjectId, model.Region, model.InstanceId).WaitWithContext(ctx) + _, err = wait.DeleteInstanceWaitHandler(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, model.InstanceId).WaitWithContext(ctx) return err }) if err != nil { @@ -113,7 +113,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { // Wait for async operation, if async mode not enabled if !model.Async { err := spinner.Run(params.Printer, "Forcing deletion of instance", func() error { - _, err = wait.ForceDeleteInstanceWaitHandler(ctx, apiClient, model.ProjectId, model.Region, model.InstanceId).WaitWithContext(ctx) + _, err = wait.ForceDeleteInstanceWaitHandler(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, model.InstanceId).WaitWithContext(ctx) return err }) if err != nil { @@ -163,22 +163,16 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildDeleteRequest(ctx context.Context, model *inputModel, apiClient *postgresflex.APIClient) postgresflex.ApiDeleteInstanceRequest { - req := apiClient.DeleteInstance(ctx, model.ProjectId, model.Region, model.InstanceId) + req := apiClient.DefaultAPI.DeleteInstance(ctx, model.ProjectId, model.Region, model.InstanceId) return req } func buildForceDeleteRequest(ctx context.Context, model *inputModel, apiClient *postgresflex.APIClient) postgresflex.ApiForceDeleteInstanceRequest { - req := apiClient.ForceDeleteInstance(ctx, model.ProjectId, model.Region, model.InstanceId) + req := apiClient.DefaultAPI.ForceDeleteInstance(ctx, model.ProjectId, model.Region, model.InstanceId) return req } -type PostgreSQLFlexClient interface { - GetInstanceExecute(ctx context.Context, projectId, region, instanceId string) (*postgresflex.InstanceResponse, error) - ListVersionsExecute(ctx context.Context, projectId, region string) (*postgresflex.ListVersionsResponse, error) - GetUserExecute(ctx context.Context, projectId, region, instanceId, userId string) (*postgresflex.GetUserResponse, error) -} - -func getNextOperations(ctx context.Context, model *inputModel, apiClient PostgreSQLFlexClient) (toDelete, toForceDelete bool, err error) { +func getNextOperations(ctx context.Context, model *inputModel, apiClient postgresflex.DefaultAPI) (toDelete, toForceDelete bool, err error) { instanceStatus, err := postgresflexUtils.GetInstanceStatus(ctx, apiClient, model.ProjectId, model.Region, model.InstanceId) if err != nil { return false, false, fmt.Errorf("get PostgreSQL Flex instance status: %w", err) diff --git a/internal/cmd/postgresflex/instance/delete/delete_test.go b/internal/cmd/postgresflex/instance/delete/delete_test.go index fdbe26f4c..ffdd8c3b9 100644 --- a/internal/cmd/postgresflex/instance/delete/delete_test.go +++ b/internal/cmd/postgresflex/instance/delete/delete_test.go @@ -12,37 +12,32 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/postgresflex" - "github.com/stackitcloud/stackit-sdk-go/services/postgresflex/wait" + postgresflex "github.com/stackitcloud/stackit-sdk-go/services/postgresflex/v2api" + wait "github.com/stackitcloud/stackit-sdk-go/services/postgresflex/v2api/wait" ) type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &postgresflex.APIClient{} +var testClient = &postgresflex.APIClient{DefaultAPI: &postgresflex.DefaultAPIService{}} var testProjectId = uuid.NewString() var testInstanceId = uuid.NewString() var testRegion = "eu01" -type postgresFlexClientMocked struct { +type mockSettings struct { getInstanceFails bool getInstanceResp *postgresflex.InstanceResponse } -func (c *postgresFlexClientMocked) GetInstanceExecute(_ context.Context, _, _, _ string) (*postgresflex.InstanceResponse, error) { - if c.getInstanceFails { - return nil, fmt.Errorf("get instance failed") +func newAPIMockClient(c mockSettings) postgresflex.DefaultAPI { + return postgresflex.DefaultAPIServiceMock{ + GetInstanceExecuteMock: utils.Ptr(func(_ postgresflex.ApiGetInstanceRequest) (*postgresflex.InstanceResponse, error) { + if c.getInstanceFails { + return nil, fmt.Errorf("get instance failed") + } + return c.getInstanceResp, nil + }), } - return c.getInstanceResp, nil -} - -func (c *postgresFlexClientMocked) ListVersionsExecute(_ context.Context, _, _ string) (*postgresflex.ListVersionsResponse, error) { - // Not used in testing - return nil, nil -} -func (c *postgresFlexClientMocked) GetUserExecute(_ context.Context, _, _, _, _ string) (*postgresflex.GetUserResponse, error) { - // Not used in testing - return nil, nil } func fixtureArgValues(mods ...func(argValues []string)) []string { @@ -82,7 +77,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureDeleteRequest(mods ...func(request *postgresflex.ApiDeleteInstanceRequest)) postgresflex.ApiDeleteInstanceRequest { - request := testClient.DeleteInstance(testCtx, testProjectId, testRegion, testInstanceId) + request := testClient.DefaultAPI.DeleteInstance(testCtx, testProjectId, testRegion, testInstanceId) for _, mod := range mods { mod(&request) } @@ -90,7 +85,7 @@ func fixtureDeleteRequest(mods ...func(request *postgresflex.ApiDeleteInstanceRe } func fixtureForceDeleteRequest(mods ...func(request *postgresflex.ApiForceDeleteInstanceRequest)) postgresflex.ApiForceDeleteInstanceRequest { - request := testClient.ForceDeleteInstance(testCtx, testProjectId, testRegion, testInstanceId) + request := testClient.DefaultAPI.ForceDeleteInstance(testCtx, testProjectId, testRegion, testInstanceId) for _, mod := range mods { mod(&request) } @@ -194,7 +189,7 @@ func TestBuildDeleteRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, postgresflex.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) @@ -222,7 +217,7 @@ func TestBuildForceDeleteRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, postgresflex.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) @@ -237,8 +232,7 @@ func TestCheckIfInstanceIsDeleted(t *testing.T) { model *inputModel expectedToDelete bool expectedToForceDelete bool - getInstanceResponse *postgresflex.InstanceResponse - getInstanceFails bool + mockClientSettings mockSettings isValid bool }{ { @@ -246,9 +240,11 @@ func TestCheckIfInstanceIsDeleted(t *testing.T) { model: fixtureInputModel(), expectedToDelete: true, expectedToForceDelete: false, - getInstanceResponse: &postgresflex.InstanceResponse{ - Item: &postgresflex.Instance{ - Status: utils.Ptr(wait.InstanceStateSuccess), + mockClientSettings: mockSettings{ + getInstanceResp: &postgresflex.InstanceResponse{ + Item: &postgresflex.Instance{ + Status: utils.Ptr(wait.InstanceStateSuccess), + }, }, }, isValid: true, @@ -260,9 +256,11 @@ func TestCheckIfInstanceIsDeleted(t *testing.T) { }), expectedToDelete: true, expectedToForceDelete: true, - getInstanceResponse: &postgresflex.InstanceResponse{ - Item: &postgresflex.Instance{ - Status: utils.Ptr(wait.InstanceStateSuccess), + mockClientSettings: mockSettings{ + getInstanceResp: &postgresflex.InstanceResponse{ + Item: &postgresflex.Instance{ + Status: utils.Ptr(wait.InstanceStateSuccess), + }, }, }, isValid: true, @@ -274,9 +272,11 @@ func TestCheckIfInstanceIsDeleted(t *testing.T) { }), expectedToDelete: false, expectedToForceDelete: true, - getInstanceResponse: &postgresflex.InstanceResponse{ - Item: &postgresflex.Instance{ - Status: utils.Ptr(wait.InstanceStateDeleted), + mockClientSettings: mockSettings{ + getInstanceResp: &postgresflex.InstanceResponse{ + Item: &postgresflex.Instance{ + Status: utils.Ptr(wait.InstanceStateDeleted), + }, }, }, isValid: true, @@ -284,29 +284,28 @@ func TestCheckIfInstanceIsDeleted(t *testing.T) { { description: "delete instance state Deleted", model: fixtureInputModel(), - getInstanceResponse: &postgresflex.InstanceResponse{ - Item: &postgresflex.Instance{ - Status: utils.Ptr(wait.InstanceStateDeleted), + mockClientSettings: mockSettings{ + getInstanceResp: &postgresflex.InstanceResponse{ + Item: &postgresflex.Instance{ + Status: utils.Ptr(wait.InstanceStateDeleted), + }, }, }, isValid: false, }, { - description: "delete instance get instance fails", - model: fixtureInputModel(), - getInstanceFails: true, - isValid: false, + description: "delete instance get instance fails", + model: fixtureInputModel(), + mockClientSettings: mockSettings{ + getInstanceFails: true, + }, + isValid: false, }, } for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { - client := &postgresFlexClientMocked{ - getInstanceResp: tt.getInstanceResponse, - getInstanceFails: tt.getInstanceFails, - } - - toDelete, toForceDelete, err := getNextOperations(testCtx, tt.model, client) + toDelete, toForceDelete, err := getNextOperations(testCtx, tt.model, newAPIMockClient(tt.mockClientSettings)) if err != nil { if !tt.isValid { return diff --git a/internal/cmd/postgresflex/instance/describe/describe.go b/internal/cmd/postgresflex/instance/describe/describe.go index c97762a76..8a3b277c4 100644 --- a/internal/cmd/postgresflex/instance/describe/describe.go +++ b/internal/cmd/postgresflex/instance/describe/describe.go @@ -20,7 +20,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/postgresflex" + postgresflex "github.com/stackitcloud/stackit-sdk-go/services/postgresflex/v2api" ) const ( @@ -89,18 +89,18 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *postgresflex.APIClient) postgresflex.ApiGetInstanceRequest { - req := apiClient.GetInstance(ctx, model.ProjectId, model.Region, model.InstanceId) + req := apiClient.DefaultAPI.GetInstance(ctx, model.ProjectId, model.Region, model.InstanceId) return req } func outputResult(p *print.Printer, outputFormat string, instance *postgresflex.Instance) error { - if instance == nil { - return fmt.Errorf("no response passed") - } return p.OutputResult(outputFormat, instance, func() error { + if instance == nil { + return fmt.Errorf("no response passed") + } acls := "" if instance.HasAcl() && instance.Acl.HasItems() { - acls = utils.JoinStringPtr(instance.Acl.Items, ",") + acls = utils.JoinStringPtr(&instance.Acl.Items, ",") } instanceType, err := postgresflexUtils.GetInstanceType(utils.PtrValue(instance.Replicas)) diff --git a/internal/cmd/postgresflex/instance/describe/describe_test.go b/internal/cmd/postgresflex/instance/describe/describe_test.go index 026940b76..487343136 100644 --- a/internal/cmd/postgresflex/instance/describe/describe_test.go +++ b/internal/cmd/postgresflex/instance/describe/describe_test.go @@ -7,7 +7,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/postgresflex" + postgresflex "github.com/stackitcloud/stackit-sdk-go/services/postgresflex/v2api" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" @@ -17,7 +17,7 @@ import ( type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &postgresflex.APIClient{} +var testClient = &postgresflex.APIClient{DefaultAPI: &postgresflex.DefaultAPIService{}} var testProjectId = uuid.NewString() var testInstanceId = uuid.NewString() var testRegion = "eu01" @@ -59,7 +59,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *postgresflex.ApiGetInstanceRequest)) postgresflex.ApiGetInstanceRequest { - request := testClient.GetInstance(testCtx, testProjectId, testRegion, testInstanceId) + request := testClient.DefaultAPI.GetInstance(testCtx, testProjectId, testRegion, testInstanceId) for _, mod := range mods { mod(&request) } @@ -163,7 +163,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, postgresflex.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) @@ -191,7 +191,7 @@ func Test_outputResult(t *testing.T) { outputFormat: "", instance: &postgresflex.Instance{ Acl: &postgresflex.ACL{ - Items: &[]string{}, + Items: []string{}, }, BackupSchedule: new(string), Flavor: &postgresflex.Flavor{ @@ -203,7 +203,7 @@ func Test_outputResult(t *testing.T) { Id: new(string), Name: new(string), Options: &map[string]string{}, - Replicas: new(int64), + Replicas: new(int32), Status: new(string), Storage: &postgresflex.Storage{ Class: new(string), diff --git a/internal/cmd/postgresflex/instance/list/list.go b/internal/cmd/postgresflex/instance/list/list.go index 9f1b0f690..ac3eac5a7 100644 --- a/internal/cmd/postgresflex/instance/list/list.go +++ b/internal/cmd/postgresflex/instance/list/list.go @@ -7,7 +7,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/types" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/postgresflex" + postgresflex "github.com/stackitcloud/stackit-sdk-go/services/postgresflex/v2api" "golang.org/x/text/cases" "golang.org/x/text/language" @@ -68,23 +68,20 @@ func NewCmd(params *types.CmdParams) *cobra.Command { if err != nil { return fmt.Errorf("get PostgreSQL Flex instances: %w", err) } - if resp.Items == nil || len(*resp.Items) == 0 { - projectLabel, err := projectname.GetProjectName(ctx, params.Printer, params.CliVersion, cmd) - if err != nil { - params.Printer.Debug(print.ErrorLevel, "get project name: %v", err) - projectLabel = model.ProjectId - } - params.Printer.Info("No instances found for project %q\n", projectLabel) - return nil - } - instances := *resp.Items + + instances := resp.Items // Truncate output if model.Limit != nil && len(instances) > int(*model.Limit) { instances = instances[:*model.Limit] } - return outputResult(params.Printer, model.OutputFormat, instances) + projectLabel, err := projectname.GetProjectName(ctx, params.Printer, params.CliVersion, cmd) + if err != nil { + params.Printer.Debug(print.ErrorLevel, "get project name: %v", err) + projectLabel = model.ProjectId + } + return outputResult(params.Printer, model.OutputFormat, projectLabel, instances) }, } @@ -120,12 +117,16 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, } func buildRequest(ctx context.Context, model *inputModel, apiClient *postgresflex.APIClient) postgresflex.ApiListInstancesRequest { - req := apiClient.ListInstances(ctx, model.ProjectId, model.Region) + req := apiClient.DefaultAPI.ListInstances(ctx, model.ProjectId, model.Region) return req } -func outputResult(p *print.Printer, outputFormat string, instances []postgresflex.InstanceListInstance) error { +func outputResult(p *print.Printer, outputFormat, projectLabel string, instances []postgresflex.InstanceListInstance) error { return p.OutputResult(outputFormat, instances, func() error { + if len(instances) == 0 { + p.Outputf("No instances found for project %q\n", projectLabel) + return nil + } caser := cases.Title(language.English) table := tables.NewTable() table.SetHeader("ID", "NAME", "STATUS") diff --git a/internal/cmd/postgresflex/instance/list/list_test.go b/internal/cmd/postgresflex/instance/list/list_test.go index 87d9d9111..9e08559f7 100644 --- a/internal/cmd/postgresflex/instance/list/list_test.go +++ b/internal/cmd/postgresflex/instance/list/list_test.go @@ -7,7 +7,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/postgresflex" + postgresflex "github.com/stackitcloud/stackit-sdk-go/services/postgresflex/v2api" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" @@ -18,7 +18,7 @@ import ( type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &postgresflex.APIClient{} +var testClient = &postgresflex.APIClient{DefaultAPI: &postgresflex.DefaultAPIService{}} var testProjectId = uuid.NewString() var testRegion = "eu01" @@ -50,7 +50,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *postgresflex.ApiListInstancesRequest)) postgresflex.ApiListInstancesRequest { - request := testClient.ListInstances(testCtx, testProjectId, testRegion) + request := testClient.DefaultAPI.ListInstances(testCtx, testProjectId, testRegion) for _, mod := range mods { mod(&request) } @@ -139,7 +139,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, postgresflex.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) @@ -151,6 +151,7 @@ func TestBuildRequest(t *testing.T) { func Test_outputResult(t *testing.T) { type args struct { outputFormat string + projectLabel string instances []postgresflex.InstanceListInstance } tests := []struct { @@ -159,8 +160,8 @@ func Test_outputResult(t *testing.T) { wantErr bool }{ {"empty", args{}, false}, - {"standard", args{"", []postgresflex.InstanceListInstance{}}, false}, - {"complete", args{"", []postgresflex.InstanceListInstance{ + {"standard", args{"", "label", []postgresflex.InstanceListInstance{}}, false}, + {"complete", args{"", "label", []postgresflex.InstanceListInstance{ { Id: new(string), Name: new(string), @@ -181,7 +182,7 @@ func Test_outputResult(t *testing.T) { params := testparams.NewTestParams() for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - if err := outputResult(params.Printer, tt.args.outputFormat, tt.args.instances); (err != nil) != tt.wantErr { + if err := outputResult(params.Printer, tt.args.outputFormat, tt.args.projectLabel, tt.args.instances); (err != nil) != tt.wantErr { t.Errorf("outputResult() error = %v, wantErr %v", err, tt.wantErr) } }) diff --git a/internal/cmd/postgresflex/instance/update/update.go b/internal/cmd/postgresflex/instance/update/update.go index fc2bc8986..aaeedd410 100644 --- a/internal/cmd/postgresflex/instance/update/update.go +++ b/internal/cmd/postgresflex/instance/update/update.go @@ -19,8 +19,8 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/postgresflex" - "github.com/stackitcloud/stackit-sdk-go/services/postgresflex/wait" + postgresflex "github.com/stackitcloud/stackit-sdk-go/services/postgresflex/v2api" + wait "github.com/stackitcloud/stackit-sdk-go/services/postgresflex/v2api/wait" ) const ( @@ -48,7 +48,7 @@ type inputModel struct { InstanceId string InstanceName *string - ACL *[]string + ACL []string BackupSchedule *string FlavorId *string CPU *int64 @@ -87,7 +87,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return err } - instanceLabel, err := postgresflexUtils.GetInstanceName(ctx, apiClient, model.ProjectId, model.Region, model.InstanceId) + instanceLabel, err := postgresflexUtils.GetInstanceName(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, model.InstanceId) if err != nil { params.Printer.Debug(print.ErrorLevel, "get instance name: %v", err) instanceLabel = model.InstanceId @@ -100,7 +100,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } // Call API - req, err := buildRequest(ctx, model, apiClient) + req, err := buildRequest(ctx, model, apiClient.DefaultAPI) if err != nil { return err } @@ -113,7 +113,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { // Wait for async operation, if async mode not enabled if !model.Async { err := spinner.Run(params.Printer, "Updating instance", func() error { - _, err = wait.PartialUpdateInstanceWaitHandler(ctx, apiClient, model.ProjectId, model.Region, instanceId).WaitWithContext(ctx) + _, err = wait.PartialUpdateInstanceWaitHandler(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, instanceId).WaitWithContext(ctx) return err }) if err != nil { @@ -153,7 +153,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu flavorId := flags.FlagToStringPointer(p, cmd, flavorIdFlag) cpu := flags.FlagToInt64Pointer(p, cmd, cpuFlag) ram := flags.FlagToInt64Pointer(p, cmd, ramFlag) - acl := flags.FlagToStringSlicePointer(p, cmd, aclFlag) + acl := flags.FlagToStringSliceValue(p, cmd, aclFlag) backupSchedule := flags.FlagToStringPointer(p, cmd, backupScheduleFlag) storageClass := flags.FlagToStringPointer(p, cmd, storageClassFlag) storageSize := flags.FlagToInt64Pointer(p, cmd, storageSizeFlag) @@ -191,20 +191,13 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu return &model, nil } -type PostgreSQLFlexClient interface { - PartialUpdateInstance(ctx context.Context, projectId, region, instanceId string) postgresflex.ApiPartialUpdateInstanceRequest - GetInstanceExecute(ctx context.Context, projectId, region, instanceId string) (*postgresflex.InstanceResponse, error) - ListFlavorsExecute(ctx context.Context, projectId, region string) (*postgresflex.ListFlavorsResponse, error) - ListStoragesExecute(ctx context.Context, projectId, region, flavorId string) (*postgresflex.ListStoragesResponse, error) -} - -func buildRequest(ctx context.Context, model *inputModel, apiClient PostgreSQLFlexClient) (postgresflex.ApiPartialUpdateInstanceRequest, error) { +func buildRequest(ctx context.Context, model *inputModel, apiClient postgresflex.DefaultAPI) (postgresflex.ApiPartialUpdateInstanceRequest, error) { req := apiClient.PartialUpdateInstance(ctx, model.ProjectId, model.Region, model.InstanceId) var flavorId *string var err error - flavors, err := apiClient.ListFlavorsExecute(ctx, model.ProjectId, model.Region) + flavors, err := apiClient.ListFlavors(ctx, model.ProjectId, model.Region).Execute() if err != nil { return req, fmt.Errorf("get PostgreSQL Flex flavors: %w", err) } @@ -213,7 +206,7 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient PostgreSQLFl ram := model.RAM cpu := model.CPU if model.RAM == nil || model.CPU == nil { - currentInstance, err := apiClient.GetInstanceExecute(ctx, model.ProjectId, model.Region, model.InstanceId) + currentInstance, err := apiClient.GetInstance(ctx, model.ProjectId, model.Region, model.InstanceId).Execute() if err != nil { return req, fmt.Errorf("get PostgreSQL Flex instance: %w", err) } @@ -244,13 +237,13 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient PostgreSQLFl if model.StorageClass != nil || model.StorageSize != nil { validationFlavorId := flavorId if validationFlavorId == nil { - currentInstance, err := apiClient.GetInstanceExecute(ctx, model.ProjectId, model.Region, model.InstanceId) + currentInstance, err := apiClient.GetInstance(ctx, model.ProjectId, model.Region, model.InstanceId).Execute() if err != nil { return req, fmt.Errorf("get PostgreSQL Flex instance: %w", err) } validationFlavorId = currentInstance.Item.Flavor.Id } - storages, err = apiClient.ListStoragesExecute(ctx, model.ProjectId, model.Region, *validationFlavorId) + storages, err = apiClient.ListStorages(ctx, model.ProjectId, model.Region, *validationFlavorId).Execute() if err != nil { return req, fmt.Errorf("get PostgreSQL Flex storages: %w", err) } @@ -273,7 +266,7 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient PostgreSQLFl } } - var replicas *int64 + var replicas *int32 var payloadOptions *map[string]string if model.Type != nil { replicasInt, err := postgresflexUtils.GetInstanceReplicas(*model.Type) diff --git a/internal/cmd/postgresflex/instance/update/update_test.go b/internal/cmd/postgresflex/instance/update/update_test.go index 401348b92..1cb0b5aff 100644 --- a/internal/cmd/postgresflex/instance/update/update_test.go +++ b/internal/cmd/postgresflex/instance/update/update_test.go @@ -8,7 +8,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/postgresflex" + postgresflex "github.com/stackitcloud/stackit-sdk-go/services/postgresflex/v2api" "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" @@ -19,41 +19,38 @@ import ( type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &postgresflex.APIClient{} +var testClient = &postgresflex.APIClient{DefaultAPI: &postgresflex.DefaultAPIService{}} var testRegion = "eu01" -type postgresFlexClientMocked struct { - listFlavorsFails bool - listFlavorsResp *postgresflex.ListFlavorsResponse - listStoragesFails bool - listStoragesResp *postgresflex.ListStoragesResponse - getInstanceFails bool - getInstanceResp *postgresflex.InstanceResponse +type mockSettings struct { + listFlavorsFails bool + listFlavorsResp *postgresflex.ListFlavorsResponse + listStoragesResp *postgresflex.ListStoragesResponse + getInstanceFails bool + getInstanceResp *postgresflex.InstanceResponse } -func (c *postgresFlexClientMocked) PartialUpdateInstance(ctx context.Context, projectId, region, instanceId string) postgresflex.ApiPartialUpdateInstanceRequest { - return testClient.PartialUpdateInstance(ctx, projectId, region, instanceId) -} - -func (c *postgresFlexClientMocked) GetInstanceExecute(_ context.Context, _, _, _ string) (*postgresflex.InstanceResponse, error) { - if c.getInstanceFails { - return nil, fmt.Errorf("get instance failed") - } - return c.getInstanceResp, nil -} - -func (c *postgresFlexClientMocked) ListStoragesExecute(_ context.Context, _, _, _ string) (*postgresflex.ListStoragesResponse, error) { - if c.listFlavorsFails { - return nil, fmt.Errorf("list storages failed") - } - return c.listStoragesResp, nil -} - -func (c *postgresFlexClientMocked) ListFlavorsExecute(_ context.Context, _, _ string) (*postgresflex.ListFlavorsResponse, error) { - if c.listFlavorsFails { - return nil, fmt.Errorf("list flavors failed") +func newAPIClientMock(c mockSettings) postgresflex.DefaultAPI { + return postgresflex.DefaultAPIServiceMock{ + GetInstanceExecuteMock: utils.Ptr(func(_ postgresflex.ApiGetInstanceRequest) (*postgresflex.InstanceResponse, error) { + if c.getInstanceFails { + return nil, fmt.Errorf("get instance failed") + } + return c.getInstanceResp, nil + }), + ListStoragesExecuteMock: utils.Ptr(func(_ postgresflex.ApiListStoragesRequest) (*postgresflex.ListStoragesResponse, error) { + if c.listFlavorsFails { + return nil, fmt.Errorf("list storages failed") + } + return c.listStoragesResp, nil + }), + ListFlavorsExecuteMock: utils.Ptr(func(_ postgresflex.ApiListFlavorsRequest) (*postgresflex.ListFlavorsResponse, error) { + if c.listFlavorsFails { + return nil, fmt.Errorf("list flavors failed") + } + return c.listFlavorsResp, nil + }), } - return c.listFlavorsResp, nil } var testProjectId = uuid.NewString() @@ -125,7 +122,7 @@ func fixtureStandardInputModel(mods ...func(model *inputModel)) *inputModel { InstanceId: testInstanceId, FlavorId: utils.Ptr(testFlavorId), InstanceName: utils.Ptr("example-name"), - ACL: utils.Ptr([]string{"0.0.0.0/0"}), + ACL: []string{"0.0.0.0/0"}, BackupSchedule: utils.Ptr("0 0 * * *"), StorageClass: utils.Ptr("class"), StorageSize: utils.Ptr(int64(10)), @@ -139,7 +136,7 @@ func fixtureStandardInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *postgresflex.ApiPartialUpdateInstanceRequest)) postgresflex.ApiPartialUpdateInstanceRequest { - request := testClient.PartialUpdateInstance(testCtx, testProjectId, testRegion, testInstanceId) + request := testClient.DefaultAPI.PartialUpdateInstance(testCtx, testProjectId, testRegion, testInstanceId) request = request.PartialUpdateInstancePayload(postgresflex.PartialUpdateInstancePayload{}) for _, mod := range mods { mod(&request) @@ -276,7 +273,7 @@ func TestParseInput(t *testing.T) { aclValues: []string{"198.51.100.14/24", "198.51.100.14/32"}, isValid: true, expectedModel: fixtureRequiredInputModel(func(model *inputModel) { - model.ACL = utils.Ptr([]string{"198.51.100.14/24", "198.51.100.14/32"}) + model.ACL = []string{"198.51.100.14/24", "198.51.100.14/32"} }), }, } @@ -348,16 +345,11 @@ func TestParseInput(t *testing.T) { func TestBuildRequest(t *testing.T) { tests := []struct { - description string - model *inputModel - expectedRequest postgresflex.ApiPartialUpdateInstanceRequest - getInstanceFails bool - getInstanceResp *postgresflex.InstanceResponse - listFlavorsFails bool - listFlavorsResp *postgresflex.ListFlavorsResponse - listStoragesFails bool - listStoragesResp *postgresflex.ListStoragesResponse - isValid bool + description string + model *inputModel + expectedRequest postgresflex.ApiPartialUpdateInstanceRequest + mockClientSettings mockSettings + isValid bool }{ { description: "no values", @@ -371,16 +363,18 @@ func TestBuildRequest(t *testing.T) { model.FlavorId = utils.Ptr(testFlavorId) }), isValid: true, - listFlavorsResp: &postgresflex.ListFlavorsResponse{ - Flavors: &[]postgresflex.Flavor{ - { - Id: utils.Ptr(testFlavorId), - Cpu: utils.Ptr(int64(2)), - Memory: utils.Ptr(int64(4)), + mockClientSettings: mockSettings{ + listFlavorsResp: &postgresflex.ListFlavorsResponse{ + Flavors: []postgresflex.Flavor{ + { + Id: utils.Ptr(testFlavorId), + Cpu: utils.Ptr(int64(2)), + Memory: utils.Ptr(int64(4)), + }, }, }, }, - expectedRequest: testClient.PartialUpdateInstance(testCtx, testProjectId, testRegion, testInstanceId). + expectedRequest: testClient.DefaultAPI.PartialUpdateInstance(testCtx, testProjectId, testRegion, testInstanceId). PartialUpdateInstancePayload(postgresflex.PartialUpdateInstancePayload{ FlavorId: utils.Ptr(testFlavorId), }), @@ -392,16 +386,18 @@ func TestBuildRequest(t *testing.T) { model.RAM = utils.Ptr(int64(4)) }), isValid: true, - listFlavorsResp: &postgresflex.ListFlavorsResponse{ - Flavors: &[]postgresflex.Flavor{ - { - Id: utils.Ptr(testFlavorId), - Cpu: utils.Ptr(int64(2)), - Memory: utils.Ptr(int64(4)), + mockClientSettings: mockSettings{ + listFlavorsResp: &postgresflex.ListFlavorsResponse{ + Flavors: []postgresflex.Flavor{ + { + Id: utils.Ptr(testFlavorId), + Cpu: utils.Ptr(int64(2)), + Memory: utils.Ptr(int64(4)), + }, }, }, }, - expectedRequest: testClient.PartialUpdateInstance(testCtx, testProjectId, testRegion, testInstanceId). + expectedRequest: testClient.DefaultAPI.PartialUpdateInstance(testCtx, testProjectId, testRegion, testInstanceId). PartialUpdateInstancePayload(postgresflex.PartialUpdateInstancePayload{ FlavorId: utils.Ptr(testFlavorId), }), @@ -412,21 +408,23 @@ func TestBuildRequest(t *testing.T) { model.StorageClass = utils.Ptr("class") }), isValid: true, - getInstanceResp: &postgresflex.InstanceResponse{ - Item: &postgresflex.Instance{ - Flavor: &postgresflex.Flavor{ - Id: utils.Ptr(testFlavorId), + mockClientSettings: mockSettings{ + getInstanceResp: &postgresflex.InstanceResponse{ + Item: &postgresflex.Instance{ + Flavor: &postgresflex.Flavor{ + Id: utils.Ptr(testFlavorId), + }, }, }, - }, - listStoragesResp: &postgresflex.ListStoragesResponse{ - StorageClasses: &[]string{"class"}, - StorageRange: &postgresflex.StorageRange{ - Min: utils.Ptr(int64(10)), - Max: utils.Ptr(int64(100)), + listStoragesResp: &postgresflex.ListStoragesResponse{ + StorageClasses: []string{"class"}, + StorageRange: &postgresflex.StorageRange{ + Min: utils.Ptr(int64(10)), + Max: utils.Ptr(int64(100)), + }, }, }, - expectedRequest: testClient.PartialUpdateInstance(testCtx, testProjectId, testRegion, testInstanceId). + expectedRequest: testClient.DefaultAPI.PartialUpdateInstance(testCtx, testProjectId, testRegion, testInstanceId). PartialUpdateInstancePayload(postgresflex.PartialUpdateInstancePayload{ Storage: &postgresflex.StorageUpdate{ Class: utils.Ptr("class"), @@ -440,21 +438,23 @@ func TestBuildRequest(t *testing.T) { model.StorageSize = utils.Ptr(int64(10)) }), isValid: true, - getInstanceResp: &postgresflex.InstanceResponse{ - Item: &postgresflex.Instance{ - Flavor: &postgresflex.Flavor{ - Id: utils.Ptr(testFlavorId), + mockClientSettings: mockSettings{ + getInstanceResp: &postgresflex.InstanceResponse{ + Item: &postgresflex.Instance{ + Flavor: &postgresflex.Flavor{ + Id: utils.Ptr(testFlavorId), + }, }, }, - }, - listStoragesResp: &postgresflex.ListStoragesResponse{ - StorageClasses: &[]string{"class"}, - StorageRange: &postgresflex.StorageRange{ - Min: utils.Ptr(int64(10)), - Max: utils.Ptr(int64(100)), + listStoragesResp: &postgresflex.ListStoragesResponse{ + StorageClasses: []string{"class"}, + StorageRange: &postgresflex.StorageRange{ + Min: utils.Ptr(int64(10)), + Max: utils.Ptr(int64(100)), + }, }, }, - expectedRequest: testClient.PartialUpdateInstance(testCtx, testProjectId, testRegion, testInstanceId). + expectedRequest: testClient.DefaultAPI.PartialUpdateInstance(testCtx, testProjectId, testRegion, testInstanceId). PartialUpdateInstancePayload(postgresflex.PartialUpdateInstancePayload{ Storage: &postgresflex.StorageUpdate{ Class: utils.Ptr("class"), @@ -470,8 +470,10 @@ func TestBuildRequest(t *testing.T) { model.RAM = utils.Ptr(int64(4)) }, ), - listFlavorsFails: true, - isValid: false, + mockClientSettings: mockSettings{ + listFlavorsFails: true, + }, + isValid: false, }, { description: "flavor id not found", @@ -481,17 +483,19 @@ func TestBuildRequest(t *testing.T) { model.RAM = utils.Ptr(int64(9)) }, ), - listFlavorsResp: &postgresflex.ListFlavorsResponse{ - Flavors: &[]postgresflex.Flavor{ - { - Id: utils.Ptr(testFlavorId), - Cpu: utils.Ptr(int64(2)), - Memory: utils.Ptr(int64(4)), - }, - { - Id: utils.Ptr("other-flavor"), - Cpu: utils.Ptr(int64(1)), - Memory: utils.Ptr(int64(8)), + mockClientSettings: mockSettings{ + listFlavorsResp: &postgresflex.ListFlavorsResponse{ + Flavors: []postgresflex.Flavor{ + { + Id: utils.Ptr(testFlavorId), + Cpu: utils.Ptr(int64(2)), + Memory: utils.Ptr(int64(4)), + }, + { + Id: utils.Ptr("other-flavor"), + Cpu: utils.Ptr(int64(1)), + Memory: utils.Ptr(int64(8)), + }, }, }, }, @@ -504,8 +508,10 @@ func TestBuildRequest(t *testing.T) { model.StorageClass = utils.Ptr("class") }, ), - getInstanceFails: true, - isValid: false, + mockClientSettings: mockSettings{ + getInstanceFails: true, + }, + isValid: false, }, { description: "get storages fails", @@ -516,8 +522,10 @@ func TestBuildRequest(t *testing.T) { model.RAM = utils.Ptr(int64(4)) }, ), - listFlavorsFails: true, - isValid: false, + mockClientSettings: mockSettings{ + listFlavorsFails: true, + }, + isValid: false, }, { description: "invalid storage class", @@ -526,18 +534,20 @@ func TestBuildRequest(t *testing.T) { model.StorageClass = utils.Ptr("non-existing-class") }, ), - getInstanceResp: &postgresflex.InstanceResponse{ - Item: &postgresflex.Instance{ - Flavor: &postgresflex.Flavor{ - Id: utils.Ptr(testFlavorId), + mockClientSettings: mockSettings{ + getInstanceResp: &postgresflex.InstanceResponse{ + Item: &postgresflex.Instance{ + Flavor: &postgresflex.Flavor{ + Id: utils.Ptr(testFlavorId), + }, }, }, - }, - listStoragesResp: &postgresflex.ListStoragesResponse{ - StorageClasses: &[]string{"class"}, - StorageRange: &postgresflex.StorageRange{ - Min: utils.Ptr(int64(10)), - Max: utils.Ptr(int64(100)), + listStoragesResp: &postgresflex.ListStoragesResponse{ + StorageClasses: []string{"class"}, + StorageRange: &postgresflex.StorageRange{ + Min: utils.Ptr(int64(10)), + Max: utils.Ptr(int64(100)), + }, }, }, isValid: false, @@ -549,18 +559,20 @@ func TestBuildRequest(t *testing.T) { model.StorageSize = utils.Ptr(int64(9)) }, ), - getInstanceResp: &postgresflex.InstanceResponse{ - Item: &postgresflex.Instance{ - Flavor: &postgresflex.Flavor{ - Id: utils.Ptr(testFlavorId), + mockClientSettings: mockSettings{ + getInstanceResp: &postgresflex.InstanceResponse{ + Item: &postgresflex.Instance{ + Flavor: &postgresflex.Flavor{ + Id: utils.Ptr(testFlavorId), + }, }, }, - }, - listStoragesResp: &postgresflex.ListStoragesResponse{ - StorageClasses: &[]string{"class"}, - StorageRange: &postgresflex.StorageRange{ - Min: utils.Ptr(int64(10)), - Max: utils.Ptr(int64(100)), + listStoragesResp: &postgresflex.ListStoragesResponse{ + StorageClasses: []string{"class"}, + StorageRange: &postgresflex.StorageRange{ + Min: utils.Ptr(int64(10)), + Max: utils.Ptr(int64(100)), + }, }, }, isValid: false, @@ -569,15 +581,7 @@ func TestBuildRequest(t *testing.T) { for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { - client := &postgresFlexClientMocked{ - getInstanceFails: tt.getInstanceFails, - getInstanceResp: tt.getInstanceResp, - listFlavorsFails: tt.listFlavorsFails, - listFlavorsResp: tt.listFlavorsResp, - listStoragesFails: tt.listStoragesFails, - listStoragesResp: tt.listStoragesResp, - } - request, err := buildRequest(testCtx, tt.model, client) + request, err := buildRequest(testCtx, tt.model, newAPIClientMock(tt.mockClientSettings)) if err != nil { if !tt.isValid { return @@ -588,6 +592,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), cmpopts.EquateComparable(testCtx), + cmpopts.IgnoreFields(tt.expectedRequest, "ApiService"), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/postgresflex/options/options.go b/internal/cmd/postgresflex/options/options.go index e569b331e..c2e6e5b08 100644 --- a/internal/cmd/postgresflex/options/options.go +++ b/internal/cmd/postgresflex/options/options.go @@ -7,7 +7,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/types" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/postgresflex" + postgresflex "github.com/stackitcloud/stackit-sdk-go/services/postgresflex/v2api" "github.com/stackitcloud/stackit-cli/internal/pkg/args" cliErr "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -37,9 +37,9 @@ type inputModel struct { } type options struct { - Flavors *[]postgresflex.Flavor `json:"flavors,omitempty"` - Versions *[]string `json:"versions,omitempty"` - Storages *flavorStorages `json:"flavorStorages,omitempty"` + Flavors []postgresflex.Flavor `json:"flavors,omitempty"` + Versions []string `json:"versions,omitempty"` + Storages *flavorStorages `json:"flavorStorages,omitempty"` } type flavorStorages struct { @@ -78,7 +78,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } // Call API - err = buildAndExecuteRequest(ctx, params.Printer, model, apiClient) + err = buildAndExecuteRequest(ctx, params.Printer, model, apiClient.DefaultAPI) if err != nil { return fmt.Errorf("get PostgreSQL Flex options: %w", err) } @@ -132,32 +132,26 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, return &model, nil } -type postgresFlexOptionsClient interface { - ListFlavorsExecute(ctx context.Context, projectId, region string) (*postgresflex.ListFlavorsResponse, error) - ListVersionsExecute(ctx context.Context, projectId, region string) (*postgresflex.ListVersionsResponse, error) - ListStoragesExecute(ctx context.Context, projectId, region, flavorId string) (*postgresflex.ListStoragesResponse, error) -} - -func buildAndExecuteRequest(ctx context.Context, p *print.Printer, model *inputModel, apiClient postgresFlexOptionsClient) error { +func buildAndExecuteRequest(ctx context.Context, p *print.Printer, model *inputModel, apiClient postgresflex.DefaultAPI) error { var flavors *postgresflex.ListFlavorsResponse var versions *postgresflex.ListVersionsResponse var storages *postgresflex.ListStoragesResponse var err error if model.Flavors { - flavors, err = apiClient.ListFlavorsExecute(ctx, model.ProjectId, model.Region) + flavors, err = apiClient.ListFlavors(ctx, model.ProjectId, model.Region).Execute() if err != nil { return fmt.Errorf("get PostgreSQL Flex flavors: %w", err) } } if model.Versions { - versions, err = apiClient.ListVersionsExecute(ctx, model.ProjectId, model.Region) + versions, err = apiClient.ListVersions(ctx, model.ProjectId, model.Region).Execute() if err != nil { return fmt.Errorf("get PostgreSQL Flex versions: %w", err) } } if model.Storages { - storages, err = apiClient.ListStoragesExecute(ctx, model.ProjectId, model.Region, *model.FlavorId) + storages, err = apiClient.ListStorages(ctx, model.ProjectId, model.Region, *model.FlavorId).Execute() if err != nil { return fmt.Errorf("get PostgreSQL Flex storages: %w", err) } @@ -186,13 +180,13 @@ func outputResult(p *print.Printer, model inputModel, flavors *postgresflex.List return p.OutputResult(model.OutputFormat, options, func() error { content := []tables.Table{} - if model.Flavors && len(*options.Flavors) != 0 { - content = append(content, buildFlavorsTable(*options.Flavors)) + if model.Flavors && len(options.Flavors) != 0 { + content = append(content, buildFlavorsTable(options.Flavors)) } - if model.Versions && len(*options.Versions) != 0 { - content = append(content, buildVersionsTable(*options.Versions)) + if model.Versions && len(options.Versions) != 0 { + content = append(content, buildVersionsTable(options.Versions)) } - if model.Storages && options.Storages.Storages != nil && len(*options.Storages.Storages.StorageClasses) > 0 { + if model.Storages && options.Storages.Storages != nil && len(options.Storages.Storages.StorageClasses) > 0 { content = append(content, buildStoragesTable(*options.Storages.Storages)) } @@ -233,12 +227,10 @@ func buildVersionsTable(versions []string) tables.Table { } func buildStoragesTable(storagesResp postgresflex.ListStoragesResponse) tables.Table { - storages := *storagesResp.StorageClasses table := tables.NewTable() table.SetTitle("Storages") table.SetHeader("MINIMUM", "MAXIMUM", "STORAGE CLASS") - for i := range storages { - sc := storages[i] + for _, sc := range storagesResp.StorageClasses { table.AddRow( utils.PtrString(storagesResp.StorageRange.Min), utils.PtrString(storagesResp.StorageRange.Max), diff --git a/internal/cmd/postgresflex/options/options_test.go b/internal/cmd/postgresflex/options/options_test.go index b42f3bfe0..f2798225f 100644 --- a/internal/cmd/postgresflex/options/options_test.go +++ b/internal/cmd/postgresflex/options/options_test.go @@ -6,7 +6,7 @@ import ( "testing" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/postgresflex" + postgresflex "github.com/stackitcloud/stackit-sdk-go/services/postgresflex/v2api" "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" @@ -20,7 +20,7 @@ type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") var testProjectId = uuid.NewString() -type postgresFlexClientMocked struct { +type mockSettings struct { listFlavorsFails bool listVersionsFails bool listStoragesFails bool @@ -30,38 +30,40 @@ type postgresFlexClientMocked struct { listStoragesCalled bool } -func (c *postgresFlexClientMocked) ListFlavorsExecute(_ context.Context, _, _ string) (*postgresflex.ListFlavorsResponse, error) { - c.listFlavorsCalled = true - if c.listFlavorsFails { - return nil, fmt.Errorf("list flavors failed") - } - return utils.Ptr(postgresflex.ListFlavorsResponse{ - Flavors: utils.Ptr([]postgresflex.Flavor{}), - }), nil -} - -func (c *postgresFlexClientMocked) ListVersionsExecute(_ context.Context, _, _ string) (*postgresflex.ListVersionsResponse, error) { - c.listVersionsCalled = true - if c.listVersionsFails { - return nil, fmt.Errorf("list versions failed") - } - return utils.Ptr(postgresflex.ListVersionsResponse{ - Versions: utils.Ptr([]string{}), - }), nil -} - -func (c *postgresFlexClientMocked) ListStoragesExecute(_ context.Context, _, _, _ string) (*postgresflex.ListStoragesResponse, error) { - c.listStoragesCalled = true - if c.listStoragesFails { - return nil, fmt.Errorf("list storages failed") +func newAPIClientMock(c *mockSettings) postgresflex.DefaultAPI { + return postgresflex.DefaultAPIServiceMock{ + ListFlavorsExecuteMock: utils.Ptr(func(_ postgresflex.ApiListFlavorsRequest) (*postgresflex.ListFlavorsResponse, error) { + c.listFlavorsCalled = true + if c.listFlavorsFails { + return nil, fmt.Errorf("list flavors failed") + } + return utils.Ptr(postgresflex.ListFlavorsResponse{ + Flavors: []postgresflex.Flavor{}, + }), nil + }), + ListVersionsExecuteMock: utils.Ptr(func(_ postgresflex.ApiListVersionsRequest) (*postgresflex.ListVersionsResponse, error) { + c.listVersionsCalled = true + if c.listVersionsFails { + return nil, fmt.Errorf("list versions failed") + } + return utils.Ptr(postgresflex.ListVersionsResponse{ + Versions: []string{}, + }), nil + }), + ListStoragesExecuteMock: utils.Ptr(func(_ postgresflex.ApiListStoragesRequest) (*postgresflex.ListStoragesResponse, error) { + c.listStoragesCalled = true + if c.listStoragesFails { + return nil, fmt.Errorf("list storages failed") + } + return utils.Ptr(postgresflex.ListStoragesResponse{ + StorageClasses: []string{}, + StorageRange: &postgresflex.StorageRange{ + Min: utils.Ptr(int64(10)), + Max: utils.Ptr(int64(100)), + }, + }), nil + }), } - return utils.Ptr(postgresflex.ListStoragesResponse{ - StorageClasses: utils.Ptr([]string{}), - StorageRange: &postgresflex.StorageRange{ - Min: utils.Ptr(int64(10)), - Max: utils.Ptr(int64(100)), - }, - }), nil } func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string { @@ -187,9 +189,7 @@ func TestBuildAndExecuteRequest(t *testing.T) { description string model *inputModel isValid bool - listFlavorsFails bool - listVersionsFails bool - listStoragesFails bool + mockClientSettings mockSettings expectListFlavorsCalled bool expectListVersionsCalled bool expectListStoragesCalled bool @@ -232,28 +232,34 @@ func TestBuildAndExecuteRequest(t *testing.T) { expectListStoragesCalled: true, }, { - description: "list flavors fails", - model: fixtureInputModelAllTrue(), - isValid: false, - listFlavorsFails: true, + description: "list flavors fails", + model: fixtureInputModelAllTrue(), + isValid: false, + mockClientSettings: mockSettings{ + listFlavorsFails: true, + }, expectListFlavorsCalled: true, expectListVersionsCalled: false, expectListStoragesCalled: false, }, { - description: "list versions fails", - model: fixtureInputModelAllTrue(), - isValid: false, - listVersionsFails: true, + description: "list versions fails", + model: fixtureInputModelAllTrue(), + isValid: false, + mockClientSettings: mockSettings{ + listVersionsFails: true, + }, expectListFlavorsCalled: true, expectListVersionsCalled: true, expectListStoragesCalled: false, }, { - description: "list storages fails", - model: fixtureInputModelAllTrue(), - isValid: false, - listStoragesFails: true, + description: "list storages fails", + model: fixtureInputModelAllTrue(), + isValid: false, + mockClientSettings: mockSettings{ + listStoragesFails: true, + }, expectListFlavorsCalled: true, expectListVersionsCalled: true, expectListStoragesCalled: true, @@ -263,12 +269,7 @@ func TestBuildAndExecuteRequest(t *testing.T) { for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { params := testparams.NewTestParams() - client := &postgresFlexClientMocked{ - listFlavorsFails: tt.listFlavorsFails, - listVersionsFails: tt.listVersionsFails, - listStoragesFails: tt.listStoragesFails, - } - + client := newAPIClientMock(&tt.mockClientSettings) err := buildAndExecuteRequest(testCtx, params.Printer, tt.model, client) if err != nil && tt.isValid { t.Fatalf("error building and executing request: %v", err) @@ -280,14 +281,14 @@ func TestBuildAndExecuteRequest(t *testing.T) { return } - if tt.expectListFlavorsCalled != client.listFlavorsCalled { - t.Fatalf("expected listFlavorsCalled to be %v, got %v", tt.expectListFlavorsCalled, client.listFlavorsCalled) + if tt.expectListFlavorsCalled != tt.mockClientSettings.listFlavorsCalled { + t.Fatalf("expected listFlavorsCalled to be %v, got %v", tt.expectListFlavorsCalled, tt.mockClientSettings.listFlavorsCalled) } - if tt.expectListVersionsCalled != client.listVersionsCalled { - t.Fatalf("expected listVersionsCalled to be %v, got %v", tt.expectListVersionsCalled, client.listVersionsCalled) + if tt.expectListVersionsCalled != tt.mockClientSettings.listVersionsCalled { + t.Fatalf("expected listVersionsCalled to be %v, got %v", tt.expectListVersionsCalled, tt.mockClientSettings.listVersionsCalled) } - if tt.expectListStoragesCalled != client.listStoragesCalled { - t.Fatalf("expected listStoragesCalled to be %v, got %v", tt.expectListStoragesCalled, client.listStoragesCalled) + if tt.expectListStoragesCalled != tt.mockClientSettings.listStoragesCalled { + t.Fatalf("expected listStoragesCalled to be %v, got %v", tt.expectListStoragesCalled, tt.mockClientSettings.listStoragesCalled) } }) } @@ -317,13 +318,13 @@ func Test_outputResult(t *testing.T) { args{ model: inputModel{GlobalFlagModel: &globalflags.GlobalFlagModel{}, Flavors: false, Versions: false, Storages: false, FlavorId: new(string)}, flavors: &postgresflex.ListFlavorsResponse{ - Flavors: &[]postgresflex.Flavor{}, + Flavors: []postgresflex.Flavor{}, }, versions: &postgresflex.ListVersionsResponse{ - Versions: &[]string{}, + Versions: []string{}, }, storages: &postgresflex.ListStoragesResponse{ - StorageClasses: &[]string{}, + StorageClasses: []string{}, StorageRange: &postgresflex.StorageRange{}, }, }, diff --git a/internal/cmd/postgresflex/user/create/create.go b/internal/cmd/postgresflex/user/create/create.go index c4742e2a0..3ea952b06 100644 --- a/internal/cmd/postgresflex/user/create/create.go +++ b/internal/cmd/postgresflex/user/create/create.go @@ -7,7 +7,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/types" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/postgresflex" + postgresflex "github.com/stackitcloud/stackit-sdk-go/services/postgresflex/v2api" "github.com/stackitcloud/stackit-cli/internal/pkg/args" "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -40,7 +40,7 @@ type inputModel struct { InstanceId string Username *string - Roles *[]string + Roles []string } func NewCmd(params *types.CmdParams) *cobra.Command { @@ -75,7 +75,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return err } - instanceLabel, err := postgresflexUtils.GetInstanceName(ctx, apiClient, model.ProjectId, model.Region, model.InstanceId) + instanceLabel, err := postgresflexUtils.GetInstanceName(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, model.InstanceId) if err != nil { params.Printer.Debug(print.ErrorLevel, "get instance name: %v", err) instanceLabel = model.InstanceId @@ -121,7 +121,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, GlobalFlagModel: globalFlags, InstanceId: flags.FlagToStringValue(p, cmd, instanceIdFlag), Username: flags.FlagToStringPointer(p, cmd, usernameFlag), - Roles: roleFlag.Ptr(), + Roles: roleFlag.Get(), } p.DebugInputModel(model) @@ -129,7 +129,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, } func buildRequest(ctx context.Context, model *inputModel, apiClient *postgresflex.APIClient) postgresflex.ApiCreateUserRequest { - req := apiClient.CreateUser(ctx, model.ProjectId, model.Region, model.InstanceId) + req := apiClient.DefaultAPI.CreateUser(ctx, model.ProjectId, model.Region, model.InstanceId) req = req.CreateUserPayload(postgresflex.CreateUserPayload{ Username: model.Username, Roles: model.Roles, @@ -147,7 +147,7 @@ func outputResult(p *print.Printer, outputFormat, instanceLabel string, resp *po p.Outputf("Created user for instance %q. User ID: %s\n\n", instanceLabel, utils.PtrString(user.Id)) p.Outputf("Username: %s\n", utils.PtrString(user.Username)) p.Outputf("Password: %s\n", utils.PtrString(user.Password)) - p.Outputf("Roles: %v\n", utils.PtrString(user.Roles)) + p.Outputf("Roles: %v\n", user.Roles) p.Outputf("Host: %s\n", utils.PtrString(user.Host)) p.Outputf("Port: %s\n", utils.PtrString(user.Port)) p.Outputf("URI: %s\n", utils.PtrString(user.Uri)) diff --git a/internal/cmd/postgresflex/user/create/create_test.go b/internal/cmd/postgresflex/user/create/create_test.go index 2c9e50a7c..82bf6cec8 100644 --- a/internal/cmd/postgresflex/user/create/create_test.go +++ b/internal/cmd/postgresflex/user/create/create_test.go @@ -7,7 +7,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/postgresflex" + postgresflex "github.com/stackitcloud/stackit-sdk-go/services/postgresflex/v2api" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" @@ -18,7 +18,7 @@ import ( type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &postgresflex.APIClient{} +var testClient = &postgresflex.APIClient{DefaultAPI: &postgresflex.DefaultAPIService{}} var testProjectId = uuid.NewString() var testInstanceId = uuid.NewString() var testRegion = "eu01" @@ -46,7 +46,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { }, InstanceId: testInstanceId, Username: utils.Ptr("johndoe"), - Roles: utils.Ptr([]string{"login"}), + Roles: []string{"login"}, } for _, mod := range mods { mod(model) @@ -55,10 +55,10 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *postgresflex.ApiCreateUserRequest)) postgresflex.ApiCreateUserRequest { - request := testClient.CreateUser(testCtx, testProjectId, testRegion, testInstanceId) + request := testClient.DefaultAPI.CreateUser(testCtx, testProjectId, testRegion, testInstanceId) request = request.CreateUserPayload(postgresflex.CreateUserPayload{ Username: utils.Ptr("johndoe"), - Roles: utils.Ptr([]string{"login"}), + Roles: []string{"login"}, }) for _, mod := range mods { @@ -136,7 +136,7 @@ func TestParseInput(t *testing.T) { }), isValid: true, expectedModel: fixtureInputModel(func(model *inputModel) { - model.Roles = &rolesDefault + model.Roles = rolesDefault }), }, { @@ -172,7 +172,7 @@ func TestBuildRequest(t *testing.T) { model.Username = nil }), expectedRequest: fixtureRequest().CreateUserPayload(postgresflex.CreateUserPayload{ - Roles: utils.Ptr([]string{"login"}), + Roles: []string{"login"}, }), }, } @@ -183,7 +183,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, postgresflex.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) @@ -212,7 +212,7 @@ func Test_outputResult(t *testing.T) { Id: new(string), Password: new(string), Port: new(int64), - Roles: &[]string{}, + Roles: []string{}, Uri: new(string), Username: new(string), }, diff --git a/internal/cmd/postgresflex/user/delete/delete.go b/internal/cmd/postgresflex/user/delete/delete.go index d3646805a..f6667191c 100644 --- a/internal/cmd/postgresflex/user/delete/delete.go +++ b/internal/cmd/postgresflex/user/delete/delete.go @@ -16,7 +16,7 @@ import ( postgresflexUtils "github.com/stackitcloud/stackit-cli/internal/pkg/services/postgresflex/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/postgresflex" + postgresflex "github.com/stackitcloud/stackit-sdk-go/services/postgresflex/v2api" ) const ( @@ -60,13 +60,13 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return err } - instanceLabel, err := postgresflexUtils.GetInstanceName(ctx, apiClient, model.ProjectId, model.Region, model.InstanceId) + instanceLabel, err := postgresflexUtils.GetInstanceName(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, model.InstanceId) if err != nil { params.Printer.Debug(print.ErrorLevel, "get instance name: %v", err) instanceLabel = model.InstanceId } - userLabel, err := postgresflexUtils.GetUserName(ctx, apiClient, model.ProjectId, model.Region, model.InstanceId, model.UserId) + userLabel, err := postgresflexUtils.GetUserName(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, model.InstanceId, model.UserId) if err != nil { params.Printer.Debug(print.ErrorLevel, "get user name: %v", err) userLabel = model.UserId @@ -119,6 +119,6 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *postgresflex.APIClient) postgresflex.ApiDeleteUserRequest { - req := apiClient.DeleteUser(ctx, model.ProjectId, model.Region, model.InstanceId, model.UserId) + req := apiClient.DefaultAPI.DeleteUser(ctx, model.ProjectId, model.Region, model.InstanceId, model.UserId) return req } diff --git a/internal/cmd/postgresflex/user/delete/delete_test.go b/internal/cmd/postgresflex/user/delete/delete_test.go index a3ff66105..a91291466 100644 --- a/internal/cmd/postgresflex/user/delete/delete_test.go +++ b/internal/cmd/postgresflex/user/delete/delete_test.go @@ -10,13 +10,13 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/postgresflex" + postgresflex "github.com/stackitcloud/stackit-sdk-go/services/postgresflex/v2api" ) type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &postgresflex.APIClient{} +var testClient = &postgresflex.APIClient{DefaultAPI: &postgresflex.DefaultAPIService{}} var testProjectId = uuid.NewString() var testInstanceId = uuid.NewString() var testUserId = "12345" @@ -61,7 +61,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *postgresflex.ApiDeleteUserRequest)) postgresflex.ApiDeleteUserRequest { - request := testClient.DeleteUser(testCtx, testProjectId, testRegion, testInstanceId, testUserId) + request := testClient.DefaultAPI.DeleteUser(testCtx, testProjectId, testRegion, testInstanceId, testUserId) for _, mod := range mods { mod(&request) } @@ -183,7 +183,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, postgresflex.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/postgresflex/user/describe/describe.go b/internal/cmd/postgresflex/user/describe/describe.go index da2dac16a..17a68f2e0 100644 --- a/internal/cmd/postgresflex/user/describe/describe.go +++ b/internal/cmd/postgresflex/user/describe/describe.go @@ -7,7 +7,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/types" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/postgresflex" + postgresflex "github.com/stackitcloud/stackit-sdk-go/services/postgresflex/v2api" "github.com/stackitcloud/stackit-cli/internal/pkg/args" "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -105,7 +105,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *postgresflex.APIClient) postgresflex.ApiGetUserRequest { - req := apiClient.GetUser(ctx, model.ProjectId, model.Region, model.InstanceId, model.UserId) + req := apiClient.DefaultAPI.GetUser(ctx, model.ProjectId, model.Region, model.InstanceId, model.UserId) return req } @@ -116,7 +116,7 @@ func outputResult(p *print.Printer, outputFormat string, user postgresflex.UserR table.AddSeparator() table.AddRow("USERNAME", utils.PtrString(user.Username)) table.AddSeparator() - table.AddRow("ROLES", utils.PtrString(user.Roles)) + table.AddRow("ROLES", user.Roles) table.AddSeparator() table.AddRow("HOST", utils.PtrString(user.Host)) table.AddSeparator() diff --git a/internal/cmd/postgresflex/user/describe/describe_test.go b/internal/cmd/postgresflex/user/describe/describe_test.go index 3bb99678e..e5f64a31f 100644 --- a/internal/cmd/postgresflex/user/describe/describe_test.go +++ b/internal/cmd/postgresflex/user/describe/describe_test.go @@ -7,7 +7,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/postgresflex" + postgresflex "github.com/stackitcloud/stackit-sdk-go/services/postgresflex/v2api" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" @@ -17,7 +17,7 @@ import ( type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &postgresflex.APIClient{} +var testClient = &postgresflex.APIClient{DefaultAPI: &postgresflex.DefaultAPIService{}} var testProjectId = uuid.NewString() var testInstanceId = uuid.NewString() var testUserId = "12345" @@ -62,7 +62,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *postgresflex.ApiGetUserRequest)) postgresflex.ApiGetUserRequest { - request := testClient.GetUser(testCtx, testProjectId, testRegion, testInstanceId, testUserId) + request := testClient.DefaultAPI.GetUser(testCtx, testProjectId, testRegion, testInstanceId, testUserId) for _, mod := range mods { mod(&request) } @@ -184,7 +184,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, postgresflex.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) @@ -209,7 +209,7 @@ func Test_outputResult(t *testing.T) { Host: new(string), Id: new(string), Port: new(int64), - Roles: &[]string{}, + Roles: []string{}, Username: new(string), }}, false}, } diff --git a/internal/cmd/postgresflex/user/list/list.go b/internal/cmd/postgresflex/user/list/list.go index d0c9dbd36..abe95d1a4 100644 --- a/internal/cmd/postgresflex/user/list/list.go +++ b/internal/cmd/postgresflex/user/list/list.go @@ -7,7 +7,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/types" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/postgresflex" + postgresflex "github.com/stackitcloud/stackit-sdk-go/services/postgresflex/v2api" "github.com/stackitcloud/stackit-cli/internal/pkg/args" "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -29,7 +29,7 @@ const ( type inputModel struct { *globalflags.GlobalFlagModel - InstanceId *string + InstanceId string Limit *int64 } @@ -69,23 +69,19 @@ func NewCmd(params *types.CmdParams) *cobra.Command { if err != nil { return fmt.Errorf("get PostgreSQL Flex users: %w", err) } - if resp.Items == nil || len(*resp.Items) == 0 { - instanceLabel, err := postgresflexUtils.GetInstanceName(ctx, apiClient, model.ProjectId, model.Region, *model.InstanceId) - if err != nil { - params.Printer.Debug(print.ErrorLevel, "get instance name: %v", err) - instanceLabel = *model.InstanceId - } - params.Printer.Info("No users found for instance %q\n", instanceLabel) - return nil - } - users := *resp.Items + users := resp.Items // Truncate output if model.Limit != nil && len(users) > int(*model.Limit) { users = users[:*model.Limit] } - return outputResult(params.Printer, model.OutputFormat, users) + instanceLabel, err := postgresflexUtils.GetInstanceName(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, model.InstanceId) + if err != nil { + params.Printer.Debug(print.ErrorLevel, "get instance name: %v", err) + instanceLabel = model.InstanceId + } + return outputResult(params.Printer, model.OutputFormat, instanceLabel, users) }, } @@ -117,7 +113,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, model := inputModel{ GlobalFlagModel: globalFlags, - InstanceId: flags.FlagToStringPointer(p, cmd, instanceIdFlag), + InstanceId: flags.FlagToStringValue(p, cmd, instanceIdFlag), Limit: flags.FlagToInt64Pointer(p, cmd, limitFlag), } @@ -126,12 +122,16 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, } func buildRequest(ctx context.Context, model *inputModel, apiClient *postgresflex.APIClient) postgresflex.ApiListUsersRequest { - req := apiClient.ListUsers(ctx, model.ProjectId, model.Region, *model.InstanceId) + req := apiClient.DefaultAPI.ListUsers(ctx, model.ProjectId, model.Region, model.InstanceId) return req } -func outputResult(p *print.Printer, outputFormat string, users []postgresflex.ListUsersResponseItem) error { +func outputResult(p *print.Printer, outputFormat, instanceLabel string, users []postgresflex.ListUsersResponseItem) error { return p.OutputResult(outputFormat, users, func() error { + if len(users) == 0 { + p.Outputf("No users found for instance %q\n", instanceLabel) + return nil + } table := tables.NewTable() table.SetHeader("ID", "USERNAME") for i := range users { diff --git a/internal/cmd/postgresflex/user/list/list_test.go b/internal/cmd/postgresflex/user/list/list_test.go index caa4a46f8..808079f8a 100644 --- a/internal/cmd/postgresflex/user/list/list_test.go +++ b/internal/cmd/postgresflex/user/list/list_test.go @@ -7,7 +7,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/postgresflex" + postgresflex "github.com/stackitcloud/stackit-sdk-go/services/postgresflex/v2api" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" @@ -18,7 +18,7 @@ import ( type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &postgresflex.APIClient{} +var testClient = &postgresflex.APIClient{DefaultAPI: &postgresflex.DefaultAPIService{}} var testProjectId = uuid.NewString() var testInstanceId = uuid.NewString() var testRegion = "eu01" @@ -43,7 +43,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { Region: testRegion, Verbosity: globalflags.VerbosityDefault, }, - InstanceId: utils.Ptr(testInstanceId), + InstanceId: testInstanceId, Limit: utils.Ptr(int64(10)), } for _, mod := range mods { @@ -53,7 +53,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *postgresflex.ApiListUsersRequest)) postgresflex.ApiListUsersRequest { - request := testClient.ListUsers(testCtx, testProjectId, testRegion, testInstanceId) + request := testClient.DefaultAPI.ListUsers(testCtx, testProjectId, testRegion, testInstanceId) for _, mod := range mods { mod(&request) } @@ -156,7 +156,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, postgresflex.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) @@ -167,8 +167,9 @@ func TestBuildRequest(t *testing.T) { func Test_outputResult(t *testing.T) { type args struct { - outputFormat string - users []postgresflex.ListUsersResponseItem + outputFormat string + instanceLabel string + users []postgresflex.ListUsersResponseItem } tests := []struct { name string @@ -177,7 +178,7 @@ func Test_outputResult(t *testing.T) { }{ {"empty", args{}, false}, {"standard", args{users: []postgresflex.ListUsersResponseItem{{}}}, false}, - {"complete", args{users: []postgresflex.ListUsersResponseItem{{ + {"complete", args{instanceLabel: "label", users: []postgresflex.ListUsersResponseItem{{ Id: new(string), Username: new(string), }}}, false}, @@ -185,7 +186,7 @@ func Test_outputResult(t *testing.T) { params := testparams.NewTestParams() for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - if err := outputResult(params.Printer, tt.args.outputFormat, tt.args.users); (err != nil) != tt.wantErr { + if err := outputResult(params.Printer, tt.args.outputFormat, tt.args.instanceLabel, tt.args.users); (err != nil) != tt.wantErr { t.Errorf("outputResult() error = %v, wantErr %v", err, tt.wantErr) } }) diff --git a/internal/cmd/postgresflex/user/reset-password/reset_password.go b/internal/cmd/postgresflex/user/reset-password/reset_password.go index 19e34dd2e..7a6ce4efb 100644 --- a/internal/cmd/postgresflex/user/reset-password/reset_password.go +++ b/internal/cmd/postgresflex/user/reset-password/reset_password.go @@ -7,7 +7,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/types" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/postgresflex" + postgresflex "github.com/stackitcloud/stackit-sdk-go/services/postgresflex/v2api" "github.com/stackitcloud/stackit-cli/internal/pkg/args" "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -60,13 +60,13 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return err } - instanceLabel, err := postgresflexUtils.GetInstanceName(ctx, apiClient, model.ProjectId, model.Region, model.InstanceId) + instanceLabel, err := postgresflexUtils.GetInstanceName(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, model.InstanceId) if err != nil { params.Printer.Debug(print.ErrorLevel, "get instance name: %v", err) instanceLabel = model.InstanceId } - userLabel, err := postgresflexUtils.GetUserName(ctx, apiClient, model.ProjectId, model.Region, model.InstanceId, model.UserId) + userLabel, err := postgresflexUtils.GetUserName(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, model.InstanceId, model.UserId) if err != nil { params.Printer.Debug(print.ErrorLevel, "get user name: %v", err) userLabel = model.UserId @@ -119,15 +119,15 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *postgresflex.APIClient) postgresflex.ApiResetUserRequest { - req := apiClient.ResetUser(ctx, model.ProjectId, model.Region, model.InstanceId, model.UserId) + req := apiClient.DefaultAPI.ResetUser(ctx, model.ProjectId, model.Region, model.InstanceId, model.UserId) return req } func outputResult(p *print.Printer, outputFormat, userLabel, instanceLabel string, user *postgresflex.ResetUserResponse) error { - if user == nil { - return fmt.Errorf("no response passed") - } return p.OutputResult(outputFormat, user, func() error { + if user == nil { + return fmt.Errorf("no response passed") + } p.Outputf("Reset password for user %q of instance %q\n\n", userLabel, instanceLabel) if item := user.Item; item != nil { p.Outputf("Username: %s\n", utils.PtrString(item.Username)) diff --git a/internal/cmd/postgresflex/user/reset-password/reset_password_test.go b/internal/cmd/postgresflex/user/reset-password/reset_password_test.go index 799bbc712..4ee3fc726 100644 --- a/internal/cmd/postgresflex/user/reset-password/reset_password_test.go +++ b/internal/cmd/postgresflex/user/reset-password/reset_password_test.go @@ -7,7 +7,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/postgresflex" + postgresflex "github.com/stackitcloud/stackit-sdk-go/services/postgresflex/v2api" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" @@ -17,7 +17,7 @@ import ( type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &postgresflex.APIClient{} +var testClient = &postgresflex.APIClient{DefaultAPI: &postgresflex.DefaultAPIService{}} var testProjectId = uuid.NewString() var testInstanceId = uuid.NewString() var testUserId = "12345" @@ -62,7 +62,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *postgresflex.ApiResetUserRequest)) postgresflex.ApiResetUserRequest { - request := testClient.ResetUser(testCtx, testProjectId, testRegion, testInstanceId, testUserId) + request := testClient.DefaultAPI.ResetUser(testCtx, testProjectId, testRegion, testInstanceId, testUserId) for _, mod := range mods { mod(&request) } @@ -184,7 +184,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, postgresflex.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/postgresflex/user/update/update.go b/internal/cmd/postgresflex/user/update/update.go index 33ca9d18d..e76bce64c 100644 --- a/internal/cmd/postgresflex/user/update/update.go +++ b/internal/cmd/postgresflex/user/update/update.go @@ -16,7 +16,7 @@ import ( postgresflexUtils "github.com/stackitcloud/stackit-cli/internal/pkg/services/postgresflex/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/postgresflex" + postgresflex "github.com/stackitcloud/stackit-sdk-go/services/postgresflex/v2api" ) const ( @@ -36,7 +36,7 @@ type inputModel struct { InstanceId string UserId string - Roles *[]string + Roles []string } func NewCmd(params *types.CmdParams) *cobra.Command { @@ -63,13 +63,13 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return err } - instanceLabel, err := postgresflexUtils.GetInstanceName(ctx, apiClient, model.ProjectId, model.Region, model.InstanceId) + instanceLabel, err := postgresflexUtils.GetInstanceName(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, model.InstanceId) if err != nil { params.Printer.Debug(print.ErrorLevel, "get instance name: %v", err) instanceLabel = model.InstanceId } - userLabel, err := postgresflexUtils.GetUserName(ctx, apiClient, model.ProjectId, model.Region, model.InstanceId, model.UserId) + userLabel, err := postgresflexUtils.GetUserName(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, model.InstanceId, model.UserId) if err != nil { params.Printer.Debug(print.ErrorLevel, "get user name: %v", err) userLabel = model.UserId @@ -113,8 +113,8 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu return nil, &errors.ProjectIdError{} } - roles := roleFlag.Ptr() - if roles == nil { + roles := roleFlag.Get() + if len(roles) == 0 { return nil, &errors.EmptyUpdateError{} } @@ -130,7 +130,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *postgresflex.APIClient) postgresflex.ApiPartialUpdateUserRequest { - req := apiClient.PartialUpdateUser(ctx, model.ProjectId, model.Region, model.InstanceId, model.UserId) + req := apiClient.DefaultAPI.PartialUpdateUser(ctx, model.ProjectId, model.Region, model.InstanceId, model.UserId) req = req.PartialUpdateUserPayload(postgresflex.PartialUpdateUserPayload{ Roles: model.Roles, }) diff --git a/internal/cmd/postgresflex/user/update/update_test.go b/internal/cmd/postgresflex/user/update/update_test.go index c2192e84f..89a194b4b 100644 --- a/internal/cmd/postgresflex/user/update/update_test.go +++ b/internal/cmd/postgresflex/user/update/update_test.go @@ -6,18 +6,17 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/testutils" - "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/postgresflex" + postgresflex "github.com/stackitcloud/stackit-sdk-go/services/postgresflex/v2api" ) type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &postgresflex.APIClient{} +var testClient = &postgresflex.APIClient{DefaultAPI: &postgresflex.DefaultAPIService{}} var testProjectId = uuid.NewString() var testInstanceId = uuid.NewString() var testUserId = "12345" @@ -55,7 +54,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { }, InstanceId: testInstanceId, UserId: testUserId, - Roles: utils.Ptr([]string{"login"}), + Roles: []string{"login"}, } for _, mod := range mods { mod(model) @@ -64,9 +63,9 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *postgresflex.ApiPartialUpdateUserRequest)) postgresflex.ApiPartialUpdateUserRequest { - request := testClient.PartialUpdateUser(testCtx, testProjectId, testRegion, testInstanceId, testUserId) + request := testClient.DefaultAPI.PartialUpdateUser(testCtx, testProjectId, testRegion, testInstanceId, testUserId) request = request.PartialUpdateUserPayload(postgresflex.PartialUpdateUserPayload{ - Roles: utils.Ptr([]string{"login"}), + Roles: []string{"login"}, }) for _, mod := range mods { mod(&request) @@ -192,7 +191,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, postgresflex.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/pkg/services/postgresflex/client/client.go b/internal/pkg/services/postgresflex/client/client.go index d5b77761f..a40b07aec 100644 --- a/internal/pkg/services/postgresflex/client/client.go +++ b/internal/pkg/services/postgresflex/client/client.go @@ -6,9 +6,9 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/print" "github.com/spf13/viper" - "github.com/stackitcloud/stackit-sdk-go/services/postgresflex" + postgresflex "github.com/stackitcloud/stackit-sdk-go/services/postgresflex/v2api" ) func ConfigureClient(p *print.Printer, cliVersion string) (*postgresflex.APIClient, error) { - return genericclient.ConfigureClientGeneric(p, cliVersion, viper.GetString(config.PostgresFlexCustomEndpointKey), true, genericclient.CreateApiClient[*postgresflex.APIClient](postgresflex.NewAPIClient)) + return genericclient.ConfigureClientGeneric(p, cliVersion, viper.GetString(config.PostgresFlexCustomEndpointKey), false, genericclient.CreateApiClient[*postgresflex.APIClient](postgresflex.NewAPIClient)) } diff --git a/internal/pkg/services/postgresflex/utils/utils.go b/internal/pkg/services/postgresflex/utils/utils.go index fc1965bdd..4920feb15 100644 --- a/internal/pkg/services/postgresflex/utils/utils.go +++ b/internal/pkg/services/postgresflex/utils/utils.go @@ -8,20 +8,20 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/errors" - "github.com/stackitcloud/stackit-sdk-go/services/postgresflex" + postgresflex "github.com/stackitcloud/stackit-sdk-go/services/postgresflex/v2api" "golang.org/x/mod/semver" ) // The number of replicas is enforced by the API according to the instance type -var instanceTypeToReplicas = map[string]int64{ +var instanceTypeToReplicas = map[string]int32{ "Single": 1, "Replica": 3, } type PostgresFlexClient interface { - ListVersionsExecute(ctx context.Context, projectId, region string) (*postgresflex.ListVersionsResponse, error) - GetInstanceExecute(ctx context.Context, projectId, region, instanceId string) (*postgresflex.InstanceResponse, error) - GetUserExecute(ctx context.Context, projectId, region, instanceId, userId string) (*postgresflex.GetUserResponse, error) + ListVersions(ctx context.Context, projectId, region string) postgresflex.ApiListVersionsRequest + GetInstance(ctx context.Context, projectId, region, instanceId string) postgresflex.ApiGetInstanceRequest + GetUser(ctx context.Context, projectId, region, instanceId, userId string) postgresflex.ApiGetUserRequest } func AvailableInstanceTypes() []string { @@ -37,7 +37,7 @@ func AvailableInstanceTypes() []string { return instanceTypes } -func GetInstanceReplicas(instanceType string) (int64, error) { +func GetInstanceReplicas(instanceType string) (int32, error) { numReplicas, ok := instanceTypeToReplicas[instanceType] if !ok { return 0, fmt.Errorf("invalid instance type: %v", instanceType) @@ -45,7 +45,7 @@ func GetInstanceReplicas(instanceType string) (int64, error) { return numReplicas, nil } -func GetInstanceType(numReplicas int64) (string, error) { +func GetInstanceType(numReplicas int32) (string, error) { for k, v := range instanceTypeToReplicas { if v == numReplicas { return k, nil @@ -54,12 +54,12 @@ func GetInstanceType(numReplicas int64) (string, error) { return "", fmt.Errorf("invalid number of replicas: %v", numReplicas) } -func ValidateFlavorId(flavorId string, flavors *[]postgresflex.Flavor) error { +func ValidateFlavorId(flavorId string, flavors []postgresflex.Flavor) error { if flavors == nil { return fmt.Errorf("nil flavors") } - for _, f := range *flavors { + for _, f := range flavors { if f.Id != nil && strings.EqualFold(*f.Id, flavorId) { return nil } @@ -86,7 +86,7 @@ func ValidateStorage(storageClass *string, storageSize *int64, storages *postgre return nil } - for _, sc := range *storages.StorageClasses { + for _, sc := range storages.StorageClasses { if strings.EqualFold(*storageClass, sc) { return nil } @@ -98,13 +98,13 @@ func ValidateStorage(storageClass *string, storageSize *int64, storages *postgre } } -func LoadFlavorId(cpu, ram int64, flavors *[]postgresflex.Flavor) (*string, error) { +func LoadFlavorId(cpu, ram int64, flavors []postgresflex.Flavor) (*string, error) { if flavors == nil { return nil, fmt.Errorf("nil flavors") } availableFlavors := "" - for _, f := range *flavors { + for _, f := range flavors { if f.Id == nil || f.Cpu == nil || f.Memory == nil { continue } @@ -120,20 +120,19 @@ func LoadFlavorId(cpu, ram int64, flavors *[]postgresflex.Flavor) (*string, erro } func GetLatestPostgreSQLVersion(ctx context.Context, apiClient PostgresFlexClient, projectId, region string) (string, error) { - resp, err := apiClient.ListVersionsExecute(ctx, projectId, region) + resp, err := apiClient.ListVersions(ctx, projectId, region).Execute() if err != nil { return "", fmt.Errorf("get PostgreSQL versions: %w", err) } - versions := *resp.Versions latestVersion := "0" - for i := range versions { + for i := range resp.Versions { oldSemVer := fmt.Sprintf("v%s", latestVersion) - newSemVer := fmt.Sprintf("v%s", versions[i]) + newSemVer := fmt.Sprintf("v%s", resp.Versions[i]) if semver.Compare(newSemVer, oldSemVer) != 1 { continue } - latestVersion = versions[i] + latestVersion = resp.Versions[i] } if latestVersion == "0" { return "", fmt.Errorf("no PostgreSQL versions found") @@ -142,7 +141,7 @@ func GetLatestPostgreSQLVersion(ctx context.Context, apiClient PostgresFlexClien } func GetInstanceName(ctx context.Context, apiClient PostgresFlexClient, projectId, region, instanceId string) (string, error) { - resp, err := apiClient.GetInstanceExecute(ctx, projectId, region, instanceId) + resp, err := apiClient.GetInstance(ctx, projectId, region, instanceId).Execute() if err != nil { return "", fmt.Errorf("get PostgreSQL Flex instance: %w", err) } @@ -150,7 +149,7 @@ func GetInstanceName(ctx context.Context, apiClient PostgresFlexClient, projectI } func GetInstanceStatus(ctx context.Context, apiClient PostgresFlexClient, projectId, region, instanceId string) (string, error) { - resp, err := apiClient.GetInstanceExecute(ctx, projectId, region, instanceId) + resp, err := apiClient.GetInstance(ctx, projectId, region, instanceId).Execute() if err != nil { return "", fmt.Errorf("get PostgreSQL Flex instance: %w", err) } @@ -158,7 +157,7 @@ func GetInstanceStatus(ctx context.Context, apiClient PostgresFlexClient, projec } func GetUserName(ctx context.Context, apiClient PostgresFlexClient, projectId, region, instanceId, userId string) (string, error) { - resp, err := apiClient.GetUserExecute(ctx, projectId, region, instanceId, userId) + resp, err := apiClient.GetUser(ctx, projectId, region, instanceId, userId).Execute() if err != nil { return "", fmt.Errorf("get PostgreSQL Flex user: %w", err) } diff --git a/internal/pkg/services/postgresflex/utils/utils_test.go b/internal/pkg/services/postgresflex/utils/utils_test.go index 346debe49..34a0d4b9c 100644 --- a/internal/pkg/services/postgresflex/utils/utils_test.go +++ b/internal/pkg/services/postgresflex/utils/utils_test.go @@ -9,7 +9,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/postgresflex" + postgresflex "github.com/stackitcloud/stackit-sdk-go/services/postgresflex/v2api" ) var ( @@ -25,7 +25,7 @@ const ( testRegion = "eu01" ) -type postgresFlexClientMocked struct { +type mockSettings struct { listVersionsFails bool listVersionsResp *postgresflex.ListVersionsResponse getInstanceFails bool @@ -34,25 +34,27 @@ type postgresFlexClientMocked struct { getUserResp *postgresflex.GetUserResponse } -func (m *postgresFlexClientMocked) ListVersionsExecute(_ context.Context, _, _ string) (*postgresflex.ListVersionsResponse, error) { - if m.listVersionsFails { - return nil, fmt.Errorf("could not list versions") - } - return m.listVersionsResp, nil -} - -func (m *postgresFlexClientMocked) GetInstanceExecute(_ context.Context, _, _, _ string) (*postgresflex.InstanceResponse, error) { - if m.getInstanceFails { - return nil, fmt.Errorf("could not get instance") - } - return m.getInstanceResp, nil -} - -func (m *postgresFlexClientMocked) GetUserExecute(_ context.Context, _, _, _, _ string) (*postgresflex.GetUserResponse, error) { - if m.getUserFails { - return nil, fmt.Errorf("could not get user") +func newAPIMockClient(s mockSettings) postgresflex.DefaultAPI { + return postgresflex.DefaultAPIServiceMock{ + ListVersionsExecuteMock: utils.Ptr(func(_ postgresflex.ApiListVersionsRequest) (*postgresflex.ListVersionsResponse, error) { + if s.listVersionsFails { + return nil, fmt.Errorf("could not list versions") + } + return s.listVersionsResp, nil + }), + GetInstanceExecuteMock: utils.Ptr(func(_ postgresflex.ApiGetInstanceRequest) (*postgresflex.InstanceResponse, error) { + if s.getInstanceFails { + return nil, fmt.Errorf("could not get instance") + } + return s.getInstanceResp, nil + }), + GetUserExecuteMock: utils.Ptr(func(_ postgresflex.ApiGetUserRequest) (*postgresflex.GetUserResponse, error) { + if s.getUserFails { + return nil, fmt.Errorf("could not get user") + } + return s.getUserResp, nil + }), } - return m.getUserResp, nil } func TestValidateStorage(t *testing.T) { @@ -68,7 +70,7 @@ func TestValidateStorage(t *testing.T) { storageClass: utils.Ptr("foo"), storageSize: utils.Ptr(int64(10)), storages: &postgresflex.ListStoragesResponse{ - StorageClasses: &[]string{"bar-1", "bar-2", "foo"}, + StorageClasses: []string{"bar-1", "bar-2", "foo"}, StorageRange: &postgresflex.StorageRange{ Min: utils.Ptr(int64(5)), Max: utils.Ptr(int64(20)), @@ -88,7 +90,7 @@ func TestValidateStorage(t *testing.T) { storageClass: utils.Ptr("foo"), storageSize: utils.Ptr(int64(1)), storages: &postgresflex.ListStoragesResponse{ - StorageClasses: &[]string{"bar-1", "bar-2", "foo"}, + StorageClasses: []string{"bar-1", "bar-2", "foo"}, StorageRange: &postgresflex.StorageRange{ Min: utils.Ptr(int64(5)), Max: utils.Ptr(int64(20)), @@ -101,7 +103,7 @@ func TestValidateStorage(t *testing.T) { storageClass: utils.Ptr("foo"), storageSize: utils.Ptr(int64(200)), storages: &postgresflex.ListStoragesResponse{ - StorageClasses: &[]string{"bar-1", "bar-2", "foo"}, + StorageClasses: []string{"bar-1", "bar-2", "foo"}, StorageRange: &postgresflex.StorageRange{ Min: utils.Ptr(int64(5)), Max: utils.Ptr(int64(20)), @@ -114,7 +116,7 @@ func TestValidateStorage(t *testing.T) { storageClass: utils.Ptr("foo"), storageSize: utils.Ptr(int64(5)), storages: &postgresflex.ListStoragesResponse{ - StorageClasses: &[]string{"bar-1", "bar-2", "foo"}, + StorageClasses: []string{"bar-1", "bar-2", "foo"}, StorageRange: &postgresflex.StorageRange{ Min: utils.Ptr(int64(5)), Max: utils.Ptr(int64(20)), @@ -127,7 +129,7 @@ func TestValidateStorage(t *testing.T) { storageClass: utils.Ptr("foo"), storageSize: utils.Ptr(int64(20)), storages: &postgresflex.ListStoragesResponse{ - StorageClasses: &[]string{"bar-1", "bar-2", "foo"}, + StorageClasses: []string{"bar-1", "bar-2", "foo"}, StorageRange: &postgresflex.StorageRange{ Min: utils.Ptr(int64(5)), Max: utils.Ptr(int64(20)), @@ -140,7 +142,7 @@ func TestValidateStorage(t *testing.T) { storageClass: utils.Ptr("foo"), storageSize: utils.Ptr(int64(10)), storages: &postgresflex.ListStoragesResponse{ - StorageClasses: &[]string{"bar-1", "bar-2", "bar-3"}, + StorageClasses: []string{"bar-1", "bar-2", "bar-3"}, StorageRange: &postgresflex.StorageRange{ Min: utils.Ptr(int64(5)), Max: utils.Ptr(int64(20)), @@ -167,13 +169,13 @@ func TestValidateFlavorId(t *testing.T) { tests := []struct { description string flavorId string - flavors *[]postgresflex.Flavor + flavors []postgresflex.Flavor isValid bool }{ { description: "base", flavorId: "foo", - flavors: &[]postgresflex.Flavor{ + flavors: []postgresflex.Flavor{ {Id: utils.Ptr("bar-1")}, {Id: utils.Ptr("bar-2")}, {Id: utils.Ptr("foo")}, @@ -189,13 +191,13 @@ func TestValidateFlavorId(t *testing.T) { { description: "no flavors", flavorId: "foo", - flavors: &[]postgresflex.Flavor{}, + flavors: []postgresflex.Flavor{}, isValid: false, }, { description: "nil flavor id", flavorId: "foo", - flavors: &[]postgresflex.Flavor{ + flavors: []postgresflex.Flavor{ {Id: utils.Ptr("bar-1")}, {Id: nil}, {Id: utils.Ptr("foo")}, @@ -205,7 +207,7 @@ func TestValidateFlavorId(t *testing.T) { { description: "invalid flavor", flavorId: "foo", - flavors: &[]postgresflex.Flavor{ + flavors: []postgresflex.Flavor{ {Id: utils.Ptr("bar-1")}, {Id: utils.Ptr("bar-2")}, {Id: utils.Ptr("bar-3")}, @@ -232,7 +234,7 @@ func TestLoadFlavorId(t *testing.T) { description string cpu int64 ram int64 - flavors *[]postgresflex.Flavor + flavors []postgresflex.Flavor isValid bool expectedOutput *string }{ @@ -240,7 +242,7 @@ func TestLoadFlavorId(t *testing.T) { description: "base", cpu: 2, ram: 4, - flavors: &[]postgresflex.Flavor{ + flavors: []postgresflex.Flavor{ { Id: utils.Ptr("bar-1"), Cpu: utils.Ptr(int64(2)), @@ -271,14 +273,14 @@ func TestLoadFlavorId(t *testing.T) { description: "no flavors", cpu: 2, ram: 4, - flavors: &[]postgresflex.Flavor{}, + flavors: []postgresflex.Flavor{}, isValid: false, }, { description: "flavors with details missing", cpu: 2, ram: 4, - flavors: &[]postgresflex.Flavor{ + flavors: []postgresflex.Flavor{ { Id: utils.Ptr("bar-1"), Cpu: nil, @@ -302,7 +304,7 @@ func TestLoadFlavorId(t *testing.T) { description: "match with nil id", cpu: 2, ram: 4, - flavors: &[]postgresflex.Flavor{ + flavors: []postgresflex.Flavor{ { Id: utils.Ptr("bar-1"), Cpu: utils.Ptr(int64(2)), @@ -325,7 +327,7 @@ func TestLoadFlavorId(t *testing.T) { description: "invalid settings", cpu: 2, ram: 4, - flavors: &[]postgresflex.Flavor{ + flavors: []postgresflex.Flavor{ { Id: utils.Ptr("bar-1"), Cpu: utils.Ptr(int64(2)), @@ -368,29 +370,34 @@ func TestLoadFlavorId(t *testing.T) { func TestGetLatestPostgreSQLVersion(t *testing.T) { tests := []struct { - description string - listVersionsFails bool - listVersionsResp *postgresflex.ListVersionsResponse - isValid bool - expectedOutput string + description string + mockClientSettings mockSettings + isValid bool + expectedOutput string }{ { description: "base", - listVersionsResp: &postgresflex.ListVersionsResponse{ - Versions: &[]string{"8", "10", "9"}, + mockClientSettings: mockSettings{ + listVersionsResp: &postgresflex.ListVersionsResponse{ + Versions: []string{"8", "10", "9"}, + }, }, isValid: true, expectedOutput: "10", }, { - description: "get instance fails", - listVersionsFails: true, - isValid: false, + description: "get instance fails", + mockClientSettings: mockSettings{ + listVersionsFails: true, + }, + isValid: false, }, { description: "no versions", - listVersionsResp: &postgresflex.ListVersionsResponse{ - Versions: &[]string{}, + mockClientSettings: mockSettings{ + listVersionsResp: &postgresflex.ListVersionsResponse{ + Versions: []string{}, + }, }, isValid: false, }, @@ -398,12 +405,7 @@ func TestGetLatestPostgreSQLVersion(t *testing.T) { for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { - client := &postgresFlexClientMocked{ - listVersionsFails: tt.listVersionsFails, - listVersionsResp: tt.listVersionsResp, - } - - output, err := GetLatestPostgreSQLVersion(context.Background(), client, testProjectId, testRegion) + output, err := GetLatestPostgreSQLVersion(context.Background(), newAPIMockClient(tt.mockClientSettings), testProjectId, testRegion) if tt.isValid && err != nil { t.Errorf("failed on valid input") @@ -423,37 +425,35 @@ func TestGetLatestPostgreSQLVersion(t *testing.T) { func TestGetInstanceName(t *testing.T) { tests := []struct { - description string - getInstanceFails bool - getInstanceResp *postgresflex.InstanceResponse - isValid bool - expectedOutput string + description string + mockClientSettings mockSettings + isValid bool + expectedOutput string }{ { description: "base", - getInstanceResp: &postgresflex.InstanceResponse{ - Item: &postgresflex.Instance{ - Name: utils.Ptr(testInstanceName), + mockClientSettings: mockSettings{ + getInstanceResp: &postgresflex.InstanceResponse{ + Item: &postgresflex.Instance{ + Name: utils.Ptr(testInstanceName), + }, }, }, isValid: true, expectedOutput: testInstanceName, }, { - description: "get instance fails", - getInstanceFails: true, - isValid: false, + description: "get instance fails", + mockClientSettings: mockSettings{ + getInstanceFails: true, + }, + isValid: false, }, } for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { - client := &postgresFlexClientMocked{ - getInstanceFails: tt.getInstanceFails, - getInstanceResp: tt.getInstanceResp, - } - - output, err := GetInstanceName(context.Background(), client, testProjectId, testRegion, testInstanceId) + output, err := GetInstanceName(context.Background(), newAPIMockClient(tt.mockClientSettings), testProjectId, testRegion, testInstanceId) if tt.isValid && err != nil { t.Errorf("failed on valid input") @@ -473,37 +473,35 @@ func TestGetInstanceName(t *testing.T) { func TestGetInstanceStatus(t *testing.T) { tests := []struct { - description string - getInstanceFails bool - getInstanceResp *postgresflex.InstanceResponse - isValid bool - expectedOutput string + description string + mockClientSettings mockSettings + isValid bool + expectedOutput string }{ { description: "base", - getInstanceResp: &postgresflex.InstanceResponse{ - Item: &postgresflex.Instance{ - Status: utils.Ptr(testStatus), + mockClientSettings: mockSettings{ + getInstanceResp: &postgresflex.InstanceResponse{ + Item: &postgresflex.Instance{ + Status: utils.Ptr(testStatus), + }, }, }, isValid: true, expectedOutput: testStatus, }, { - description: "get instance fails", - getInstanceFails: true, - isValid: false, + description: "get instance fails", + mockClientSettings: mockSettings{ + getInstanceFails: true, + }, + isValid: false, }, } for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { - client := &postgresFlexClientMocked{ - getInstanceFails: tt.getInstanceFails, - getInstanceResp: tt.getInstanceResp, - } - - output, err := GetInstanceStatus(context.Background(), client, testProjectId, testRegion, testInstanceId) + output, err := GetInstanceStatus(context.Background(), newAPIMockClient(tt.mockClientSettings), testProjectId, testRegion, testInstanceId) if tt.isValid && err != nil { t.Errorf("failed on valid input") @@ -523,37 +521,35 @@ func TestGetInstanceStatus(t *testing.T) { func TestGetUserName(t *testing.T) { tests := []struct { - description string - getUserFails bool - getUserResp *postgresflex.GetUserResponse - isValid bool - expectedOutput string + description string + mockClientSettings mockSettings + isValid bool + expectedOutput string }{ { description: "base", - getUserResp: &postgresflex.GetUserResponse{ - Item: &postgresflex.UserResponse{ - Username: utils.Ptr(testUserName), + mockClientSettings: mockSettings{ + getUserResp: &postgresflex.GetUserResponse{ + Item: &postgresflex.UserResponse{ + Username: utils.Ptr(testUserName), + }, }, }, isValid: true, expectedOutput: testUserName, }, { - description: "get user fails", - getUserFails: true, - isValid: false, + description: "get user fails", + mockClientSettings: mockSettings{ + getUserFails: true, + }, + isValid: false, }, } for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { - client := &postgresFlexClientMocked{ - getUserFails: tt.getUserFails, - getUserResp: tt.getUserResp, - } - - output, err := GetUserName(context.Background(), client, testProjectId, testRegion, testInstanceId, testUserId) + output, err := GetUserName(context.Background(), newAPIMockClient(tt.mockClientSettings), testProjectId, testRegion, testInstanceId, testUserId) if tt.isValid && err != nil { t.Errorf("failed on valid input") @@ -574,7 +570,7 @@ func TestGetUserName(t *testing.T) { func TestGetInstanceType(t *testing.T) { tests := []struct { description string - numReplicas int64 + numReplicas int32 expectedOutput string isValid bool }{ From eb09bc874504767eb48720db51506dcb3e73e6b6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 21 Jul 2026 07:26:32 +0200 Subject: [PATCH 34/44] chore(deps): bump github.com/stackitcloud/stackit-sdk-go/services/iaas (#1481) Bumps [github.com/stackitcloud/stackit-sdk-go/services/iaas](https://github.com/stackitcloud/stackit-sdk-go) from 1.12.0 to 1.13.0. - [Release notes](https://github.com/stackitcloud/stackit-sdk-go/releases) - [Changelog](https://github.com/stackitcloud/stackit-sdk-go/blob/main/CHANGELOG.md) - [Commits](https://github.com/stackitcloud/stackit-sdk-go/compare/services/cdn/v1.12.0...services/cdn/v1.13.0) --- updated-dependencies: - dependency-name: github.com/stackitcloud/stackit-sdk-go/services/iaas dependency-version: 1.13.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 160310ab2..89aedac59 100644 --- a/go.mod +++ b/go.mod @@ -22,7 +22,7 @@ require ( github.com/stackitcloud/stackit-sdk-go/services/dns v0.21.0 github.com/stackitcloud/stackit-sdk-go/services/edge v0.4.3 github.com/stackitcloud/stackit-sdk-go/services/git v0.14.0 - github.com/stackitcloud/stackit-sdk-go/services/iaas v1.12.0 + github.com/stackitcloud/stackit-sdk-go/services/iaas v1.13.0 github.com/stackitcloud/stackit-sdk-go/services/intake v0.7.1 github.com/stackitcloud/stackit-sdk-go/services/logs v0.5.2 github.com/stackitcloud/stackit-sdk-go/services/mongodbflex v1.12.0 diff --git a/go.sum b/go.sum index a00946832..041ef8d7c 100644 --- a/go.sum +++ b/go.sum @@ -604,8 +604,8 @@ github.com/stackitcloud/stackit-sdk-go/services/edge v0.4.3 h1:TxChb2qbO82JiQEBY github.com/stackitcloud/stackit-sdk-go/services/edge v0.4.3/go.mod h1:KVWvQHb7CQLD9DzA4Np3WmakiCCsrHaCXvFEnOQ7nPk= github.com/stackitcloud/stackit-sdk-go/services/git v0.14.0 h1:VZBneGprCmHqckcSMPs3puBlK8rBpLMtYKmBktwdoVE= github.com/stackitcloud/stackit-sdk-go/services/git v0.14.0/go.mod h1:YZEL+gaK+ELn5E9VtK8yvz5RcmCBH+JkRpf6YbNVSbM= -github.com/stackitcloud/stackit-sdk-go/services/iaas v1.12.0 h1:H4V3H8qSKOaOalIrf4nAPDHhXnHYGs6SDGuK8Zj41Zo= -github.com/stackitcloud/stackit-sdk-go/services/iaas v1.12.0/go.mod h1:Ts06id0KejUlQWbpR+/rm+tKng6QkTuFV1VQTPJ4dA4= +github.com/stackitcloud/stackit-sdk-go/services/iaas v1.13.0 h1:PQZ6n71CMadLU3DjJxJXiPHdK9Bz4hMttBREQD6no34= +github.com/stackitcloud/stackit-sdk-go/services/iaas v1.13.0/go.mod h1:AbPN9BGkdjc+tVsXEX9Vr8BPDjdlDmG26K1FwCKZQVU= github.com/stackitcloud/stackit-sdk-go/services/intake v0.7.1 h1:7ZSrwps/zI41rl+xYkG4osld8cyAwssyl/UZ/Iu/F2g= github.com/stackitcloud/stackit-sdk-go/services/intake v0.7.1/go.mod h1:ZIvwBZwEMFO+YfJLCNXqabslI0Fp9zxV7ZBwlZjk7uE= github.com/stackitcloud/stackit-sdk-go/services/kms v1.11.0 h1:OrUaDypQNr1nOXZfVQXCwUpN4YhR5y0vtvYi9/Ogoi4= From bc0a6f259cee22370a88a3d8109bdd1bca38343a Mon Sep 17 00:00:00 2001 From: Philipp Date: Tue, 21 Jul 2026 15:08:57 +0200 Subject: [PATCH 35/44] feat(auth): add Workload Identity Federation (OIDC) support (#1424) relates to STACKITCLI-337 --- AUTHENTICATION.md | 25 +++ docs/stackit_auth_activate-service-account.md | 4 + .../activate_service_account.go | 63 ++++++ .../activate_service_account_test.go | 37 ++++ internal/pkg/auth/auth.go | 33 +++ internal/pkg/auth/auth_test.go | 1 + internal/pkg/auth/oidc.go | 80 +++++++ internal/pkg/auth/oidc_test.go | 200 ++++++++++++++++++ internal/pkg/auth/service_account.go | 15 ++ internal/pkg/auth/service_account_test.go | 89 ++++++++ 10 files changed, 547 insertions(+) create mode 100644 internal/pkg/auth/oidc.go create mode 100644 internal/pkg/auth/oidc_test.go diff --git a/AUTHENTICATION.md b/AUTHENTICATION.md index 7da16657f..21cfd2833 100644 --- a/AUTHENTICATION.md +++ b/AUTHENTICATION.md @@ -106,3 +106,28 @@ Using this flow is less secure since the token is long-lived. You can provide th 1. Providing the flag `--service-account-token` 2. Setting the environment variable `STACKIT_SERVICE_ACCOUNT_TOKEN` 3. Setting `STACKIT_SERVICE_ACCOUNT_TOKEN` in the credentials file (see above) + +### Workload Identity Federation (OIDC) + +1. Create a service account trusted relation in the STACKIT Portal: + + - Navigate to `Service Accounts` → Select account → `Federated Identity Providers` + - [Configure a Federated Identity Provider](https://docs.stackit.cloud/platform/access-and-identity/service-accounts/how-tos/manage-service-account-federations/#create-a-federated-identity-provider) and the required assertions. For detailed assertion configuration per platform, see the [Terraform provider WIF guide](https://github.com/stackitcloud/terraform-provider-stackit/blob/main/docs/guides/workload_identity_federation.md). + +2. Configure authentication for `stackit auth activate-service-account` using one of the options below: + + - Explicit flag: `--use-oidc` (takes precedence) + - Environment variable: `STACKIT_USE_OIDC=1` + + If both are provided, the explicit flag value is used. + + Example using environment variables: + + ```bash + STACKIT_USE_OIDC=1 + STACKIT_SERVICE_ACCOUNT_EMAIL=my-sa@sa.stackit.cloud + # Optional: provide the OIDC token directly instead of auto-detecting it from the CI environment + STACKIT_SERVICE_ACCOUNT_FEDERATED_TOKEN= + # Optional: provide a file path containing the OIDC token + STACKIT_FEDERATED_TOKEN_FILE=/path/to/oidc-token.jwt + ``` diff --git a/docs/stackit_auth_activate-service-account.md b/docs/stackit_auth_activate-service-account.md index df85aa682..a38eaccba 100644 --- a/docs/stackit_auth_activate-service-account.md +++ b/docs/stackit_auth_activate-service-account.md @@ -26,6 +26,9 @@ stackit auth activate-service-account [flags] Only print the corresponding access token by using the service account token. This access token can be stored as environment variable (STACKIT_ACCESS_TOKEN) in order to be used for all subsequent commands. $ stackit auth activate-service-account --service-account-token my-service-account-token --only-print-access-token + + Authenticate via Workload Identity Federation (OIDC) and print the short-lived access token. Use --use-oidc to explicitly enable OIDC (takes precedence over STACKIT_USE_OIDC); no service account key file is required. + $ STACKIT_SERVICE_ACCOUNT_EMAIL=ci@sa.stackit.cloud stackit auth activate-service-account --use-oidc --only-print-access-token ``` ### Options @@ -36,6 +39,7 @@ stackit auth activate-service-account [flags] --private-key-path string RSA private key path. It takes precedence over the private key included in the service account key, if present --service-account-key-path string Service account key path --service-account-token string Service account long-lived access token + --use-oidc Use Workload Identity Federation (OIDC). If set, this takes precedence over STACKIT_USE_OIDC ``` ### Options inherited from parent commands diff --git a/internal/cmd/auth/activate-service-account/activate_service_account.go b/internal/cmd/auth/activate-service-account/activate_service_account.go index b69de90d7..aa17b6def 100644 --- a/internal/cmd/auth/activate-service-account/activate_service_account.go +++ b/internal/cmd/auth/activate-service-account/activate_service_account.go @@ -25,6 +25,7 @@ const ( serviceAccountTokenFlag = "service-account-token" serviceAccountKeyPathFlag = "service-account-key-path" privateKeyPathFlag = "private-key-path" + useOIDCFlag = "use-oidc" onlyPrintAccessTokenFlag = "only-print-access-token" // #nosec G101 ) @@ -32,6 +33,7 @@ type inputModel struct { ServiceAccountToken string ServiceAccountKeyPath string PrivateKeyPath string + UseOIDC *bool OnlyPrintAccessToken bool } @@ -59,6 +61,10 @@ func NewCmd(params *types.CmdParams) *cobra.Command { `Only print the corresponding access token by using the service account token. This access token can be stored as environment variable (STACKIT_ACCESS_TOKEN) in order to be used for all subsequent commands.`, "$ stackit auth activate-service-account --service-account-token my-service-account-token --only-print-access-token", ), + examples.NewExample( + `Authenticate via Workload Identity Federation (OIDC) and print the short-lived access token. Use --use-oidc to explicitly enable OIDC (takes precedence over STACKIT_USE_OIDC); no service account key file is required.`, + "$ STACKIT_SERVICE_ACCOUNT_EMAIL=ci@sa.stackit.cloud stackit auth activate-service-account --use-oidc --only-print-access-token", + ), ), RunE: func(cmd *cobra.Command, args []string) error { model, err := parseInput(params.Printer, cmd, args) @@ -66,6 +72,11 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return err } + // use workload identity federation (OIDC) if enabled; no key file required + if auth.IsOIDCEnabledWithOverride(model.UseOIDC) { + return runOIDCMode(params, model) + } + tokenCustomEndpoint := viper.GetString(config.TokenCustomEndpointKey) if !model.OnlyPrintAccessToken { if err := storeCustomEndpoint(tokenCustomEndpoint); err != nil { @@ -115,6 +126,7 @@ func configureFlags(cmd *cobra.Command) { cmd.Flags().String(serviceAccountTokenFlag, "", "Service account long-lived access token") cmd.Flags().String(serviceAccountKeyPathFlag, "", "Service account key path") cmd.Flags().String(privateKeyPathFlag, "", "RSA private key path. It takes precedence over the private key included in the service account key, if present") + cmd.Flags().Bool(useOIDCFlag, false, "Use Workload Identity Federation (OIDC). If set, this takes precedence over STACKIT_USE_OIDC") cmd.Flags().Bool(onlyPrintAccessTokenFlag, false, "If this is set to true the credentials are not stored in either the keyring or a file") } @@ -125,6 +137,10 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, PrivateKeyPath: flags.FlagToStringValue(p, cmd, privateKeyPathFlag), OnlyPrintAccessToken: flags.FlagToBoolValue(p, cmd, onlyPrintAccessTokenFlag), } + if cmd.Flags().Changed(useOIDCFlag) { + useOIDC := flags.FlagToBoolValue(p, cmd, useOIDCFlag) + model.UseOIDC = &useOIDC + } p.DebugInputModel(model) return &model, nil @@ -133,3 +149,50 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, func storeCustomEndpoint(tokenCustomEndpoint string) error { return auth.SetAuthField(auth.TOKEN_CUSTOM_ENDPOINT, tokenCustomEndpoint) } + +func runOIDCMode(params *types.CmdParams, model *inputModel) error { + email := auth.OIDCServiceAccountEmail() + if email == "" { + return fmt.Errorf( + "env var %s must be set when %s is enabled", + auth.EnvServiceAccountEmail, auth.EnvUseOIDC, + ) + } + + tokenFunc, err := auth.OIDCTokenFunc() + if err != nil { + return err + } + + tokenCustomEndpoint := viper.GetString(config.TokenCustomEndpointKey) + + wifCfg := &sdkConfig.Configuration{ + WorkloadIdentityFederation: true, + ServiceAccountEmail: email, + ServiceAccountFederatedTokenFunc: tokenFunc, + TokenCustomUrl: tokenCustomEndpoint, + } + + rt, err := sdkAuth.SetupAuth(wifCfg) + if err != nil { + params.Printer.Debug(print.ErrorLevel, "setup workload identity federation auth: %v", err) + return &cliErr.ActivateServiceAccountError{} + } + + // credentials are never written to disk in OIDC mode + saEmail, accessToken, err := auth.AuthenticateServiceAccount(params.Printer, rt, true) + if err != nil { + var activateErr *cliErr.ActivateServiceAccountError + if !errors.As(err, &activateErr) { + return fmt.Errorf("authenticate service account via workload identity federation: %w", err) + } + return err + } + + if model.OnlyPrintAccessToken { + params.Printer.Outputf("%s\n", accessToken) + } else { + params.Printer.Outputf("Authenticated via Workload Identity Federation.\nService account email: %s\n", saEmail) + } + return nil +} diff --git a/internal/cmd/auth/activate-service-account/activate_service_account_test.go b/internal/cmd/auth/activate-service-account/activate_service_account_test.go index 22a777ac4..be10fc8e2 100644 --- a/internal/cmd/auth/activate-service-account/activate_service_account_test.go +++ b/internal/cmd/auth/activate-service-account/activate_service_account_test.go @@ -4,6 +4,7 @@ import ( "testing" "github.com/stackitcloud/stackit-cli/internal/pkg/testutils" + "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/spf13/viper" "github.com/zalando/go-keyring" @@ -19,6 +20,7 @@ func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]st serviceAccountTokenFlag: "token", serviceAccountKeyPathFlag: "sa_key", privateKeyPathFlag: "private_key", + useOIDCFlag: "true", onlyPrintAccessTokenFlag: "true", } for _, mod := range mods { @@ -32,6 +34,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { ServiceAccountToken: "token", ServiceAccountKeyPath: "sa_key", PrivateKeyPath: "private_key", + UseOIDC: utils.Ptr(true), OnlyPrintAccessToken: true, } for _, mod := range mods { @@ -65,6 +68,7 @@ func TestParseInput(t *testing.T) { ServiceAccountToken: "", ServiceAccountKeyPath: "", PrivateKeyPath: "", + UseOIDC: nil, }, }, { @@ -80,8 +84,29 @@ func TestParseInput(t *testing.T) { ServiceAccountToken: "", ServiceAccountKeyPath: "", PrivateKeyPath: "", + UseOIDC: nil, }, }, + { + description: "use_oidc_true", + flagValues: fixtureFlagValues(func(flagValues map[string]string) { + flagValues[useOIDCFlag] = "true" + }), + isValid: true, + expectedModel: fixtureInputModel(func(model *inputModel) { + model.UseOIDC = utils.Ptr(true) + }), + }, + { + description: "use_oidc_false", + flagValues: fixtureFlagValues(func(flagValues map[string]string) { + flagValues[useOIDCFlag] = "false" + }), + isValid: true, + expectedModel: fixtureInputModel(func(model *inputModel) { + model.UseOIDC = utils.Ptr(false) + }), + }, { description: "invalid_flag", flagValues: fixtureFlagValues(func(flagValues map[string]string) { @@ -101,6 +126,18 @@ func TestParseInput(t *testing.T) { model.OnlyPrintAccessToken = false }), }, + { + description: "default value UseOIDC", + flagValues: fixtureFlagValues( + func(flagValues map[string]string) { + delete(flagValues, useOIDCFlag) + }, + ), + isValid: true, + expectedModel: fixtureInputModel(func(model *inputModel) { + model.UseOIDC = nil + }), + }, } for _, tt := range tests { diff --git a/internal/pkg/auth/auth.go b/internal/pkg/auth/auth.go index 685a1737a..3d241ed9a 100644 --- a/internal/pkg/auth/auth.go +++ b/internal/pkg/auth/auth.go @@ -12,6 +12,7 @@ import ( "github.com/golang-jwt/jwt/v5" "github.com/spf13/viper" + sdkAuth "github.com/stackitcloud/stackit-sdk-go/core/auth" sdkConfig "github.com/stackitcloud/stackit-sdk-go/core/config" ) @@ -33,6 +34,38 @@ func AuthenticationConfig(p *print.Printer, reauthorizeUserRoutine func(p *print return authCfgOption, nil } + // use workload identity federation (OIDC) if enabled; takes priority over stored flows + if IsOIDCEnabled() { + p.Debug(print.DebugLevel, "authenticating using workload identity federation (OIDC)") + + email := OIDCServiceAccountEmail() + if email == "" { + return nil, fmt.Errorf( + "env var %s must be set when %s is enabled", + EnvServiceAccountEmail, EnvUseOIDC, + ) + } + + tokenFunc, err := OIDCTokenFunc() + if err != nil { + return nil, err + } + + wifCfg := &sdkConfig.Configuration{ + WorkloadIdentityFederation: true, + ServiceAccountEmail: email, + ServiceAccountFederatedTokenFunc: tokenFunc, + TokenCustomUrl: viper.GetString(config.TokenCustomEndpointKey), + } + + rt, err := sdkAuth.WorkloadIdentityFederationAuth(wifCfg) + if err != nil { + return nil, fmt.Errorf("initialize workload identity federation: %w", err) + } + + return sdkConfig.WithCustomAuth(rt), nil + } + flow, err := GetAuthFlow() if err != nil { return nil, fmt.Errorf("get authentication flow: %w", err) diff --git a/internal/pkg/auth/auth_test.go b/internal/pkg/auth/auth_test.go index e29b482f9..192645d21 100644 --- a/internal/pkg/auth/auth_test.go +++ b/internal/pkg/auth/auth_test.go @@ -155,6 +155,7 @@ func TestAuthenticationConfig(t *testing.T) { for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { + t.Setenv(EnvUseOIDC, "") // ensure OIDC mode is off for these tests keyring.MockInit() timestamp := time.Now().Add(24 * time.Hour) authFields := make(map[authFieldKey]string) diff --git a/internal/pkg/auth/oidc.go b/internal/pkg/auth/oidc.go new file mode 100644 index 000000000..38584687e --- /dev/null +++ b/internal/pkg/auth/oidc.go @@ -0,0 +1,80 @@ +package auth + +import ( + "context" + "fmt" + "os" + + "github.com/stackitcloud/stackit-sdk-go/core/oidcadapters" +) + +const ( + EnvUseOIDC = "STACKIT_USE_OIDC" + EnvServiceAccountEmail = "STACKIT_SERVICE_ACCOUNT_EMAIL" + EnvServiceAccountFederatedToken = "STACKIT_SERVICE_ACCOUNT_FEDERATED_TOKEN" //nolint:gosec // linter false positive + EnvFederatedTokenFile = "STACKIT_FEDERATED_TOKEN_FILE" //nolint:gosec // linter false positive + EnvGitHubRequestURL = "ACTIONS_ID_TOKEN_REQUEST_URL" + EnvGitHubRequestToken = "ACTIONS_ID_TOKEN_REQUEST_TOKEN" //nolint:gosec // linter false positive + EnvAzureOIDCRequestURI = "SYSTEM_OIDCREQUESTURI" + EnvAzureAccessToken = "SYSTEM_ACCESSTOKEN" //nolint:gosec // linter false positive +) + +func IsOIDCEnabled() bool { + return os.Getenv(EnvUseOIDC) == "1" +} + +// IsOIDCEnabledWithOverride resolves OIDC mode using explicit input first and env fallback. +// If useOIDC is not nil, its value is used directly; otherwise STACKIT_USE_OIDC is evaluated. +func IsOIDCEnabledWithOverride(useOIDC *bool) bool { + if useOIDC != nil { + return *useOIDC + } + + return IsOIDCEnabled() +} + +func OIDCServiceAccountEmail() string { + return os.Getenv(EnvServiceAccountEmail) +} + +// TokenFunc returns the OIDCTokenFunc to use for Workload Identity Federation. +// It checks the following token sources in order: STACKIT_SERVICE_ACCOUNT_FEDERATED_TOKEN, +// STACKIT_FEDERATED_TOKEN_FILE, GitHub Actions (ACTIONS_ID_TOKEN_REQUEST_URL + +// ACTIONS_ID_TOKEN_REQUEST_TOKEN), and Azure DevOps (SYSTEM_OIDCREQUESTURI + SYSTEM_ACCESSTOKEN). +// Returns an error if no source is detected. +func OIDCTokenFunc() (oidcadapters.OIDCTokenFunc, error) { + // static token provided directly via env var + if token := os.Getenv(EnvServiceAccountFederatedToken); token != "" { + return func(_ context.Context) (string, error) { + return token, nil + }, nil + } + + // token read from filesystem path via env var + if tokenFilePath := os.Getenv(EnvFederatedTokenFile); tokenFilePath != "" { + return oidcadapters.ReadJWTFromFileSystem(tokenFilePath), nil + } + + // GitHub Actions + if ghURL := os.Getenv(EnvGitHubRequestURL); ghURL != "" { + if ghToken := os.Getenv(EnvGitHubRequestToken); ghToken != "" { + return oidcadapters.RequestGHOIDCToken(ghURL, ghToken), nil + } + } + + // Azure DevOps + if adoURL := os.Getenv(EnvAzureOIDCRequestURI); adoURL != "" { + if adoToken := os.Getenv(EnvAzureAccessToken); adoToken != "" { + return oidcadapters.RequestAzureDevOpsOIDCToken(adoURL, adoToken, ""), nil + } + } + + return nil, fmt.Errorf( + "%s is enabled but no OIDC token source was detected\n"+ + "Provide the token via %s or %s, or run in a supported CI environment:\n"+ + " - GitHub Actions: grant 'id-token: write' permission; %s and %s are set automatically by the runner\n"+ + " - Azure DevOps: pass 'SYSTEM_ACCESSTOKEN: $(System.AccessToken)' in your pipeline step", + EnvUseOIDC, EnvServiceAccountFederatedToken, EnvFederatedTokenFile, + EnvGitHubRequestURL, EnvGitHubRequestToken, + ) +} diff --git a/internal/pkg/auth/oidc_test.go b/internal/pkg/auth/oidc_test.go new file mode 100644 index 000000000..12e762980 --- /dev/null +++ b/internal/pkg/auth/oidc_test.go @@ -0,0 +1,200 @@ +package auth_test + +import ( + "context" + "encoding/json" + "net/http" + "net/http/httptest" + "testing" + + "github.com/stackitcloud/stackit-cli/internal/pkg/auth" + "github.com/stackitcloud/stackit-cli/internal/pkg/utils" +) + +func TestIsEnabled(t *testing.T) { + tests := []struct { + value string + expected bool + }{ + {"1", true}, + {"0", false}, + {"", false}, + {"true", false}, + {"yes", false}, + {"random", false}, + } + for _, tt := range tests { + t.Run(tt.value, func(t *testing.T) { + t.Setenv(auth.EnvUseOIDC, tt.value) + got := auth.IsOIDCEnabled() + if got != tt.expected { + t.Errorf("IsOIDCEnabled() = %v, want %v (env=%q)", got, tt.expected, tt.value) + } + }) + } +} + +func TestIsEnabled_Unset(t *testing.T) { + // When the env var is not set at all IsEnabled must return false + t.Setenv(auth.EnvUseOIDC, "") + if auth.IsOIDCEnabled() { + t.Error("IsOIDCEnabled() = true, want false when env var is empty") + } +} + +func TestIsOIDCEnabledWithOverride(t *testing.T) { + tests := []struct { + description string + envUseOIDC string + override *bool + expected bool + }{ + { + description: "uses env when override is nil", + envUseOIDC: "1", + override: nil, + expected: true, + }, + { + description: "override true wins over env false", + envUseOIDC: "0", + override: utils.Ptr(true), + expected: true, + }, + { + description: "override false wins over env true", + envUseOIDC: "1", + override: utils.Ptr(false), + expected: false, + }, + } + + for _, tt := range tests { + t.Run(tt.description, func(t *testing.T) { + t.Setenv(auth.EnvUseOIDC, tt.envUseOIDC) + + got := auth.IsOIDCEnabledWithOverride(tt.override) + if got != tt.expected { + t.Errorf("IsOIDCEnabledWithOverride() = %v, want %v", got, tt.expected) + } + }) + } +} + +func TestServiceAccountEmail(t *testing.T) { + const want = "ci@sa.stackit.cloud" + t.Setenv(auth.EnvServiceAccountEmail, want) + if got := auth.OIDCServiceAccountEmail(); got != want { + t.Errorf("OIDCServiceAccountEmail() = %q, want %q", got, want) + } +} + +func TestTokenFunc_StaticToken(t *testing.T) { + const want = "my-static-oidc-token" + t.Setenv(auth.EnvServiceAccountFederatedToken, want) + // ensure GitHub / Azure vars are absent so we hit the static path first + t.Setenv(auth.EnvGitHubRequestURL, "") + t.Setenv(auth.EnvGitHubRequestToken, "") + t.Setenv(auth.EnvAzureOIDCRequestURI, "") + t.Setenv(auth.EnvAzureAccessToken, "") + t.Setenv(auth.EnvFederatedTokenFile, "") + + fn, err := auth.OIDCTokenFunc() + if err != nil { + t.Fatalf("OIDCTokenFunc() unexpected error: %v", err) + } + got, err := fn(context.Background()) + if err != nil { + t.Fatalf("fn() unexpected error: %v", err) + } + if got != want { + t.Errorf("fn() = %q, want %q", got, want) + } +} + +func TestTokenFunc_GitHubActions(t *testing.T) { + // Spin up a fake GitHub OIDC endpoint that matches the SDK's expected format. + srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { + w.Header().Set("Content-Type", "application/json") + _ = json.NewEncoder(w).Encode(map[string]string{"value": "gh-oidc-token"}) + })) + defer srv.Close() + + t.Setenv(auth.EnvServiceAccountFederatedToken, "") + t.Setenv(auth.EnvFederatedTokenFile, "") + t.Setenv(auth.EnvGitHubRequestURL, srv.URL) + t.Setenv(auth.EnvGitHubRequestToken, "gh-bearer-token") + t.Setenv(auth.EnvAzureOIDCRequestURI, "") + t.Setenv(auth.EnvAzureAccessToken, "") + + fn, err := auth.OIDCTokenFunc() + if err != nil { + t.Fatalf("OIDCTokenFunc() unexpected error: %v", err) + } + got, err := fn(context.Background()) + if err != nil { + t.Fatalf("fn() unexpected error: %v", err) + } + if got != "gh-oidc-token" { + t.Errorf("fn() = %q, want %q", got, "gh-oidc-token") + } +} + +func TestTokenFunc_AzureDevOps(t *testing.T) { + // Spin up a fake Azure DevOps OIDC endpoint that matches the SDK's expected format. + srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { + w.Header().Set("Content-Type", "application/json") + tok := "ado-oidc-token" + _ = json.NewEncoder(w).Encode(map[string]*string{"oidcToken": &tok}) + })) + defer srv.Close() + + t.Setenv(auth.EnvServiceAccountFederatedToken, "") + t.Setenv(auth.EnvFederatedTokenFile, "") + t.Setenv(auth.EnvGitHubRequestURL, "") + t.Setenv(auth.EnvGitHubRequestToken, "") + t.Setenv(auth.EnvAzureOIDCRequestURI, srv.URL) + t.Setenv(auth.EnvAzureAccessToken, "ado-access-token") + + fn, err := auth.OIDCTokenFunc() + if err != nil { + t.Fatalf("OIDCTokenFunc() unexpected error: %v", err) + } + got, err := fn(context.Background()) + if err != nil { + t.Fatalf("fn() unexpected error: %v", err) + } + if got != "ado-oidc-token" { + t.Errorf("fn() = %q, want %q", got, "ado-oidc-token") + } +} + +func TestTokenFunc_NoSource(t *testing.T) { + // All env vars absent → must return an actionable error, no panic. + t.Setenv(auth.EnvServiceAccountFederatedToken, "") + t.Setenv(auth.EnvFederatedTokenFile, "") + t.Setenv(auth.EnvGitHubRequestURL, "") + t.Setenv(auth.EnvGitHubRequestToken, "") + t.Setenv(auth.EnvAzureOIDCRequestURI, "") + t.Setenv(auth.EnvAzureAccessToken, "") + + _, err := auth.OIDCTokenFunc() + if err == nil { + t.Fatal("OIDCTokenFunc() expected error when no OIDC source is available, got nil") + } +} + +func TestTokenFunc_GitHubURL_NoToken(t *testing.T) { + // URL present but token absent → should fall through to Azure / error. + t.Setenv(auth.EnvServiceAccountFederatedToken, "") + t.Setenv(auth.EnvFederatedTokenFile, "") + t.Setenv(auth.EnvGitHubRequestURL, "https://example.com") + t.Setenv(auth.EnvGitHubRequestToken, "") + t.Setenv(auth.EnvAzureOIDCRequestURI, "") + t.Setenv(auth.EnvAzureAccessToken, "") + + _, err := auth.OIDCTokenFunc() + if err == nil { + t.Fatal("OIDCTokenFunc() expected error when GitHub token is missing, got nil") + } +} diff --git a/internal/pkg/auth/service_account.go b/internal/pkg/auth/service_account.go index 8aecaf0b4..dd02dc81d 100644 --- a/internal/pkg/auth/service_account.go +++ b/internal/pkg/auth/service_account.go @@ -22,6 +22,10 @@ type tokenFlowInterface interface { RoundTrip(*http.Request) (*http.Response, error) } +type wifFlowInterface interface { + GetAccessToken() (string, error) +} + type keyFlowWithStorage struct { keyFlow *clients.KeyFlow } @@ -62,6 +66,17 @@ func AuthenticateServiceAccount(p *print.Printer, rt http.RoundTripper, disableW authFlowType = AUTH_FLOW_SERVICE_ACCOUNT_TOKEN authFields[ACCESS_TOKEN] = flow.GetConfig().ServiceAccountToken + case wifFlowInterface: + p.Debug(print.DebugLevel, "authenticating using workload identity federation") + authFlowType = AUTH_FLOW_SERVICE_ACCOUNT_KEY + + accessToken, err := flow.GetAccessToken() + if err != nil { + p.Debug(print.ErrorLevel, "get workload identity access token: %v", err) + return "", "", &errors.ActivateServiceAccountError{} + } + authFields[ACCESS_TOKEN] = accessToken + disableWriting = true default: return "", "", fmt.Errorf("could not authenticate using any of the supported authentication flows (key and token): please report this issue") } diff --git a/internal/pkg/auth/service_account_test.go b/internal/pkg/auth/service_account_test.go index 328fb6e48..250285f65 100644 --- a/internal/pkg/auth/service_account_test.go +++ b/internal/pkg/auth/service_account_test.go @@ -66,6 +66,22 @@ func (f *tokenFlowMocked) RoundTrip(*http.Request) (*http.Response, error) { return nil, nil } +type wifFlowMocked struct { + accessToken string + getAccessTokenFail bool +} + +func (f *wifFlowMocked) GetAccessToken() (string, error) { + if f.getAccessTokenFail { + return "", fmt.Errorf("mock WIF error") + } + return f.accessToken, nil +} + +func (f *wifFlowMocked) RoundTrip(*http.Request) (*http.Response, error) { + return nil, nil +} + func TestAuthenticateServiceAccount(t *testing.T) { tests := []struct { description string @@ -170,3 +186,76 @@ func TestAuthenticateServiceAccount(t *testing.T) { }) } } + +func TestAuthenticateServiceAccount_WIF(t *testing.T) { + // Build a signed test JWT that getEmailFromToken can parse. + testEmail := "ci@sa.stackit.cloud" + tok := jwt.NewWithClaims(jwt.SigningMethodHS256, &tokenClaims{ + Email: testEmail, + RegisteredClaims: jwt.RegisteredClaims{}, + }) + raw, err := tok.SignedString(accessTokenSigningKey) + if err != nil { + t.Fatalf("sign test token: %v", err) + } + + tests := []struct { + description string + accessToken string + getAccessTokenFail bool + disableWriting bool + isValid bool + }{ + { + description: "wif_success_no_credentials_written", + accessToken: raw, + disableWriting: false, // even when false, WIF forces no-write internally + isValid: true, + }, + { + description: "wif_get_access_token_fails", + getAccessTokenFail: true, + isValid: false, + }, + } + + for _, tt := range tests { + t.Run(tt.description, func(t *testing.T) { + keyring.MockInit() + config.InitConfig() + + flow := &wifFlowMocked{ + accessToken: tt.accessToken, + getAccessTokenFail: tt.getAccessTokenFail, + } + + params := testparams.NewTestParams() + email, _, err := AuthenticateServiceAccount(params.Printer, flow, tt.disableWriting) + + if !tt.isValid { + if err == nil { + t.Fatal("Expected error but no error was returned") + } + return + } + if err != nil { + t.Fatalf("Unexpected error: %v", err) + } + if email != testEmail { + t.Fatalf("email = %q, want %q", email, testEmail) + } + + // Verify no credentials were written to the keyring / file. + // After a WIF authentication, the auth storage should not contain a + // service account key or private key. + storedKey, _ := GetAuthField(SERVICE_ACCOUNT_KEY) + if storedKey != "" { + t.Errorf("SERVICE_ACCOUNT_KEY was written to storage in WIF mode, want empty") + } + storedPrivKey, _ := GetAuthField(PRIVATE_KEY) + if storedPrivKey != "" { + t.Errorf("PRIVATE_KEY was written to storage in WIF mode, want empty") + } + }) + } +} From fcdf9ab591c162ae59aef837d6be2fe9e84bd005 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 21 Jul 2026 17:37:33 +0200 Subject: [PATCH 36/44] chore(deps): bump golang.org/x/text from 0.36.0 to 0.40.0 (#1491) --- go.mod | 12 ++++++------ go.sum | 24 ++++++++++++------------ 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/go.mod b/go.mod index 89aedac59..11949757e 100644 --- a/go.mod +++ b/go.mod @@ -39,16 +39,16 @@ require ( github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex v1.11.0 github.com/stackitcloud/stackit-sdk-go/services/vpn v0.14.0 github.com/zalando/go-keyring v0.2.8 - golang.org/x/mod v0.34.0 + golang.org/x/mod v0.37.0 golang.org/x/oauth2 v0.36.0 golang.org/x/term v0.44.0 - golang.org/x/text v0.36.0 + golang.org/x/text v0.40.0 k8s.io/apimachinery v0.35.4 k8s.io/client-go v0.35.1 ) require ( - golang.org/x/net v0.52.0 // indirect + golang.org/x/net v0.56.0 // indirect golang.org/x/time v0.11.0 // indirect gopkg.in/inf.v0 v0.9.1 // indirect ) @@ -233,9 +233,9 @@ require ( go.yaml.in/yaml/v2 v2.4.3 // indirect go.yaml.in/yaml/v3 v3.0.4 // indirect golang.org/x/exp/typeparams v0.0.0-20260209203927-2842357ff358 // indirect - golang.org/x/sync v0.20.0 // indirect - golang.org/x/telemetry v0.0.0-20260311193753-579e4da9a98c // indirect - golang.org/x/tools v0.43.0 // indirect + golang.org/x/sync v0.22.0 // indirect + golang.org/x/telemetry v0.0.0-20260625142307-59b4966ccb57 // indirect + golang.org/x/tools v0.47.0 // indirect google.golang.org/protobuf v1.36.8 // indirect honnef.co/go/tools v0.7.0 // indirect k8s.io/kube-openapi v0.0.0-20250910181357-589584f1c912 // indirect diff --git a/go.sum b/go.sum index 041ef8d7c..aac834ef2 100644 --- a/go.sum +++ b/go.sum @@ -789,8 +789,8 @@ golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91 golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.13.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= -golang.org/x/mod v0.34.0 h1:xIHgNUUnW6sYkcM5Jleh05DvLOtwc6RitGHbDk4akRI= -golang.org/x/mod v0.34.0/go.mod h1:ykgH52iCZe79kzLLMhyCUzhMci+nQj+0XkbXpNYtVjY= +golang.org/x/mod v0.37.0 h1:vF1DjpVEshcIqoEaauuHebaLk1O1forxjxBaVn884JQ= +golang.org/x/mod v0.37.0/go.mod h1:m8S8VeM9r4dzDwjrKO0a1sZP3YjeMamRRlD+fmR2Q/0= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -829,8 +829,8 @@ golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk= golang.org/x/net v0.16.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= -golang.org/x/net v0.52.0 h1:He/TN1l0e4mmR3QqHMT2Xab3Aj3L9qjbhRm78/6jrW0= -golang.org/x/net v0.52.0/go.mod h1:R1MAz7uMZxVMualyPXb+VaqGSa3LIaUqk0eEt3w36Sw= +golang.org/x/net v0.56.0 h1:Rw8j/hFzGvJUZwNBXnAtf5sVDVt+65SK2C7IxCxZt5o= +golang.org/x/net v0.56.0/go.mod h1:D3Ku6r+V6JROoZK144D2XfMHFcMq/0zSfLelVTCFKec= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -854,8 +854,8 @@ golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= golang.org/x/sync v0.4.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= -golang.org/x/sync v0.20.0 h1:e0PTpb7pjO8GAtTs2dQ6jYa5BWYlMuX047Dco/pItO4= -golang.org/x/sync v0.20.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0= +golang.org/x/sync v0.22.0 h1:SZjpbeLmrCk4xhRSZFNZW5gFUeCeFgjekvI/+gfScek= +golang.org/x/sync v0.22.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -907,8 +907,8 @@ golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.46.0 h1:noSf2Fq6F8DBgS+LysIkx7rIExoNHJsxOAtPp4rthXw= golang.org/x/sys v0.46.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw= -golang.org/x/telemetry v0.0.0-20260311193753-579e4da9a98c h1:6a8FdnNk6bTXBjR4AGKFgUKuo+7GnR3FX5L7CbveeZc= -golang.org/x/telemetry v0.0.0-20260311193753-579e4da9a98c/go.mod h1:TpUTTEp9frx7rTdLpC9gFG9kdI7zVLFTFFlqaH2Cncw= +golang.org/x/telemetry v0.0.0-20260625142307-59b4966ccb57 h1:nwGZBCt+FnXUrGsj5vjzAsEmkcaFvd82BbOjECiFYZc= +golang.org/x/telemetry v0.0.0-20260625142307-59b4966ccb57/go.mod h1:3AWMyWHS+caVoiEXpiq6+tzKA40J4vQT3MYr80ZtQpc= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= @@ -927,8 +927,8 @@ golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= -golang.org/x/text v0.36.0 h1:JfKh3XmcRPqZPKevfXVpI1wXPTqbkE5f7JA92a55Yxg= -golang.org/x/text v0.36.0/go.mod h1:NIdBknypM8iqVmPiuco0Dh6P5Jcdk8lJL0CUebqK164= +golang.org/x/text v0.40.0 h1:Ub2Z6/xjgF1WrYQz2nuITOEegKFtiIy+rieRJ5lHZKs= +golang.org/x/text v0.40.0/go.mod h1:hpnzDAfGV753zIKo+wk3u1bVKCGPbrnF7+7LBF/UHVY= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -984,8 +984,8 @@ golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58= golang.org/x/tools v0.14.0/go.mod h1:uYBEerGOWcJyEORxN+Ek8+TT266gXkNlHdJBwexUsBg= -golang.org/x/tools v0.43.0 h1:12BdW9CeB3Z+J/I/wj34VMl8X+fEXBxVR90JeMX5E7s= -golang.org/x/tools v0.43.0/go.mod h1:uHkMso649BX2cZK6+RpuIPXS3ho2hZo4FVwfoy1vIk0= +golang.org/x/tools v0.47.0 h1:7Kn5x/d1svx/PzryTsqeoZN4TZwqeH5pGWjefhLi/1Q= +golang.org/x/tools v0.47.0/go.mod h1:dFHnyTvFWY212G+h7ZY4Vsp/K3U4/7W9TyVaAul8uCA= golang.org/x/tools/go/expect v0.1.1-deprecated h1:jpBZDwmgPhXsKZC6WhL20P4b/wmnpsEAGHaNy0n/rJM= golang.org/x/tools/go/expect v0.1.1-deprecated/go.mod h1:eihoPOH+FgIqa3FpoTwguz/bVUSGBlGQU67vpBeOrBY= golang.org/x/tools/go/packages/packagestest v0.1.1-deprecated h1:1h2MnaIAIXISqTFKdENegdpAgUXz6NrPEsbIeWaBRvM= From 521b57dc39ab75a416f800307e1c51ad5f533735 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ruben=20H=C3=B6nle?= Date: Tue, 21 Jul 2026 17:46:40 +0200 Subject: [PATCH 37/44] chore(iaas): remove deprecated SNA region flags from SNA cmds (#1483) relates to STACKITCLI-283 --- internal/cmd/network-area/create/create.go | 163 +--------- .../cmd/network-area/create/create_test.go | 303 +----------------- internal/cmd/network-area/delete/delete.go | 23 -- internal/cmd/network-area/update/update.go | 94 +----- .../cmd/network-area/update/update_test.go | 202 ------------ 5 files changed, 18 insertions(+), 767 deletions(-) diff --git a/internal/cmd/network-area/create/create.go b/internal/cmd/network-area/create/create.go index 5122e89d5..9b30bd871 100644 --- a/internal/cmd/network-area/create/create.go +++ b/internal/cmd/network-area/create/create.go @@ -3,15 +3,12 @@ package create import ( "context" "fmt" - "strings" "github.com/stackitcloud/stackit-cli/internal/pkg/types" iaas "github.com/stackitcloud/stackit-sdk-go/services/iaas/v2api" - wait "github.com/stackitcloud/stackit-sdk-go/services/iaas/v2api/wait" "github.com/stackitcloud/stackit-cli/internal/pkg/args" - cliErr "github.com/stackitcloud/stackit-cli/internal/pkg/errors" "github.com/stackitcloud/stackit-cli/internal/pkg/examples" "github.com/stackitcloud/stackit-cli/internal/pkg/flags" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" @@ -19,7 +16,6 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/services/iaas/client" rmClient "github.com/stackitcloud/stackit-cli/internal/pkg/services/resourcemanager/client" rmUtils "github.com/stackitcloud/stackit-cli/internal/pkg/services/resourcemanager/utils" - "github.com/stackitcloud/stackit-cli/internal/pkg/spinner" "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/spf13/cobra" @@ -28,40 +24,14 @@ import ( const ( nameFlag = "name" organizationIdFlag = "organization-id" - // Deprecated: dnsNameServersFlag is deprecated, because with iaas v2 the create endpoint for network area was separated, remove this after April 2026. - dnsNameServersFlag = "dns-name-servers" - // Deprecated: networkRangesFlag is deprecated, because with iaas v2 the create endpoint for network area was separated, remove this after April 2026. - networkRangesFlag = "network-ranges" - // Deprecated: transferNetworkFlag is deprecated, because with iaas v2 the create endpoint for network area was separated, remove this after April 2026. - transferNetworkFlag = "transfer-network" - // Deprecated: defaultPrefixLengthFlag is deprecated, because with iaas v2 the create endpoint for network area was separated, remove this after April 2026. - defaultPrefixLengthFlag = "default-prefix-length" - // Deprecated: maxPrefixLengthFlag is deprecated, because with iaas v2 the create endpoint for network area was separated, remove this after April 2026. - maxPrefixLengthFlag = "max-prefix-length" - // Deprecated: minPrefixLengthFlag is deprecated, because with iaas v2 the create endpoint for network area was separated, remove this after April 2026. - minPrefixLengthFlag = "min-prefix-length" - labelFlag = "labels" - - deprecationMessage = "Deprecated and will be removed after April 2026. Use instead the new command `$ stackit network-area region` to configure these options for a network area." + labelFlag = "labels" ) type inputModel struct { *globalflags.GlobalFlagModel Name string OrganizationId string - // Deprecated: DnsNameServers is deprecated, because with iaas v2 the create endpoint for network area was separated, remove this after April 2026. - DnsNameServers *[]string - // Deprecated: NetworkRanges is deprecated, because with iaas v2 the create endpoint for network area was separated, remove this after April 2026. - NetworkRanges *[]string - // Deprecated: TransferNetwork is deprecated, because with iaas v2 the create endpoint for network area was separated, remove this after April 2026. - TransferNetwork *string - // Deprecated: DefaultPrefixLength is deprecated, because with iaas v2 the create endpoint for network area was separated, remove this after April 2026. - DefaultPrefixLength *int64 - // Deprecated: MaxPrefixLength is deprecated, because with iaas v2 the create endpoint for network area was separated, remove this after April 2026. - MaxPrefixLength *int64 - // Deprecated: MinPrefixLength is deprecated, because with iaas v2 the create endpoint for network area was separated, remove this after April 2026. - MinPrefixLength *int64 - Labels map[string]any + Labels map[string]any } // NetworkAreaResponses is a workaround, to keep the two responses of the iaas v2 api together for the json and yaml output @@ -134,29 +104,6 @@ func NewCmd(params *types.CmdParams) *cobra.Command { NetworkArea: *resp, } - if hasDeprecatedFlagsSet(model) { - deprecatedFlags := getConfiguredDeprecatedFlags(model) - params.Printer.Warn("the flags %q are deprecated and will be removed after April 2026. Use `$ stackit network-area region` to configure these options for a network area.\n", strings.Join(deprecatedFlags, ",")) - if resp == nil || resp.Id == nil { - return fmt.Errorf("create network area: empty response") - } - reqNetworkArea := buildRequestNetworkAreaRegion(ctx, model, *resp.Id, apiClient) - respNetworkArea, err := reqNetworkArea.Execute() - if err != nil { - return fmt.Errorf("create network area region: %w", err) - } - if !model.Async { - err := spinner.Run(params.Printer, "Create network area region", func() error { - _, err = wait.CreateNetworkAreaRegionWaitHandler(ctx, apiClient.DefaultAPI, model.OrganizationId, *resp.Id, model.Region).WaitWithContext(ctx) - return err - }) - if err != nil { - return fmt.Errorf("wait for creating network area region %w", err) - } - } - responses.RegionalArea = respNetworkArea - } - return outputResult(params.Printer, model.OutputFormat, orgLabel, responses) }, } @@ -168,78 +115,19 @@ func configureFlags(cmd *cobra.Command) { cmd.Flags().StringP(nameFlag, "n", "", "Network area name") cmd.Flags().Var(flags.UUIDFlag(), organizationIdFlag, "Organization ID") cmd.Flags().StringToString(labelFlag, nil, "Labels are key-value string pairs which can be attached to a network-area. E.g. '--labels key1=value1,key2=value2,...'") - cmd.Flags().StringSlice(dnsNameServersFlag, nil, "List of DNS name server IPs") - cmd.Flags().Var(flags.CIDRSliceFlag(), networkRangesFlag, "List of network ranges") - cmd.Flags().Var(flags.CIDRFlag(), transferNetworkFlag, "Transfer network in CIDR notation") - cmd.Flags().Int64(defaultPrefixLengthFlag, 0, "The default prefix length for networks in the network area") - cmd.Flags().Int64(maxPrefixLengthFlag, 0, "The maximum prefix length for networks in the network area") - cmd.Flags().Int64(minPrefixLengthFlag, 0, "The minimum prefix length for networks in the network area") - - cobra.CheckErr(cmd.Flags().MarkDeprecated(dnsNameServersFlag, deprecationMessage)) - cobra.CheckErr(cmd.Flags().MarkDeprecated(networkRangesFlag, deprecationMessage)) - cobra.CheckErr(cmd.Flags().MarkDeprecated(transferNetworkFlag, deprecationMessage)) - cobra.CheckErr(cmd.Flags().MarkDeprecated(defaultPrefixLengthFlag, deprecationMessage)) - cobra.CheckErr(cmd.Flags().MarkDeprecated(maxPrefixLengthFlag, deprecationMessage)) - cobra.CheckErr(cmd.Flags().MarkDeprecated(minPrefixLengthFlag, deprecationMessage)) - - cmd.MarkFlagsRequiredTogether(networkRangesFlag, transferNetworkFlag) err := flags.MarkFlagsRequired(cmd, nameFlag, organizationIdFlag) cobra.CheckErr(err) } -func hasDeprecatedFlagsSet(model *inputModel) bool { - deprecatedFlags := getConfiguredDeprecatedFlags(model) - return len(deprecatedFlags) > 0 -} - -func getConfiguredDeprecatedFlags(model *inputModel) []string { - var result []string - if model.DnsNameServers != nil { - result = append(result, dnsNameServersFlag) - } - if model.NetworkRanges != nil { - result = append(result, networkRangesFlag) - } - if model.TransferNetwork != nil { - result = append(result, transferNetworkFlag) - } - if model.DefaultPrefixLength != nil { - result = append(result, defaultPrefixLengthFlag) - } - if model.MaxPrefixLength != nil { - result = append(result, maxPrefixLengthFlag) - } - if model.MinPrefixLength != nil { - result = append(result, minPrefixLengthFlag) - } - return result -} - func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, error) { globalFlags := globalflags.Parse(p, cmd) model := inputModel{ - GlobalFlagModel: globalFlags, - Name: flags.FlagToStringValue(p, cmd, nameFlag), - OrganizationId: flags.FlagToStringValue(p, cmd, organizationIdFlag), - DnsNameServers: flags.FlagToStringSlicePointer(p, cmd, dnsNameServersFlag), - NetworkRanges: flags.FlagToStringSlicePointer(p, cmd, networkRangesFlag), - TransferNetwork: flags.FlagToStringPointer(p, cmd, transferNetworkFlag), - DefaultPrefixLength: flags.FlagToInt64Pointer(p, cmd, defaultPrefixLengthFlag), - MaxPrefixLength: flags.FlagToInt64Pointer(p, cmd, maxPrefixLengthFlag), - MinPrefixLength: flags.FlagToInt64Pointer(p, cmd, minPrefixLengthFlag), - Labels: flags.FlagToStringToAny(p, cmd, labelFlag), - } - - // Check if any of the deprecated **optional** fields are set and if no of the associated deprecated **required** fields is set. - hasAllRequiredRegionalAreaFieldsSet := model.NetworkRanges != nil && model.TransferNetwork != nil - hasOptionalRegionalAreaFieldsSet := model.DnsNameServers != nil || model.DefaultPrefixLength != nil || model.MaxPrefixLength != nil || model.MinPrefixLength != nil - if hasOptionalRegionalAreaFieldsSet && !hasAllRequiredRegionalAreaFieldsSet { - return nil, &cliErr.MultipleFlagsAreMissing{ - MissingFlags: []string{networkRangesFlag, transferNetworkFlag}, - SetFlags: []string{dnsNameServersFlag, defaultPrefixLengthFlag, minPrefixLengthFlag, maxPrefixLengthFlag}, - } + GlobalFlagModel: globalFlags, + Name: flags.FlagToStringValue(p, cmd, nameFlag), + OrganizationId: flags.FlagToStringValue(p, cmd, organizationIdFlag), + Labels: flags.FlagToStringToAny(p, cmd, labelFlag), } p.DebugInputModel(model) @@ -257,45 +145,6 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient *iaas.APICli return req.CreateNetworkAreaPayload(payload) } -func buildRequestNetworkAreaRegion(ctx context.Context, model *inputModel, networkAreaId string, apiClient *iaas.APIClient) iaas.ApiCreateNetworkAreaRegionRequest { - req := apiClient.DefaultAPI.CreateNetworkAreaRegion(ctx, model.OrganizationId, networkAreaId, model.Region) - - var networkRanges []iaas.NetworkRange - if model.NetworkRanges != nil { - networkRanges = make([]iaas.NetworkRange, len(*model.NetworkRanges)) - for i, networkRange := range *model.NetworkRanges { - networkRanges[i] = iaas.NetworkRange{ - Prefix: networkRange, - } - } - } - - ipv4 := &iaas.RegionalAreaIPv4{ - NetworkRanges: networkRanges, - } - if model.DnsNameServers != nil { - ipv4.DefaultNameservers = *model.DnsNameServers - } - if model.TransferNetwork != nil { - ipv4.TransferNetwork = *model.TransferNetwork - } - if model.DefaultPrefixLength != nil { - ipv4.DefaultPrefixLen = *model.DefaultPrefixLength - } - if model.MaxPrefixLength != nil { - ipv4.MaxPrefixLen = *model.MaxPrefixLength - } - if model.MinPrefixLength != nil { - ipv4.MinPrefixLen = *model.MinPrefixLength - } - - payload := iaas.CreateNetworkAreaRegionPayload{ - Ipv4: ipv4, - } - - return req.CreateNetworkAreaRegionPayload(payload) -} - func outputResult(p *print.Printer, outputFormat, orgLabel string, responses *NetworkAreaResponses) error { if responses == nil { return fmt.Errorf("network area is nil") diff --git a/internal/cmd/network-area/create/create_test.go b/internal/cmd/network-area/create/create_test.go index 1a7dd4c4e..6c772b42c 100644 --- a/internal/cmd/network-area/create/create_test.go +++ b/internal/cmd/network-area/create/create_test.go @@ -2,19 +2,16 @@ package create import ( "context" - "strconv" - "strings" "testing" - "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" - "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" - "github.com/stackitcloud/stackit-cli/internal/pkg/testutils" - "github.com/stackitcloud/stackit-cli/internal/pkg/utils" - "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" iaas "github.com/stackitcloud/stackit-sdk-go/services/iaas/v2api" + + "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" + "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" + "github.com/stackitcloud/stackit-cli/internal/pkg/testutils" ) const ( @@ -30,13 +27,7 @@ type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") var testClient = &iaas.APIClient{DefaultAPI: &iaas.DefaultAPIService{}} - -var ( - testOrgId = uuid.NewString() - testAreaId = uuid.NewString() - testDnsNameservers = []string{"1.1.1.0", "1.1.2.0"} - testNetworkRanges = []string{"192.0.0.0/24", "102.0.0.0/24"} -) +var testOrgId = uuid.NewString() func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string { flagValues := map[string]string{ @@ -92,40 +83,6 @@ func fixturePayload(mods ...func(payload *iaas.CreateNetworkAreaPayload)) iaas.C return payload } -func fixtureRequestRegionalArea(mods ...func(request *iaas.ApiCreateNetworkAreaRegionRequest)) iaas.ApiCreateNetworkAreaRegionRequest { - req := testClient.DefaultAPI.CreateNetworkAreaRegion(testCtx, testOrgId, testAreaId, testRegion) - req = req.CreateNetworkAreaRegionPayload(fixtureRegionalAreaPayload()) - for _, mod := range mods { - mod(&req) - } - return req -} - -func fixtureRegionalAreaPayload(mods ...func(request *iaas.CreateNetworkAreaRegionPayload)) iaas.CreateNetworkAreaRegionPayload { - var networkRanges []iaas.NetworkRange - for _, networkRange := range testNetworkRanges { - networkRanges = append(networkRanges, iaas.NetworkRange{ - Prefix: networkRange, - }) - } - - payload := iaas.CreateNetworkAreaRegionPayload{ - Ipv4: &iaas.RegionalAreaIPv4{ - DefaultNameservers: testDnsNameservers, - DefaultPrefixLen: testDefaultPrefixLength, - MaxPrefixLen: testMaxPrefixLength, - MinPrefixLen: testMinPrefixLength, - NetworkRanges: networkRanges, - TransferNetwork: testTransferNetwork, - }, - Status: nil, - } - for _, mod := range mods { - mod(&payload) - } - return payload -} - func TestParseInput(t *testing.T) { tests := []struct { description string @@ -141,37 +98,6 @@ func TestParseInput(t *testing.T) { isValid: true, expectedModel: fixtureInputModel(), }, - { - description: "with deprecated flags", - flagValues: map[string]string{ - nameFlag: testName, - organizationIdFlag: testOrgId, - - // Deprecated flags - dnsNameServersFlag: strings.Join(testDnsNameservers, ","), - networkRangesFlag: strings.Join(testNetworkRanges, ","), - transferNetworkFlag: testTransferNetwork, - defaultPrefixLengthFlag: strconv.FormatInt(testDefaultPrefixLength, 10), - maxPrefixLengthFlag: strconv.FormatInt(testMaxPrefixLength, 10), - minPrefixLengthFlag: strconv.FormatInt(testMinPrefixLength, 10), - }, - isValid: true, - expectedModel: &inputModel{ - GlobalFlagModel: &globalflags.GlobalFlagModel{ - Verbosity: globalflags.VerbosityDefault, - }, - Name: testName, - OrganizationId: testOrgId, - - // Deprecated fields - DnsNameServers: utils.Ptr(testDnsNameservers), - NetworkRanges: utils.Ptr(testNetworkRanges), - TransferNetwork: utils.Ptr(testTransferNetwork), - DefaultPrefixLength: utils.Ptr(testDefaultPrefixLength), - MaxPrefixLength: utils.Ptr(testMaxPrefixLength), - MinPrefixLength: utils.Ptr(testMinPrefixLength), - }, - }, { description: "name missing", flagValues: fixtureFlagValues(func(flagValues map[string]string) { @@ -179,42 +105,6 @@ func TestParseInput(t *testing.T) { }), isValid: false, }, - { - description: "set deprecated network ranges - missing transfer network", - flagValues: fixtureFlagValues(func(flagValues map[string]string) { - flagValues[networkRangesFlag] = strings.Join(testNetworkRanges, ",") - }), - isValid: false, - }, - { - description: "set deprecated transfer network - missing network ranges", - flagValues: fixtureFlagValues(func(flagValues map[string]string) { - flagValues[transferNetworkFlag] = testTransferNetwork - }), - isValid: false, - }, - { - description: "set deprecated transfer network and network ranges", - flagValues: fixtureFlagValues(func(flagValues map[string]string) { - flagValues[networkRangesFlag] = strings.Join(testNetworkRanges, ",") - flagValues[transferNetworkFlag] = testTransferNetwork - }), - isValid: true, - expectedModel: fixtureInputModel(func(model *inputModel) { - model.NetworkRanges = utils.Ptr(testNetworkRanges) - model.TransferNetwork = utils.Ptr(testTransferNetwork) - }), - }, - { - description: "set deprecated optional flags", - flagValues: fixtureFlagValues(func(flagValues map[string]string) { - flagValues[dnsNameServersFlag] = strings.Join(testDnsNameservers, ",") - flagValues[defaultPrefixLengthFlag] = strconv.FormatInt(testDefaultPrefixLength, 10) - flagValues[maxPrefixLengthFlag] = strconv.FormatInt(testMaxPrefixLength, 10) - flagValues[minPrefixLengthFlag] = strconv.FormatInt(testMinPrefixLength, 10) - }), - isValid: false, - }, { description: "no values", flagValues: map[string]string{}, @@ -288,58 +178,6 @@ func TestBuildRequest(t *testing.T) { } } -func TestBuildRequestNetworkAreaRegion(t *testing.T) { - tests := []struct { - description string - model *inputModel - areaId string - expectedRequest iaas.ApiCreateNetworkAreaRegionRequest - }{ - { - description: "base", - model: fixtureInputModel(func(model *inputModel) { - // Deprecated fields - model.DnsNameServers = utils.Ptr(testDnsNameservers) - model.NetworkRanges = utils.Ptr(testNetworkRanges) - model.TransferNetwork = utils.Ptr(testTransferNetwork) - model.DefaultPrefixLength = utils.Ptr(testDefaultPrefixLength) - model.MaxPrefixLength = utils.Ptr(testMaxPrefixLength) - model.MinPrefixLength = utils.Ptr(testMinPrefixLength) - }), - areaId: testAreaId, - expectedRequest: fixtureRequestRegionalArea(), - }, - { - description: "base without network ranges", - model: fixtureInputModel(func(model *inputModel) { - // Deprecated fields - model.DnsNameServers = utils.Ptr(testDnsNameservers) - model.NetworkRanges = utils.Ptr(testNetworkRanges) - model.TransferNetwork = utils.Ptr(testTransferNetwork) - model.DefaultPrefixLength = utils.Ptr(testDefaultPrefixLength) - model.MaxPrefixLength = utils.Ptr(testMaxPrefixLength) - model.MinPrefixLength = utils.Ptr(testMinPrefixLength) - }), - areaId: testAreaId, - expectedRequest: fixtureRequestRegionalArea(), - }, - } - - for _, tt := range tests { - t.Run(tt.description, func(t *testing.T) { - request := buildRequestNetworkAreaRegion(testCtx, tt.model, testAreaId, testClient) - - diff := cmp.Diff(request, tt.expectedRequest, - cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx, iaas.DefaultAPIService{}), - ) - if diff != "" { - t.Fatalf("Data does not match: %s", diff) - } - }) - } -} - func Test_outputResult(t *testing.T) { type args struct { outputFormat string @@ -382,134 +220,3 @@ func Test_outputResult(t *testing.T) { }) } } - -func TestGetConfiguredDeprecatedFlags(t *testing.T) { - type args struct { - model *inputModel - } - tests := []struct { - name string - args args - want []string - }{ - { - name: "no deprecated flags", - args: args{ - model: &inputModel{ - GlobalFlagModel: &globalflags.GlobalFlagModel{ - Verbosity: globalflags.VerbosityDefault, - }, - Name: testName, - OrganizationId: testOrgId, - Labels: map[string]any{ - "key": "value", - }, - DnsNameServers: nil, - NetworkRanges: nil, - TransferNetwork: nil, - DefaultPrefixLength: nil, - MaxPrefixLength: nil, - MinPrefixLength: nil, - }, - }, - want: nil, - }, - { - name: "deprecated flags", - args: args{ - model: &inputModel{ - GlobalFlagModel: &globalflags.GlobalFlagModel{ - Verbosity: globalflags.VerbosityDefault, - }, - Name: testName, - OrganizationId: testOrgId, - Labels: map[string]any{ - "key": "value", - }, - DnsNameServers: utils.Ptr(testDnsNameservers), - NetworkRanges: utils.Ptr(testNetworkRanges), - TransferNetwork: utils.Ptr(testTransferNetwork), - DefaultPrefixLength: utils.Ptr(testDefaultPrefixLength), - MaxPrefixLength: utils.Ptr(testMaxPrefixLength), - MinPrefixLength: utils.Ptr(testMinPrefixLength), - }, - }, - want: []string{dnsNameServersFlag, networkRangesFlag, transferNetworkFlag, defaultPrefixLengthFlag, minPrefixLengthFlag, maxPrefixLengthFlag}, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - got := getConfiguredDeprecatedFlags(tt.args.model) - - less := func(a, b string) bool { - return a < b - } - if diff := cmp.Diff(tt.want, got, cmpopts.SortSlices(less)); diff != "" { - t.Fatalf("Data does not match: %s", diff) - } - }) - } -} - -func TestHasDeprecatedFlagsSet(t *testing.T) { - type args struct { - model *inputModel - } - tests := []struct { - name string - args args - want bool - }{ - { - name: "no deprecated flags", - args: args{ - model: &inputModel{ - GlobalFlagModel: &globalflags.GlobalFlagModel{ - Verbosity: globalflags.VerbosityDefault, - }, - Name: testName, - OrganizationId: testOrgId, - Labels: map[string]any{ - "key": "value", - }, - DnsNameServers: nil, - NetworkRanges: nil, - TransferNetwork: nil, - DefaultPrefixLength: nil, - MaxPrefixLength: nil, - MinPrefixLength: nil, - }, - }, - want: false, - }, - { - name: "deprecated flags", - args: args{ - model: &inputModel{ - GlobalFlagModel: &globalflags.GlobalFlagModel{ - Verbosity: globalflags.VerbosityDefault, - }, - Name: testName, - OrganizationId: testOrgId, - Labels: map[string]any{ - "key": "value", - }, - DnsNameServers: utils.Ptr(testDnsNameservers), - NetworkRanges: utils.Ptr(testNetworkRanges), - TransferNetwork: utils.Ptr(testTransferNetwork), - DefaultPrefixLength: utils.Ptr(testDefaultPrefixLength), - MaxPrefixLength: utils.Ptr(testMaxPrefixLength), - MinPrefixLength: utils.Ptr(testMinPrefixLength), - }, - }, - want: true, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := hasDeprecatedFlagsSet(tt.args.model); got != tt.want { - t.Errorf("hasDeprecatedFlagsSet() = %v, want %v", got, tt.want) - } - }) - } -} diff --git a/internal/cmd/network-area/delete/delete.go b/internal/cmd/network-area/delete/delete.go index b45746426..e3e984d6e 100644 --- a/internal/cmd/network-area/delete/delete.go +++ b/internal/cmd/network-area/delete/delete.go @@ -8,7 +8,6 @@ import ( "github.com/spf13/cobra" iaas "github.com/stackitcloud/stackit-sdk-go/services/iaas/v2api" - wait "github.com/stackitcloud/stackit-sdk-go/services/iaas/v2api/wait" "github.com/stackitcloud/stackit-cli/internal/pkg/args" "github.com/stackitcloud/stackit-cli/internal/pkg/examples" @@ -23,11 +22,6 @@ import ( const ( areaIdArg = "AREA_ID" organizationIdFlag = "organization-id" - - deprecationMessage = "The regional network area configuration %q for the area %q still exists.\n" + - "The regional configuration of the network area was moved to the new command group `$ stackit network-area region`.\n" + - "The regional area will be automatically deleted. This behavior is deprecated and will be removed after April 2026.\n" + - "Use in the future the command `$ stackit network-area region delete` to delete the regional network area and afterwards delete the network-area with the command `$ stackit network-area delete`.\n" ) type inputModel struct { @@ -76,23 +70,6 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return err } - // Check if the network area has a regional configuration - regionalArea, err := apiClient.DefaultAPI.GetNetworkAreaRegion(ctx, *model.OrganizationId, model.AreaId, model.Region).Execute() - if err != nil { - params.Printer.Debug(print.ErrorLevel, "get regional area: %v", err) - } - if regionalArea != nil { - params.Printer.Warn(deprecationMessage, model.Region, networkAreaLabel) - err = apiClient.DefaultAPI.DeleteNetworkAreaRegion(ctx, *model.OrganizationId, model.AreaId, model.Region).Execute() - if err != nil { - return fmt.Errorf("delete network area region: %w", err) - } - _, err := wait.DeleteNetworkAreaRegionWaitHandler(ctx, apiClient.DefaultAPI, *model.OrganizationId, model.AreaId, model.Region).WaitWithContext(ctx) - if err != nil { - return fmt.Errorf("wait delete network area region: %w", err) - } - } - // Call API req := buildRequest(ctx, model, apiClient) err = req.Execute() diff --git a/internal/cmd/network-area/update/update.go b/internal/cmd/network-area/update/update.go index cf55e8fe5..7db534f50 100644 --- a/internal/cmd/network-area/update/update.go +++ b/internal/cmd/network-area/update/update.go @@ -3,7 +3,6 @@ package update import ( "context" "fmt" - "strings" "github.com/stackitcloud/stackit-cli/internal/pkg/types" @@ -28,17 +27,7 @@ const ( nameFlag = "name" organizationIdFlag = "organization-id" areaIdFlag = "area-id" - // Deprecated: dnsNameServersFlag is deprecated, because with iaas v2 the create endpoint for network area was separated, remove this after April 2026. - dnsNameServersFlag = "dns-name-servers" - // Deprecated: defaultPrefixLengthFlag is deprecated, because with iaas v2 the create endpoint for network area was separated, remove this after April 2026. - defaultPrefixLengthFlag = "default-prefix-length" - // Deprecated: maxPrefixLengthFlag is deprecated, because with iaas v2 the create endpoint for network area was separated, remove this after April 2026. - maxPrefixLengthFlag = "max-prefix-length" - // Deprecated: minPrefixLengthFlag is deprecated, because with iaas v2 the create endpoint for network area was separated, remove this after April 2026. - minPrefixLengthFlag = "min-prefix-length" - labelFlag = "labels" - - deprecationMessage = "Deprecated and will be removed after April 2026. Use instead the new command `$ stackit network-area region` to configure these options for a network area." + labelFlag = "labels" ) // NetworkAreaResponses is a workaround, to keep the two responses of the iaas v2 api together for the json and yaml output @@ -53,15 +42,7 @@ type inputModel struct { AreaId string Name *string OrganizationId *string - // Deprecated: DnsNameServers is deprecated, because with iaas v2 the create endpoint for network area was separated, remove this after April 2026. - DnsNameServers []string - // Deprecated: DefaultPrefixLength is deprecated, because with iaas v2 the create endpoint for network area was separated, remove this after April 2026. - DefaultPrefixLength *int64 - // Deprecated: MaxPrefixLength is deprecated, because with iaas v2 the create endpoint for network area was separated, remove this after April 2026. - MaxPrefixLength *int64 - // Deprecated: MinPrefixLength is deprecated, because with iaas v2 the create endpoint for network area was separated, remove this after April 2026. - MinPrefixLength *int64 - Labels map[string]any + Labels map[string]any } func NewCmd(params *types.CmdParams) *cobra.Command { @@ -124,17 +105,6 @@ func NewCmd(params *types.CmdParams) *cobra.Command { NetworkArea: *resp, } - if hasDeprecatedFlagsSet(model) { - deprecatedFlags := getConfiguredDeprecatedFlags(model) - params.Printer.Warn("the flags %q are deprecated and will be removed after April 2026. Use `$ stackit network-area region` to configure these options for a network area.\n", strings.Join(deprecatedFlags, ",")) - reqNetworkArea := buildRequestNetworkAreaRegion(ctx, model, apiClient) - respNetworkArea, err := reqNetworkArea.Execute() - if err != nil { - return fmt.Errorf("create network area region: %w", err) - } - responses.RegionalArea = respNetworkArea - } - return outputResult(params.Printer, model.OutputFormat, orgLabel, responses) }, } @@ -145,17 +115,8 @@ func NewCmd(params *types.CmdParams) *cobra.Command { func configureFlags(cmd *cobra.Command) { cmd.Flags().StringP(nameFlag, "n", "", "Network area name") cmd.Flags().Var(flags.UUIDFlag(), organizationIdFlag, "Organization ID") - cmd.Flags().StringSlice(dnsNameServersFlag, nil, "List of DNS name server IPs") - cmd.Flags().Int64(defaultPrefixLengthFlag, 0, "The default prefix length for networks in the network area") - cmd.Flags().Int64(maxPrefixLengthFlag, 0, "The maximum prefix length for networks in the network area") - cmd.Flags().Int64(minPrefixLengthFlag, 0, "The minimum prefix length for networks in the network area") cmd.Flags().StringToString(labelFlag, nil, "Labels are key-value string pairs which can be attached to a network-area. E.g. '--labels key1=value1,key2=value2,...'") - cobra.CheckErr(cmd.Flags().MarkDeprecated(dnsNameServersFlag, deprecationMessage)) - cobra.CheckErr(cmd.Flags().MarkDeprecated(defaultPrefixLengthFlag, deprecationMessage)) - cobra.CheckErr(cmd.Flags().MarkDeprecated(maxPrefixLengthFlag, deprecationMessage)) - cobra.CheckErr(cmd.Flags().MarkDeprecated(minPrefixLengthFlag, deprecationMessage)) - err := flags.MarkFlagsRequired(cmd, organizationIdFlag) cobra.CheckErr(err) } @@ -166,43 +127,17 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu globalFlags := globalflags.Parse(p, cmd) model := inputModel{ - GlobalFlagModel: globalFlags, - Name: flags.FlagToStringPointer(p, cmd, nameFlag), - OrganizationId: flags.FlagToStringPointer(p, cmd, organizationIdFlag), - AreaId: areaId, - DnsNameServers: flags.FlagToStringSliceValue(p, cmd, dnsNameServersFlag), - DefaultPrefixLength: flags.FlagToInt64Pointer(p, cmd, defaultPrefixLengthFlag), - MaxPrefixLength: flags.FlagToInt64Pointer(p, cmd, maxPrefixLengthFlag), - MinPrefixLength: flags.FlagToInt64Pointer(p, cmd, minPrefixLengthFlag), - Labels: flags.FlagToStringToAny(p, cmd, labelFlag), + GlobalFlagModel: globalFlags, + Name: flags.FlagToStringPointer(p, cmd, nameFlag), + OrganizationId: flags.FlagToStringPointer(p, cmd, organizationIdFlag), + AreaId: areaId, + Labels: flags.FlagToStringToAny(p, cmd, labelFlag), } p.DebugInputModel(model) return &model, nil } -func hasDeprecatedFlagsSet(model *inputModel) bool { - deprecatedFlags := getConfiguredDeprecatedFlags(model) - return len(deprecatedFlags) > 0 -} - -func getConfiguredDeprecatedFlags(model *inputModel) []string { - var result []string - if model.DnsNameServers != nil { - result = append(result, dnsNameServersFlag) - } - if model.DefaultPrefixLength != nil { - result = append(result, defaultPrefixLengthFlag) - } - if model.MaxPrefixLength != nil { - result = append(result, maxPrefixLengthFlag) - } - if model.MinPrefixLength != nil { - result = append(result, minPrefixLengthFlag) - } - return result -} - func buildRequest(ctx context.Context, model *inputModel, apiClient *iaas.APIClient) iaas.ApiPartialUpdateNetworkAreaRequest { req := apiClient.DefaultAPI.PartialUpdateNetworkArea(ctx, *model.OrganizationId, model.AreaId) @@ -214,21 +149,6 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient *iaas.APICli return req.PartialUpdateNetworkAreaPayload(payload) } -func buildRequestNetworkAreaRegion(ctx context.Context, model *inputModel, apiClient *iaas.APIClient) iaas.ApiUpdateNetworkAreaRegionRequest { - req := apiClient.DefaultAPI.UpdateNetworkAreaRegion(ctx, *model.OrganizationId, model.AreaId, model.Region) - - payload := iaas.UpdateNetworkAreaRegionPayload{ - Ipv4: &iaas.UpdateRegionalAreaIPv4{ - DefaultNameservers: model.DnsNameServers, - DefaultPrefixLen: model.DefaultPrefixLength, - MaxPrefixLen: model.MaxPrefixLength, - MinPrefixLen: model.MinPrefixLength, - }, - } - - return req.UpdateNetworkAreaRegionPayload(payload) -} - func outputResult(p *print.Printer, outputFormat, projectLabel string, responses NetworkAreaResponses) error { prettyOutputFunc := func() error { p.Outputf("Updated STACKIT Network Area for project %q.\n", projectLabel) diff --git a/internal/cmd/network-area/update/update_test.go b/internal/cmd/network-area/update/update_test.go index b58777a7a..a3a1704fe 100644 --- a/internal/cmd/network-area/update/update_test.go +++ b/internal/cmd/network-area/update/update_test.go @@ -2,8 +2,6 @@ package update import ( "context" - "strconv" - "strings" "testing" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" @@ -32,8 +30,6 @@ var testClient = &iaas.APIClient{DefaultAPI: &iaas.DefaultAPIService{}} var ( testOrgId = uuid.NewString() testAreaId = uuid.NewString() - - testDnsNameservers = []string{"1.1.1.0", "1.1.2.0"} ) func fixtureArgValues(mods ...func(argValues []string)) []string { @@ -101,30 +97,6 @@ func fixturePayload(mods ...func(payload *iaas.PartialUpdateNetworkAreaPayload)) return payload } -func fixtureRequestRegionalArea(mods ...func(request *iaas.ApiUpdateNetworkAreaRegionRequest)) iaas.ApiUpdateNetworkAreaRegionRequest { - request := testClient.DefaultAPI.UpdateNetworkAreaRegion(testCtx, testOrgId, testAreaId, testRegion) - request = request.UpdateNetworkAreaRegionPayload(fixturePayloadRegionalArea()) - for _, mod := range mods { - mod(&request) - } - return request -} - -func fixturePayloadRegionalArea(mods ...func(payload *iaas.UpdateNetworkAreaRegionPayload)) iaas.UpdateNetworkAreaRegionPayload { - payload := iaas.UpdateNetworkAreaRegionPayload{ - Ipv4: &iaas.UpdateRegionalAreaIPv4{ - DefaultNameservers: testDnsNameservers, - DefaultPrefixLen: utils.Ptr(testDefaultPrefixLength), - MaxPrefixLen: utils.Ptr(testMaxPrefixLength), - MinPrefixLen: utils.Ptr(testMinPrefixLength), - }, - } - for _, mod := range mods { - mod(&payload) - } - return payload -} - func TestParseInput(t *testing.T) { tests := []struct { description string @@ -141,24 +113,6 @@ func TestParseInput(t *testing.T) { isValid: true, expectedModel: fixtureInputModel(), }, - { - description: "with deprecated flags", - argValues: fixtureArgValues(), - flagValues: fixtureFlagValues(func(flagValues map[string]string) { - flagValues[dnsNameServersFlag] = strings.Join(testDnsNameservers, ",") - flagValues[defaultPrefixLengthFlag] = strconv.FormatInt(testDefaultPrefixLength, 10) - flagValues[maxPrefixLengthFlag] = strconv.FormatInt(testMaxPrefixLength, 10) - flagValues[minPrefixLengthFlag] = strconv.FormatInt(testMinPrefixLength, 10) - }), - isValid: true, - expectedModel: fixtureInputModel(func(model *inputModel) { - model.DnsNameServers = testDnsNameservers - model.DefaultPrefixLength = utils.Ptr(testDefaultPrefixLength) - model.MaxPrefixLength = utils.Ptr(testMaxPrefixLength) - model.MinPrefixLength = utils.Ptr(testMinPrefixLength) - }), - }, - { description: "no values", argValues: []string{}, @@ -310,39 +264,6 @@ func TestBuildRequest(t *testing.T) { } } -func TestBuildRequestNetworkAreaRegion(t *testing.T) { - tests := []struct { - description string - model *inputModel - expectedRequest iaas.ApiUpdateNetworkAreaRegionRequest - }{ - { - description: "base", - model: fixtureInputModel(func(model *inputModel) { - model.DnsNameServers = testDnsNameservers - model.DefaultPrefixLength = utils.Ptr(testDefaultPrefixLength) - model.MaxPrefixLength = utils.Ptr(testMaxPrefixLength) - model.MinPrefixLength = utils.Ptr(testMinPrefixLength) - }), - expectedRequest: fixtureRequestRegionalArea(), - }, - } - - for _, tt := range tests { - t.Run(tt.description, func(t *testing.T) { - request := buildRequestNetworkAreaRegion(testCtx, tt.model, testClient) - - diff := cmp.Diff(request, tt.expectedRequest, - cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx, iaas.DefaultAPIService{}), - ) - if diff != "" { - t.Fatalf("Data does not match: %s", diff) - } - }) - } -} - func TestOutputResult(t *testing.T) { type args struct { outputFormat string @@ -379,126 +300,3 @@ func TestOutputResult(t *testing.T) { }) } } - -func TestGetConfiguredDeprecatedFlags(t *testing.T) { - type args struct { - model *inputModel - } - tests := []struct { - name string - args args - want []string - }{ - { - name: "no deprecated flags", - args: args{ - model: &inputModel{ - GlobalFlagModel: &globalflags.GlobalFlagModel{ - Verbosity: globalflags.VerbosityDefault, - }, - Name: utils.Ptr(testName), - OrganizationId: utils.Ptr(testOrgId), - Labels: map[string]any{ - "key": "value", - }, - DnsNameServers: nil, - DefaultPrefixLength: nil, - MaxPrefixLength: nil, - MinPrefixLength: nil, - }, - }, - want: nil, - }, - { - name: "deprecated flags", - args: args{ - model: &inputModel{ - GlobalFlagModel: &globalflags.GlobalFlagModel{ - Verbosity: globalflags.VerbosityDefault, - }, - Name: utils.Ptr(testName), - OrganizationId: utils.Ptr(testOrgId), - Labels: map[string]any{ - "key": "value", - }, - DnsNameServers: testDnsNameservers, - DefaultPrefixLength: utils.Ptr(testDefaultPrefixLength), - MaxPrefixLength: utils.Ptr(testMaxPrefixLength), - MinPrefixLength: utils.Ptr(testMinPrefixLength), - }, - }, - want: []string{dnsNameServersFlag, defaultPrefixLengthFlag, minPrefixLengthFlag, maxPrefixLengthFlag}, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - got := getConfiguredDeprecatedFlags(tt.args.model) - - less := func(a, b string) bool { - return a < b - } - if diff := cmp.Diff(tt.want, got, cmpopts.SortSlices(less)); diff != "" { - t.Fatalf("Data does not match: %s", diff) - } - }) - } -} - -func TestHasDeprecatedFlagsSet(t *testing.T) { - type args struct { - model *inputModel - } - tests := []struct { - name string - args args - want bool - }{ - { - name: "no deprecated flags", - args: args{ - model: &inputModel{ - GlobalFlagModel: &globalflags.GlobalFlagModel{ - Verbosity: globalflags.VerbosityDefault, - }, - Name: utils.Ptr(testName), - OrganizationId: utils.Ptr(testOrgId), - Labels: map[string]any{ - "key": "value", - }, - DnsNameServers: nil, - DefaultPrefixLength: nil, - MaxPrefixLength: nil, - MinPrefixLength: nil, - }, - }, - want: false, - }, - { - name: "deprecated flags", - args: args{ - model: &inputModel{ - GlobalFlagModel: &globalflags.GlobalFlagModel{ - Verbosity: globalflags.VerbosityDefault, - }, - Name: utils.Ptr(testName), - OrganizationId: utils.Ptr(testOrgId), - Labels: map[string]any{ - "key": "value", - }, - DnsNameServers: testDnsNameservers, - DefaultPrefixLength: utils.Ptr(testDefaultPrefixLength), - MaxPrefixLength: utils.Ptr(testMaxPrefixLength), - MinPrefixLength: utils.Ptr(testMinPrefixLength), - }, - }, - want: true, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := hasDeprecatedFlagsSet(tt.args.model); got != tt.want { - t.Errorf("hasDeprecatedFlagsSet() = %v, want %v", got, tt.want) - } - }) - } -} From fa62984cab89e4dd44899416e0a6e40ac11af90b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ruben=20H=C3=B6nle?= Date: Wed, 22 Jul 2026 10:46:20 +0200 Subject: [PATCH 38/44] chore(runcommand): switch to new sdk structure (#1484) relates to STACKITCLI-354 --- go.mod | 2 +- go.sum | 4 +-- internal/cmd/server/command/create/create.go | 6 ++--- .../cmd/server/command/create/create_test.go | 19 +++++++------- .../cmd/server/command/describe/describe.go | 12 ++++++--- .../server/command/describe/describe_test.go | 26 ++++++++++++++----- internal/cmd/server/command/list/list.go | 4 +-- internal/cmd/server/command/list/list_test.go | 8 +++--- .../command/template/describe/describe.go | 6 ++--- .../template/describe/describe_test.go | 8 +++--- .../cmd/server/command/template/list/list.go | 12 ++++----- .../server/command/template/list/list_test.go | 8 +++--- .../pkg/services/runcommand/client/client.go | 2 +- 13 files changed, 65 insertions(+), 52 deletions(-) diff --git a/go.mod b/go.mod index 11949757e..e36afda0c 100644 --- a/go.mod +++ b/go.mod @@ -29,7 +29,7 @@ require ( github.com/stackitcloud/stackit-sdk-go/services/opensearch v1.1.0 github.com/stackitcloud/stackit-sdk-go/services/postgresflex v1.11.0 github.com/stackitcloud/stackit-sdk-go/services/resourcemanager v0.24.0 - github.com/stackitcloud/stackit-sdk-go/services/runcommand v1.4.3 + github.com/stackitcloud/stackit-sdk-go/services/runcommand v1.8.0 github.com/stackitcloud/stackit-sdk-go/services/secretsmanager v0.18.1 github.com/stackitcloud/stackit-sdk-go/services/serverbackup v1.3.8 github.com/stackitcloud/stackit-sdk-go/services/serverupdate v1.2.6 diff --git a/go.sum b/go.sum index aac834ef2..f83170615 100644 --- a/go.sum +++ b/go.sum @@ -634,8 +634,8 @@ github.com/stackitcloud/stackit-sdk-go/services/redis v1.1.0 h1:ckYMRXAGE2/vaxPe github.com/stackitcloud/stackit-sdk-go/services/redis v1.1.0/go.mod h1:yjej6QfYoYdRIyKXlmbVz8fZYxbuUdl+QBkvLDPgA4k= github.com/stackitcloud/stackit-sdk-go/services/resourcemanager v0.24.0 h1:JPP6a0ME1tZXr4iB69d/LtJsCAr58ENBadFaK9f48/c= github.com/stackitcloud/stackit-sdk-go/services/resourcemanager v0.24.0/go.mod h1:NEz3f+GV5G++BE9/MmZCsXJyCih7jtg0pZuSyG2sLEs= -github.com/stackitcloud/stackit-sdk-go/services/runcommand v1.4.3 h1:AiGNJmpQ/f9cglaIQQ4SyePbtCI3K1DQLNvqVN9jKSo= -github.com/stackitcloud/stackit-sdk-go/services/runcommand v1.4.3/go.mod h1:U/q0V89fvCF2O1ZJfi68/Chie9YY/5s7xBHI1Klq7wA= +github.com/stackitcloud/stackit-sdk-go/services/runcommand v1.8.0 h1:T5gy5i+NxrpJPYDEJNjGjljhfD7PWTFia7us8A4mL/c= +github.com/stackitcloud/stackit-sdk-go/services/runcommand v1.8.0/go.mod h1:iB27HtF0UcAugURc9w+nlNrtbAj7Mukw/ptAz+7p2WE= github.com/stackitcloud/stackit-sdk-go/services/secretsmanager v0.18.1 h1:U5rstX5e6Am2t+Ukv5K1Sbftzxt5aFALMa9YS4jCJoo= github.com/stackitcloud/stackit-sdk-go/services/secretsmanager v0.18.1/go.mod h1:2XA8PE05Qg6BL2YXO4XgfGI9qskJ3cicLE5Qq0aqDdY= github.com/stackitcloud/stackit-sdk-go/services/serverbackup v1.3.8 h1:LLyANBzE8sQa0/49tQBqq4sVLhNgwdqCeQm76srJHWw= diff --git a/internal/cmd/server/command/create/create.go b/internal/cmd/server/command/create/create.go index 924a53fcb..12757c4ec 100644 --- a/internal/cmd/server/command/create/create.go +++ b/internal/cmd/server/command/create/create.go @@ -9,7 +9,7 @@ import ( iaasClient "github.com/stackitcloud/stackit-cli/internal/pkg/services/iaas/client" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/runcommand" + runcommand "github.com/stackitcloud/stackit-sdk-go/services/runcommand/v2api" "github.com/stackitcloud/stackit-cli/internal/pkg/args" cliErr "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -135,9 +135,9 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, } func buildRequest(ctx context.Context, model *inputModel, apiClient *runcommand.APIClient) (runcommand.ApiCreateCommandRequest, error) { - req := apiClient.CreateCommand(ctx, model.ProjectId, model.ServerId, model.Region) + req := apiClient.DefaultAPI.CreateCommand(ctx, model.ProjectId, model.ServerId, model.Region) req = req.CreateCommandPayload(runcommand.CreateCommandPayload{ - CommandTemplateName: &model.CommandTemplateName, + CommandTemplateName: model.CommandTemplateName, Parameters: model.Params, }) return req, nil diff --git a/internal/cmd/server/command/create/create_test.go b/internal/cmd/server/command/create/create_test.go index 7895f7d83..408dcaeac 100644 --- a/internal/cmd/server/command/create/create_test.go +++ b/internal/cmd/server/command/create/create_test.go @@ -4,21 +4,20 @@ import ( "context" "testing" - "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" - "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" - "github.com/stackitcloud/stackit-cli/internal/pkg/testutils" - "github.com/stackitcloud/stackit-cli/internal/pkg/utils" - "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/runcommand" + runcommand "github.com/stackitcloud/stackit-sdk-go/services/runcommand/v2api" + + "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" + "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" + "github.com/stackitcloud/stackit-cli/internal/pkg/testutils" ) type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &runcommand.APIClient{} +var testClient = &runcommand.APIClient{DefaultAPI: &runcommand.DefaultAPIService{}} var testProjectId = uuid.NewString() var testServerId = uuid.NewString() @@ -59,7 +58,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *runcommand.ApiCreateCommandRequest)) runcommand.ApiCreateCommandRequest { - request := testClient.CreateCommand(testCtx, testProjectId, testServerId, testRegion) + request := testClient.DefaultAPI.CreateCommand(testCtx, testProjectId, testServerId, testRegion) request = request.CreateCommandPayload(fixturePayload()) for _, mod := range mods { mod(&request) @@ -69,7 +68,7 @@ func fixtureRequest(mods ...func(request *runcommand.ApiCreateCommandRequest)) r func fixturePayload(mods ...func(payload *runcommand.CreateCommandPayload)) runcommand.CreateCommandPayload { payload := runcommand.CreateCommandPayload{ - CommandTemplateName: utils.Ptr("RunShellScript"), + CommandTemplateName: "RunShellScript", Parameters: &map[string]string{"script": "'echo hello'"}, } for _, mod := range mods { @@ -170,7 +169,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, runcommand.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/server/command/describe/describe.go b/internal/cmd/server/command/describe/describe.go index 520ead530..9b0e25796 100644 --- a/internal/cmd/server/command/describe/describe.go +++ b/internal/cmd/server/command/describe/describe.go @@ -7,7 +7,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/types" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/runcommand" + runcommand "github.com/stackitcloud/stackit-sdk-go/services/runcommand/v2api" "github.com/stackitcloud/stackit-cli/internal/pkg/args" "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -64,7 +64,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return fmt.Errorf("read server command: %w", err) } - return outputResult(params.Printer, model.OutputFormat, *resp) + return outputResult(params.Printer, model.OutputFormat, resp) }, } configureFlags(cmd) @@ -97,12 +97,16 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *runcommand.APIClient) runcommand.ApiGetCommandRequest { - req := apiClient.GetCommand(ctx, model.ProjectId, model.Region, model.ServerId, model.CommandId) + req := apiClient.DefaultAPI.GetCommand(ctx, model.ProjectId, model.Region, model.ServerId, model.CommandId) return req } -func outputResult(p *print.Printer, outputFormat string, command runcommand.CommandDetails) error { +func outputResult(p *print.Printer, outputFormat string, command *runcommand.CommandDetails) error { return p.OutputResult(outputFormat, command, func() error { + if command == nil { + return fmt.Errorf("command is nil") + } + table := tables.NewTable() table.AddRow("ID", utils.PtrString(command.Id)) table.AddSeparator() diff --git a/internal/cmd/server/command/describe/describe_test.go b/internal/cmd/server/command/describe/describe_test.go index 67ec73b57..3440e3efd 100644 --- a/internal/cmd/server/command/describe/describe_test.go +++ b/internal/cmd/server/command/describe/describe_test.go @@ -5,19 +5,20 @@ import ( "testing" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" + "github.com/stackitcloud/stackit-cli/internal/pkg/print" "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" "github.com/stackitcloud/stackit-cli/internal/pkg/testutils" "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/runcommand" + runcommand "github.com/stackitcloud/stackit-sdk-go/services/runcommand/v2api" ) type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &runcommand.APIClient{} +var testClient = &runcommand.APIClient{DefaultAPI: &runcommand.DefaultAPIService{}} var testProjectId = uuid.NewString() var testServerId = uuid.NewString() @@ -65,7 +66,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *runcommand.ApiGetCommandRequest)) runcommand.ApiGetCommandRequest { - request := testClient.GetCommand(testCtx, testProjectId, testRegion, testServerId, testCommandId) + request := testClient.DefaultAPI.GetCommand(testCtx, testProjectId, testRegion, testServerId, testCommandId) for _, mod := range mods { mod(&request) } @@ -189,7 +190,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, runcommand.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) @@ -201,7 +202,7 @@ func TestBuildRequest(t *testing.T) { func TestOutputResult(t *testing.T) { type args struct { outputFormat string - command runcommand.CommandDetails + command *runcommand.CommandDetails } tests := []struct { name string @@ -209,10 +210,21 @@ func TestOutputResult(t *testing.T) { wantErr bool }{ { - name: "empty", - args: args{}, + name: "empty", + args: args{ + outputFormat: print.PrettyOutputFormat, + command: &runcommand.CommandDetails{}, + }, wantErr: false, }, + { + name: "command is nil", + args: args{ + outputFormat: print.PrettyOutputFormat, + command: nil, + }, + wantErr: true, + }, } params := testparams.NewTestParams() for _, tt := range tests { diff --git a/internal/cmd/server/command/list/list.go b/internal/cmd/server/command/list/list.go index 8d5e1cb77..c50cb0c0b 100644 --- a/internal/cmd/server/command/list/list.go +++ b/internal/cmd/server/command/list/list.go @@ -9,7 +9,7 @@ import ( iaasClient "github.com/stackitcloud/stackit-cli/internal/pkg/services/iaas/client" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/runcommand" + runcommand "github.com/stackitcloud/stackit-sdk-go/services/runcommand/v2api" "github.com/stackitcloud/stackit-cli/internal/pkg/args" "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -125,7 +125,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, } func buildRequest(ctx context.Context, model *inputModel, apiClient *runcommand.APIClient) runcommand.ApiListCommandsRequest { - req := apiClient.ListCommands(ctx, model.ProjectId, model.ServerId, model.Region) + req := apiClient.DefaultAPI.ListCommands(ctx, model.ProjectId, model.ServerId, model.Region) return req } diff --git a/internal/cmd/server/command/list/list_test.go b/internal/cmd/server/command/list/list_test.go index 413546d30..c6cafa8f8 100644 --- a/internal/cmd/server/command/list/list_test.go +++ b/internal/cmd/server/command/list/list_test.go @@ -12,13 +12,13 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/runcommand" + runcommand "github.com/stackitcloud/stackit-sdk-go/services/runcommand/v2api" ) type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &runcommand.APIClient{} +var testClient = &runcommand.APIClient{DefaultAPI: &runcommand.DefaultAPIService{}} var testProjectId = uuid.NewString() var testServerId = uuid.NewString() @@ -56,7 +56,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *runcommand.ApiListCommandsRequest)) runcommand.ApiListCommandsRequest { - request := testClient.ListCommands(testCtx, testProjectId, testServerId, testRegion) + request := testClient.DefaultAPI.ListCommands(testCtx, testProjectId, testServerId, testRegion) for _, mod := range mods { mod(&request) } @@ -145,7 +145,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, runcommand.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/server/command/template/describe/describe.go b/internal/cmd/server/command/template/describe/describe.go index 486e5c6ac..3c3f6a2b1 100644 --- a/internal/cmd/server/command/template/describe/describe.go +++ b/internal/cmd/server/command/template/describe/describe.go @@ -7,7 +7,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/types" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/runcommand" + runcommand "github.com/stackitcloud/stackit-sdk-go/services/runcommand/v2api" "github.com/stackitcloud/stackit-cli/internal/pkg/args" "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -97,7 +97,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *runcommand.APIClient) runcommand.ApiGetCommandTemplateRequest { - req := apiClient.GetCommandTemplate(ctx, model.ProjectId, model.ServerId, model.CommandTemplateName, model.Region) + req := apiClient.DefaultAPI.GetCommandTemplate(ctx, model.ProjectId, model.ServerId, model.CommandTemplateName, model.Region) return req } @@ -111,7 +111,7 @@ func outputResult(p *print.Printer, outputFormat string, commandTemplate runcomm table.AddRow("DESCRIPTION", utils.PtrString(commandTemplate.Description)) table.AddSeparator() if commandTemplate.OsType != nil { - table.AddRow("OS TYPE", utils.JoinStringPtr(commandTemplate.OsType, "\n")) + table.AddRow("OS TYPE", utils.JoinStringPtr(&commandTemplate.OsType, "\n")) table.AddSeparator() } if commandTemplate.ParametersSchema != nil { diff --git a/internal/cmd/server/command/template/describe/describe_test.go b/internal/cmd/server/command/template/describe/describe_test.go index 38068bfcb..bd4cacb53 100644 --- a/internal/cmd/server/command/template/describe/describe_test.go +++ b/internal/cmd/server/command/template/describe/describe_test.go @@ -11,13 +11,13 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/runcommand" + runcommand "github.com/stackitcloud/stackit-sdk-go/services/runcommand/v2api" ) type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &runcommand.APIClient{} +var testClient = &runcommand.APIClient{DefaultAPI: &runcommand.DefaultAPIService{}} var testProjectId = uuid.NewString() var testServerId = uuid.NewString() @@ -65,7 +65,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *runcommand.ApiGetCommandTemplateRequest)) runcommand.ApiGetCommandTemplateRequest { - request := testClient.GetCommandTemplate(testCtx, testProjectId, testServerId, testCommandTemplateName, testRegion) + request := testClient.DefaultAPI.GetCommandTemplate(testCtx, testProjectId, testServerId, testCommandTemplateName, testRegion) for _, mod := range mods { mod(&request) } @@ -189,7 +189,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, runcommand.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/server/command/template/list/list.go b/internal/cmd/server/command/template/list/list.go index 5fe35fb86..6258a0608 100644 --- a/internal/cmd/server/command/template/list/list.go +++ b/internal/cmd/server/command/template/list/list.go @@ -7,7 +7,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/types" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/runcommand" + runcommand "github.com/stackitcloud/stackit-sdk-go/services/runcommand/v2api" "github.com/stackitcloud/stackit-cli/internal/pkg/args" "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -104,7 +104,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, } func buildRequest(ctx context.Context, _ *inputModel, apiClient *runcommand.APIClient) runcommand.ApiListCommandTemplatesRequest { - req := apiClient.ListCommandTemplates(ctx) + req := apiClient.DefaultAPI.ListCommandTemplates(ctx) return req } @@ -116,12 +116,10 @@ func outputResult(p *print.Printer, outputFormat string, templates []runcommand. } table := tables.NewTable() table.SetHeader("NAME", "OS TYPE", "TITLE") - for i := range templates { - s := templates[i] - + for _, s := range templates { var osType string - if s.OsType != nil && len(*s.OsType) > 0 { - osType = utils.JoinStringPtr(s.OsType, ",") + if len(s.OsType) > 0 { + osType = utils.JoinStringPtr(&s.OsType, ",") } table.AddRow( diff --git a/internal/cmd/server/command/template/list/list_test.go b/internal/cmd/server/command/template/list/list_test.go index 63a71ab6e..895bb5f23 100644 --- a/internal/cmd/server/command/template/list/list_test.go +++ b/internal/cmd/server/command/template/list/list_test.go @@ -12,13 +12,13 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/runcommand" + runcommand "github.com/stackitcloud/stackit-sdk-go/services/runcommand/v2api" ) type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &runcommand.APIClient{} +var testClient = &runcommand.APIClient{DefaultAPI: &runcommand.DefaultAPIService{}} var testProjectId = uuid.NewString() func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string { @@ -47,7 +47,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *runcommand.ApiListCommandTemplatesRequest)) runcommand.ApiListCommandTemplatesRequest { - request := testClient.ListCommandTemplates(testCtx) + request := testClient.DefaultAPI.ListCommandTemplates(testCtx) for _, mod := range mods { mod(&request) } @@ -136,7 +136,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, runcommand.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/pkg/services/runcommand/client/client.go b/internal/pkg/services/runcommand/client/client.go index 1ecb49f4f..f1c3cd94b 100644 --- a/internal/pkg/services/runcommand/client/client.go +++ b/internal/pkg/services/runcommand/client/client.go @@ -6,7 +6,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/print" "github.com/spf13/viper" - "github.com/stackitcloud/stackit-sdk-go/services/runcommand" + runcommand "github.com/stackitcloud/stackit-sdk-go/services/runcommand/v2api" ) func ConfigureClient(p *print.Printer, cliVersion string) (*runcommand.APIClient, error) { From 749be04f44bd1410a9bb3dffe29f487b6571af36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ruben=20H=C3=B6nle?= Date: Wed, 22 Jul 2026 10:55:07 +0200 Subject: [PATCH 39/44] chore(serverupdate): switch to new sdk structure (#1486) relates to STACKITCLI-354 --- docs/stackit_server_os-update_create.md | 6 +-- ...tackit_server_os-update_schedule_create.md | 12 +++--- ...tackit_server_os-update_schedule_update.md | 12 +++--- go.mod | 2 +- go.sum | 4 +- .../cmd/server/os-update/create/create.go | 27 +++++++------ .../server/os-update/create/create_test.go | 39 ++++++++++++------- .../cmd/server/os-update/describe/describe.go | 18 +++++---- .../os-update/describe/describe_test.go | 27 +++++++++---- .../cmd/server/os-update/disable/disable.go | 4 +- .../server/os-update/disable/disable_test.go | 8 ++-- .../cmd/server/os-update/enable/enable.go | 4 +- .../server/os-update/enable/enable_test.go | 8 ++-- internal/cmd/server/os-update/list/list.go | 15 ++++--- .../cmd/server/os-update/list/list_test.go | 8 ++-- .../os-update/schedule/create/create.go | 25 ++++++------ .../os-update/schedule/create/create_test.go | 27 +++++++------ .../os-update/schedule/delete/delete.go | 4 +- .../os-update/schedule/delete/delete_test.go | 8 ++-- .../os-update/schedule/describe/describe.go | 15 ++++--- .../schedule/describe/describe_test.go | 8 ++-- .../server/os-update/schedule/list/list.go | 15 ++++--- .../os-update/schedule/list/list_test.go | 8 ++-- .../os-update/schedule/update/update.go | 23 ++++++----- .../os-update/schedule/update/update_test.go | 36 ++++++++--------- internal/pkg/flags/flag_to_value.go | 11 ++++++ .../services/serverosupdate/client/client.go | 2 +- 27 files changed, 205 insertions(+), 171 deletions(-) diff --git a/docs/stackit_server_os-update_create.md b/docs/stackit_server_os-update_create.md index d7661419a..b6ef789a6 100644 --- a/docs/stackit_server_os-update_create.md +++ b/docs/stackit_server_os-update_create.md @@ -23,9 +23,9 @@ stackit server os-update create [flags] ### Options ``` - -h, --help Help for "stackit server os-update create" - -m, --maintenance-window int Maintenance window (in hours, 1-24) (default 23) - -s, --server-id string Server ID + -h, --help Help for "stackit server os-update create" + -m, --maintenance-window int32 Maintenance window (in hours, 1-24) (default 23) + -s, --server-id string Server ID ``` ### Options inherited from parent commands diff --git a/docs/stackit_server_os-update_schedule_create.md b/docs/stackit_server_os-update_schedule_create.md index fed9333d2..8ca37455e 100644 --- a/docs/stackit_server_os-update_schedule_create.md +++ b/docs/stackit_server_os-update_schedule_create.md @@ -23,12 +23,12 @@ stackit server os-update schedule create [flags] ### Options ``` - -e, --enabled Is the server os-update schedule enabled (default true) - -h, --help Help for "stackit server os-update schedule create" - -d, --maintenance-window int os-update maintenance window (in hours, 1-24) (default 23) - -n, --name string os-update schedule name - -r, --rrule string os-update RRULE (recurrence rule) (default "DTSTART;TZID=Europe/Sofia:20200803T023000 RRULE:FREQ=DAILY;INTERVAL=1") - -s, --server-id string Server ID + -e, --enabled Is the server os-update schedule enabled (default true) + -h, --help Help for "stackit server os-update schedule create" + -d, --maintenance-window int32 os-update maintenance window (in hours, 1-24) (default 23) + -n, --name string os-update schedule name + -r, --rrule string os-update RRULE (recurrence rule) (default "DTSTART;TZID=Europe/Sofia:20200803T023000 RRULE:FREQ=DAILY;INTERVAL=1") + -s, --server-id string Server ID ``` ### Options inherited from parent commands diff --git a/docs/stackit_server_os-update_schedule_update.md b/docs/stackit_server_os-update_schedule_update.md index 1515127ac..607150636 100644 --- a/docs/stackit_server_os-update_schedule_update.md +++ b/docs/stackit_server_os-update_schedule_update.md @@ -20,12 +20,12 @@ stackit server os-update schedule update SCHEDULE_ID [flags] ### Options ``` - -e, --enabled Is the server os-update schedule enabled (default true) - -h, --help Help for "stackit server os-update schedule update" - -d, --maintenance-window int Maintenance window (in hours, 1-24) (default 23) - -n, --name string os-update schedule name - -r, --rrule string os-update RRULE (recurrence rule) (default "DTSTART;TZID=Europe/Sofia:20200803T023000 RRULE:FREQ=DAILY;INTERVAL=1") - -s, --server-id string Server ID + -e, --enabled Is the server os-update schedule enabled (default true) + -h, --help Help for "stackit server os-update schedule update" + -d, --maintenance-window int32 Maintenance window (in hours, 1-24) (default 23) + -n, --name string os-update schedule name + -r, --rrule string os-update RRULE (recurrence rule) (default "DTSTART;TZID=Europe/Sofia:20200803T023000 RRULE:FREQ=DAILY;INTERVAL=1") + -s, --server-id string Server ID ``` ### Options inherited from parent commands diff --git a/go.mod b/go.mod index e36afda0c..a8db820bb 100644 --- a/go.mod +++ b/go.mod @@ -32,7 +32,7 @@ require ( github.com/stackitcloud/stackit-sdk-go/services/runcommand v1.8.0 github.com/stackitcloud/stackit-sdk-go/services/secretsmanager v0.18.1 github.com/stackitcloud/stackit-sdk-go/services/serverbackup v1.3.8 - github.com/stackitcloud/stackit-sdk-go/services/serverupdate v1.2.6 + github.com/stackitcloud/stackit-sdk-go/services/serverupdate v1.5.2 github.com/stackitcloud/stackit-sdk-go/services/serviceaccount v0.12.0 github.com/stackitcloud/stackit-sdk-go/services/serviceenablement v1.2.7 github.com/stackitcloud/stackit-sdk-go/services/ske v1.11.0 diff --git a/go.sum b/go.sum index f83170615..f64e57464 100644 --- a/go.sum +++ b/go.sum @@ -640,8 +640,8 @@ github.com/stackitcloud/stackit-sdk-go/services/secretsmanager v0.18.1 h1:U5rstX github.com/stackitcloud/stackit-sdk-go/services/secretsmanager v0.18.1/go.mod h1:2XA8PE05Qg6BL2YXO4XgfGI9qskJ3cicLE5Qq0aqDdY= github.com/stackitcloud/stackit-sdk-go/services/serverbackup v1.3.8 h1:LLyANBzE8sQa0/49tQBqq4sVLhNgwdqCeQm76srJHWw= github.com/stackitcloud/stackit-sdk-go/services/serverbackup v1.3.8/go.mod h1:/bmg57XZu+bGczzcoumrukiGMPGzI2mOyTT4BVIQUBs= -github.com/stackitcloud/stackit-sdk-go/services/serverupdate v1.2.6 h1:sQ3fdtUjgIL2Ul8nRYVVacHOwi5aSMTGGbYVL30oQBU= -github.com/stackitcloud/stackit-sdk-go/services/serverupdate v1.2.6/go.mod h1:3fjlL+9YtuI9Oocl1ZeYIK48ImtY4DwPggFhqAygr7o= +github.com/stackitcloud/stackit-sdk-go/services/serverupdate v1.5.2 h1:6C/iTPoYPCrZOc3JMmvyDNs4hm+JR5p9O3DIfFGgnbo= +github.com/stackitcloud/stackit-sdk-go/services/serverupdate v1.5.2/go.mod h1:/OHYZXQb9KXDdZK5J9C2YS6DJUD2i6ednZ1rK7zpDZ0= github.com/stackitcloud/stackit-sdk-go/services/serviceaccount v0.12.0 h1:l1EDIlXce2C8JcbBDHVa6nZ4SjPTqmnALTgrhms+NKI= github.com/stackitcloud/stackit-sdk-go/services/serviceaccount v0.12.0/go.mod h1:EXq8/J7t9p8zPmdIq+atuxyAbnQwxrQT18fI+Qpv98k= github.com/stackitcloud/stackit-sdk-go/services/serviceenablement v1.2.7 h1:M2PYLF8k3zmAwYWSKfUiCTNTXr7ROGuJganVVEQA3YI= diff --git a/internal/cmd/server/os-update/create/create.go b/internal/cmd/server/os-update/create/create.go index eb0f26614..a41e2da18 100644 --- a/internal/cmd/server/os-update/create/create.go +++ b/internal/cmd/server/os-update/create/create.go @@ -8,6 +8,9 @@ import ( iaasClient "github.com/stackitcloud/stackit-cli/internal/pkg/services/iaas/client" + "github.com/spf13/cobra" + serverupdate "github.com/stackitcloud/stackit-sdk-go/services/serverupdate/v2api" + "github.com/stackitcloud/stackit-cli/internal/pkg/args" cliErr "github.com/stackitcloud/stackit-cli/internal/pkg/errors" "github.com/stackitcloud/stackit-cli/internal/pkg/examples" @@ -16,10 +19,6 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/print" iaasUtils "github.com/stackitcloud/stackit-cli/internal/pkg/services/iaas/utils" "github.com/stackitcloud/stackit-cli/internal/pkg/services/serverosupdate/client" - "github.com/stackitcloud/stackit-cli/internal/pkg/utils" - - "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/serverupdate" ) const ( @@ -32,7 +31,7 @@ type inputModel struct { *globalflags.GlobalFlagModel ServerId string - MaintenanceWindow int64 + MaintenanceWindow int32 } func NewCmd(params *types.CmdParams) *cobra.Command { @@ -90,7 +89,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return fmt.Errorf("create Server os-update: %w", err) } - return outputResult(params.Printer, model.OutputFormat, serverLabel, *resp) + return outputResult(params.Printer, model.OutputFormat, serverLabel, resp) }, } configureFlags(cmd) @@ -99,7 +98,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { func configureFlags(cmd *cobra.Command) { cmd.Flags().VarP(flags.UUIDFlag(), serverIdFlag, "s", "Server ID") - cmd.Flags().Int64P(maintenanceWindowFlag, "m", defaultMaintenanceWindow, "Maintenance window (in hours, 1-24)") + cmd.Flags().Int32P(maintenanceWindowFlag, "m", defaultMaintenanceWindow, "Maintenance window (in hours, 1-24)") } func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, error) { @@ -111,7 +110,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, model := inputModel{ GlobalFlagModel: globalFlags, ServerId: flags.FlagToStringValue(p, cmd, serverIdFlag), - MaintenanceWindow: flags.FlagWithDefaultToInt64Value(p, cmd, maintenanceWindowFlag), + MaintenanceWindow: flags.FlagWithDefaultToInt32Value(p, cmd, maintenanceWindowFlag), } p.DebugInputModel(model) @@ -119,17 +118,21 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, } func buildRequest(ctx context.Context, model *inputModel, apiClient *serverupdate.APIClient) (serverupdate.ApiCreateUpdateRequest, error) { - req := apiClient.CreateUpdate(ctx, model.ProjectId, model.ServerId, model.Region) + req := apiClient.DefaultAPI.CreateUpdate(ctx, model.ProjectId, model.ServerId, model.Region) payload := serverupdate.CreateUpdatePayload{ - MaintenanceWindow: &model.MaintenanceWindow, + MaintenanceWindow: model.MaintenanceWindow, } req = req.CreateUpdatePayload(payload) return req, nil } -func outputResult(p *print.Printer, outputFormat, serverLabel string, resp serverupdate.Update) error { +func outputResult(p *print.Printer, outputFormat, serverLabel string, resp *serverupdate.Update) error { return p.OutputResult(outputFormat, resp, func() error { - p.Outputf("Triggered creation of server os-update for server %s. Update ID: %s\n", serverLabel, utils.PtrString(resp.Id)) + if resp == nil { + return fmt.Errorf("response is nil") + } + + p.Outputf("Triggered creation of server os-update for server %s. Update ID: %d\n", serverLabel, resp.Id) return nil }) } diff --git a/internal/cmd/server/os-update/create/create_test.go b/internal/cmd/server/os-update/create/create_test.go index 672dc948a..fd0cdf2ff 100644 --- a/internal/cmd/server/os-update/create/create_test.go +++ b/internal/cmd/server/os-update/create/create_test.go @@ -4,15 +4,15 @@ import ( "context" "testing" - "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" - "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" - "github.com/stackitcloud/stackit-cli/internal/pkg/testutils" - "github.com/stackitcloud/stackit-cli/internal/pkg/utils" - "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/serverupdate" + serverupdate "github.com/stackitcloud/stackit-sdk-go/services/serverupdate/v2api" + + "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" + "github.com/stackitcloud/stackit-cli/internal/pkg/print" + "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" + "github.com/stackitcloud/stackit-cli/internal/pkg/testutils" ) const ( @@ -22,7 +22,7 @@ const ( type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &serverupdate.APIClient{} +var testClient = &serverupdate.APIClient{DefaultAPI: &serverupdate.DefaultAPIService{}} var testProjectId = uuid.NewString() var testServerId = uuid.NewString() @@ -48,7 +48,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { Verbosity: globalflags.VerbosityDefault, }, ServerId: testServerId, - MaintenanceWindow: int64(13), + MaintenanceWindow: int32(13), } for _, mod := range mods { mod(model) @@ -57,7 +57,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *serverupdate.ApiCreateUpdateRequest)) serverupdate.ApiCreateUpdateRequest { - request := testClient.CreateUpdate(testCtx, testProjectId, testServerId, testRegion) + request := testClient.DefaultAPI.CreateUpdate(testCtx, testProjectId, testServerId, testRegion) request = request.CreateUpdatePayload(fixturePayload()) for _, mod := range mods { mod(&request) @@ -67,7 +67,7 @@ func fixtureRequest(mods ...func(request *serverupdate.ApiCreateUpdateRequest)) func fixturePayload(mods ...func(payload *serverupdate.CreateUpdatePayload)) serverupdate.CreateUpdatePayload { payload := serverupdate.CreateUpdatePayload{ - MaintenanceWindow: utils.Ptr(int64(13)), + MaintenanceWindow: int32(13), } for _, mod := range mods { mod(&payload) @@ -162,7 +162,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, serverupdate.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) @@ -175,7 +175,7 @@ func TestOutputResult(t *testing.T) { type args struct { outputFormat string serverLabel string - resp serverupdate.Update + resp *serverupdate.Update } tests := []struct { name string @@ -183,10 +183,21 @@ func TestOutputResult(t *testing.T) { wantErr bool }{ { - name: "empty", - args: args{}, + name: "empty", + args: args{ + outputFormat: print.PrettyOutputFormat, + resp: &serverupdate.Update{}, + }, wantErr: false, }, + { + name: "nil", + args: args{ + outputFormat: print.PrettyOutputFormat, + resp: nil, + }, + wantErr: true, + }, } params := testparams.NewTestParams() for _, tt := range tests { diff --git a/internal/cmd/server/os-update/describe/describe.go b/internal/cmd/server/os-update/describe/describe.go index 8d349791b..f1550583e 100644 --- a/internal/cmd/server/os-update/describe/describe.go +++ b/internal/cmd/server/os-update/describe/describe.go @@ -7,7 +7,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/types" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/serverupdate" + serverupdate "github.com/stackitcloud/stackit-sdk-go/services/serverupdate/v2api" "github.com/stackitcloud/stackit-cli/internal/pkg/args" "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -64,7 +64,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return fmt.Errorf("read server os-update: %w", err) } - return outputResult(params.Printer, model.OutputFormat, *resp) + return outputResult(params.Printer, model.OutputFormat, resp) }, } configureFlags(cmd) @@ -97,16 +97,20 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *serverupdate.APIClient) serverupdate.ApiGetUpdateRequest { - req := apiClient.GetUpdate(ctx, model.ProjectId, model.ServerId, model.UpdateId, model.Region) + req := apiClient.DefaultAPI.GetUpdate(ctx, model.ProjectId, model.ServerId, model.UpdateId, model.Region) return req } -func outputResult(p *print.Printer, outputFormat string, update serverupdate.Update) error { +func outputResult(p *print.Printer, outputFormat string, update *serverupdate.Update) error { return p.OutputResult(outputFormat, update, func() error { + if update == nil { + return fmt.Errorf("update is nil") + } + table := tables.NewTable() - table.AddRow("ID", utils.PtrString(update.Id)) + table.AddRow("ID", update.Id) table.AddSeparator() - table.AddRow("STATUS", utils.PtrString(update.Status)) + table.AddRow("STATUS", update.Status) table.AddSeparator() installedUpdates := utils.PtrStringDefault(update.InstalledUpdates, "n/a") table.AddRow("INSTALLED UPDATES", installedUpdates) @@ -114,7 +118,7 @@ func outputResult(p *print.Printer, outputFormat string, update serverupdate.Upd failedUpdates := utils.PtrStringDefault(update.FailedUpdates, "n/a") table.AddRow("FAILED UPDATES", failedUpdates) - table.AddRow("START DATE", utils.PtrString(update.StartDate)) + table.AddRow("START DATE", update.StartDate) table.AddSeparator() table.AddRow("END DATE", utils.PtrString(update.EndDate)) table.AddSeparator() diff --git a/internal/cmd/server/os-update/describe/describe_test.go b/internal/cmd/server/os-update/describe/describe_test.go index 5284f9016..e3c84be5c 100644 --- a/internal/cmd/server/os-update/describe/describe_test.go +++ b/internal/cmd/server/os-update/describe/describe_test.go @@ -11,7 +11,9 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/serverupdate" + serverupdate "github.com/stackitcloud/stackit-sdk-go/services/serverupdate/v2api" + + "github.com/stackitcloud/stackit-cli/internal/pkg/print" ) const ( @@ -21,7 +23,7 @@ const ( type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &serverupdate.APIClient{} +var testClient = &serverupdate.APIClient{DefaultAPI: &serverupdate.DefaultAPIService{}} var testProjectId = uuid.NewString() var testServerId = uuid.NewString() var testUpdateId = uuid.NewString() @@ -65,7 +67,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *serverupdate.ApiGetUpdateRequest)) serverupdate.ApiGetUpdateRequest { - request := testClient.GetUpdate(testCtx, testProjectId, testServerId, testUpdateId, testRegion) + request := testClient.DefaultAPI.GetUpdate(testCtx, testProjectId, testServerId, testUpdateId, testRegion) for _, mod := range mods { mod(&request) } @@ -159,7 +161,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, serverupdate.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) @@ -171,7 +173,7 @@ func TestBuildRequest(t *testing.T) { func TestOutputResult(t *testing.T) { type args struct { outputFormat string - update serverupdate.Update + update *serverupdate.Update } tests := []struct { name string @@ -179,10 +181,21 @@ func TestOutputResult(t *testing.T) { wantErr bool }{ { - name: "empty", - args: args{}, + name: "empty", + args: args{ + outputFormat: print.PrettyOutputFormat, + update: &serverupdate.Update{}, + }, wantErr: false, }, + { + name: "nil", + args: args{ + outputFormat: print.PrettyOutputFormat, + update: nil, + }, + wantErr: true, + }, } params := testparams.NewTestParams() for _, tt := range tests { diff --git a/internal/cmd/server/os-update/disable/disable.go b/internal/cmd/server/os-update/disable/disable.go index b5e63b750..9766e3526 100644 --- a/internal/cmd/server/os-update/disable/disable.go +++ b/internal/cmd/server/os-update/disable/disable.go @@ -17,7 +17,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/services/serverosupdate/client" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/serverupdate" + serverupdate "github.com/stackitcloud/stackit-sdk-go/services/serverupdate/v2api" ) const ( @@ -108,6 +108,6 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, } func buildRequest(ctx context.Context, model *inputModel, apiClient *serverupdate.APIClient) serverupdate.ApiDisableServiceResourceRequest { - req := apiClient.DisableServiceResource(ctx, model.ProjectId, model.ServerId, model.Region) + req := apiClient.DefaultAPI.DisableServiceResource(ctx, model.ProjectId, model.ServerId, model.Region) return req } diff --git a/internal/cmd/server/os-update/disable/disable_test.go b/internal/cmd/server/os-update/disable/disable_test.go index b7d28e23c..7726b10e6 100644 --- a/internal/cmd/server/os-update/disable/disable_test.go +++ b/internal/cmd/server/os-update/disable/disable_test.go @@ -10,7 +10,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/serverupdate" + serverupdate "github.com/stackitcloud/stackit-sdk-go/services/serverupdate/v2api" ) const ( @@ -20,7 +20,7 @@ const ( type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &serverupdate.APIClient{} +var testClient = &serverupdate.APIClient{DefaultAPI: &serverupdate.DefaultAPIService{}} var testProjectId = uuid.NewString() var testServerId = uuid.NewString() @@ -52,7 +52,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *serverupdate.ApiDisableServiceResourceRequest)) serverupdate.ApiDisableServiceResourceRequest { - request := testClient.DisableServiceResource(testCtx, testProjectId, testServerId, testRegion) + request := testClient.DefaultAPI.DisableServiceResource(testCtx, testProjectId, testServerId, testRegion) for _, mod := range mods { mod(&request) } @@ -134,7 +134,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, serverupdate.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/server/os-update/enable/enable.go b/internal/cmd/server/os-update/enable/enable.go index b8eba5760..779a6150f 100644 --- a/internal/cmd/server/os-update/enable/enable.go +++ b/internal/cmd/server/os-update/enable/enable.go @@ -18,7 +18,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/services/serverosupdate/client" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/serverupdate" + serverupdate "github.com/stackitcloud/stackit-sdk-go/services/serverupdate/v2api" ) const ( @@ -112,6 +112,6 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, func buildRequest(ctx context.Context, model *inputModel, apiClient *serverupdate.APIClient) serverupdate.ApiEnableServiceResourceRequest { payload := serverupdate.EnableServiceResourcePayload{} - req := apiClient.EnableServiceResource(ctx, model.ProjectId, model.ServerId, model.Region).EnableServiceResourcePayload(payload) + req := apiClient.DefaultAPI.EnableServiceResource(ctx, model.ProjectId, model.ServerId, model.Region).EnableServiceResourcePayload(payload) return req } diff --git a/internal/cmd/server/os-update/enable/enable_test.go b/internal/cmd/server/os-update/enable/enable_test.go index 4ebed0b3a..94d9f1ce9 100644 --- a/internal/cmd/server/os-update/enable/enable_test.go +++ b/internal/cmd/server/os-update/enable/enable_test.go @@ -10,7 +10,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/serverupdate" + serverupdate "github.com/stackitcloud/stackit-sdk-go/services/serverupdate/v2api" ) const ( @@ -20,7 +20,7 @@ const ( type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &serverupdate.APIClient{} +var testClient = &serverupdate.APIClient{DefaultAPI: &serverupdate.DefaultAPIService{}} var testProjectId = uuid.NewString() var testServerId = uuid.NewString() @@ -52,7 +52,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *serverupdate.ApiEnableServiceResourceRequest)) serverupdate.ApiEnableServiceResourceRequest { - request := testClient.EnableServiceResource(testCtx, testProjectId, testServerId, testRegion).EnableServiceResourcePayload(serverupdate.EnableServiceResourcePayload{}) + request := testClient.DefaultAPI.EnableServiceResource(testCtx, testProjectId, testServerId, testRegion).EnableServiceResourcePayload(serverupdate.EnableServiceResourcePayload{}) for _, mod := range mods { mod(&request) } @@ -134,7 +134,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, serverupdate.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/server/os-update/list/list.go b/internal/cmd/server/os-update/list/list.go index 6dc0557c5..19ef3ba2f 100644 --- a/internal/cmd/server/os-update/list/list.go +++ b/internal/cmd/server/os-update/list/list.go @@ -3,7 +3,6 @@ package list import ( "context" "fmt" - "strconv" "github.com/stackitcloud/stackit-cli/internal/pkg/types" @@ -20,7 +19,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/serverupdate" + serverupdate "github.com/stackitcloud/stackit-sdk-go/services/serverupdate/v2api" ) const ( @@ -124,7 +123,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, } func buildRequest(ctx context.Context, model *inputModel, apiClient *serverupdate.APIClient) serverupdate.ApiListUpdatesRequest { - req := apiClient.ListUpdates(ctx, model.ProjectId, model.ServerId, model.Region) + req := apiClient.DefaultAPI.ListUpdates(ctx, model.ProjectId, model.ServerId, model.Region) return req } @@ -143,20 +142,20 @@ func outputResult(p *print.Printer, outputFormat, serverLabel string, updates [] installed := "n/a" if s.InstalledUpdates != nil { - installed = strconv.FormatInt(*s.InstalledUpdates, 10) + installed = utils.PtrString(s.InstalledUpdates) } failed := "n/a" if s.FailedUpdates != nil { - failed = strconv.FormatInt(*s.FailedUpdates, 10) + failed = utils.PtrString(s.FailedUpdates) } table.AddRow( - utils.PtrString(s.Id), - utils.PtrString(s.Status), + s.Id, + s.Status, installed, failed, - utils.PtrString(s.StartDate), + s.StartDate, endDate, ) } diff --git a/internal/cmd/server/os-update/list/list_test.go b/internal/cmd/server/os-update/list/list_test.go index 7655b1d68..b91621d4e 100644 --- a/internal/cmd/server/os-update/list/list_test.go +++ b/internal/cmd/server/os-update/list/list_test.go @@ -12,7 +12,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/serverupdate" + serverupdate "github.com/stackitcloud/stackit-sdk-go/services/serverupdate/v2api" ) const ( @@ -22,7 +22,7 @@ const ( type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &serverupdate.APIClient{} +var testClient = &serverupdate.APIClient{DefaultAPI: &serverupdate.DefaultAPIService{}} var testProjectId = uuid.NewString() var testServerId = uuid.NewString() @@ -56,7 +56,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *serverupdate.ApiListUpdatesRequest)) serverupdate.ApiListUpdatesRequest { - request := testClient.ListUpdates(testCtx, testProjectId, testServerId, testRegion) + request := testClient.DefaultAPI.ListUpdates(testCtx, testProjectId, testServerId, testRegion) for _, mod := range mods { mod(&request) } @@ -145,7 +145,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, serverupdate.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/server/os-update/schedule/create/create.go b/internal/cmd/server/os-update/schedule/create/create.go index b77a50483..d58deb706 100644 --- a/internal/cmd/server/os-update/schedule/create/create.go +++ b/internal/cmd/server/os-update/schedule/create/create.go @@ -6,6 +6,9 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/types" + "github.com/spf13/cobra" + serverupdate "github.com/stackitcloud/stackit-sdk-go/services/serverupdate/v2api" + "github.com/stackitcloud/stackit-cli/internal/pkg/args" cliErr "github.com/stackitcloud/stackit-cli/internal/pkg/errors" "github.com/stackitcloud/stackit-cli/internal/pkg/examples" @@ -15,10 +18,6 @@ import ( iaasClient "github.com/stackitcloud/stackit-cli/internal/pkg/services/iaas/client" iaasUtils "github.com/stackitcloud/stackit-cli/internal/pkg/services/iaas/utils" "github.com/stackitcloud/stackit-cli/internal/pkg/services/serverosupdate/client" - "github.com/stackitcloud/stackit-cli/internal/pkg/utils" - - "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/serverupdate" ) const ( @@ -40,7 +39,7 @@ type inputModel struct { ScheduleName string Enabled bool Rrule string - MaintenanceWindow int64 + MaintenanceWindow int32 } func NewCmd(params *types.CmdParams) *cobra.Command { @@ -108,7 +107,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { func configureFlags(cmd *cobra.Command) { cmd.Flags().VarP(flags.UUIDFlag(), serverIdFlag, "s", "Server ID") cmd.Flags().StringP(nameFlag, "n", "", "os-update schedule name") - cmd.Flags().Int64P(maintenanceWindowFlag, "d", defaultMaintenanceWindow, "os-update maintenance window (in hours, 1-24)") + cmd.Flags().Int32P(maintenanceWindowFlag, "d", defaultMaintenanceWindow, "os-update maintenance window (in hours, 1-24)") cmd.Flags().BoolP(enabledFlag, "e", defaultEnabled, "Is the server os-update schedule enabled") cmd.Flags().StringP(rruleFlag, "r", defaultRrule, "os-update RRULE (recurrence rule)") @@ -125,7 +124,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, model := inputModel{ GlobalFlagModel: globalFlags, ServerId: flags.FlagToStringValue(p, cmd, serverIdFlag), - MaintenanceWindow: flags.FlagWithDefaultToInt64Value(p, cmd, maintenanceWindowFlag), + MaintenanceWindow: flags.FlagWithDefaultToInt32Value(p, cmd, maintenanceWindowFlag), ScheduleName: flags.FlagToStringValue(p, cmd, nameFlag), Rrule: flags.FlagWithDefaultToStringValue(p, cmd, rruleFlag), Enabled: flags.FlagToBoolValue(p, cmd, enabledFlag), @@ -136,19 +135,19 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, } func buildRequest(ctx context.Context, model *inputModel, apiClient *serverupdate.APIClient) (serverupdate.ApiCreateUpdateScheduleRequest, error) { - req := apiClient.CreateUpdateSchedule(ctx, model.ProjectId, model.ServerId, model.Region) + req := apiClient.DefaultAPI.CreateUpdateSchedule(ctx, model.ProjectId, model.ServerId, model.Region) req = req.CreateUpdateSchedulePayload(serverupdate.CreateUpdateSchedulePayload{ - Enabled: &model.Enabled, - Name: &model.ScheduleName, - Rrule: &model.Rrule, - MaintenanceWindow: &model.MaintenanceWindow, + Enabled: model.Enabled, + Name: model.ScheduleName, + Rrule: model.Rrule, + MaintenanceWindow: model.MaintenanceWindow, }) return req, nil } func outputResult(p *print.Printer, outputFormat, serverLabel string, resp serverupdate.UpdateSchedule) error { return p.OutputResult(outputFormat, resp, func() error { - p.Outputf("Created server os-update schedule for server %s. os-update Schedule ID: %s\n", serverLabel, utils.PtrString(resp.Id)) + p.Outputf("Created server os-update schedule for server %s. os-update Schedule ID: %d\n", serverLabel, resp.Id) return nil }) } diff --git a/internal/cmd/server/os-update/schedule/create/create_test.go b/internal/cmd/server/os-update/schedule/create/create_test.go index 02140ea02..3e046359d 100644 --- a/internal/cmd/server/os-update/schedule/create/create_test.go +++ b/internal/cmd/server/os-update/schedule/create/create_test.go @@ -4,15 +4,14 @@ import ( "context" "testing" - "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" - "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" - "github.com/stackitcloud/stackit-cli/internal/pkg/testutils" - "github.com/stackitcloud/stackit-cli/internal/pkg/utils" - "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/serverupdate" + serverupdate "github.com/stackitcloud/stackit-sdk-go/services/serverupdate/v2api" + + "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" + "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" + "github.com/stackitcloud/stackit-cli/internal/pkg/testutils" ) const ( @@ -22,7 +21,7 @@ const ( type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &serverupdate.APIClient{} +var testClient = &serverupdate.APIClient{DefaultAPI: &serverupdate.DefaultAPIService{}} var testProjectId = uuid.NewString() var testServerId = uuid.NewString() @@ -54,7 +53,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { ScheduleName: "example-schedule-name", Enabled: defaultEnabled, Rrule: defaultRrule, - MaintenanceWindow: int64(23), + MaintenanceWindow: int32(23), } for _, mod := range mods { mod(model) @@ -63,7 +62,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *serverupdate.ApiCreateUpdateScheduleRequest)) serverupdate.ApiCreateUpdateScheduleRequest { - request := testClient.CreateUpdateSchedule(testCtx, testProjectId, testServerId, testRegion) + request := testClient.DefaultAPI.CreateUpdateSchedule(testCtx, testProjectId, testServerId, testRegion) request = request.CreateUpdateSchedulePayload(fixturePayload()) for _, mod := range mods { mod(&request) @@ -73,10 +72,10 @@ func fixtureRequest(mods ...func(request *serverupdate.ApiCreateUpdateScheduleRe func fixturePayload(mods ...func(payload *serverupdate.CreateUpdateSchedulePayload)) serverupdate.CreateUpdateSchedulePayload { payload := serverupdate.CreateUpdateSchedulePayload{ - Name: utils.Ptr("example-schedule-name"), - Enabled: utils.Ptr(defaultEnabled), - Rrule: utils.Ptr("DTSTART;TZID=Europe/Sofia:20200803T023000 RRULE:FREQ=DAILY;INTERVAL=1"), - MaintenanceWindow: utils.Ptr(int64(23)), + Name: "example-schedule-name", + Enabled: defaultEnabled, + Rrule: "DTSTART;TZID=Europe/Sofia:20200803T023000 RRULE:FREQ=DAILY;INTERVAL=1", + MaintenanceWindow: int32(23), } for _, mod := range mods { mod(&payload) @@ -169,7 +168,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, serverupdate.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/server/os-update/schedule/delete/delete.go b/internal/cmd/server/os-update/schedule/delete/delete.go index b26084c9a..8fddbb7bd 100644 --- a/internal/cmd/server/os-update/schedule/delete/delete.go +++ b/internal/cmd/server/os-update/schedule/delete/delete.go @@ -15,7 +15,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/services/serverosupdate/client" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/serverupdate" + serverupdate "github.com/stackitcloud/stackit-sdk-go/services/serverupdate/v2api" ) const ( @@ -100,6 +100,6 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *serverupdate.APIClient) serverupdate.ApiDeleteUpdateScheduleRequest { - req := apiClient.DeleteUpdateSchedule(ctx, model.ProjectId, model.ServerId, model.ScheduleId, model.Region) + req := apiClient.DefaultAPI.DeleteUpdateSchedule(ctx, model.ProjectId, model.ServerId, model.ScheduleId, model.Region) return req } diff --git a/internal/cmd/server/os-update/schedule/delete/delete_test.go b/internal/cmd/server/os-update/schedule/delete/delete_test.go index 99b0aaafb..c965330f4 100644 --- a/internal/cmd/server/os-update/schedule/delete/delete_test.go +++ b/internal/cmd/server/os-update/schedule/delete/delete_test.go @@ -10,7 +10,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/serverupdate" + serverupdate "github.com/stackitcloud/stackit-sdk-go/services/serverupdate/v2api" ) const ( @@ -21,7 +21,7 @@ const ( type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &serverupdate.APIClient{} +var testClient = &serverupdate.APIClient{DefaultAPI: &serverupdate.DefaultAPIService{}} var testProjectId = uuid.NewString() var testServerId = uuid.NewString() @@ -64,7 +64,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *serverupdate.ApiDeleteUpdateScheduleRequest)) serverupdate.ApiDeleteUpdateScheduleRequest { - request := testClient.DeleteUpdateSchedule(testCtx, testProjectId, testServerId, testUpdateScheduleId, testRegion) + request := testClient.DefaultAPI.DeleteUpdateSchedule(testCtx, testProjectId, testServerId, testUpdateScheduleId, testRegion) for _, mod := range mods { mod(&request) } @@ -156,7 +156,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, serverupdate.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/server/os-update/schedule/describe/describe.go b/internal/cmd/server/os-update/schedule/describe/describe.go index 0e810343d..f926701ba 100644 --- a/internal/cmd/server/os-update/schedule/describe/describe.go +++ b/internal/cmd/server/os-update/schedule/describe/describe.go @@ -7,7 +7,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/types" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/serverupdate" + serverupdate "github.com/stackitcloud/stackit-sdk-go/services/serverupdate/v2api" "github.com/stackitcloud/stackit-cli/internal/pkg/args" "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -17,7 +17,6 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/print" "github.com/stackitcloud/stackit-cli/internal/pkg/services/serverosupdate/client" "github.com/stackitcloud/stackit-cli/internal/pkg/tables" - "github.com/stackitcloud/stackit-cli/internal/pkg/utils" ) const ( @@ -97,22 +96,22 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *serverupdate.APIClient) serverupdate.ApiGetUpdateScheduleRequest { - req := apiClient.GetUpdateSchedule(ctx, model.ProjectId, model.ServerId, model.ScheduleId, model.Region) + req := apiClient.DefaultAPI.GetUpdateSchedule(ctx, model.ProjectId, model.ServerId, model.ScheduleId, model.Region) return req } func outputResult(p *print.Printer, outputFormat string, schedule serverupdate.UpdateSchedule) error { return p.OutputResult(outputFormat, schedule, func() error { table := tables.NewTable() - table.AddRow("SCHEDULE ID", utils.PtrString(schedule.Id)) + table.AddRow("SCHEDULE ID", schedule.Id) table.AddSeparator() - table.AddRow("SCHEDULE NAME", utils.PtrString(schedule.Name)) + table.AddRow("SCHEDULE NAME", schedule.Name) table.AddSeparator() - table.AddRow("ENABLED", utils.PtrString(schedule.Enabled)) + table.AddRow("ENABLED", schedule.Enabled) table.AddSeparator() - table.AddRow("RRULE", utils.PtrString(schedule.Rrule)) + table.AddRow("RRULE", schedule.Rrule) table.AddSeparator() - table.AddRow("MAINTENANCE WINDOW", utils.PtrString(schedule.MaintenanceWindow)) + table.AddRow("MAINTENANCE WINDOW", schedule.MaintenanceWindow) table.AddSeparator() err := table.Display(p) diff --git a/internal/cmd/server/os-update/schedule/describe/describe_test.go b/internal/cmd/server/os-update/schedule/describe/describe_test.go index 9ecb85552..c9fc42390 100644 --- a/internal/cmd/server/os-update/schedule/describe/describe_test.go +++ b/internal/cmd/server/os-update/schedule/describe/describe_test.go @@ -11,7 +11,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/serverupdate" + serverupdate "github.com/stackitcloud/stackit-sdk-go/services/serverupdate/v2api" ) const ( @@ -22,7 +22,7 @@ const ( type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &serverupdate.APIClient{} +var testClient = &serverupdate.APIClient{DefaultAPI: &serverupdate.DefaultAPIService{}} var testProjectId = uuid.NewString() var testServerId = uuid.NewString() @@ -65,7 +65,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *serverupdate.ApiGetUpdateScheduleRequest)) serverupdate.ApiGetUpdateScheduleRequest { - request := testClient.GetUpdateSchedule(testCtx, testProjectId, testServerId, testScheduleId, testRegion) + request := testClient.DefaultAPI.GetUpdateSchedule(testCtx, testProjectId, testServerId, testScheduleId, testRegion) for _, mod := range mods { mod(&request) } @@ -159,7 +159,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, serverupdate.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/server/os-update/schedule/list/list.go b/internal/cmd/server/os-update/schedule/list/list.go index 7f7f7162a..95f90665a 100644 --- a/internal/cmd/server/os-update/schedule/list/list.go +++ b/internal/cmd/server/os-update/schedule/list/list.go @@ -9,7 +9,7 @@ import ( iaasClient "github.com/stackitcloud/stackit-cli/internal/pkg/services/iaas/client" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/serverupdate" + serverupdate "github.com/stackitcloud/stackit-sdk-go/services/serverupdate/v2api" "github.com/stackitcloud/stackit-cli/internal/pkg/args" "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -20,7 +20,6 @@ import ( iaasUtils "github.com/stackitcloud/stackit-cli/internal/pkg/services/iaas/utils" "github.com/stackitcloud/stackit-cli/internal/pkg/services/serverosupdate/client" "github.com/stackitcloud/stackit-cli/internal/pkg/tables" - "github.com/stackitcloud/stackit-cli/internal/pkg/utils" ) const ( @@ -125,7 +124,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, } func buildRequest(ctx context.Context, model *inputModel, apiClient *serverupdate.APIClient) serverupdate.ApiListUpdateSchedulesRequest { - req := apiClient.ListUpdateSchedules(ctx, model.ProjectId, model.ServerId, model.Region) + req := apiClient.DefaultAPI.ListUpdateSchedules(ctx, model.ProjectId, model.ServerId, model.Region) return req } @@ -140,11 +139,11 @@ func outputResult(p *print.Printer, outputFormat, serverLabel string, schedules for i := range schedules { s := schedules[i] table.AddRow( - utils.PtrString(s.Id), - utils.PtrString(s.Name), - utils.PtrString(s.Enabled), - utils.PtrString(s.Rrule), - utils.PtrString(s.MaintenanceWindow), + s.Id, + s.Name, + s.Enabled, + s.Rrule, + s.MaintenanceWindow, ) } err := table.Display(p) diff --git a/internal/cmd/server/os-update/schedule/list/list_test.go b/internal/cmd/server/os-update/schedule/list/list_test.go index f8c370c7b..4534e1718 100644 --- a/internal/cmd/server/os-update/schedule/list/list_test.go +++ b/internal/cmd/server/os-update/schedule/list/list_test.go @@ -12,7 +12,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/serverupdate" + serverupdate "github.com/stackitcloud/stackit-sdk-go/services/serverupdate/v2api" ) const ( @@ -22,7 +22,7 @@ const ( type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &serverupdate.APIClient{} +var testClient = &serverupdate.APIClient{DefaultAPI: &serverupdate.DefaultAPIService{}} var testProjectId = uuid.NewString() var testServerId = uuid.NewString() @@ -56,7 +56,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *serverupdate.ApiListUpdateSchedulesRequest)) serverupdate.ApiListUpdateSchedulesRequest { - request := testClient.ListUpdateSchedules(testCtx, testProjectId, testServerId, testRegion) + request := testClient.DefaultAPI.ListUpdateSchedules(testCtx, testProjectId, testServerId, testRegion) for _, mod := range mods { mod(&request) } @@ -145,7 +145,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, serverupdate.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/server/os-update/schedule/update/update.go b/internal/cmd/server/os-update/schedule/update/update.go index f14429e2c..54609394f 100644 --- a/internal/cmd/server/os-update/schedule/update/update.go +++ b/internal/cmd/server/os-update/schedule/update/update.go @@ -7,7 +7,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/types" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/serverupdate" + serverupdate "github.com/stackitcloud/stackit-sdk-go/services/serverupdate/v2api" "github.com/stackitcloud/stackit-cli/internal/pkg/args" cliErr "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -16,7 +16,6 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/print" "github.com/stackitcloud/stackit-cli/internal/pkg/services/serverosupdate/client" - "github.com/stackitcloud/stackit-cli/internal/pkg/utils" ) const ( @@ -41,7 +40,7 @@ type inputModel struct { ScheduleName *string Enabled *bool Rrule *string - MaintenanceWindow *int64 + MaintenanceWindow *int32 } func NewCmd(params *types.CmdParams) *cobra.Command { @@ -69,7 +68,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return err } - currentSchedule, err := apiClient.GetUpdateScheduleExecute(ctx, model.ProjectId, model.ServerId, model.ScheduleId, model.Region) + currentSchedule, err := apiClient.DefaultAPI.GetUpdateSchedule(ctx, model.ProjectId, model.ServerId, model.ScheduleId, model.Region).Execute() if err != nil { params.Printer.Debug(print.ErrorLevel, "get current server os-update schedule: %v", err) return err @@ -102,7 +101,7 @@ func configureFlags(cmd *cobra.Command) { cmd.Flags().VarP(flags.UUIDFlag(), serverIdFlag, "s", "Server ID") cmd.Flags().StringP(nameFlag, "n", "", "os-update schedule name") - cmd.Flags().Int64P(maintenanceWindowFlag, "d", defaultMaintenanceWindow, "Maintenance window (in hours, 1-24)") + cmd.Flags().Int32P(maintenanceWindowFlag, "d", defaultMaintenanceWindow, "Maintenance window (in hours, 1-24)") cmd.Flags().BoolP(enabledFlag, "e", defaultEnabled, "Is the server os-update schedule enabled") cmd.Flags().StringP(rruleFlag, "r", defaultRrule, "os-update RRULE (recurrence rule)") @@ -123,7 +122,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu ScheduleId: scheduleId, ScheduleName: flags.FlagToStringPointer(p, cmd, nameFlag), ServerId: flags.FlagToStringValue(p, cmd, serverIdFlag), - MaintenanceWindow: flags.FlagToInt64Pointer(p, cmd, maintenanceWindowFlag), + MaintenanceWindow: flags.FlagToInt32Pointer(p, cmd, maintenanceWindowFlag), Rrule: flags.FlagToStringPointer(p, cmd, rruleFlag), Enabled: flags.FlagToBoolPointer(p, cmd, enabledFlag), } @@ -133,19 +132,19 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *serverupdate.APIClient, old serverupdate.UpdateSchedule) (serverupdate.ApiUpdateUpdateScheduleRequest, error) { - req := apiClient.UpdateUpdateSchedule(ctx, model.ProjectId, model.ServerId, model.ScheduleId, model.Region) + req := apiClient.DefaultAPI.UpdateUpdateSchedule(ctx, model.ProjectId, model.ServerId, model.ScheduleId, model.Region) if model.MaintenanceWindow != nil { - old.MaintenanceWindow = model.MaintenanceWindow + old.MaintenanceWindow = *model.MaintenanceWindow } if model.Enabled != nil { - old.Enabled = model.Enabled + old.Enabled = *model.Enabled } if model.ScheduleName != nil { - old.Name = model.ScheduleName + old.Name = *model.ScheduleName } if model.Rrule != nil { - old.Rrule = model.Rrule + old.Rrule = *model.Rrule } req = req.UpdateUpdateSchedulePayload(serverupdate.UpdateUpdateSchedulePayload{ @@ -159,7 +158,7 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient *serverupdat func outputResult(p *print.Printer, outputFormat string, resp serverupdate.UpdateSchedule) error { return p.OutputResult(outputFormat, resp, func() error { - p.Info("Updated server os-update schedule %s\n", utils.PtrString(resp.Id)) + p.Info("Updated server os-update schedule %d\n", resp.Id) return nil }) } diff --git a/internal/cmd/server/os-update/schedule/update/update_test.go b/internal/cmd/server/os-update/schedule/update/update_test.go index 3ba40a22f..edda8debe 100644 --- a/internal/cmd/server/os-update/schedule/update/update_test.go +++ b/internal/cmd/server/os-update/schedule/update/update_test.go @@ -2,7 +2,6 @@ package update import ( "context" - "strconv" "testing" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" @@ -12,24 +11,24 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/serverupdate" + serverupdate "github.com/stackitcloud/stackit-sdk-go/services/serverupdate/v2api" ) const ( testRegion = "eu02" - testScheduleId = "5" + testScheduleId = int32(5) ) type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &serverupdate.APIClient{} +var testClient = &serverupdate.APIClient{DefaultAPI: &serverupdate.DefaultAPIService{}} var testProjectId = uuid.NewString() var testServerId = uuid.NewString() func fixtureArgValues(mods ...func(argValues []string)) []string { argValues := []string{ - testScheduleId, + string(testScheduleId), } for _, mod := range mods { mod(argValues) @@ -60,12 +59,12 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { Region: testRegion, Verbosity: globalflags.VerbosityDefault, }, - ScheduleId: testScheduleId, + ScheduleId: string(testScheduleId), ServerId: testServerId, ScheduleName: utils.Ptr("example-schedule-name"), Enabled: utils.Ptr(defaultEnabled), Rrule: utils.Ptr(defaultRrule), - MaintenanceWindow: utils.Ptr(int64(23)), + MaintenanceWindow: utils.Ptr(int32(23)), } for _, mod := range mods { mod(model) @@ -74,13 +73,12 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureUpdateSchedule(mods ...func(schedule *serverupdate.UpdateSchedule)) *serverupdate.UpdateSchedule { - id, _ := strconv.ParseInt(testScheduleId, 10, 64) schedule := &serverupdate.UpdateSchedule{ - Name: utils.Ptr("example-schedule-name"), - Id: utils.Ptr(id), - Enabled: utils.Ptr(defaultEnabled), - Rrule: utils.Ptr(defaultRrule), - MaintenanceWindow: utils.Ptr(int64(23)), + Name: "example-schedule-name", + Id: testScheduleId, + Enabled: defaultEnabled, + Rrule: defaultRrule, + MaintenanceWindow: int32(23), } for _, mod := range mods { mod(schedule) @@ -90,10 +88,10 @@ func fixtureUpdateSchedule(mods ...func(schedule *serverupdate.UpdateSchedule)) func fixturePayload(mods ...func(payload *serverupdate.UpdateUpdateSchedulePayload)) serverupdate.UpdateUpdateSchedulePayload { payload := serverupdate.UpdateUpdateSchedulePayload{ - Name: utils.Ptr("example-schedule-name"), - Enabled: utils.Ptr(defaultEnabled), - Rrule: utils.Ptr("DTSTART;TZID=Europe/Sofia:20200803T023000 RRULE:FREQ=DAILY;INTERVAL=1"), - MaintenanceWindow: utils.Ptr(int64(23)), + Name: "example-schedule-name", + Enabled: defaultEnabled, + Rrule: "DTSTART;TZID=Europe/Sofia:20200803T023000 RRULE:FREQ=DAILY;INTERVAL=1", + MaintenanceWindow: int32(23), } for _, mod := range mods { mod(&payload) @@ -102,7 +100,7 @@ func fixturePayload(mods ...func(payload *serverupdate.UpdateUpdateSchedulePaylo } func fixtureRequest(mods ...func(request *serverupdate.ApiUpdateUpdateScheduleRequest)) serverupdate.ApiUpdateUpdateScheduleRequest { - request := testClient.UpdateUpdateSchedule(testCtx, testProjectId, testServerId, testScheduleId, testRegion) + request := testClient.DefaultAPI.UpdateUpdateSchedule(testCtx, testProjectId, testServerId, string(testScheduleId), testRegion) request = request.UpdateUpdateSchedulePayload(fixturePayload()) for _, mod := range mods { mod(&request) @@ -259,7 +257,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, serverupdate.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/pkg/flags/flag_to_value.go b/internal/pkg/flags/flag_to_value.go index dfcd50893..c53aa751e 100644 --- a/internal/pkg/flags/flag_to_value.go +++ b/internal/pkg/flags/flag_to_value.go @@ -207,6 +207,17 @@ func FlagWithDefaultToInt64Value(p *print.Printer, cmd *cobra.Command, flag stri return value } +// Returns the int32 value set on the flag. If no value is set, returns the flag's default value. +// Returns 0 if the flag value can not be converted to int32 or if the flag does not exist. +func FlagWithDefaultToInt32Value(p *print.Printer, cmd *cobra.Command, flag string) int32 { + value, err := cmd.Flags().GetInt32(flag) + if err != nil { + p.Debug(print.ErrorLevel, "convert flag with default to Int32 value: %v", err) + return 0 + } + return value +} + // Returns the string value set on the flag. If no value is set, returns the flag's default value. // Returns nil if the flag value can not be converted to string or if the flag does not exist. func FlagWithDefaultToStringValue(p *print.Printer, cmd *cobra.Command, flag string) string { diff --git a/internal/pkg/services/serverosupdate/client/client.go b/internal/pkg/services/serverosupdate/client/client.go index a3d324d90..ac2c6dba2 100644 --- a/internal/pkg/services/serverosupdate/client/client.go +++ b/internal/pkg/services/serverosupdate/client/client.go @@ -6,7 +6,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/print" "github.com/spf13/viper" - "github.com/stackitcloud/stackit-sdk-go/services/serverupdate" + serverupdate "github.com/stackitcloud/stackit-sdk-go/services/serverupdate/v2api" ) func ConfigureClient(p *print.Printer, cliVersion string) (*serverupdate.APIClient, error) { From 1e4db53f1d3a5366c6e59aa6363b7ca77a71464b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ruben=20H=C3=B6nle?= Date: Wed, 22 Jul 2026 12:09:31 +0200 Subject: [PATCH 40/44] chore(serviceenablement): switch to new sdk structure (#1487) relates to STACKITCLI-354 --- go.mod | 2 +- go.sum | 4 +- internal/cmd/ske/cluster/create/create.go | 2 +- internal/cmd/ske/cluster/list/list.go | 2 +- internal/cmd/ske/describe/describe.go | 4 +- internal/cmd/ske/describe/describe_test.go | 11 +-- internal/cmd/ske/disable/disable.go | 8 +- internal/cmd/ske/disable/disable_test.go | 11 +-- internal/cmd/ske/enable/enable.go | 8 +- internal/cmd/ske/enable/enable_test.go | 11 +-- .../service-enablement/client/client.go | 4 +- .../service-enablement/utils/utils.go | 10 +-- .../service-enablement/utils/utils_test.go | 85 +++++++++++-------- internal/pkg/services/ske/client/client.go | 2 +- 14 files changed, 88 insertions(+), 76 deletions(-) diff --git a/go.mod b/go.mod index a8db820bb..cfdf51f57 100644 --- a/go.mod +++ b/go.mod @@ -34,7 +34,7 @@ require ( github.com/stackitcloud/stackit-sdk-go/services/serverbackup v1.3.8 github.com/stackitcloud/stackit-sdk-go/services/serverupdate v1.5.2 github.com/stackitcloud/stackit-sdk-go/services/serviceaccount v0.12.0 - github.com/stackitcloud/stackit-sdk-go/services/serviceenablement v1.2.7 + github.com/stackitcloud/stackit-sdk-go/services/serviceenablement v1.7.0 github.com/stackitcloud/stackit-sdk-go/services/ske v1.11.0 github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex v1.11.0 github.com/stackitcloud/stackit-sdk-go/services/vpn v0.14.0 diff --git a/go.sum b/go.sum index f64e57464..bcf939f5a 100644 --- a/go.sum +++ b/go.sum @@ -644,8 +644,8 @@ github.com/stackitcloud/stackit-sdk-go/services/serverupdate v1.5.2 h1:6C/iTPoYP github.com/stackitcloud/stackit-sdk-go/services/serverupdate v1.5.2/go.mod h1:/OHYZXQb9KXDdZK5J9C2YS6DJUD2i6ednZ1rK7zpDZ0= github.com/stackitcloud/stackit-sdk-go/services/serviceaccount v0.12.0 h1:l1EDIlXce2C8JcbBDHVa6nZ4SjPTqmnALTgrhms+NKI= github.com/stackitcloud/stackit-sdk-go/services/serviceaccount v0.12.0/go.mod h1:EXq8/J7t9p8zPmdIq+atuxyAbnQwxrQT18fI+Qpv98k= -github.com/stackitcloud/stackit-sdk-go/services/serviceenablement v1.2.7 h1:M2PYLF8k3zmAwYWSKfUiCTNTXr7ROGuJganVVEQA3YI= -github.com/stackitcloud/stackit-sdk-go/services/serviceenablement v1.2.7/go.mod h1:jitkQuP2K/SH63Qor0C4pcqz1GDCy/lK2H4t8/VDse4= +github.com/stackitcloud/stackit-sdk-go/services/serviceenablement v1.7.0 h1:TNZHrunhsXRbuqZcucLs2Gqy1sEyvabufM7pB5Tscmo= +github.com/stackitcloud/stackit-sdk-go/services/serviceenablement v1.7.0/go.mod h1:fXq3TmVLb4JMSve989NFFViMFoYa83s7M3hJWgN6mdQ= github.com/stackitcloud/stackit-sdk-go/services/sfs v0.9.0 h1:JWAFnskRbNKT8x62pZcAMCC+p5hyTEkAyxqFwy39jFA= github.com/stackitcloud/stackit-sdk-go/services/sfs v0.9.0/go.mod h1:jMlBoXqrPNX5nXbo6oT7exalqilw1jiLPoIp4Cn0CdI= github.com/stackitcloud/stackit-sdk-go/services/ske v1.11.0 h1:QoKyQPe8FqDqJLNgE5uRlZ/y1c1GUxjV1DDLu5QEBD8= diff --git a/internal/cmd/ske/cluster/create/create.go b/internal/cmd/ske/cluster/create/create.go index edcf85dfb..92c761656 100644 --- a/internal/cmd/ske/cluster/create/create.go +++ b/internal/cmd/ske/cluster/create/create.go @@ -99,7 +99,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { exists, err := skeUtils.ClusterExists(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, model.ClusterName) if err != nil { // Check if the project is enabled - enabled, enabledErr := serviceEnablementUtils.ProjectEnabled(ctx, serviceEnablementApiClient, model.ProjectId, model.Region) + enabled, enabledErr := serviceEnablementUtils.ProjectEnabled(ctx, serviceEnablementApiClient.DefaultAPI, model.ProjectId, model.Region) if enabledErr != nil { return fmt.Errorf("check if project is enabled failed: %w", enabledErr) } diff --git a/internal/cmd/ske/cluster/list/list.go b/internal/cmd/ske/cluster/list/list.go index 543fa212e..c3943a914 100644 --- a/internal/cmd/ske/cluster/list/list.go +++ b/internal/cmd/ske/cluster/list/list.go @@ -73,7 +73,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { resp, err := req.Execute() if err != nil { // Check if SKE is enabled for this project - enabled, enabledErr := serviceEnablementUtils.ProjectEnabled(ctx, serviceEnablementApiClient, model.ProjectId, model.Region) + enabled, enabledErr := serviceEnablementUtils.ProjectEnabled(ctx, serviceEnablementApiClient.DefaultAPI, model.ProjectId, model.Region) if enabledErr != nil { return fmt.Errorf("check if project is enabled failed: %w", enabledErr) } diff --git a/internal/cmd/ske/describe/describe.go b/internal/cmd/ske/describe/describe.go index 07fedda34..68804458b 100644 --- a/internal/cmd/ske/describe/describe.go +++ b/internal/cmd/ske/describe/describe.go @@ -7,7 +7,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/types" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/serviceenablement" + serviceenablement "github.com/stackitcloud/stackit-sdk-go/services/serviceenablement/v2api" "github.com/stackitcloud/stackit-cli/internal/pkg/args" "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -75,7 +75,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, } func buildRequest(ctx context.Context, model *inputModel, apiClient *serviceenablement.APIClient) serviceenablement.ApiGetServiceStatusRegionalRequest { - req := apiClient.GetServiceStatusRegional(ctx, model.Region, model.ProjectId, skeUtils.SKEServiceId) + req := apiClient.DefaultAPI.GetServiceStatusRegional(ctx, model.Region, model.ProjectId, skeUtils.SKEServiceId) return req } diff --git a/internal/cmd/ske/describe/describe_test.go b/internal/cmd/ske/describe/describe_test.go index c20dac396..4104ef5f0 100644 --- a/internal/cmd/ske/describe/describe_test.go +++ b/internal/cmd/ske/describe/describe_test.go @@ -4,7 +4,7 @@ import ( "context" "testing" - "github.com/stackitcloud/stackit-sdk-go/services/serviceenablement" + serviceenablement "github.com/stackitcloud/stackit-sdk-go/services/serviceenablement/v2api" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" serviceEnablementUtils "github.com/stackitcloud/stackit-cli/internal/pkg/services/service-enablement/utils" @@ -19,9 +19,10 @@ import ( type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &serviceenablement.APIClient{} +var testClient = &serviceenablement.APIClient{DefaultAPI: &serviceenablement.DefaultAPIService{}} var testProjectId = uuid.NewString() -var testRegion = "eu01" + +const testRegion = "eu01" func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string { flagValues := map[string]string{ @@ -49,7 +50,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *serviceenablement.ApiGetServiceStatusRegionalRequest)) serviceenablement.ApiGetServiceStatusRegionalRequest { - request := testClient.GetServiceStatusRegional(testCtx, testRegion, testProjectId, serviceEnablementUtils.SKEServiceId) //nolint:staticcheck //command will be removed in a later update + request := testClient.DefaultAPI.GetServiceStatusRegional(testCtx, testRegion, testProjectId, serviceEnablementUtils.SKEServiceId) //nolint:staticcheck //command will be removed in a later update for _, mod := range mods { mod(&request) } @@ -125,7 +126,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, serviceenablement.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/ske/disable/disable.go b/internal/cmd/ske/disable/disable.go index 43c103e7b..f2607018d 100644 --- a/internal/cmd/ske/disable/disable.go +++ b/internal/cmd/ske/disable/disable.go @@ -17,8 +17,8 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/spinner" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/serviceenablement" - "github.com/stackitcloud/stackit-sdk-go/services/serviceenablement/wait" + serviceenablement "github.com/stackitcloud/stackit-sdk-go/services/serviceenablement/v2api" + "github.com/stackitcloud/stackit-sdk-go/services/serviceenablement/v2api/wait" ) type inputModel struct { @@ -71,7 +71,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { // Wait for async operation, if async mode not enabled if !model.Async { err := spinner.Run(params.Printer, "Disabling SKE", func() error { - _, err = wait.DisableServiceWaitHandler(ctx, apiClient, model.Region, model.ProjectId, utils.SKEServiceId).WaitWithContext(ctx) + _, err = wait.DisableServiceWaitHandler(ctx, apiClient.DefaultAPI, model.Region, model.ProjectId, utils.SKEServiceId).WaitWithContext(ctx) return err }) if err != nil { @@ -105,6 +105,6 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, } func buildRequest(ctx context.Context, model *inputModel, apiClient *serviceenablement.APIClient) serviceenablement.ApiDisableServiceRegionalRequest { - req := apiClient.DisableServiceRegional(ctx, model.Region, model.ProjectId, utils.SKEServiceId) + req := apiClient.DefaultAPI.DisableServiceRegional(ctx, model.Region, model.ProjectId, utils.SKEServiceId) return req } diff --git a/internal/cmd/ske/disable/disable_test.go b/internal/cmd/ske/disable/disable_test.go index 978e383ed..cf2987742 100644 --- a/internal/cmd/ske/disable/disable_test.go +++ b/internal/cmd/ske/disable/disable_test.go @@ -11,15 +11,16 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/serviceenablement" + serviceenablement "github.com/stackitcloud/stackit-sdk-go/services/serviceenablement/v2api" ) type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &serviceenablement.APIClient{} +var testClient = &serviceenablement.APIClient{DefaultAPI: &serviceenablement.DefaultAPIService{}} var testProjectId = uuid.NewString() -var testRegion = "eu01" + +const testRegion = "eu01" func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string { flagValues := map[string]string{ @@ -47,7 +48,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *serviceenablement.ApiDisableServiceRegionalRequest)) serviceenablement.ApiDisableServiceRegionalRequest { - request := testClient.DisableServiceRegional(testCtx, testRegion, testProjectId, utils.SKEServiceId) + request := testClient.DefaultAPI.DisableServiceRegional(testCtx, testRegion, testProjectId, utils.SKEServiceId) for _, mod := range mods { mod(&request) } @@ -122,7 +123,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, serviceenablement.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/ske/enable/enable.go b/internal/cmd/ske/enable/enable.go index ea83a337b..6fed3949a 100644 --- a/internal/cmd/ske/enable/enable.go +++ b/internal/cmd/ske/enable/enable.go @@ -17,8 +17,8 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/spinner" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/serviceenablement" - "github.com/stackitcloud/stackit-sdk-go/services/serviceenablement/wait" + serviceenablement "github.com/stackitcloud/stackit-sdk-go/services/serviceenablement/v2api" + "github.com/stackitcloud/stackit-sdk-go/services/serviceenablement/v2api/wait" ) type inputModel struct { @@ -71,7 +71,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { // Wait for async operation, if async mode not enabled if !model.Async { err := spinner.Run(params.Printer, "Enabling SKE", func() error { - _, err = wait.EnableServiceWaitHandler(ctx, apiClient, model.Region, model.ProjectId, utils.SKEServiceId).WaitWithContext(ctx) + _, err = wait.EnableServiceWaitHandler(ctx, apiClient.DefaultAPI, model.Region, model.ProjectId, utils.SKEServiceId).WaitWithContext(ctx) return err }) if err != nil { @@ -105,6 +105,6 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, } func buildRequest(ctx context.Context, model *inputModel, apiClient *serviceenablement.APIClient) serviceenablement.ApiEnableServiceRegionalRequest { - req := apiClient.EnableServiceRegional(ctx, model.Region, model.ProjectId, utils.SKEServiceId) + req := apiClient.DefaultAPI.EnableServiceRegional(ctx, model.Region, model.ProjectId, utils.SKEServiceId) return req } diff --git a/internal/cmd/ske/enable/enable_test.go b/internal/cmd/ske/enable/enable_test.go index add7b850b..1ecea575a 100644 --- a/internal/cmd/ske/enable/enable_test.go +++ b/internal/cmd/ske/enable/enable_test.go @@ -11,15 +11,16 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/serviceenablement" + serviceenablement "github.com/stackitcloud/stackit-sdk-go/services/serviceenablement/v2api" ) type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &serviceenablement.APIClient{} +var testClient = &serviceenablement.APIClient{DefaultAPI: &serviceenablement.DefaultAPIService{}} var testProjectId = uuid.NewString() -var testRegion = "eu01" + +const testRegion = "eu01" func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string { flagValues := map[string]string{ @@ -47,7 +48,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *serviceenablement.ApiEnableServiceRegionalRequest)) serviceenablement.ApiEnableServiceRegionalRequest { - request := testClient.EnableServiceRegional(testCtx, testRegion, testProjectId, utils.SKEServiceId) + request := testClient.DefaultAPI.EnableServiceRegional(testCtx, testRegion, testProjectId, utils.SKEServiceId) for _, mod := range mods { mod(&request) } @@ -122,7 +123,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, serviceenablement.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/pkg/services/service-enablement/client/client.go b/internal/pkg/services/service-enablement/client/client.go index 6aa7324b1..a35e8bba0 100644 --- a/internal/pkg/services/service-enablement/client/client.go +++ b/internal/pkg/services/service-enablement/client/client.go @@ -7,9 +7,9 @@ import ( genericclient "github.com/stackitcloud/stackit-cli/internal/pkg/generic-client" "github.com/stackitcloud/stackit-cli/internal/pkg/print" - "github.com/stackitcloud/stackit-sdk-go/services/serviceenablement" + serviceenablement "github.com/stackitcloud/stackit-sdk-go/services/serviceenablement/v2api" ) func ConfigureClient(p *print.Printer, cliVersion string) (*serviceenablement.APIClient, error) { - return genericclient.ConfigureClientGeneric(p, cliVersion, viper.GetString(config.ServiceEnablementCustomEndpointKey), true, genericclient.CreateApiClient[*serviceenablement.APIClient](serviceenablement.NewAPIClient)) + return genericclient.ConfigureClientGeneric(p, cliVersion, viper.GetString(config.ServiceEnablementCustomEndpointKey), false, serviceenablement.NewAPIClient) } diff --git a/internal/pkg/services/service-enablement/utils/utils.go b/internal/pkg/services/service-enablement/utils/utils.go index 5f1976164..a650c692f 100644 --- a/internal/pkg/services/service-enablement/utils/utils.go +++ b/internal/pkg/services/service-enablement/utils/utils.go @@ -5,19 +5,15 @@ import ( "net/http" "github.com/stackitcloud/stackit-sdk-go/core/oapierror" - "github.com/stackitcloud/stackit-sdk-go/services/serviceenablement" + serviceenablement "github.com/stackitcloud/stackit-sdk-go/services/serviceenablement/v2api" ) const ( SKEServiceId = "cloud.stackit.ske" ) -type ServiceEnablementClient interface { - GetServiceStatusRegionalExecute(ctx context.Context, region, projectId, serviceId string) (*serviceenablement.ServiceStatus, error) -} - -func ProjectEnabled(ctx context.Context, apiClient ServiceEnablementClient, projectId, region string) (bool, error) { - project, err := apiClient.GetServiceStatusRegionalExecute(ctx, region, projectId, SKEServiceId) +func ProjectEnabled(ctx context.Context, apiClient serviceenablement.DefaultAPI, projectId, region string) (bool, error) { + project, err := apiClient.GetServiceStatusRegional(ctx, region, projectId, SKEServiceId).Execute() if err != nil { oapiErr, ok := err.(*oapierror.GenericOpenAPIError) //nolint:errorlint //complaining that error.As should be used to catch wrapped errors, but this error should not be wrapped if !ok { diff --git a/internal/pkg/services/service-enablement/utils/utils_test.go b/internal/pkg/services/service-enablement/utils/utils_test.go index b898adb69..3b8b5194f 100644 --- a/internal/pkg/services/service-enablement/utils/utils_test.go +++ b/internal/pkg/services/service-enablement/utils/utils_test.go @@ -7,83 +7,96 @@ import ( "github.com/google/uuid" "github.com/stackitcloud/stackit-sdk-go/core/oapierror" - "github.com/stackitcloud/stackit-sdk-go/services/serviceenablement" + serviceenablement "github.com/stackitcloud/stackit-sdk-go/services/serviceenablement/v2api" + + "github.com/stackitcloud/stackit-cli/internal/pkg/utils" ) +const testRegion = "eu01" + var ( testProjectId = uuid.NewString() - testRegion = "eu01" ) -type serviceEnableClientMocked struct { +type mockSettings struct { serviceDisabled bool getServiceStatusFails bool getServiceStatusResp *serviceenablement.ServiceStatus } -func (m *serviceEnableClientMocked) GetServiceStatusRegionalExecute(_ context.Context, _, _, _ string) (*serviceenablement.ServiceStatus, error) { - if m.getServiceStatusFails { - return nil, fmt.Errorf("could not get service status") - } - if m.serviceDisabled { - return nil, &oapierror.GenericOpenAPIError{StatusCode: 404} +func newServiceEnableClientMock(m mockSettings) serviceenablement.DefaultAPI { + return serviceenablement.DefaultAPIServiceMock{ + GetServiceStatusRegionalExecuteMock: utils.Ptr(func(_ serviceenablement.ApiGetServiceStatusRegionalRequest) (*serviceenablement.ServiceStatus, error) { + if m.getServiceStatusFails { + return nil, fmt.Errorf("could not get service status") + } + if m.serviceDisabled { + return nil, &oapierror.GenericOpenAPIError{StatusCode: 404} + } + return m.getServiceStatusResp, nil + }), } - return m.getServiceStatusResp, nil } func TestProjectEnabled(t *testing.T) { tests := []struct { - description string - serviceDisabled bool - getProjectFails bool - getProjectResp *serviceenablement.ServiceStatus - isValid bool - expectedOutput bool + description string + mockSettings mockSettings + isValid bool + expectedOutput bool }{ { - description: "project enabled", - getProjectResp: &serviceenablement.ServiceStatus{State: serviceenablement.SERVICESTATUSSTATE_ENABLED.Ptr()}, + description: "project enabled", + mockSettings: mockSettings{ + getServiceStatusResp: &serviceenablement.ServiceStatus{State: serviceenablement.SERVICESTATUSSTATE_ENABLED.Ptr()}, + }, isValid: true, expectedOutput: true, }, { - description: "project disabled (404)", - serviceDisabled: true, - isValid: true, - expectedOutput: false, + description: "project disabled (404)", + mockSettings: mockSettings{ + serviceDisabled: true, + }, + isValid: true, + expectedOutput: false, }, { - description: "project disabled 1", - getProjectResp: &serviceenablement.ServiceStatus{State: serviceenablement.SERVICESTATUSSTATE_ENABLING.Ptr()}, + description: "project disabled 1", + mockSettings: mockSettings{ + getServiceStatusResp: &serviceenablement.ServiceStatus{State: serviceenablement.SERVICESTATUSSTATE_ENABLING.Ptr()}, + }, isValid: true, expectedOutput: false, }, { - description: "project disabled 2", - getProjectResp: &serviceenablement.ServiceStatus{State: serviceenablement.SERVICESTATUSSTATE_DISABLING.Ptr()}, + description: "project disabled 2", + mockSettings: mockSettings{ + getServiceStatusResp: &serviceenablement.ServiceStatus{State: serviceenablement.SERVICESTATUSSTATE_DISABLING.Ptr()}, + }, isValid: true, expectedOutput: false, }, { - description: "project disabled 3", - getProjectResp: &serviceenablement.ServiceStatus{State: serviceenablement.SERVICESTATUSSTATE_DISABLING.Ptr()}, + description: "project disabled 3", + mockSettings: mockSettings{ + getServiceStatusResp: &serviceenablement.ServiceStatus{State: serviceenablement.SERVICESTATUSSTATE_DISABLING.Ptr()}, + }, isValid: true, expectedOutput: false, }, { - description: "get clusters fails", - getProjectFails: true, - isValid: false, + description: "get clusters fails", + mockSettings: mockSettings{ + getServiceStatusFails: true, + }, + isValid: false, }, } for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { - client := &serviceEnableClientMocked{ - serviceDisabled: tt.serviceDisabled, - getServiceStatusFails: tt.getProjectFails, - getServiceStatusResp: tt.getProjectResp, - } + client := newServiceEnableClientMock(tt.mockSettings) output, err := ProjectEnabled(context.Background(), client, testRegion, testProjectId) diff --git a/internal/pkg/services/ske/client/client.go b/internal/pkg/services/ske/client/client.go index dd3af9872..1fba24bc6 100644 --- a/internal/pkg/services/ske/client/client.go +++ b/internal/pkg/services/ske/client/client.go @@ -10,5 +10,5 @@ import ( ) func ConfigureClient(p *print.Printer, cliVersion string) (*ske.APIClient, error) { - return genericclient.ConfigureClientGeneric(p, cliVersion, viper.GetString(config.SKECustomEndpointKey), false, genericclient.CreateApiClient[*ske.APIClient](ske.NewAPIClient)) + return genericclient.ConfigureClientGeneric(p, cliVersion, viper.GetString(config.SKECustomEndpointKey), false, ske.NewAPIClient) } From 96d51c47be6c9d9e73652a4947eb24dc8f62284c Mon Sep 17 00:00:00 2001 From: Jan Obernberger <52105660+j1n-o9r@users.noreply.github.com> Date: Wed, 22 Jul 2026 13:32:07 +0200 Subject: [PATCH 41/44] chore(logs): sdk migration (#1444) relates to STACKITCLI-367 --- docs/stackit_logs_access-token_create.md | 2 +- docs/stackit_logs_instance_create.md | 10 ++-- docs/stackit_logs_instance_update.md | 10 ++-- go.mod | 2 +- go.sum | 4 +- .../cmd/logs/access_token/create/create.go | 21 +++---- .../logs/access_token/create/create_test.go | 40 ++++++------- .../cmd/logs/access_token/delete/delete.go | 6 +- .../logs/access_token/delete/delete_test.go | 8 +-- .../access_token/delete_all/delete_all.go | 14 ++--- .../delete_all/delete_all_test.go | 8 +-- .../delete_all_expired/delete_all_expired.go | 16 +++--- .../delete_all_expired_test.go | 8 +-- .../logs/access_token/describe/describe.go | 18 +++--- .../access_token/describe/describe_test.go | 26 ++++----- internal/cmd/logs/access_token/list/list.go | 14 ++--- .../cmd/logs/access_token/list/list_test.go | 26 ++++----- .../cmd/logs/access_token/update/update.go | 8 +-- .../logs/access_token/update/update_test.go | 8 +-- internal/cmd/logs/instance/create/create.go | 32 ++++------- .../cmd/logs/instance/create/create_test.go | 22 +++---- internal/cmd/logs/instance/delete/delete.go | 10 ++-- .../cmd/logs/instance/delete/delete_test.go | 8 +-- .../cmd/logs/instance/describe/describe.go | 12 ++-- .../logs/instance/describe/describe_test.go | 8 +-- internal/cmd/logs/instance/list/list.go | 11 ++-- internal/cmd/logs/instance/list/list_test.go | 8 +-- internal/cmd/logs/instance/update/update.go | 19 ++++--- .../cmd/logs/instance/update/update_test.go | 22 +++---- internal/pkg/services/logs/client/client.go | 4 +- internal/pkg/services/logs/utils/utils.go | 24 +++----- .../pkg/services/logs/utils/utils_test.go | 57 +++++++------------ internal/pkg/utils/utils.go | 9 +++ internal/pkg/utils/utils_test.go | 37 ++++++++++++ 34 files changed, 272 insertions(+), 260 deletions(-) diff --git a/docs/stackit_logs_access-token_create.md b/docs/stackit_logs_access-token_create.md index d55edbeb1..6c6a3a73d 100644 --- a/docs/stackit_logs_access-token_create.md +++ b/docs/stackit_logs_access-token_create.md @@ -30,7 +30,7 @@ stackit logs access-token create [flags] --display-name string Display name for the access token -h, --help Help for "stackit logs access-token create" --instance-id string ID of the Logs instance - --lifetime int Lifetime of the access token in days [1 - 180] + --lifetime int32 Lifetime of the access token in days [1 - 180] --permissions strings Permissions of the access token ["read" "write"] ``` diff --git a/docs/stackit_logs_instance_create.md b/docs/stackit_logs_instance_create.md index 65c5e48ae..cee96d60f 100644 --- a/docs/stackit_logs_instance_create.md +++ b/docs/stackit_logs_instance_create.md @@ -26,11 +26,11 @@ stackit logs instance create [flags] ### Options ``` - --acl strings Access control list - --description string Description - --display-name string Display name - -h, --help Help for "stackit logs instance create" - --retention-days int The days for how long the logs should be stored before being cleaned up + --acl strings Access control list + --description string Description + --display-name string Display name + -h, --help Help for "stackit logs instance create" + --retention-days int32 The days for how long the logs should be stored before being cleaned up ``` ### Options inherited from parent commands diff --git a/docs/stackit_logs_instance_update.md b/docs/stackit_logs_instance_update.md index 0157806f3..877903b3b 100644 --- a/docs/stackit_logs_instance_update.md +++ b/docs/stackit_logs_instance_update.md @@ -26,11 +26,11 @@ stackit logs instance update INSTANCE_ID [flags] ### Options ``` - --acl strings Access control list - --description string Description - --display-name string Display name - -h, --help Help for "stackit logs instance update" - --retention-days int The days for how long the logs should be stored before being cleaned up + --acl strings Access control list + --description string Description + --display-name string Display name + -h, --help Help for "stackit logs instance update" + --retention-days int32 The days for how long the logs should be stored before being cleaned up ``` ### Options inherited from parent commands diff --git a/go.mod b/go.mod index cfdf51f57..8908bb9c5 100644 --- a/go.mod +++ b/go.mod @@ -24,7 +24,7 @@ require ( github.com/stackitcloud/stackit-sdk-go/services/git v0.14.0 github.com/stackitcloud/stackit-sdk-go/services/iaas v1.13.0 github.com/stackitcloud/stackit-sdk-go/services/intake v0.7.1 - github.com/stackitcloud/stackit-sdk-go/services/logs v0.5.2 + github.com/stackitcloud/stackit-sdk-go/services/logs v0.10.0 github.com/stackitcloud/stackit-sdk-go/services/mongodbflex v1.12.0 github.com/stackitcloud/stackit-sdk-go/services/opensearch v1.1.0 github.com/stackitcloud/stackit-sdk-go/services/postgresflex v1.11.0 diff --git a/go.sum b/go.sum index bcf939f5a..9b23bdb34 100644 --- a/go.sum +++ b/go.sum @@ -614,8 +614,8 @@ github.com/stackitcloud/stackit-sdk-go/services/loadbalancer v1.14.0 h1:1dvL7tX9 github.com/stackitcloud/stackit-sdk-go/services/loadbalancer v1.14.0/go.mod h1:+Ld3dn648I+YKcBV3fEkYpDSr3fel421+LurJGywSBs= github.com/stackitcloud/stackit-sdk-go/services/logme v1.0.1 h1:iteL61eMMPWT6872nF4Ko/tBU1IXemvS++XR09pj6NA= github.com/stackitcloud/stackit-sdk-go/services/logme v1.0.1/go.mod h1:JDOOYaGgcBts2x52nKPRMFgSZe7qqOFmfz1xIXCQgRY= -github.com/stackitcloud/stackit-sdk-go/services/logs v0.5.2 h1:vr4atxFRT+EL+DqONMT5R44f7AzEMbePa9U7PEE0THU= -github.com/stackitcloud/stackit-sdk-go/services/logs v0.5.2/go.mod h1:CAPsiTX7osAImfrG5RnIjaJ/Iz3QpoBKuH2fS346wuQ= +github.com/stackitcloud/stackit-sdk-go/services/logs v0.10.0 h1:g7zpfQFFq3UhAWrMK9rPaZY6dLMAuMJf5g6+r7VRTXc= +github.com/stackitcloud/stackit-sdk-go/services/logs v0.10.0/go.mod h1:tvRejL8w5KpGBbLFPQ+dXOJURgZ3OMbZmwxlKQrGMuA= github.com/stackitcloud/stackit-sdk-go/services/mariadb v0.30.0 h1:LFIH1wAp633ZAJw/7H3F4nq1DZe0Qu3rlDeXhobZEZA= github.com/stackitcloud/stackit-sdk-go/services/mariadb v0.30.0/go.mod h1:joa89Y1dyn0j22FstRcIKfW2ada3FDxNfttxSvq27uY= github.com/stackitcloud/stackit-sdk-go/services/mongodbflex v1.12.0 h1:SVd3WMmLAE0Jxk2SaRuM85DTOOXHycyMpZGx9vzqNkI= diff --git a/internal/cmd/logs/access_token/create/create.go b/internal/cmd/logs/access_token/create/create.go index 852810a85..0cec80e40 100644 --- a/internal/cmd/logs/access_token/create/create.go +++ b/internal/cmd/logs/access_token/create/create.go @@ -7,7 +7,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/types" "github.com/stackitcloud/stackit-cli/internal/pkg/utils" - "github.com/stackitcloud/stackit-sdk-go/services/logs" + logs "github.com/stackitcloud/stackit-sdk-go/services/logs/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/args" cliErr "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -35,7 +35,7 @@ type inputModel struct { InstanceId string Description *string DisplayName string - Lifetime *int64 + Lifetime *int32 Permissions []string } @@ -80,7 +80,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { projectLabel = model.ProjectId } - instanceLabel, err := logsUtils.GetInstanceName(ctx, apiClient, model.ProjectId, model.Region, model.InstanceId) + instanceLabel, err := logsUtils.GetInstanceName(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, model.InstanceId) if err != nil { params.Printer.Debug(print.ErrorLevel, "get instance name: %v", err) instanceLabel = model.InstanceId @@ -110,7 +110,7 @@ func configureFlags(cmd *cobra.Command) { cmd.Flags().Var(flags.UUIDFlag(), instanceIdFlag, "ID of the Logs instance") cmd.Flags().String(displayNameFlag, "", "Display name for the access token") cmd.Flags().String(descriptionFlag, "", "Description of the access token") - cmd.Flags().Int64(lifetimeFlag, 0, "Lifetime of the access token in days [1 - 180]") + cmd.Flags().Int32(lifetimeFlag, 0, "Lifetime of the access token in days [1 - 180]") cmd.Flags().StringSlice(permissionsFlag, []string{}, `Permissions of the access token ["read" "write"]`) err := flags.MarkFlagsRequired(cmd, instanceIdFlag, displayNameFlag, permissionsFlag) @@ -128,7 +128,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, DisplayName: flags.FlagToStringValue(p, cmd, displayNameFlag), InstanceId: flags.FlagToStringValue(p, cmd, instanceIdFlag), Description: flags.FlagToStringPointer(p, cmd, descriptionFlag), - Lifetime: flags.FlagToInt64Pointer(p, cmd, lifetimeFlag), + Lifetime: flags.FlagToInt32Pointer(p, cmd, lifetimeFlag), Permissions: flags.FlagToStringSliceValue(p, cmd, permissionsFlag), } @@ -137,13 +137,14 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, } func buildRequest(ctx context.Context, model *inputModel, apiClient *logs.APIClient) logs.ApiCreateAccessTokenRequest { - req := apiClient.CreateAccessToken(ctx, model.ProjectId, model.Region, model.InstanceId) - + req := apiClient.DefaultAPI.CreateAccessToken(ctx, model.ProjectId, model.Region, model.InstanceId) return req.CreateAccessTokenPayload(logs.CreateAccessTokenPayload{ Description: model.Description, - DisplayName: &model.DisplayName, + DisplayName: model.DisplayName, Lifetime: model.Lifetime, - Permissions: &model.Permissions, + Permissions: utils.Map(model.Permissions, func(t string) logs.PermissionsInner { + return logs.PermissionsInner(t) + }), }) } @@ -152,7 +153,7 @@ func outputResult(p *print.Printer, outputFormat, instanceLabel string, accessTo return fmt.Errorf("access token cannot be nil") } return p.OutputResult(outputFormat, accessToken, func() error { - p.Outputf("Created access token for Logs instance %q.\n\nID: %s\nToken: %s\n", instanceLabel, utils.PtrValue(accessToken.Id), utils.PtrValue(accessToken.AccessToken)) + p.Outputf("Created access token for Logs instance %q.\n\nID: %s\nToken: %s\n", instanceLabel, accessToken.Id, utils.PtrValue(accessToken.AccessToken)) return nil }) } diff --git a/internal/cmd/logs/access_token/create/create_test.go b/internal/cmd/logs/access_token/create/create_test.go index 27ecc0380..64053f791 100644 --- a/internal/cmd/logs/access_token/create/create_test.go +++ b/internal/cmd/logs/access_token/create/create_test.go @@ -12,7 +12,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/logs" + logs "github.com/stackitcloud/stackit-sdk-go/services/logs/v1api" ) const ( @@ -26,7 +26,7 @@ type testCtxKey struct{} var ( testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") - testClient = &logs.APIClient{} + testClient = &logs.APIClient{DefaultAPI: &logs.DefaultAPIService{}} testProjectId = uuid.NewString() testInstanceId = uuid.NewString() ) @@ -59,7 +59,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { InstanceId: testInstanceId, Description: utils.Ptr(testDescription), DisplayName: testDisplayName, - Lifetime: utils.Ptr(int64(0)), + Lifetime: utils.Ptr(int32(0)), Permissions: []string{ "read", "write", @@ -72,7 +72,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *logs.ApiCreateAccessTokenRequest)) logs.ApiCreateAccessTokenRequest { - request := testClient.CreateAccessToken(testCtx, testProjectId, testRegion, testInstanceId) + request := testClient.DefaultAPI.CreateAccessToken(testCtx, testProjectId, testRegion, testInstanceId) request = request.CreateAccessTokenPayload(fixturePayload()) for _, mod := range mods { mod(&request) @@ -82,13 +82,13 @@ func fixtureRequest(mods ...func(request *logs.ApiCreateAccessTokenRequest)) log func fixturePayload(mods ...func(payload *logs.CreateAccessTokenPayload)) logs.CreateAccessTokenPayload { payload := logs.CreateAccessTokenPayload{ - DisplayName: utils.Ptr(testDisplayName), + DisplayName: testDisplayName, Description: utils.Ptr(testDescription), - Lifetime: utils.Ptr(int64(0)), - Permissions: utils.Ptr([]string{ - "read", - "write", - }), + Lifetime: utils.Ptr(int32(0)), + Permissions: []logs.PermissionsInner{ + logs.PERMISSIONSINNER_READ, + logs.PERMISSIONSINNER_WRITE, + }, } for _, mod := range mods { mod(&payload) @@ -215,7 +215,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(tt.expectedRequest, request, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, logs.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) @@ -240,16 +240,16 @@ func TestOutputResult(t *testing.T) { args: args{ instanceLabel: "", accessToken: utils.Ptr(logs.AccessToken{ - Id: utils.Ptr(uuid.NewString()), - Permissions: utils.Ptr([]string{ - "read", - "write", - }), - DisplayName: utils.Ptr("Token"), + Id: uuid.NewString(), + Permissions: []logs.PermissionsInner{ + logs.PERMISSIONSINNER_READ, + logs.PERMISSIONSINNER_WRITE, + }, + DisplayName: "Token", AccessToken: utils.Ptr("Secret access token"), - Creator: utils.Ptr(uuid.NewString()), - Expires: utils.Ptr(false), - Status: utils.Ptr(logs.ACCESSTOKENSTATUS_ACTIVE), + Creator: uuid.NewString(), + Expires: false, + Status: logs.ACCESSTOKENSTATUS_ACTIVE, }), }, wantErr: false, diff --git a/internal/cmd/logs/access_token/delete/delete.go b/internal/cmd/logs/access_token/delete/delete.go index d55c8d3a2..62761727e 100644 --- a/internal/cmd/logs/access_token/delete/delete.go +++ b/internal/cmd/logs/access_token/delete/delete.go @@ -4,7 +4,7 @@ import ( "context" "fmt" - "github.com/stackitcloud/stackit-sdk-go/services/logs" + logs "github.com/stackitcloud/stackit-sdk-go/services/logs/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/flags" "github.com/stackitcloud/stackit-cli/internal/pkg/types" @@ -58,7 +58,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } // Get the display name for confirmation - accessTokenLabel, err := logUtils.GetAccessTokenName(ctx, apiClient, model.ProjectId, model.Region, model.InstanceId, model.AccessTokenId) + accessTokenLabel, err := logUtils.GetAccessTokenName(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, model.InstanceId, model.AccessTokenId) if err != nil { params.Printer.Debug(print.ErrorLevel, "get access token: %v", err) } @@ -113,5 +113,5 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *logs.APIClient) logs.ApiDeleteAccessTokenRequest { - return apiClient.DeleteAccessToken(ctx, model.ProjectId, model.Region, model.InstanceId, model.AccessTokenId) + return apiClient.DefaultAPI.DeleteAccessToken(ctx, model.ProjectId, model.Region, model.InstanceId, model.AccessTokenId) } diff --git a/internal/cmd/logs/access_token/delete/delete_test.go b/internal/cmd/logs/access_token/delete/delete_test.go index 23bbb5464..a81be1bd1 100644 --- a/internal/cmd/logs/access_token/delete/delete_test.go +++ b/internal/cmd/logs/access_token/delete/delete_test.go @@ -10,7 +10,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/logs" + logs "github.com/stackitcloud/stackit-sdk-go/services/logs/v1api" ) const ( @@ -21,7 +21,7 @@ type testCtxKey struct{} var ( testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") - testClient = &logs.APIClient{} + testClient = &logs.APIClient{DefaultAPI: &logs.DefaultAPIService{}} testProjectId = uuid.NewString() testInstanceId = uuid.NewString() @@ -69,7 +69,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *logs.ApiDeleteAccessTokenRequest)) logs.ApiDeleteAccessTokenRequest { - request := testClient.DeleteAccessToken(testCtx, testProjectId, testRegion, testInstanceId, testAccessTokenId) + request := testClient.DefaultAPI.DeleteAccessToken(testCtx, testProjectId, testRegion, testInstanceId, testAccessTokenId) for _, mod := range mods { mod(&request) } @@ -197,7 +197,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, logs.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/logs/access_token/delete_all/delete_all.go b/internal/cmd/logs/access_token/delete_all/delete_all.go index e12e89804..8492a2f9b 100644 --- a/internal/cmd/logs/access_token/delete_all/delete_all.go +++ b/internal/cmd/logs/access_token/delete_all/delete_all.go @@ -4,19 +4,17 @@ import ( "context" "fmt" - "github.com/stackitcloud/stackit-sdk-go/services/logs" + logs "github.com/stackitcloud/stackit-sdk-go/services/logs/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/args" - "github.com/stackitcloud/stackit-cli/internal/pkg/flags" - "github.com/stackitcloud/stackit-cli/internal/pkg/types" - "github.com/stackitcloud/stackit-cli/internal/pkg/utils" - "github.com/stackitcloud/stackit-cli/internal/pkg/errors" "github.com/stackitcloud/stackit-cli/internal/pkg/examples" + "github.com/stackitcloud/stackit-cli/internal/pkg/flags" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/print" "github.com/stackitcloud/stackit-cli/internal/pkg/services/logs/client" logUtils "github.com/stackitcloud/stackit-cli/internal/pkg/services/logs/utils" + "github.com/stackitcloud/stackit-cli/internal/pkg/types" "github.com/spf13/cobra" ) @@ -55,7 +53,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return err } - instanceLabel, err := logUtils.GetInstanceName(ctx, apiClient, model.ProjectId, model.Region, model.InstanceId) + instanceLabel, err := logUtils.GetInstanceName(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, model.InstanceId) if err != nil { params.Printer.Debug(print.ErrorLevel, "get instance name: %v", err) instanceLabel = model.InstanceId @@ -77,7 +75,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return fmt.Errorf("delete all access token: nil result") } - params.Printer.Outputf("Deleted %d access token(s)\n", len(utils.PtrValue(items.Tokens))) + params.Printer.Outputf("Deleted %d access token(s)\n", len(items.Tokens)) return nil }, } @@ -108,5 +106,5 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, } func buildRequest(ctx context.Context, model *inputModel, apiClient *logs.APIClient) logs.ApiDeleteAllAccessTokensRequest { - return apiClient.DeleteAllAccessTokens(ctx, model.ProjectId, model.Region, model.InstanceId) + return apiClient.DefaultAPI.DeleteAllAccessTokens(ctx, model.ProjectId, model.Region, model.InstanceId) } diff --git a/internal/cmd/logs/access_token/delete_all/delete_all_test.go b/internal/cmd/logs/access_token/delete_all/delete_all_test.go index 7cc8e8a81..57551c1f2 100644 --- a/internal/cmd/logs/access_token/delete_all/delete_all_test.go +++ b/internal/cmd/logs/access_token/delete_all/delete_all_test.go @@ -10,7 +10,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/logs" + logs "github.com/stackitcloud/stackit-sdk-go/services/logs/v1api" ) const ( @@ -21,7 +21,7 @@ type testCtxKey struct{} var ( testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") - testClient = &logs.APIClient{} + testClient = &logs.APIClient{DefaultAPI: &logs.DefaultAPIService{}} testProjectId = uuid.NewString() testInstanceId = uuid.NewString() @@ -57,7 +57,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *logs.ApiDeleteAllAccessTokensRequest)) logs.ApiDeleteAllAccessTokensRequest { - request := testClient.DeleteAllAccessTokens(testCtx, testProjectId, testRegion, testInstanceId) + request := testClient.DefaultAPI.DeleteAllAccessTokens(testCtx, testProjectId, testRegion, testInstanceId) for _, mod := range mods { mod(&request) } @@ -153,7 +153,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, logs.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/logs/access_token/delete_all_expired/delete_all_expired.go b/internal/cmd/logs/access_token/delete_all_expired/delete_all_expired.go index fbad9528a..1c4b540d0 100644 --- a/internal/cmd/logs/access_token/delete_all_expired/delete_all_expired.go +++ b/internal/cmd/logs/access_token/delete_all_expired/delete_all_expired.go @@ -4,19 +4,17 @@ import ( "context" "fmt" - "github.com/stackitcloud/stackit-sdk-go/services/logs" + logs "github.com/stackitcloud/stackit-sdk-go/services/logs/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/args" - "github.com/stackitcloud/stackit-cli/internal/pkg/flags" - "github.com/stackitcloud/stackit-cli/internal/pkg/types" - "github.com/stackitcloud/stackit-cli/internal/pkg/utils" - "github.com/stackitcloud/stackit-cli/internal/pkg/errors" "github.com/stackitcloud/stackit-cli/internal/pkg/examples" + "github.com/stackitcloud/stackit-cli/internal/pkg/flags" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/print" "github.com/stackitcloud/stackit-cli/internal/pkg/services/logs/client" logUtils "github.com/stackitcloud/stackit-cli/internal/pkg/services/logs/utils" + "github.com/stackitcloud/stackit-cli/internal/pkg/types" "github.com/spf13/cobra" ) @@ -55,7 +53,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return err } - instanceLabel, err := logUtils.GetInstanceName(ctx, apiClient, model.ProjectId, model.Region, model.InstanceId) + instanceLabel, err := logUtils.GetInstanceName(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, model.InstanceId) if err != nil { params.Printer.Debug(print.ErrorLevel, "get instance name: %v", err) instanceLabel = model.InstanceId @@ -77,7 +75,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return fmt.Errorf("delete all expired access token: nil result") } - params.Printer.Outputf("Deleted %d expired access token(s)\n", len(utils.PtrValue(items.Tokens))) + params.Printer.Outputf("Deleted %d expired access token(s)\n", len(items.Tokens)) return nil }, } @@ -107,6 +105,6 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, return &model, nil } -func buildRequest(ctx context.Context, model *inputModel, apiClient *logs.APIClient) logs.ApiDeleteAllAccessTokensRequest { - return apiClient.DeleteAllExpiredAccessTokens(ctx, model.ProjectId, model.Region, model.InstanceId) +func buildRequest(ctx context.Context, model *inputModel, apiClient *logs.APIClient) logs.ApiDeleteAllExpiredAccessTokensRequest { + return apiClient.DefaultAPI.DeleteAllExpiredAccessTokens(ctx, model.ProjectId, model.Region, model.InstanceId) } diff --git a/internal/cmd/logs/access_token/delete_all_expired/delete_all_expired_test.go b/internal/cmd/logs/access_token/delete_all_expired/delete_all_expired_test.go index f369afa91..20eda0fcf 100644 --- a/internal/cmd/logs/access_token/delete_all_expired/delete_all_expired_test.go +++ b/internal/cmd/logs/access_token/delete_all_expired/delete_all_expired_test.go @@ -10,7 +10,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/logs" + logs "github.com/stackitcloud/stackit-sdk-go/services/logs/v1api" ) const ( @@ -21,7 +21,7 @@ type testCtxKey struct{} var ( testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") - testClient = &logs.APIClient{} + testClient = &logs.APIClient{DefaultAPI: &logs.DefaultAPIService{}} testProjectId = uuid.NewString() testInstanceId = uuid.NewString() @@ -57,7 +57,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *logs.ApiDeleteAllExpiredAccessTokensRequest)) logs.ApiDeleteAllExpiredAccessTokensRequest { - request := testClient.DeleteAllExpiredAccessTokens(testCtx, testProjectId, testRegion, testInstanceId) + request := testClient.DefaultAPI.DeleteAllExpiredAccessTokens(testCtx, testProjectId, testRegion, testInstanceId) for _, mod := range mods { mod(&request) } @@ -153,7 +153,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, logs.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/logs/access_token/describe/describe.go b/internal/cmd/logs/access_token/describe/describe.go index d81a8b258..841ed8c27 100644 --- a/internal/cmd/logs/access_token/describe/describe.go +++ b/internal/cmd/logs/access_token/describe/describe.go @@ -7,7 +7,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/flags" "github.com/stackitcloud/stackit-cli/internal/pkg/types" - "github.com/stackitcloud/stackit-sdk-go/services/logs" + logs "github.com/stackitcloud/stackit-sdk-go/services/logs/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/args" "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -101,7 +101,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *logs.APIClient) logs.ApiGetAccessTokenRequest { - return apiClient.GetAccessToken(ctx, model.ProjectId, model.Region, model.InstanceId, model.AccessTokenId) + return apiClient.DefaultAPI.GetAccessToken(ctx, model.ProjectId, model.Region, model.InstanceId, model.AccessTokenId) } func outputResult(p *print.Printer, outputFormat string, token *logs.AccessToken) error { @@ -110,21 +110,21 @@ func outputResult(p *print.Printer, outputFormat string, token *logs.AccessToken } return p.OutputResult(outputFormat, token, func() error { table := tables.NewTable() - table.AddRow("ID", utils.PtrString(token.Id)) + table.AddRow("ID", token.Id) table.AddSeparator() - table.AddRow("DISPLAY NAME", utils.PtrString(token.DisplayName)) + table.AddRow("DISPLAY NAME", token.DisplayName) table.AddSeparator() table.AddRow("DESCRIPTION", utils.PtrString(token.Description)) table.AddSeparator() - table.AddRow("PERMISSIONS", utils.PtrString(token.Permissions)) + table.AddRow("PERMISSIONS", token.Permissions) table.AddSeparator() - table.AddRow("CREATOR", utils.PtrString(token.Creator)) + table.AddRow("CREATOR", token.Creator) table.AddSeparator() - table.AddRow("STATE", utils.PtrString(token.Status)) + table.AddRow("STATE", token.Status) table.AddSeparator() - table.AddRow("EXPIRES", utils.PtrString(token.Expires)) + table.AddRow("EXPIRES", token.Expires) table.AddSeparator() - table.AddRow("VALID UNTIL", utils.PtrString(token.ValidUntil)) + table.AddRow("VALID UNTIL", token.ValidUntil) table.AddSeparator() err := table.Display(p) diff --git a/internal/cmd/logs/access_token/describe/describe_test.go b/internal/cmd/logs/access_token/describe/describe_test.go index 8e6bd2e20..e9d4222cc 100644 --- a/internal/cmd/logs/access_token/describe/describe_test.go +++ b/internal/cmd/logs/access_token/describe/describe_test.go @@ -12,7 +12,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/logs" + logs "github.com/stackitcloud/stackit-sdk-go/services/logs/v1api" ) const ( @@ -23,7 +23,7 @@ type testCtxKey struct{} var ( testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") - testClient = &logs.APIClient{} + testClient = &logs.APIClient{DefaultAPI: &logs.DefaultAPIService{}} testProjectId = uuid.NewString() testInstanceId = uuid.NewString() @@ -71,7 +71,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *logs.ApiGetAccessTokenRequest)) logs.ApiGetAccessTokenRequest { - request := testClient.GetAccessToken(testCtx, testProjectId, testRegion, testInstanceId, testAccessTokenId) + request := testClient.DefaultAPI.GetAccessToken(testCtx, testProjectId, testRegion, testInstanceId, testAccessTokenId) for _, mod := range mods { mod(&request) } @@ -199,7 +199,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, logs.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) @@ -222,16 +222,16 @@ func TestOutputResult(t *testing.T) { name: "base", args: args{ accessToken: utils.Ptr(logs.AccessToken{ - Id: utils.Ptr(uuid.NewString()), - Permissions: utils.Ptr([]string{ - "read", - "write", - }), - DisplayName: utils.Ptr("Token"), + Id: uuid.NewString(), + Permissions: []logs.PermissionsInner{ + logs.PERMISSIONSINNER_READ, + logs.PERMISSIONSINNER_WRITE, + }, + DisplayName: "Token", AccessToken: utils.Ptr("Secret access token"), - Creator: utils.Ptr(uuid.NewString()), - Expires: utils.Ptr(false), - Status: utils.Ptr(logs.ACCESSTOKENSTATUS_ACTIVE), + Creator: uuid.NewString(), + Expires: false, + Status: logs.ACCESSTOKENSTATUS_ACTIVE, }), }, wantErr: false, diff --git a/internal/cmd/logs/access_token/list/list.go b/internal/cmd/logs/access_token/list/list.go index 27967bdc8..0843bc6c2 100644 --- a/internal/cmd/logs/access_token/list/list.go +++ b/internal/cmd/logs/access_token/list/list.go @@ -6,7 +6,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/types" - "github.com/stackitcloud/stackit-sdk-go/services/logs" + logs "github.com/stackitcloud/stackit-sdk-go/services/logs/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/args" "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -82,7 +82,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } // Truncate output - items := utils.PtrValue(resp.Tokens) + items := resp.Tokens if model.Limit != nil && len(items) > int(*model.Limit) { items = items[:*model.Limit] } @@ -127,7 +127,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, } func buildRequest(ctx context.Context, model *inputModel, apiClient *logs.APIClient) logs.ApiListAccessTokensRequest { - return apiClient.ListAccessTokens(ctx, model.ProjectId, model.Region, model.InstanceId) + return apiClient.DefaultAPI.ListAccessTokens(ctx, model.ProjectId, model.Region, model.InstanceId) } func outputResult(p *print.Printer, outputFormat string, tokens []logs.AccessToken, projectLabel string) error { @@ -142,12 +142,12 @@ func outputResult(p *print.Printer, outputFormat string, tokens []logs.AccessTok for _, token := range tokens { table.AddRow( - utils.PtrString(token.Id), - utils.PtrString(token.DisplayName), + token.Id, + token.DisplayName, utils.PtrString(token.Description), - utils.PtrString(token.Permissions), + token.Permissions, utils.PtrString(token.ValidUntil), - utils.PtrString(token.Status), + token.Status, ) table.AddSeparator() } diff --git a/internal/cmd/logs/access_token/list/list_test.go b/internal/cmd/logs/access_token/list/list_test.go index 1b05a14ad..761b2db9c 100644 --- a/internal/cmd/logs/access_token/list/list_test.go +++ b/internal/cmd/logs/access_token/list/list_test.go @@ -12,7 +12,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/logs" + logs "github.com/stackitcloud/stackit-sdk-go/services/logs/v1api" ) const ( @@ -23,7 +23,7 @@ type testCtxKey struct{} var ( testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") - testClient = &logs.APIClient{} + testClient = &logs.APIClient{DefaultAPI: &logs.DefaultAPIService{}} testProjectId = uuid.NewString() testInstanceId = uuid.NewString() @@ -61,7 +61,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *logs.ApiListAccessTokensRequest)) logs.ApiListAccessTokensRequest { - request := testClient.ListAccessTokens(testCtx, testProjectId, testRegion, testInstanceId) + request := testClient.DefaultAPI.ListAccessTokens(testCtx, testProjectId, testRegion, testInstanceId) for _, mod := range mods { mod(&request) } @@ -171,7 +171,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, logs.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) @@ -196,16 +196,16 @@ func TestOutputResult(t *testing.T) { args: args{ accessTokens: []logs.AccessToken{ { - Id: utils.Ptr(uuid.NewString()), - Permissions: utils.Ptr([]string{ - "read", - "write", - }), - DisplayName: utils.Ptr("Token"), + Id: uuid.NewString(), + Permissions: []logs.PermissionsInner{ + logs.PERMISSIONSINNER_READ, + logs.PERMISSIONSINNER_WRITE, + }, + DisplayName: "Token", AccessToken: utils.Ptr("Secret access token"), - Creator: utils.Ptr(uuid.NewString()), - Expires: utils.Ptr(false), - Status: utils.Ptr(logs.ACCESSTOKENSTATUS_ACTIVE), + Creator: uuid.NewString(), + Expires: false, + Status: logs.ACCESSTOKENSTATUS_ACTIVE, }, }, }, diff --git a/internal/cmd/logs/access_token/update/update.go b/internal/cmd/logs/access_token/update/update.go index 6fe999dba..c265b639d 100644 --- a/internal/cmd/logs/access_token/update/update.go +++ b/internal/cmd/logs/access_token/update/update.go @@ -4,7 +4,7 @@ import ( "context" "fmt" - "github.com/stackitcloud/stackit-sdk-go/services/logs" + logs "github.com/stackitcloud/stackit-sdk-go/services/logs/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/types" @@ -66,7 +66,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } // Get the display name for confirmation - instanceLabel, err := logUtils.GetInstanceName(ctx, apiClient, model.ProjectId, model.Region, model.InstanceId) + instanceLabel, err := logUtils.GetInstanceName(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, model.InstanceId) if err != nil { params.Printer.Debug(print.ErrorLevel, "get Logs instance: %v", err) } @@ -75,7 +75,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } // Get the display name for confirmation - accessTokenLabel, err := logUtils.GetAccessTokenName(ctx, apiClient, model.ProjectId, model.Region, model.InstanceId, model.AccessTokenId) + accessTokenLabel, err := logUtils.GetAccessTokenName(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, model.InstanceId, model.AccessTokenId) if err != nil { params.Printer.Debug(print.ErrorLevel, "get access token: %v", err) } @@ -134,7 +134,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *logs.APIClient) logs.ApiUpdateAccessTokenRequest { - req := apiClient.UpdateAccessToken(ctx, model.ProjectId, model.Region, model.InstanceId, model.AccessTokenId) + req := apiClient.DefaultAPI.UpdateAccessToken(ctx, model.ProjectId, model.Region, model.InstanceId, model.AccessTokenId) payload := logs.UpdateAccessTokenPayload{ DisplayName: model.DisplayName, diff --git a/internal/cmd/logs/access_token/update/update_test.go b/internal/cmd/logs/access_token/update/update_test.go index b40fb143b..3ee52f04a 100644 --- a/internal/cmd/logs/access_token/update/update_test.go +++ b/internal/cmd/logs/access_token/update/update_test.go @@ -11,7 +11,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/logs" + logs "github.com/stackitcloud/stackit-sdk-go/services/logs/v1api" ) const ( @@ -25,7 +25,7 @@ type testCtxKey struct{} var ( testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") - testClient = &logs.APIClient{} + testClient = &logs.APIClient{DefaultAPI: &logs.DefaultAPIService{}} testProjectId = uuid.NewString() testInstanceId = uuid.NewString() @@ -77,7 +77,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *logs.ApiUpdateAccessTokenRequest)) logs.ApiUpdateAccessTokenRequest { - request := testClient.UpdateAccessToken(testCtx, testProjectId, testRegion, testInstanceId, testAccessTokenId) + request := testClient.DefaultAPI.UpdateAccessToken(testCtx, testProjectId, testRegion, testInstanceId, testAccessTokenId) request = request.UpdateAccessTokenPayload(fixturePayload()) for _, mod := range mods { mod(&request) @@ -265,7 +265,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, logs.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/logs/instance/create/create.go b/internal/cmd/logs/instance/create/create.go index a7fca44c3..4e35772f5 100644 --- a/internal/cmd/logs/instance/create/create.go +++ b/internal/cmd/logs/instance/create/create.go @@ -4,7 +4,7 @@ import ( "context" "fmt" - "github.com/stackitcloud/stackit-sdk-go/services/logs" + logs "github.com/stackitcloud/stackit-sdk-go/services/logs/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/projectname" "github.com/stackitcloud/stackit-cli/internal/pkg/spinner" @@ -16,7 +16,7 @@ import ( cliErr "github.com/stackitcloud/stackit-cli/internal/pkg/errors" "github.com/stackitcloud/stackit-cli/internal/pkg/services/logs/client" - "github.com/stackitcloud/stackit-sdk-go/services/logs/wait" + "github.com/stackitcloud/stackit-sdk-go/services/logs/v1api/wait" "github.com/stackitcloud/stackit-cli/internal/pkg/examples" "github.com/stackitcloud/stackit-cli/internal/pkg/flags" @@ -36,8 +36,8 @@ type inputModel struct { *globalflags.GlobalFlagModel DisplayName *string - RetentionDays *int64 - ACL *[]string + RetentionDays *int32 + ACL []string Description *string } @@ -88,9 +88,6 @@ func NewCmd(params *types.CmdParams) *cobra.Command { // Call API req := buildRequest(ctx, model, apiClient) - if err != nil { - return err - } resp, err := req.Execute() if err != nil { return fmt.Errorf("create Logs instance: %w", err) @@ -98,15 +95,11 @@ func NewCmd(params *types.CmdParams) *cobra.Command { if resp == nil { return fmt.Errorf("create Logs instance: empty response from API") } - if resp.Id == nil { - return fmt.Errorf("create Logs instance: instance id missing in response") - } - instanceId := *resp.Id // Wait for async operation, if async mode not enabled if !model.Async { err := spinner.Run(params.Printer, "Creating instance", func() error { - _, err = wait.CreateLogsInstanceWaitHandler(ctx, apiClient, model.ProjectId, model.Region, instanceId).WaitWithContext(ctx) + _, err = wait.CreateLogsInstanceWaitHandler(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, resp.Id).WaitWithContext(ctx) return err }) if err != nil { @@ -125,7 +118,7 @@ func configureFlags(cmd *cobra.Command) { cmd.Flags().String(displayNameFlag, "", "Display name") cmd.Flags().String(descriptionFlag, "", "Description") cmd.Flags().StringSlice(aclFlag, []string{}, "Access control list") - cmd.Flags().Int64(retentionDaysFlag, 0, "The days for how long the logs should be stored before being cleaned up") + cmd.Flags().Int32(retentionDaysFlag, 0, "The days for how long the logs should be stored before being cleaned up") err := flags.MarkFlagsRequired(cmd, displayNameFlag, retentionDaysFlag) cobra.CheckErr(err) @@ -140,9 +133,9 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, model := inputModel{ GlobalFlagModel: globalFlags, DisplayName: flags.FlagToStringPointer(p, cmd, displayNameFlag), - RetentionDays: flags.FlagToInt64Pointer(p, cmd, retentionDaysFlag), + RetentionDays: flags.FlagToInt32Pointer(p, cmd, retentionDaysFlag), Description: flags.FlagToStringPointer(p, cmd, descriptionFlag), - ACL: flags.FlagToStringSlicePointer(p, cmd, aclFlag), + ACL: flags.FlagToStringSliceValue(p, cmd, aclFlag), } p.DebugInputModel(model) @@ -150,12 +143,11 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, } func buildRequest(ctx context.Context, model *inputModel, apiClient *logs.APIClient) logs.ApiCreateLogsInstanceRequest { - req := apiClient.CreateLogsInstance(ctx, model.ProjectId, model.Region) - + req := apiClient.DefaultAPI.CreateLogsInstance(ctx, model.ProjectId, model.Region) req = req.CreateLogsInstancePayload(logs.CreateLogsInstancePayload{ - DisplayName: model.DisplayName, + DisplayName: utils.PtrString(model.DisplayName), Description: model.Description, - RetentionDays: model.RetentionDays, + RetentionDays: utils.PtrValue(model.RetentionDays), Acl: model.ACL, }) return req @@ -173,7 +165,7 @@ func outputResult(p *print.Printer, model *inputModel, projectLabel string, resp if model.Async { operationState = "Triggered creation of" } - p.Outputf("%s instance for project %q. Instance ID: %s\n", operationState, projectLabel, utils.PtrString(resp.Id)) + p.Outputf("%s instance for project %q. Instance ID: %s\n", operationState, projectLabel, resp.Id) return nil }) } diff --git a/internal/cmd/logs/instance/create/create_test.go b/internal/cmd/logs/instance/create/create_test.go index 011c37c79..f2408a93f 100644 --- a/internal/cmd/logs/instance/create/create_test.go +++ b/internal/cmd/logs/instance/create/create_test.go @@ -5,7 +5,7 @@ import ( "strconv" "testing" - "github.com/stackitcloud/stackit-sdk-go/services/logs" + logs "github.com/stackitcloud/stackit-sdk-go/services/logs/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" "github.com/stackitcloud/stackit-cli/internal/pkg/testutils" @@ -31,7 +31,7 @@ type testCtxKey struct{} var ( testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") - testClient = &logs.APIClient{} + testClient = &logs.APIClient{DefaultAPI: &logs.DefaultAPIService{}} testProjectId = uuid.NewString() ) @@ -61,8 +61,8 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { }, DisplayName: utils.Ptr(testDisplayName), Description: utils.Ptr(testDescription), - RetentionDays: utils.Ptr(int64(testRetentionDays)), - ACL: utils.Ptr([]string{testAcl}), + RetentionDays: utils.Ptr(int32(testRetentionDays)), + ACL: []string{testAcl}, } for _, mod := range mods { mod(model) @@ -72,12 +72,12 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { // Request func fixtureRequest(mods ...func(request *logs.ApiCreateLogsInstanceRequest)) logs.ApiCreateLogsInstanceRequest { - request := testClient.CreateLogsInstance(testCtx, testProjectId, testRegion) + request := testClient.DefaultAPI.CreateLogsInstance(testCtx, testProjectId, testRegion) request = request.CreateLogsInstancePayload(logs.CreateLogsInstancePayload{ - DisplayName: utils.Ptr(testDisplayName), + DisplayName: testDisplayName, Description: utils.Ptr(testDescription), - RetentionDays: utils.Ptr(int64(testRetentionDays)), - Acl: utils.Ptr([]string{testAcl}), + RetentionDays: testRetentionDays, + Acl: []string{testAcl}, }) for _, mod := range mods { @@ -179,8 +179,8 @@ func TestBuildRequest(t *testing.T) { model.ACL = nil }), expectedRequest: fixtureRequest().CreateLogsInstancePayload(logs.CreateLogsInstancePayload{ - DisplayName: utils.Ptr(testDisplayName), - RetentionDays: utils.Ptr(int64(testRetentionDays)), + DisplayName: testDisplayName, + RetentionDays: int32(testRetentionDays), Description: nil, Acl: nil, }), @@ -192,7 +192,7 @@ func TestBuildRequest(t *testing.T) { request := buildRequest(testCtx, tt.model, testClient) diff := cmp.Diff(tt.expectedRequest, request, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, logs.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/logs/instance/delete/delete.go b/internal/cmd/logs/instance/delete/delete.go index d00f33fc8..8ffa95e44 100644 --- a/internal/cmd/logs/instance/delete/delete.go +++ b/internal/cmd/logs/instance/delete/delete.go @@ -4,7 +4,7 @@ import ( "context" "fmt" - "github.com/stackitcloud/stackit-sdk-go/services/logs" + logs "github.com/stackitcloud/stackit-sdk-go/services/logs/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/projectname" "github.com/stackitcloud/stackit-cli/internal/pkg/spinner" @@ -19,7 +19,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/print" "github.com/stackitcloud/stackit-cli/internal/pkg/utils" - "github.com/stackitcloud/stackit-sdk-go/services/logs/wait" + "github.com/stackitcloud/stackit-sdk-go/services/logs/v1api/wait" "github.com/stackitcloud/stackit-cli/internal/pkg/services/logs/client" logsUtils "github.com/stackitcloud/stackit-cli/internal/pkg/services/logs/utils" @@ -66,7 +66,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { projectLabel = model.ProjectId } - instanceLabel, err := logsUtils.GetInstanceName(ctx, apiClient, model.ProjectId, model.Region, model.InstanceID) + instanceLabel, err := logsUtils.GetInstanceName(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, model.InstanceID) if err != nil { params.Printer.Debug(print.ErrorLevel, "get instance name: %v", err) instanceLabel = model.InstanceID @@ -89,7 +89,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { // Wait for async operation, if async mode not enabled if !model.Async { err := spinner.Run(params.Printer, "Deleting instance", func() error { - _, err = wait.DeleteLogsInstanceWaitHandler(ctx, apiClient, model.ProjectId, model.Region, model.InstanceID).WaitWithContext(ctx) + _, err = wait.DeleteLogsInstanceWaitHandler(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, model.InstanceID).WaitWithContext(ctx) return err }) if err != nil { @@ -127,6 +127,6 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *logs.APIClient) logs.ApiDeleteLogsInstanceRequest { - req := apiClient.DeleteLogsInstance(ctx, model.ProjectId, model.Region, model.InstanceID) + req := apiClient.DefaultAPI.DeleteLogsInstance(ctx, model.ProjectId, model.Region, model.InstanceID) return req } diff --git a/internal/cmd/logs/instance/delete/delete_test.go b/internal/cmd/logs/instance/delete/delete_test.go index 64501bf2e..162ae6055 100644 --- a/internal/cmd/logs/instance/delete/delete_test.go +++ b/internal/cmd/logs/instance/delete/delete_test.go @@ -7,7 +7,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/logs" + logs "github.com/stackitcloud/stackit-sdk-go/services/logs/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/testutils" @@ -21,7 +21,7 @@ type testCtxKey struct{} var ( testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") - testClient = &logs.APIClient{} + testClient = &logs.APIClient{DefaultAPI: &logs.DefaultAPIService{}} testProjectId = uuid.NewString() testInstanceId = uuid.NewString() ) @@ -67,7 +67,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { // Request func fixtureRequest(mods ...func(request *logs.ApiDeleteLogsInstanceRequest)) logs.ApiDeleteLogsInstanceRequest { - request := testClient.DeleteLogsInstance(testCtx, testProjectId, testRegion, testInstanceId) + request := testClient.DefaultAPI.DeleteLogsInstance(testCtx, testProjectId, testRegion, testInstanceId) for _, mod := range mods { mod(&request) } @@ -165,7 +165,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, logs.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/logs/instance/describe/describe.go b/internal/cmd/logs/instance/describe/describe.go index b145e6e66..fa37d0c8e 100644 --- a/internal/cmd/logs/instance/describe/describe.go +++ b/internal/cmd/logs/instance/describe/describe.go @@ -4,7 +4,7 @@ import ( "context" "fmt" - "github.com/stackitcloud/stackit-sdk-go/services/logs" + logs "github.com/stackitcloud/stackit-sdk-go/services/logs/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/types" @@ -84,7 +84,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *logs.APIClient) logs.ApiGetLogsInstanceRequest { - return apiClient.GetLogsInstance(ctx, model.ProjectId, model.Region, model.InstanceID) + return apiClient.DefaultAPI.GetLogsInstance(ctx, model.ProjectId, model.Region, model.InstanceID) } func outputResult(p *print.Printer, outputFormat string, instance *logs.LogsInstance) error { @@ -93,13 +93,13 @@ func outputResult(p *print.Printer, outputFormat string, instance *logs.LogsInst } return p.OutputResult(outputFormat, instance, func() error { table := tables.NewTable() - table.AddRow("ID", utils.PtrString(instance.Id)) + table.AddRow("ID", instance.Id) table.AddSeparator() - table.AddRow("DISPLAY NAME", utils.PtrString(instance.DisplayName)) + table.AddRow("DISPLAY NAME", instance.DisplayName) table.AddSeparator() - table.AddRow("RETENTION DAYS", utils.PtrString(instance.RetentionDays)) + table.AddRow("RETENTION DAYS", instance.RetentionDays) table.AddSeparator() - table.AddRow("ACL IP RANGES", utils.PtrString(instance.Acl)) + table.AddRow("ACL IP RANGES", instance.Acl) table.AddSeparator() table.AddRow("DATA SOURCE", utils.PtrString(instance.DatasourceUrl)) table.AddSeparator() diff --git a/internal/cmd/logs/instance/describe/describe_test.go b/internal/cmd/logs/instance/describe/describe_test.go index 49e000d64..faca9f971 100644 --- a/internal/cmd/logs/instance/describe/describe_test.go +++ b/internal/cmd/logs/instance/describe/describe_test.go @@ -7,7 +7,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/logs" + logs "github.com/stackitcloud/stackit-sdk-go/services/logs/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/print" @@ -18,7 +18,7 @@ import ( type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &logs.APIClient{} +var testClient = &logs.APIClient{DefaultAPI: &logs.DefaultAPIService{}} var testProjectId = uuid.NewString() var testInstanceId = uuid.NewString() @@ -51,7 +51,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *logs.ApiGetLogsInstanceRequest)) logs.ApiGetLogsInstanceRequest { - request := testClient.GetLogsInstance(testCtx, testProjectId, testRegion, testInstanceId) + request := testClient.DefaultAPI.GetLogsInstance(testCtx, testProjectId, testRegion, testInstanceId) for _, mod := range mods { mod(&request) } @@ -140,7 +140,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, logs.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/logs/instance/list/list.go b/internal/cmd/logs/instance/list/list.go index 153a4c2a9..ac2d29497 100644 --- a/internal/cmd/logs/instance/list/list.go +++ b/internal/cmd/logs/instance/list/list.go @@ -7,7 +7,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/types" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/logs" + logs "github.com/stackitcloud/stackit-sdk-go/services/logs/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/args" "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -18,7 +18,6 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/projectname" "github.com/stackitcloud/stackit-cli/internal/pkg/services/logs/client" "github.com/stackitcloud/stackit-cli/internal/pkg/tables" - "github.com/stackitcloud/stackit-cli/internal/pkg/utils" ) type inputModel struct { @@ -117,7 +116,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, } func buildRequest(ctx context.Context, model *inputModel, apiClient *logs.APIClient) logs.ApiListLogsInstancesRequest { - request := apiClient.ListLogsInstances(ctx, model.ProjectId, model.Region) + request := apiClient.DefaultAPI.ListLogsInstances(ctx, model.ProjectId, model.Region) return request } @@ -133,9 +132,9 @@ func outputResult(p *print.Printer, outputFormat, projectLabel string, instances table.SetHeader("NAME", "ID", "STATUS") for _, instance := range instances { table.AddRow( - utils.PtrString(instance.DisplayName), - utils.PtrString(instance.Id), - utils.PtrString(instance.Status), + instance.DisplayName, + instance.Id, + instance.Status, ) } err := table.Display(p) diff --git a/internal/cmd/logs/instance/list/list_test.go b/internal/cmd/logs/instance/list/list_test.go index 70fa2ff9a..339523562 100644 --- a/internal/cmd/logs/instance/list/list_test.go +++ b/internal/cmd/logs/instance/list/list_test.go @@ -12,7 +12,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/logs" + logs "github.com/stackitcloud/stackit-sdk-go/services/logs/v1api" ) const ( @@ -22,7 +22,7 @@ const ( type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &logs.APIClient{} +var testClient = &logs.APIClient{DefaultAPI: &logs.DefaultAPIService{}} var testProjectId = uuid.NewString() func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string { @@ -53,7 +53,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *logs.ApiListLogsInstancesRequest)) logs.ApiListLogsInstancesRequest { - request := testClient.ListLogsInstances(testCtx, testProjectId, testRegion) + request := testClient.DefaultAPI.ListLogsInstances(testCtx, testProjectId, testRegion) for _, mod := range mods { mod(&request) } @@ -142,7 +142,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, logs.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/logs/instance/update/update.go b/internal/cmd/logs/instance/update/update.go index 8898a2969..6e89a266c 100644 --- a/internal/cmd/logs/instance/update/update.go +++ b/internal/cmd/logs/instance/update/update.go @@ -18,7 +18,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/logs" + logs "github.com/stackitcloud/stackit-sdk-go/services/logs/v1api" ) const ( @@ -34,8 +34,8 @@ type inputModel struct { *globalflags.GlobalFlagModel InstanceID string DisplayName *string - RetentionDays *int64 - ACL *[]string + RetentionDays *int32 + ACL []string Description *string } @@ -77,7 +77,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { projectLabel = model.ProjectId } - instanceLabel, err := logsUtils.GetInstanceName(ctx, apiClient, model.ProjectId, model.Region, model.InstanceID) + instanceLabel, err := logsUtils.GetInstanceName(ctx, apiClient.DefaultAPI, model.ProjectId, model.Region, model.InstanceID) if err != nil { params.Printer.Debug(print.ErrorLevel, "get instance name: %v", err) instanceLabel = model.InstanceID @@ -108,7 +108,7 @@ func configureFlags(cmd *cobra.Command) { cmd.Flags().String(displayNameFlag, "", "Display name") cmd.Flags().String(descriptionFlag, "", "Description") cmd.Flags().StringSlice(aclFlag, []string{}, "Access control list") - cmd.Flags().Int64(retentionDaysFlag, 0, "The days for how long the logs should be stored before being cleaned up") + cmd.Flags().Int32(retentionDaysFlag, 0, "The days for how long the logs should be stored before being cleaned up") } func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inputModel, error) { @@ -120,8 +120,8 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } displayName := flags.FlagToStringPointer(p, cmd, displayNameFlag) - retentionDays := flags.FlagToInt64Pointer(p, cmd, retentionDaysFlag) - acl := flags.FlagToStringSlicePointer(p, cmd, aclFlag) + retentionDays := flags.FlagToInt32Pointer(p, cmd, retentionDaysFlag) + acl := flags.FlagToStringSliceValue(p, cmd, aclFlag) description := flags.FlagToStringPointer(p, cmd, descriptionFlag) if displayName == nil && retentionDays == nil && acl == nil && description == nil { @@ -142,7 +142,8 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *logs.APIClient) logs.ApiUpdateLogsInstanceRequest { - req := apiClient.UpdateLogsInstance(ctx, model.ProjectId, model.Region, model.InstanceID) + req := apiClient.DefaultAPI.UpdateLogsInstance(ctx, model.ProjectId, model.Region, model.InstanceID) + req = req.UpdateLogsInstancePayload(logs.UpdateLogsInstancePayload{ DisplayName: model.DisplayName, Acl: model.ACL, @@ -159,7 +160,7 @@ func outputResult(p *print.Printer, model *inputModel, projectLabel string, inst return fmt.Errorf("input model is nil") } return p.OutputResult(model.OutputFormat, instance, func() error { - p.Outputf("Updated instance %q for project %q.\n", utils.PtrString(instance.DisplayName), projectLabel) + p.Outputf("Updated instance %q for project %q.\n", instance.DisplayName, projectLabel) return nil }) } diff --git a/internal/cmd/logs/instance/update/update_test.go b/internal/cmd/logs/instance/update/update_test.go index 385fe554d..c79ca18d3 100644 --- a/internal/cmd/logs/instance/update/update_test.go +++ b/internal/cmd/logs/instance/update/update_test.go @@ -4,7 +4,7 @@ import ( "context" "testing" - "github.com/stackitcloud/stackit-sdk-go/services/logs" + logs "github.com/stackitcloud/stackit-sdk-go/services/logs/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" "github.com/stackitcloud/stackit-cli/internal/pkg/testutils" @@ -26,7 +26,7 @@ const ( var ( testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") - testClient = &logs.APIClient{} + testClient = &logs.APIClient{DefaultAPI: &logs.DefaultAPIService{}} testProjectId = uuid.NewString() testInstanceId = uuid.NewString() ) @@ -65,8 +65,8 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { }, InstanceID: testInstanceId, DisplayName: utils.Ptr("name"), - ACL: utils.Ptr([]string{"0.0.0.0/0"}), - RetentionDays: utils.Ptr(int64(60)), + ACL: []string{"0.0.0.0/0"}, + RetentionDays: utils.Ptr(int32(60)), Description: utils.Ptr("Example"), } for _, mod := range mods { @@ -76,11 +76,11 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *logs.ApiUpdateLogsInstanceRequest)) logs.ApiUpdateLogsInstanceRequest { - request := testClient.UpdateLogsInstance(testCtx, testProjectId, testRegion, testInstanceId) + request := testClient.DefaultAPI.UpdateLogsInstance(testCtx, testProjectId, testRegion, testInstanceId) request = request.UpdateLogsInstancePayload(logs.UpdateLogsInstancePayload{ DisplayName: utils.Ptr("name"), - Acl: utils.Ptr([]string{"0.0.0.0/0"}), - RetentionDays: utils.Ptr(int64(60)), + Acl: []string{"0.0.0.0/0"}, + RetentionDays: utils.Ptr(int32(60)), Description: utils.Ptr("Example"), }) for _, mod := range mods { @@ -159,8 +159,8 @@ func TestParseInput(t *testing.T) { }, InstanceID: testInstanceId, DisplayName: utils.Ptr("display-name"), - ACL: utils.Ptr([]string{"0.0.0.0/24"}), - RetentionDays: utils.Ptr(int64(60)), + ACL: []string{"0.0.0.0/24"}, + RetentionDays: utils.Ptr(int32(60)), Description: utils.Ptr("description"), }, }, @@ -230,7 +230,7 @@ func TestBuildRequest(t *testing.T) { }, InstanceID: testInstanceId, }, - expectedRequest: testClient.UpdateLogsInstance(testCtx, testProjectId, testRegion, testInstanceId). + expectedRequest: testClient.DefaultAPI.UpdateLogsInstance(testCtx, testProjectId, testRegion, testInstanceId). UpdateLogsInstancePayload(logs.UpdateLogsInstancePayload{}), }, } @@ -241,7 +241,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, logs.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/pkg/services/logs/client/client.go b/internal/pkg/services/logs/client/client.go index a5297b31a..fa8abe391 100644 --- a/internal/pkg/services/logs/client/client.go +++ b/internal/pkg/services/logs/client/client.go @@ -1,7 +1,7 @@ package client import ( - "github.com/stackitcloud/stackit-sdk-go/services/logs" + logs "github.com/stackitcloud/stackit-sdk-go/services/logs/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/config" genericclient "github.com/stackitcloud/stackit-cli/internal/pkg/generic-client" @@ -11,5 +11,5 @@ import ( ) func ConfigureClient(p *print.Printer, cliVersion string) (*logs.APIClient, error) { - return genericclient.ConfigureClientGeneric(p, cliVersion, viper.GetString(config.LogsCustomEndpointKey), false, genericclient.CreateApiClient[*logs.APIClient](logs.NewAPIClient)) + return genericclient.ConfigureClientGeneric(p, cliVersion, viper.GetString(config.LogsCustomEndpointKey), false, logs.NewAPIClient) } diff --git a/internal/pkg/services/logs/utils/utils.go b/internal/pkg/services/logs/utils/utils.go index d67272254..16186d618 100644 --- a/internal/pkg/services/logs/utils/utils.go +++ b/internal/pkg/services/logs/utils/utils.go @@ -5,39 +5,29 @@ import ( "errors" "fmt" - "github.com/stackitcloud/stackit-sdk-go/services/logs" + logs "github.com/stackitcloud/stackit-sdk-go/services/logs/v1api" ) var ( ErrResponseNil = errors.New("response is nil") - ErrNameNil = errors.New("display name is nil") ) -type LogsClient interface { - GetLogsInstanceExecute(ctx context.Context, projectId, regionId, instanceId string) (*logs.LogsInstance, error) - GetAccessTokenExecute(ctx context.Context, projectId string, regionId string, instanceId string, tId string) (*logs.AccessToken, error) -} - -func GetInstanceName(ctx context.Context, apiClient LogsClient, projectId, regionId, instanceId string) (string, error) { - resp, err := apiClient.GetLogsInstanceExecute(ctx, projectId, regionId, instanceId) +func GetInstanceName(ctx context.Context, apiClient logs.DefaultAPI, projectId, regionId, instanceId string) (string, error) { + resp, err := apiClient.GetLogsInstance(ctx, projectId, regionId, instanceId).Execute() if err != nil { return "", fmt.Errorf("get Logs instance: %w", err) } else if resp == nil { return "", ErrResponseNil - } else if resp.DisplayName == nil { - return "", ErrNameNil } - return *resp.DisplayName, nil + return resp.DisplayName, nil } -func GetAccessTokenName(ctx context.Context, apiClient LogsClient, projectId, regionId, instanceId, accessTokenId string) (string, error) { - resp, err := apiClient.GetAccessTokenExecute(ctx, projectId, regionId, instanceId, accessTokenId) +func GetAccessTokenName(ctx context.Context, apiClient logs.DefaultAPI, projectId, regionId, instanceId, accessTokenId string) (string, error) { + resp, err := apiClient.GetAccessToken(ctx, projectId, regionId, instanceId, accessTokenId).Execute() if err != nil { return "", fmt.Errorf("get Logs access token: %w", err) } else if resp == nil { return "", ErrResponseNil - } else if resp.DisplayName == nil { - return "", ErrNameNil } - return *resp.DisplayName, nil + return resp.DisplayName, nil } diff --git a/internal/pkg/services/logs/utils/utils_test.go b/internal/pkg/services/logs/utils/utils_test.go index 0f780c1d6..f2c98d12c 100644 --- a/internal/pkg/services/logs/utils/utils_test.go +++ b/internal/pkg/services/logs/utils/utils_test.go @@ -5,7 +5,7 @@ import ( "fmt" "testing" - "github.com/stackitcloud/stackit-sdk-go/services/logs" + logs "github.com/stackitcloud/stackit-sdk-go/services/logs/v1api" "github.com/stackitcloud/stackit-cli/internal/pkg/utils" @@ -23,25 +23,28 @@ const ( testRegion = "eu01" ) -type logsClientMocked struct { +type mockSettings struct { getInstanceFails bool getInstanceResp *logs.LogsInstance getAccessTokenFails bool getAccessTokenResp *logs.AccessToken } -func (m *logsClientMocked) GetLogsInstanceExecute(_ context.Context, _, _, _ string) (*logs.LogsInstance, error) { - if m.getInstanceFails { - return nil, fmt.Errorf("could not get instance") - } - return m.getInstanceResp, nil -} - -func (m *logsClientMocked) GetAccessTokenExecute(_ context.Context, _, _, _, _ string) (*logs.AccessToken, error) { - if m.getAccessTokenFails { - return nil, fmt.Errorf("could not get access token") +func newAPIMock(s mockSettings) logs.DefaultAPI { + return &logs.DefaultAPIServiceMock{ + GetLogsInstanceExecuteMock: utils.Ptr(func(_ logs.ApiGetLogsInstanceRequest) (*logs.LogsInstance, error) { + if s.getInstanceFails { + return nil, fmt.Errorf("could not get instance") + } + return s.getInstanceResp, nil + }), + GetAccessTokenExecuteMock: utils.Ptr(func(_ logs.ApiGetAccessTokenRequest) (*logs.AccessToken, error) { + if s.getAccessTokenFails { + return nil, fmt.Errorf("could not get access token") + } + return s.getAccessTokenResp, nil + }), } - return m.getAccessTokenResp, nil } func TestGetInstanceName(t *testing.T) { @@ -55,7 +58,7 @@ func TestGetInstanceName(t *testing.T) { { description: "base", getInstanceResp: &logs.LogsInstance{ - DisplayName: utils.Ptr(testInstanceName), + DisplayName: testInstanceName, }, isValid: true, expectedOutput: testInstanceName, @@ -71,24 +74,16 @@ func TestGetInstanceName(t *testing.T) { getInstanceResp: nil, isValid: false, }, - { - description: "name in response is nil", - getInstanceFails: false, - getInstanceResp: &logs.LogsInstance{ - DisplayName: nil, - }, - isValid: false, - }, } for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { - client := &logsClientMocked{ + settings := mockSettings{ getInstanceFails: tt.getInstanceFails, getInstanceResp: tt.getInstanceResp, } - output, err := GetInstanceName(context.Background(), client, testProjectId, testRegion, testInstanceId) + output, err := GetInstanceName(context.Background(), newAPIMock(settings), testProjectId, testRegion, testInstanceId) if tt.isValid && err != nil { t.Errorf("failed on valid input") @@ -117,7 +112,7 @@ func TestGetAccessTokenName(t *testing.T) { { description: "base", getAccessTokenResp: &logs.AccessToken{ - DisplayName: utils.Ptr(testInstanceName), + DisplayName: testInstanceName, }, isValid: true, expectedOutput: testInstanceName, @@ -133,24 +128,16 @@ func TestGetAccessTokenName(t *testing.T) { getAccessTokenResp: nil, isValid: false, }, - { - description: "name in response is nil", - getAccessTokenFails: false, - getAccessTokenResp: &logs.AccessToken{ - DisplayName: nil, - }, - isValid: false, - }, } for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { - client := &logsClientMocked{ + settings := mockSettings{ getAccessTokenFails: tt.getAccessTokenFails, getAccessTokenResp: tt.getAccessTokenResp, } - output, err := GetAccessTokenName(context.Background(), client, testProjectId, testRegion, testInstanceId, testAccessTokenId) + output, err := GetAccessTokenName(context.Background(), newAPIMock(settings), testProjectId, testRegion, testInstanceId, testAccessTokenId) if tt.isValid && err != nil { t.Errorf("failed on valid input") diff --git a/internal/pkg/utils/utils.go b/internal/pkg/utils/utils.go index 1326ec122..f216efe1c 100644 --- a/internal/pkg/utils/utils.go +++ b/internal/pkg/utils/utils.go @@ -197,3 +197,12 @@ func FormatPossibleValues(values ...string) []string { } return formattedValues } + +// Map applies mapFn to each element in input and collects the results in a new slice +func Map[T, U any](input []T, mapFn func(T) U) []U { + values := make([]U, len(input)) + for i := range input { + values[i] = mapFn(input[i]) + } + return values +} diff --git a/internal/pkg/utils/utils_test.go b/internal/pkg/utils/utils_test.go index 1fdd5844d..b627c9321 100644 --- a/internal/pkg/utils/utils_test.go +++ b/internal/pkg/utils/utils_test.go @@ -363,3 +363,40 @@ func TestGetSliceFromPointer(t *testing.T) { }) } } + +func TestMap(t *testing.T) { + type args[T any, U any] struct { + input []T + mapFn func(T) U + } + type testCase[T any, U any] struct { + name string + args args[T, U] + want []U + } + tests := []testCase[string, *string]{ + { + name: "default", + args: args[string, *string]{ + input: []string{"foo", "bar"}, + mapFn: Ptr[string], + }, + want: []*string{Ptr("foo"), Ptr("bar")}, + }, + { + name: "input slice is nil", + args: args[string, *string]{ + input: nil, + mapFn: Ptr[string], + }, + want: []*string{}, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := Map(tt.args.input, tt.args.mapFn); !reflect.DeepEqual(got, tt.want) { + t.Errorf("Map() = %v, want %v", got, tt.want) + } + }) + } +} From b7b504cc5ac533e1fc1704cfaeb364ba7ee1c115 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ruben=20H=C3=B6nle?= Date: Wed, 22 Jul 2026 13:44:57 +0200 Subject: [PATCH 42/44] chore(serverbackup): switch to new sdk structure (#1485) relates to STACKITCLI-354 --- docs/stackit_server_backup_create.md | 10 +- docs/stackit_server_backup_schedule_create.md | 16 +- docs/stackit_server_backup_schedule_update.md | 16 +- go.mod | 2 +- go.sum | 4 +- internal/cmd/server/backup/create/create.go | 23 ++- .../cmd/server/backup/create/create_test.go | 25 ++- internal/cmd/server/backup/delete/delete.go | 4 +- .../cmd/server/backup/delete/delete_test.go | 8 +- .../cmd/server/backup/describe/describe.go | 24 +-- .../server/backup/describe/describe_test.go | 27 ++- internal/cmd/server/backup/disable/disable.go | 6 +- .../cmd/server/backup/disable/disable_test.go | 8 +- internal/cmd/server/backup/enable/enable.go | 4 +- .../cmd/server/backup/enable/enable_test.go | 8 +- internal/cmd/server/backup/list/list.go | 25 ++- internal/cmd/server/backup/list/list_test.go | 8 +- internal/cmd/server/backup/restore/restore.go | 8 +- .../cmd/server/backup/restore/restore_test.go | 11 +- .../server/backup/schedule/create/create.go | 29 ++-- .../backup/schedule/create/create_test.go | 31 ++-- .../server/backup/schedule/delete/delete.go | 4 +- .../backup/schedule/delete/delete_test.go | 8 +- .../backup/schedule/describe/describe.go | 18 +- .../backup/schedule/describe/describe_test.go | 10 +- .../cmd/server/backup/schedule/list/list.go | 18 +- .../server/backup/schedule/list/list_test.go | 8 +- .../server/backup/schedule/update/update.go | 31 ++-- .../backup/schedule/update/update_test.go | 44 +++-- .../backup/volume-backup/delete/delete.go | 4 +- .../volume-backup/delete/delete_test.go | 8 +- .../backup/volume-backup/restore/restore.go | 6 +- .../volume-backup/restore/restore_test.go | 10 +- .../services/serverbackup/client/client.go | 4 +- .../pkg/services/serverbackup/utils/utils.go | 17 +- .../services/serverbackup/utils/utils_test.go | 160 +++++++++--------- 36 files changed, 327 insertions(+), 320 deletions(-) diff --git a/docs/stackit_server_backup_create.md b/docs/stackit_server_backup_create.md index 956ac525e..7adfa52d1 100644 --- a/docs/stackit_server_backup_create.md +++ b/docs/stackit_server_backup_create.md @@ -23,11 +23,11 @@ stackit server backup create [flags] ### Options ``` - -h, --help Help for "stackit server backup create" - -b, --name string Backup name - -d, --retention-period int Backup retention period (in days) (default 14) - -s, --server-id string Server ID - -i, --volume-ids strings Backup volume IDs, as comma separated UUID values. (default []) + -h, --help Help for "stackit server backup create" + -b, --name string Backup name + -d, --retention-period int32 Backup retention period (in days) (default 14) + -s, --server-id string Server ID + -i, --volume-ids strings Backup volume IDs, as comma separated UUID values. (default []) ``` ### Options inherited from parent commands diff --git a/docs/stackit_server_backup_schedule_create.md b/docs/stackit_server_backup_schedule_create.md index bdc31cb3e..dbda024be 100644 --- a/docs/stackit_server_backup_schedule_create.md +++ b/docs/stackit_server_backup_schedule_create.md @@ -23,14 +23,14 @@ stackit server backup schedule create [flags] ### Options ``` - -b, --backup-name string Backup name - -d, --backup-retention-period int Backup retention period (in days) (default 14) - -n, --backup-schedule-name string Backup schedule name - -i, --backup-volume-ids strings Backup volume IDs, as comma separated UUID values. (default []) - -e, --enabled Is the server backup schedule enabled (default true) - -h, --help Help for "stackit server backup schedule create" - -r, --rrule string Backup RRULE (recurrence rule) (default "DTSTART;TZID=Europe/Sofia:20200803T023000 RRULE:FREQ=DAILY;INTERVAL=1") - -s, --server-id string Server ID + -b, --backup-name string Backup name + -d, --backup-retention-period int32 Backup retention period (in days) (default 14) + -n, --backup-schedule-name string Backup schedule name + -i, --backup-volume-ids strings Backup volume IDs, as comma separated UUID values. (default []) + -e, --enabled Is the server backup schedule enabled (default true) + -h, --help Help for "stackit server backup schedule create" + -r, --rrule string Backup RRULE (recurrence rule) (default "DTSTART;TZID=Europe/Sofia:20200803T023000 RRULE:FREQ=DAILY;INTERVAL=1") + -s, --server-id string Server ID ``` ### Options inherited from parent commands diff --git a/docs/stackit_server_backup_schedule_update.md b/docs/stackit_server_backup_schedule_update.md index dbb735961..f6e5bc921 100644 --- a/docs/stackit_server_backup_schedule_update.md +++ b/docs/stackit_server_backup_schedule_update.md @@ -23,14 +23,14 @@ stackit server backup schedule update SCHEDULE_ID [flags] ### Options ``` - -b, --backup-name string Backup name - -d, --backup-retention-period int Backup retention period (in days) (default 14) - -n, --backup-schedule-name string Backup schedule name - -i, --backup-volume-ids strings Backup volume IDs, as comma separated UUID values. (default []) - -e, --enabled Is the server backup schedule enabled (default true) - -h, --help Help for "stackit server backup schedule update" - -r, --rrule string Backup RRULE (recurrence rule) (default "DTSTART;TZID=Europe/Sofia:20200803T023000 RRULE:FREQ=DAILY;INTERVAL=1") - -s, --server-id string Server ID + -b, --backup-name string Backup name + -d, --backup-retention-period int32 Backup retention period (in days) (default 14) + -n, --backup-schedule-name string Backup schedule name + -i, --backup-volume-ids strings Backup volume IDs, as comma separated UUID values. (default []) + -e, --enabled Is the server backup schedule enabled (default true) + -h, --help Help for "stackit server backup schedule update" + -r, --rrule string Backup RRULE (recurrence rule) (default "DTSTART;TZID=Europe/Sofia:20200803T023000 RRULE:FREQ=DAILY;INTERVAL=1") + -s, --server-id string Server ID ``` ### Options inherited from parent commands diff --git a/go.mod b/go.mod index 8908bb9c5..1e5f5d164 100644 --- a/go.mod +++ b/go.mod @@ -31,7 +31,7 @@ require ( github.com/stackitcloud/stackit-sdk-go/services/resourcemanager v0.24.0 github.com/stackitcloud/stackit-sdk-go/services/runcommand v1.8.0 github.com/stackitcloud/stackit-sdk-go/services/secretsmanager v0.18.1 - github.com/stackitcloud/stackit-sdk-go/services/serverbackup v1.3.8 + github.com/stackitcloud/stackit-sdk-go/services/serverbackup v1.7.0 github.com/stackitcloud/stackit-sdk-go/services/serverupdate v1.5.2 github.com/stackitcloud/stackit-sdk-go/services/serviceaccount v0.12.0 github.com/stackitcloud/stackit-sdk-go/services/serviceenablement v1.7.0 diff --git a/go.sum b/go.sum index 9b23bdb34..6505f944d 100644 --- a/go.sum +++ b/go.sum @@ -638,8 +638,8 @@ github.com/stackitcloud/stackit-sdk-go/services/runcommand v1.8.0 h1:T5gy5i+Nxrp github.com/stackitcloud/stackit-sdk-go/services/runcommand v1.8.0/go.mod h1:iB27HtF0UcAugURc9w+nlNrtbAj7Mukw/ptAz+7p2WE= github.com/stackitcloud/stackit-sdk-go/services/secretsmanager v0.18.1 h1:U5rstX5e6Am2t+Ukv5K1Sbftzxt5aFALMa9YS4jCJoo= github.com/stackitcloud/stackit-sdk-go/services/secretsmanager v0.18.1/go.mod h1:2XA8PE05Qg6BL2YXO4XgfGI9qskJ3cicLE5Qq0aqDdY= -github.com/stackitcloud/stackit-sdk-go/services/serverbackup v1.3.8 h1:LLyANBzE8sQa0/49tQBqq4sVLhNgwdqCeQm76srJHWw= -github.com/stackitcloud/stackit-sdk-go/services/serverbackup v1.3.8/go.mod h1:/bmg57XZu+bGczzcoumrukiGMPGzI2mOyTT4BVIQUBs= +github.com/stackitcloud/stackit-sdk-go/services/serverbackup v1.7.0 h1:U3bm+RVHD1USpB6Fk9WNfPQxK0x0DY7ubusmRSh/A/8= +github.com/stackitcloud/stackit-sdk-go/services/serverbackup v1.7.0/go.mod h1:BJeafbecuocdirGCAJ2Vz/rPSK/LRrB5lPBEacqd1eU= github.com/stackitcloud/stackit-sdk-go/services/serverupdate v1.5.2 h1:6C/iTPoYPCrZOc3JMmvyDNs4hm+JR5p9O3DIfFGgnbo= github.com/stackitcloud/stackit-sdk-go/services/serverupdate v1.5.2/go.mod h1:/OHYZXQb9KXDdZK5J9C2YS6DJUD2i6ednZ1rK7zpDZ0= github.com/stackitcloud/stackit-sdk-go/services/serviceaccount v0.12.0 h1:l1EDIlXce2C8JcbBDHVa6nZ4SjPTqmnALTgrhms+NKI= diff --git a/internal/cmd/server/backup/create/create.go b/internal/cmd/server/backup/create/create.go index 98318ae47..cd968652a 100644 --- a/internal/cmd/server/backup/create/create.go +++ b/internal/cmd/server/backup/create/create.go @@ -8,6 +8,9 @@ import ( iaasClient "github.com/stackitcloud/stackit-cli/internal/pkg/services/iaas/client" + "github.com/spf13/cobra" + serverbackup "github.com/stackitcloud/stackit-sdk-go/services/serverbackup/v2api" + "github.com/stackitcloud/stackit-cli/internal/pkg/args" cliErr "github.com/stackitcloud/stackit-cli/internal/pkg/errors" "github.com/stackitcloud/stackit-cli/internal/pkg/examples" @@ -16,10 +19,6 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/print" iaasUtils "github.com/stackitcloud/stackit-cli/internal/pkg/services/iaas/utils" "github.com/stackitcloud/stackit-cli/internal/pkg/services/serverbackup/client" - "github.com/stackitcloud/stackit-cli/internal/pkg/utils" - - "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/serverbackup" ) const ( @@ -36,7 +35,7 @@ type inputModel struct { ServerId string BackupName string - BackupRetentionPeriod int64 + BackupRetentionPeriod int32 BackupVolumeIds []string } @@ -105,7 +104,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { func configureFlags(cmd *cobra.Command) { cmd.Flags().VarP(flags.UUIDFlag(), serverIdFlag, "s", "Server ID") cmd.Flags().StringP(backupNameFlag, "b", "", "Backup name") - cmd.Flags().Int64P(backupRetentionPeriodFlag, "d", defaultRetentionPeriod, "Backup retention period (in days)") + cmd.Flags().Int32P(backupRetentionPeriodFlag, "d", defaultRetentionPeriod, "Backup retention period (in days)") cmd.Flags().VarP(flags.UUIDSliceFlag(), backupVolumeIdsFlag, "i", "Backup volume IDs, as comma separated UUID values.") err := flags.MarkFlagsRequired(cmd, serverIdFlag, backupNameFlag) @@ -121,7 +120,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, model := inputModel{ GlobalFlagModel: globalFlags, ServerId: flags.FlagToStringValue(p, cmd, serverIdFlag), - BackupRetentionPeriod: flags.FlagWithDefaultToInt64Value(p, cmd, backupRetentionPeriodFlag), + BackupRetentionPeriod: flags.FlagWithDefaultToInt32Value(p, cmd, backupRetentionPeriodFlag), BackupName: flags.FlagToStringValue(p, cmd, backupNameFlag), BackupVolumeIds: flags.FlagToStringSliceValue(p, cmd, backupVolumeIdsFlag), } @@ -131,11 +130,11 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, } func buildRequest(ctx context.Context, model *inputModel, apiClient *serverbackup.APIClient) (serverbackup.ApiCreateBackupRequest, error) { - req := apiClient.CreateBackup(ctx, model.ProjectId, model.ServerId, model.Region) + req := apiClient.DefaultAPI.CreateBackup(ctx, model.ProjectId, model.ServerId, model.Region) payload := serverbackup.CreateBackupPayload{ - Name: &model.BackupName, - RetentionPeriod: &model.BackupRetentionPeriod, - VolumeIds: &model.BackupVolumeIds, + Name: model.BackupName, + RetentionPeriod: model.BackupRetentionPeriod, + VolumeIds: model.BackupVolumeIds, } if model.BackupVolumeIds == nil { payload.VolumeIds = nil @@ -146,7 +145,7 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient *serverbacku func outputResult(p *print.Printer, outputFormat, serverLabel string, resp serverbackup.BackupJob) error { return p.OutputResult(outputFormat, resp, func() error { - p.Outputf("Triggered creation of server backup for server %s. Backup ID: %s\n", serverLabel, utils.PtrString(resp.Id)) + p.Outputf("Triggered creation of server backup for server %s. Backup ID: %s\n", serverLabel, resp.Id) return nil }) } diff --git a/internal/cmd/server/backup/create/create_test.go b/internal/cmd/server/backup/create/create_test.go index 83d0a9331..fdb363870 100644 --- a/internal/cmd/server/backup/create/create_test.go +++ b/internal/cmd/server/backup/create/create_test.go @@ -4,21 +4,20 @@ import ( "context" "testing" - "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" - "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" - "github.com/stackitcloud/stackit-cli/internal/pkg/testutils" - "github.com/stackitcloud/stackit-cli/internal/pkg/utils" - "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/serverbackup" + serverbackup "github.com/stackitcloud/stackit-sdk-go/services/serverbackup/v2api" + + "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" + "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" + "github.com/stackitcloud/stackit-cli/internal/pkg/testutils" ) type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &serverbackup.APIClient{} +var testClient = &serverbackup.APIClient{DefaultAPI: &serverbackup.DefaultAPIService{}} var testProjectId = uuid.NewString() var testServerId = uuid.NewString() @@ -49,7 +48,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { }, ServerId: testServerId, BackupName: "example-backup-name", - BackupRetentionPeriod: int64(14), + BackupRetentionPeriod: int32(14), BackupVolumeIds: []string{testBackupVolumeId}, } for _, mod := range mods { @@ -59,7 +58,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *serverbackup.ApiCreateBackupRequest)) serverbackup.ApiCreateBackupRequest { - request := testClient.CreateBackup(testCtx, testProjectId, testServerId, testRegion) + request := testClient.DefaultAPI.CreateBackup(testCtx, testProjectId, testServerId, testRegion) request = request.CreateBackupPayload(fixturePayload()) for _, mod := range mods { mod(&request) @@ -69,9 +68,9 @@ func fixtureRequest(mods ...func(request *serverbackup.ApiCreateBackupRequest)) func fixturePayload(mods ...func(payload *serverbackup.CreateBackupPayload)) serverbackup.CreateBackupPayload { payload := serverbackup.CreateBackupPayload{ - Name: utils.Ptr("example-backup-name"), - RetentionPeriod: utils.Ptr(int64(14)), - VolumeIds: utils.Ptr([]string{testBackupVolumeId}), + Name: "example-backup-name", + RetentionPeriod: int32(14), + VolumeIds: []string{testBackupVolumeId}, } for _, mod := range mods { mod(&payload) @@ -164,7 +163,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, serverbackup.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/server/backup/delete/delete.go b/internal/cmd/server/backup/delete/delete.go index 5eedcde2d..ddca7091a 100644 --- a/internal/cmd/server/backup/delete/delete.go +++ b/internal/cmd/server/backup/delete/delete.go @@ -16,7 +16,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/serverbackup" + serverbackup "github.com/stackitcloud/stackit-sdk-go/services/serverbackup/v2api" ) const ( @@ -101,6 +101,6 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *serverbackup.APIClient) serverbackup.ApiDeleteBackupRequest { - req := apiClient.DeleteBackup(ctx, model.ProjectId, model.ServerId, model.Region, model.BackupId) + req := apiClient.DefaultAPI.DeleteBackup(ctx, model.ProjectId, model.ServerId, model.Region, model.BackupId) return req } diff --git a/internal/cmd/server/backup/delete/delete_test.go b/internal/cmd/server/backup/delete/delete_test.go index 1b90f5c00..9e8a8796e 100644 --- a/internal/cmd/server/backup/delete/delete_test.go +++ b/internal/cmd/server/backup/delete/delete_test.go @@ -10,13 +10,13 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/serverbackup" + serverbackup "github.com/stackitcloud/stackit-sdk-go/services/serverbackup/v2api" ) type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &serverbackup.APIClient{} +var testClient = &serverbackup.APIClient{DefaultAPI: &serverbackup.DefaultAPIService{}} var testProjectId = uuid.NewString() var testServerId = uuid.NewString() var testBackupId = uuid.NewString() @@ -61,7 +61,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *serverbackup.ApiDeleteBackupRequest)) serverbackup.ApiDeleteBackupRequest { - request := testClient.DeleteBackup(testCtx, testProjectId, testServerId, testRegion, testBackupId) + request := testClient.DefaultAPI.DeleteBackup(testCtx, testProjectId, testServerId, testRegion, testBackupId) for _, mod := range mods { mod(&request) } @@ -153,7 +153,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, serverbackup.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/server/backup/describe/describe.go b/internal/cmd/server/backup/describe/describe.go index b303028c3..4d95882ca 100644 --- a/internal/cmd/server/backup/describe/describe.go +++ b/internal/cmd/server/backup/describe/describe.go @@ -18,7 +18,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/serverbackup" + serverbackup "github.com/stackitcloud/stackit-sdk-go/services/serverbackup/v2api" ) const ( @@ -65,7 +65,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return fmt.Errorf("read server backup: %w", err) } - return outputResult(params.Printer, model.OutputFormat, *resp) + return outputResult(params.Printer, model.OutputFormat, resp) }, } configureFlags(cmd) @@ -98,24 +98,28 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *serverbackup.APIClient) serverbackup.ApiGetBackupRequest { - req := apiClient.GetBackup(ctx, model.ProjectId, model.ServerId, model.Region, model.BackupId) + req := apiClient.DefaultAPI.GetBackup(ctx, model.ProjectId, model.ServerId, model.Region, model.BackupId) return req } -func outputResult(p *print.Printer, outputFormat string, backup serverbackup.Backup) error { +func outputResult(p *print.Printer, outputFormat string, backup *serverbackup.Backup) error { return p.OutputResult(outputFormat, backup, func() error { + if backup == nil { + return fmt.Errorf("backup is nil") + } + table := tables.NewTable() - table.AddRow("ID", utils.PtrString(backup.Id)) + table.AddRow("ID", backup.Id) table.AddSeparator() - table.AddRow("NAME", utils.PtrString(backup.Name)) + table.AddRow("NAME", backup.Name) table.AddSeparator() table.AddRow("SIZE (GB)", utils.PtrString(backup.Size)) table.AddSeparator() - table.AddRow("STATUS", utils.PtrString(backup.Status)) + table.AddRow("STATUS", backup.Status) table.AddSeparator() - table.AddRow("CREATED AT", utils.PtrString(backup.CreatedAt)) + table.AddRow("CREATED AT", backup.CreatedAt) table.AddSeparator() - table.AddRow("EXPIRES AT", utils.PtrString(backup.ExpireAt)) + table.AddRow("EXPIRES AT", backup.ExpireAt) table.AddSeparator() lastRestored := utils.PtrStringDefault(backup.LastRestoredAt, "") @@ -123,7 +127,7 @@ func outputResult(p *print.Printer, outputFormat string, backup serverbackup.Bac table.AddSeparator() volBackups := "" if backups := backup.VolumeBackups; backups != nil { - volBackups = strconv.Itoa(len(*backups)) + volBackups = strconv.Itoa(len(backups)) } table.AddRow("VOLUME BACKUPS", volBackups) table.AddSeparator() diff --git a/internal/cmd/server/backup/describe/describe_test.go b/internal/cmd/server/backup/describe/describe_test.go index 67fad079a..c22cbbae2 100644 --- a/internal/cmd/server/backup/describe/describe_test.go +++ b/internal/cmd/server/backup/describe/describe_test.go @@ -12,13 +12,13 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/serverbackup" + serverbackup "github.com/stackitcloud/stackit-sdk-go/services/serverbackup/v2api" ) type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &serverbackup.APIClient{} +var testClient = &serverbackup.APIClient{DefaultAPI: &serverbackup.DefaultAPIService{}} var testProjectId = uuid.NewString() var testServerId = uuid.NewString() var testBackupId = uuid.NewString() @@ -63,7 +63,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *serverbackup.ApiGetBackupRequest)) serverbackup.ApiGetBackupRequest { - request := testClient.GetBackup(testCtx, testProjectId, testServerId, testRegion, testBackupId) + request := testClient.DefaultAPI.GetBackup(testCtx, testProjectId, testServerId, testRegion, testBackupId) for _, mod := range mods { mod(&request) } @@ -157,7 +157,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, serverbackup.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) @@ -169,7 +169,7 @@ func TestBuildRequest(t *testing.T) { func TestOutputResult(t *testing.T) { type args struct { outputFormat string - backup serverbackup.Backup + backup *serverbackup.Backup } tests := []struct { name string @@ -177,15 +177,26 @@ func TestOutputResult(t *testing.T) { wantErr bool }{ { - name: "empty", - args: args{}, + name: "backup is nil", + args: args{ + outputFormat: print.PrettyOutputFormat, + backup: nil, + }, + wantErr: true, + }, + { + name: "empty", + args: args{ + outputFormat: print.PrettyOutputFormat, + backup: &serverbackup.Backup{}, + }, wantErr: false, }, { name: "output format json", args: args{ outputFormat: print.JSONOutputFormat, - backup: serverbackup.Backup{}, + backup: &serverbackup.Backup{}, }, wantErr: false, }, diff --git a/internal/cmd/server/backup/disable/disable.go b/internal/cmd/server/backup/disable/disable.go index 83ffbc08c..a0cc59306 100644 --- a/internal/cmd/server/backup/disable/disable.go +++ b/internal/cmd/server/backup/disable/disable.go @@ -18,7 +18,7 @@ import ( serverbackupUtils "github.com/stackitcloud/stackit-cli/internal/pkg/services/serverbackup/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/serverbackup" + serverbackup "github.com/stackitcloud/stackit-sdk-go/services/serverbackup/v2api" ) const ( @@ -65,7 +65,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { } } - canDisable, err := serverbackupUtils.CanDisableBackupService(ctx, apiClient, model.ProjectId, model.ServerId, model.Region) + canDisable, err := serverbackupUtils.CanDisableBackupService(ctx, apiClient.DefaultAPI, model.ProjectId, model.ServerId, model.Region) if err != nil { return err } @@ -118,6 +118,6 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, } func buildRequest(ctx context.Context, model *inputModel, apiClient *serverbackup.APIClient) serverbackup.ApiDisableServiceResourceRequest { - req := apiClient.DisableServiceResource(ctx, model.ProjectId, model.ServerId, model.Region) + req := apiClient.DefaultAPI.DisableServiceResource(ctx, model.ProjectId, model.ServerId, model.Region) return req } diff --git a/internal/cmd/server/backup/disable/disable_test.go b/internal/cmd/server/backup/disable/disable_test.go index 9e74ae6ee..fb6d540f7 100644 --- a/internal/cmd/server/backup/disable/disable_test.go +++ b/internal/cmd/server/backup/disable/disable_test.go @@ -10,13 +10,13 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/serverbackup" + serverbackup "github.com/stackitcloud/stackit-sdk-go/services/serverbackup/v2api" ) type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &serverbackup.APIClient{} +var testClient = &serverbackup.APIClient{DefaultAPI: &serverbackup.DefaultAPIService{}} var testProjectId = uuid.NewString() var testServerId = uuid.NewString() var testRegion = "eu01" @@ -49,7 +49,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *serverbackup.ApiDisableServiceResourceRequest)) serverbackup.ApiDisableServiceResourceRequest { - request := testClient.DisableServiceResource(testCtx, testProjectId, testServerId, testRegion) + request := testClient.DefaultAPI.DisableServiceResource(testCtx, testProjectId, testServerId, testRegion) for _, mod := range mods { mod(&request) } @@ -131,7 +131,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, serverbackup.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/server/backup/enable/enable.go b/internal/cmd/server/backup/enable/enable.go index b2f51fc87..ca0c162a8 100644 --- a/internal/cmd/server/backup/enable/enable.go +++ b/internal/cmd/server/backup/enable/enable.go @@ -18,7 +18,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/services/serverbackup/client" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/serverbackup" + serverbackup "github.com/stackitcloud/stackit-sdk-go/services/serverbackup/v2api" ) const ( @@ -112,6 +112,6 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, func buildRequest(ctx context.Context, model *inputModel, apiClient *serverbackup.APIClient) serverbackup.ApiEnableServiceResourceRequest { payload := serverbackup.EnableServiceResourcePayload{} - req := apiClient.EnableServiceResource(ctx, model.ProjectId, model.ServerId, model.Region).EnableServiceResourcePayload(payload) + req := apiClient.DefaultAPI.EnableServiceResource(ctx, model.ProjectId, model.ServerId, model.Region).EnableServiceResourcePayload(payload) return req } diff --git a/internal/cmd/server/backup/enable/enable_test.go b/internal/cmd/server/backup/enable/enable_test.go index b7035a762..dcfedf333 100644 --- a/internal/cmd/server/backup/enable/enable_test.go +++ b/internal/cmd/server/backup/enable/enable_test.go @@ -10,13 +10,13 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/serverbackup" + serverbackup "github.com/stackitcloud/stackit-sdk-go/services/serverbackup/v2api" ) type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &serverbackup.APIClient{} +var testClient = &serverbackup.APIClient{DefaultAPI: &serverbackup.DefaultAPIService{}} var testProjectId = uuid.NewString() var testServerId = uuid.NewString() var testRegion = "eu01" @@ -49,7 +49,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *serverbackup.ApiEnableServiceResourceRequest)) serverbackup.ApiEnableServiceResourceRequest { - request := testClient.EnableServiceResource(testCtx, testProjectId, testServerId, testRegion).EnableServiceResourcePayload(serverbackup.EnableServiceResourcePayload{}) + request := testClient.DefaultAPI.EnableServiceResource(testCtx, testProjectId, testServerId, testRegion).EnableServiceResourcePayload(serverbackup.EnableServiceResourcePayload{}) for _, mod := range mods { mod(&request) } @@ -131,7 +131,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, serverbackup.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/server/backup/list/list.go b/internal/cmd/server/backup/list/list.go index 23196666d..5d652a4d2 100644 --- a/internal/cmd/server/backup/list/list.go +++ b/internal/cmd/server/backup/list/list.go @@ -9,7 +9,7 @@ import ( iaasClient "github.com/stackitcloud/stackit-cli/internal/pkg/services/iaas/client" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/serverbackup" + serverbackup "github.com/stackitcloud/stackit-sdk-go/services/serverbackup/v2api" "github.com/stackitcloud/stackit-cli/internal/pkg/args" "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -124,7 +124,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, } func buildRequest(ctx context.Context, model *inputModel, apiClient *serverbackup.APIClient) serverbackup.ApiListBackupsRequest { - req := apiClient.ListBackups(ctx, model.ProjectId, model.ServerId, model.Region) + req := apiClient.DefaultAPI.ListBackups(ctx, model.ProjectId, model.ServerId, model.Region) return req } @@ -134,24 +134,23 @@ func outputResult(p *print.Printer, outputFormat, serverLabel string, backups [] p.Outputf("No backups found for server %s\n", serverLabel) return nil } + table := tables.NewTable() table.SetHeader("ID", "NAME", "SIZE (GB)", "STATUS", "CREATED AT", "EXPIRES AT", "LAST RESTORED AT", "VOLUME BACKUPS") - for i := range backups { - s := backups[i] - - lastRestored := utils.PtrStringDefault(s.LastRestoredAt, "") + for _, s := range backups { var volBackups int if s.VolumeBackups != nil { - volBackups = len(*s.VolumeBackups) + volBackups = len(s.VolumeBackups) } + table.AddRow( - utils.PtrString(s.Id), - utils.PtrString(s.Name), + s.Id, + s.Name, utils.PtrString(s.Size), - utils.PtrString(s.Status), - utils.PtrString(s.CreatedAt), - utils.PtrString(s.ExpireAt), - lastRestored, + s.Status, + s.CreatedAt, + s.ExpireAt, + utils.PtrString(s.LastRestoredAt), volBackups, ) } diff --git a/internal/cmd/server/backup/list/list_test.go b/internal/cmd/server/backup/list/list_test.go index 98558e2a5..a4fb74acc 100644 --- a/internal/cmd/server/backup/list/list_test.go +++ b/internal/cmd/server/backup/list/list_test.go @@ -12,13 +12,13 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/serverbackup" + serverbackup "github.com/stackitcloud/stackit-sdk-go/services/serverbackup/v2api" ) type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &serverbackup.APIClient{} +var testClient = &serverbackup.APIClient{DefaultAPI: &serverbackup.DefaultAPIService{}} var testProjectId = uuid.NewString() var testServerId = uuid.NewString() var testRegion = "eu01" @@ -53,7 +53,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *serverbackup.ApiListBackupsRequest)) serverbackup.ApiListBackupsRequest { - request := testClient.ListBackups(testCtx, testProjectId, testServerId, testRegion) + request := testClient.DefaultAPI.ListBackups(testCtx, testProjectId, testServerId, testRegion) for _, mod := range mods { mod(&request) } @@ -142,7 +142,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, serverbackup.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/server/backup/restore/restore.go b/internal/cmd/server/backup/restore/restore.go index b55b2b465..5ba47b57b 100644 --- a/internal/cmd/server/backup/restore/restore.go +++ b/internal/cmd/server/backup/restore/restore.go @@ -16,7 +16,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/serverbackup" + serverbackup "github.com/stackitcloud/stackit-sdk-go/services/serverbackup/v2api" ) const ( @@ -114,10 +114,10 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *serverbackup.APIClient) serverbackup.ApiRestoreBackupRequest { - req := apiClient.RestoreBackup(ctx, model.ProjectId, model.ServerId, model.Region, model.BackupId) + req := apiClient.DefaultAPI.RestoreBackup(ctx, model.ProjectId, model.ServerId, model.Region, model.BackupId) payload := serverbackup.RestoreBackupPayload{ - StartServerAfterRestore: &model.StartServerAfterRestore, - VolumeIds: &model.BackupVolumeIds, + StartServerAfterRestore: model.StartServerAfterRestore, + VolumeIds: model.BackupVolumeIds, } if model.BackupVolumeIds == nil { payload.VolumeIds = nil diff --git a/internal/cmd/server/backup/restore/restore_test.go b/internal/cmd/server/backup/restore/restore_test.go index 9f890f3c2..ceef0fe37 100644 --- a/internal/cmd/server/backup/restore/restore_test.go +++ b/internal/cmd/server/backup/restore/restore_test.go @@ -10,13 +10,13 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/serverbackup" + serverbackup "github.com/stackitcloud/stackit-sdk-go/services/serverbackup/v2api" ) type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &serverbackup.APIClient{} +var testClient = &serverbackup.APIClient{DefaultAPI: &serverbackup.DefaultAPIService{}} var testProjectId = uuid.NewString() var testServerId = uuid.NewString() var testBackupId = uuid.NewString() @@ -61,9 +61,8 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *serverbackup.ApiRestoreBackupRequest)) serverbackup.ApiRestoreBackupRequest { - request := testClient.RestoreBackup(testCtx, testProjectId, testServerId, testRegion, testBackupId) - startServerAfterRestore := false - request = request.RestoreBackupPayload(serverbackup.RestoreBackupPayload{StartServerAfterRestore: &startServerAfterRestore}) + request := testClient.DefaultAPI.RestoreBackup(testCtx, testProjectId, testServerId, testRegion, testBackupId) + request = request.RestoreBackupPayload(serverbackup.RestoreBackupPayload{StartServerAfterRestore: false}) for _, mod := range mods { mod(&request) } @@ -155,7 +154,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, serverbackup.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/server/backup/schedule/create/create.go b/internal/cmd/server/backup/schedule/create/create.go index 9ab3a6098..4e57d4862 100644 --- a/internal/cmd/server/backup/schedule/create/create.go +++ b/internal/cmd/server/backup/schedule/create/create.go @@ -8,6 +8,9 @@ import ( iaasClient "github.com/stackitcloud/stackit-cli/internal/pkg/services/iaas/client" + "github.com/spf13/cobra" + serverbackup "github.com/stackitcloud/stackit-sdk-go/services/serverbackup/v2api" + "github.com/stackitcloud/stackit-cli/internal/pkg/args" cliErr "github.com/stackitcloud/stackit-cli/internal/pkg/errors" "github.com/stackitcloud/stackit-cli/internal/pkg/examples" @@ -16,10 +19,6 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/print" iaasUtils "github.com/stackitcloud/stackit-cli/internal/pkg/services/iaas/utils" "github.com/stackitcloud/stackit-cli/internal/pkg/services/serverbackup/client" - "github.com/stackitcloud/stackit-cli/internal/pkg/utils" - - "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/serverbackup" ) const ( @@ -44,7 +43,7 @@ type inputModel struct { Enabled bool Rrule string BackupName string - BackupRetentionPeriod int64 + BackupRetentionPeriod int32 BackupVolumeIds []string } @@ -114,7 +113,7 @@ func configureFlags(cmd *cobra.Command) { cmd.Flags().VarP(flags.UUIDFlag(), serverIdFlag, "s", "Server ID") cmd.Flags().StringP(backupScheduleNameFlag, "n", "", "Backup schedule name") cmd.Flags().StringP(backupNameFlag, "b", "", "Backup name") - cmd.Flags().Int64P(backupRetentionPeriodFlag, "d", defaultRetentionPeriod, "Backup retention period (in days)") + cmd.Flags().Int32P(backupRetentionPeriodFlag, "d", defaultRetentionPeriod, "Backup retention period (in days)") cmd.Flags().BoolP(enabledFlag, "e", defaultEnabled, "Is the server backup schedule enabled") cmd.Flags().StringP(rruleFlag, "r", defaultRrule, "Backup RRULE (recurrence rule)") cmd.Flags().VarP(flags.UUIDSliceFlag(), backupVolumeIdsFlag, "i", "Backup volume IDs, as comma separated UUID values.") @@ -132,7 +131,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, model := inputModel{ GlobalFlagModel: globalFlags, ServerId: flags.FlagToStringValue(p, cmd, serverIdFlag), - BackupRetentionPeriod: flags.FlagWithDefaultToInt64Value(p, cmd, backupRetentionPeriodFlag), + BackupRetentionPeriod: flags.FlagWithDefaultToInt32Value(p, cmd, backupRetentionPeriodFlag), BackupScheduleName: flags.FlagToStringValue(p, cmd, backupScheduleNameFlag), BackupName: flags.FlagToStringValue(p, cmd, backupNameFlag), Rrule: flags.FlagWithDefaultToStringValue(p, cmd, rruleFlag), @@ -145,19 +144,19 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, } func buildRequest(ctx context.Context, model *inputModel, apiClient *serverbackup.APIClient) (serverbackup.ApiCreateBackupScheduleRequest, error) { - req := apiClient.CreateBackupSchedule(ctx, model.ProjectId, model.ServerId, model.Region) + req := apiClient.DefaultAPI.CreateBackupSchedule(ctx, model.ProjectId, model.ServerId, model.Region) backupProperties := serverbackup.BackupProperties{ - Name: &model.BackupName, - RetentionPeriod: &model.BackupRetentionPeriod, - VolumeIds: &model.BackupVolumeIds, + Name: model.BackupName, + RetentionPeriod: model.BackupRetentionPeriod, + VolumeIds: model.BackupVolumeIds, } if model.BackupVolumeIds == nil { backupProperties.VolumeIds = nil } req = req.CreateBackupSchedulePayload(serverbackup.CreateBackupSchedulePayload{ - Enabled: &model.Enabled, - Name: &model.BackupScheduleName, - Rrule: &model.Rrule, + Enabled: model.Enabled, + Name: model.BackupScheduleName, + Rrule: model.Rrule, BackupProperties: &backupProperties, }) return req, nil @@ -165,7 +164,7 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient *serverbacku func outputResult(p *print.Printer, outputFormat, serverLabel string, resp serverbackup.BackupSchedule) error { return p.OutputResult(outputFormat, resp, func() error { - p.Outputf("Created server backup schedule for server %s. Backup Schedule ID: %s\n", serverLabel, utils.PtrString(resp.Id)) + p.Outputf("Created server backup schedule for server %s. Backup Schedule ID: %d\n", serverLabel, resp.Id) return nil }) } diff --git a/internal/cmd/server/backup/schedule/create/create_test.go b/internal/cmd/server/backup/schedule/create/create_test.go index fcfd3bbcb..87c475a83 100644 --- a/internal/cmd/server/backup/schedule/create/create_test.go +++ b/internal/cmd/server/backup/schedule/create/create_test.go @@ -4,21 +4,20 @@ import ( "context" "testing" - "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" - "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" - "github.com/stackitcloud/stackit-cli/internal/pkg/testutils" - "github.com/stackitcloud/stackit-cli/internal/pkg/utils" - "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/serverbackup" + serverbackup "github.com/stackitcloud/stackit-sdk-go/services/serverbackup/v2api" + + "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" + "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" + "github.com/stackitcloud/stackit-cli/internal/pkg/testutils" ) type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &serverbackup.APIClient{} +var testClient = &serverbackup.APIClient{DefaultAPI: &serverbackup.DefaultAPIService{}} var testProjectId = uuid.NewString() var testServerId = uuid.NewString() @@ -55,7 +54,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { Enabled: defaultEnabled, Rrule: defaultRrule, BackupName: "example-backup-name", - BackupRetentionPeriod: int64(14), + BackupRetentionPeriod: int32(14), BackupVolumeIds: []string{testVolumeId}, } for _, mod := range mods { @@ -65,7 +64,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *serverbackup.ApiCreateBackupScheduleRequest)) serverbackup.ApiCreateBackupScheduleRequest { - request := testClient.CreateBackupSchedule(testCtx, testProjectId, testServerId, testRegion) + request := testClient.DefaultAPI.CreateBackupSchedule(testCtx, testProjectId, testServerId, testRegion) request = request.CreateBackupSchedulePayload(fixturePayload()) for _, mod := range mods { mod(&request) @@ -75,13 +74,13 @@ func fixtureRequest(mods ...func(request *serverbackup.ApiCreateBackupScheduleRe func fixturePayload(mods ...func(payload *serverbackup.CreateBackupSchedulePayload)) serverbackup.CreateBackupSchedulePayload { payload := serverbackup.CreateBackupSchedulePayload{ - Name: utils.Ptr("example-backup-schedule-name"), - Enabled: utils.Ptr(defaultEnabled), - Rrule: utils.Ptr("DTSTART;TZID=Europe/Sofia:20200803T023000 RRULE:FREQ=DAILY;INTERVAL=1"), + Name: "example-backup-schedule-name", + Enabled: defaultEnabled, + Rrule: "DTSTART;TZID=Europe/Sofia:20200803T023000 RRULE:FREQ=DAILY;INTERVAL=1", BackupProperties: &serverbackup.BackupProperties{ - Name: utils.Ptr("example-backup-name"), - RetentionPeriod: utils.Ptr(int64(14)), - VolumeIds: utils.Ptr([]string{testVolumeId}), + Name: "example-backup-name", + RetentionPeriod: int32(14), + VolumeIds: []string{testVolumeId}, }, } for _, mod := range mods { @@ -175,7 +174,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, serverbackup.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/server/backup/schedule/delete/delete.go b/internal/cmd/server/backup/schedule/delete/delete.go index c0584eefa..2a1250832 100644 --- a/internal/cmd/server/backup/schedule/delete/delete.go +++ b/internal/cmd/server/backup/schedule/delete/delete.go @@ -17,7 +17,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/services/serverbackup/client" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/serverbackup" + serverbackup "github.com/stackitcloud/stackit-sdk-go/services/serverbackup/v2api" ) const ( @@ -113,6 +113,6 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *serverbackup.APIClient) serverbackup.ApiDeleteBackupScheduleRequest { - req := apiClient.DeleteBackupSchedule(ctx, model.ProjectId, model.ServerId, model.Region, model.ScheduleId) + req := apiClient.DefaultAPI.DeleteBackupSchedule(ctx, model.ProjectId, model.ServerId, model.Region, model.ScheduleId) return req } diff --git a/internal/cmd/server/backup/schedule/delete/delete_test.go b/internal/cmd/server/backup/schedule/delete/delete_test.go index 5e0f108ca..6d9420022 100644 --- a/internal/cmd/server/backup/schedule/delete/delete_test.go +++ b/internal/cmd/server/backup/schedule/delete/delete_test.go @@ -10,13 +10,13 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/serverbackup" + serverbackup "github.com/stackitcloud/stackit-sdk-go/services/serverbackup/v2api" ) type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &serverbackup.APIClient{} +var testClient = &serverbackup.APIClient{DefaultAPI: &serverbackup.DefaultAPIService{}} var testProjectId = uuid.NewString() var testServerId = uuid.NewString() var testBackupScheduleId = "5" @@ -61,7 +61,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *serverbackup.ApiDeleteBackupScheduleRequest)) serverbackup.ApiDeleteBackupScheduleRequest { - request := testClient.DeleteBackupSchedule(testCtx, testProjectId, testServerId, testRegion, testBackupScheduleId) + request := testClient.DefaultAPI.DeleteBackupSchedule(testCtx, testProjectId, testServerId, testRegion, testBackupScheduleId) for _, mod := range mods { mod(&request) } @@ -153,7 +153,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, serverbackup.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/server/backup/schedule/describe/describe.go b/internal/cmd/server/backup/schedule/describe/describe.go index a4e3b1f21..a696666d3 100644 --- a/internal/cmd/server/backup/schedule/describe/describe.go +++ b/internal/cmd/server/backup/schedule/describe/describe.go @@ -17,7 +17,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/serverbackup" + serverbackup "github.com/stackitcloud/stackit-sdk-go/services/serverbackup/v2api" ) const ( @@ -97,28 +97,28 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *serverbackup.APIClient) serverbackup.ApiGetBackupScheduleRequest { - req := apiClient.GetBackupSchedule(ctx, model.ProjectId, model.ServerId, model.Region, model.BackupScheduleId) + req := apiClient.DefaultAPI.GetBackupSchedule(ctx, model.ProjectId, model.ServerId, model.Region, model.BackupScheduleId) return req } func outputResult(p *print.Printer, outputFormat string, schedule serverbackup.BackupSchedule) error { return p.OutputResult(outputFormat, schedule, func() error { table := tables.NewTable() - table.AddRow("SCHEDULE ID", utils.PtrString(schedule.Id)) + table.AddRow("SCHEDULE ID", schedule.Id) table.AddSeparator() - table.AddRow("SCHEDULE NAME", utils.PtrString(schedule.Name)) + table.AddRow("SCHEDULE NAME", schedule.Name) table.AddSeparator() - table.AddRow("ENABLED", utils.PtrString(schedule.Enabled)) + table.AddRow("ENABLED", schedule.Enabled) table.AddSeparator() - table.AddRow("RRULE", utils.PtrString(schedule.Rrule)) + table.AddRow("RRULE", schedule.Rrule) table.AddSeparator() if schedule.BackupProperties != nil { - table.AddRow("BACKUP NAME", utils.PtrString(schedule.BackupProperties.Name)) + table.AddRow("BACKUP NAME", schedule.BackupProperties.Name) table.AddSeparator() - table.AddRow("BACKUP RETENTION DAYS", utils.PtrString(schedule.BackupProperties.RetentionPeriod)) + table.AddRow("BACKUP RETENTION DAYS", schedule.BackupProperties.RetentionPeriod) table.AddSeparator() ids := schedule.BackupProperties.VolumeIds - table.AddRow("BACKUP VOLUME IDS", utils.JoinStringPtr(ids, "\n")) + table.AddRow("BACKUP VOLUME IDS", utils.JoinStringPtr(&ids, "\n")) } err := table.Display(p) if err != nil { diff --git a/internal/cmd/server/backup/schedule/describe/describe_test.go b/internal/cmd/server/backup/schedule/describe/describe_test.go index b28769ab9..28565edc8 100644 --- a/internal/cmd/server/backup/schedule/describe/describe_test.go +++ b/internal/cmd/server/backup/schedule/describe/describe_test.go @@ -7,7 +7,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/serverbackup" + serverbackup "github.com/stackitcloud/stackit-sdk-go/services/serverbackup/v2api" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/testparams" @@ -17,7 +17,7 @@ import ( type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &serverbackup.APIClient{} +var testClient = &serverbackup.APIClient{DefaultAPI: &serverbackup.DefaultAPIService{}} var testProjectId = uuid.NewString() var testServerId = uuid.NewString() var testBackupScheduleId = "5" @@ -62,7 +62,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *serverbackup.ApiGetBackupScheduleRequest)) serverbackup.ApiGetBackupScheduleRequest { - request := testClient.GetBackupSchedule(testCtx, testProjectId, testServerId, testRegion, testBackupScheduleId) + request := testClient.DefaultAPI.GetBackupSchedule(testCtx, testProjectId, testServerId, testRegion, testBackupScheduleId) for _, mod := range mods { mod(&request) } @@ -156,7 +156,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, serverbackup.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) @@ -211,7 +211,7 @@ func TestOutputResult(t *testing.T) { args: args{ schedule: serverbackup.BackupSchedule{ BackupProperties: &serverbackup.BackupProperties{ - VolumeIds: &[]string{}, + VolumeIds: []string{}, }, }, }, diff --git a/internal/cmd/server/backup/schedule/list/list.go b/internal/cmd/server/backup/schedule/list/list.go index c04b2628c..20a7e454e 100644 --- a/internal/cmd/server/backup/schedule/list/list.go +++ b/internal/cmd/server/backup/schedule/list/list.go @@ -9,7 +9,7 @@ import ( iaasClient "github.com/stackitcloud/stackit-cli/internal/pkg/services/iaas/client" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/serverbackup" + serverbackup "github.com/stackitcloud/stackit-sdk-go/services/serverbackup/v2api" "github.com/stackitcloud/stackit-cli/internal/pkg/args" "github.com/stackitcloud/stackit-cli/internal/pkg/errors" @@ -124,7 +124,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, } func buildRequest(ctx context.Context, model *inputModel, apiClient *serverbackup.APIClient) serverbackup.ApiListBackupSchedulesRequest { - req := apiClient.ListBackupSchedules(ctx, model.ProjectId, model.ServerId, model.Region) + req := apiClient.DefaultAPI.ListBackupSchedules(ctx, model.ProjectId, model.ServerId, model.Region) return req } @@ -143,16 +143,16 @@ func outputResult(p *print.Printer, outputFormat, serverLabel string, schedules retentionPeriod := "" ids := "" if s.BackupProperties != nil { - backupName = utils.PtrString(s.BackupProperties.Name) - retentionPeriod = utils.PtrString(s.BackupProperties.RetentionPeriod) + backupName = s.BackupProperties.Name + retentionPeriod = string(s.BackupProperties.RetentionPeriod) - ids = utils.JoinStringPtr(s.BackupProperties.VolumeIds, ",") + ids = utils.JoinStringPtr(&s.BackupProperties.VolumeIds, ",") } table.AddRow( - utils.PtrString(s.Id), - utils.PtrString(s.Name), - utils.PtrString(s.Enabled), - utils.PtrString(s.Rrule), + s.Id, + s.Name, + s.Enabled, + s.Rrule, backupName, retentionPeriod, ids, diff --git a/internal/cmd/server/backup/schedule/list/list_test.go b/internal/cmd/server/backup/schedule/list/list_test.go index d16a3dcae..fff446e38 100644 --- a/internal/cmd/server/backup/schedule/list/list_test.go +++ b/internal/cmd/server/backup/schedule/list/list_test.go @@ -13,13 +13,13 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/serverbackup" + serverbackup "github.com/stackitcloud/stackit-sdk-go/services/serverbackup/v2api" ) type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &serverbackup.APIClient{} +var testClient = &serverbackup.APIClient{DefaultAPI: &serverbackup.DefaultAPIService{}} var testProjectId = uuid.NewString() var testServerId = uuid.NewString() var testRegion = "eu01" @@ -54,7 +54,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *serverbackup.ApiListBackupSchedulesRequest)) serverbackup.ApiListBackupSchedulesRequest { - request := testClient.ListBackupSchedules(testCtx, testProjectId, testServerId, testRegion) + request := testClient.DefaultAPI.ListBackupSchedules(testCtx, testProjectId, testServerId, testRegion) for _, mod := range mods { mod(&request) } @@ -143,7 +143,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, serverbackup.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/server/backup/schedule/update/update.go b/internal/cmd/server/backup/schedule/update/update.go index d16db4d63..7df44a83a 100644 --- a/internal/cmd/server/backup/schedule/update/update.go +++ b/internal/cmd/server/backup/schedule/update/update.go @@ -6,6 +6,9 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/types" + "github.com/spf13/cobra" + serverbackup "github.com/stackitcloud/stackit-sdk-go/services/serverbackup/v2api" + "github.com/stackitcloud/stackit-cli/internal/pkg/args" cliErr "github.com/stackitcloud/stackit-cli/internal/pkg/errors" "github.com/stackitcloud/stackit-cli/internal/pkg/examples" @@ -13,10 +16,6 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" "github.com/stackitcloud/stackit-cli/internal/pkg/print" "github.com/stackitcloud/stackit-cli/internal/pkg/services/serverbackup/client" - "github.com/stackitcloud/stackit-cli/internal/pkg/utils" - - "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/serverbackup" ) const ( @@ -44,7 +43,7 @@ type inputModel struct { Enabled *bool Rrule *string BackupName *string - BackupRetentionPeriod *int64 + BackupRetentionPeriod *int32 BackupVolumeIds []string } @@ -76,7 +75,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command { return err } - currentBackupSchedule, err := apiClient.GetBackupScheduleExecute(ctx, model.ProjectId, model.ServerId, model.Region, model.BackupScheduleId) + currentBackupSchedule, err := apiClient.DefaultAPI.GetBackupSchedule(ctx, model.ProjectId, model.ServerId, model.Region, model.BackupScheduleId).Execute() if err != nil { params.Printer.Debug(print.ErrorLevel, "get current server backup schedule: %v", err) return err @@ -110,7 +109,7 @@ func configureFlags(cmd *cobra.Command) { cmd.Flags().StringP(backupScheduleNameFlag, "n", "", "Backup schedule name") cmd.Flags().StringP(backupNameFlag, "b", "", "Backup name") - cmd.Flags().Int64P(backupRetentionPeriodFlag, "d", defaultRetentionPeriod, "Backup retention period (in days)") + cmd.Flags().Int32P(backupRetentionPeriodFlag, "d", defaultRetentionPeriod, "Backup retention period (in days)") cmd.Flags().BoolP(enabledFlag, "e", defaultEnabled, "Is the server backup schedule enabled") cmd.Flags().StringP(rruleFlag, "r", defaultRrule, "Backup RRULE (recurrence rule)") cmd.Flags().VarP(flags.UUIDSliceFlag(), backupVolumeIdsFlag, "i", "Backup volume IDs, as comma separated UUID values.") @@ -131,7 +130,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu GlobalFlagModel: globalFlags, BackupScheduleId: scheduleId, ServerId: flags.FlagToStringValue(p, cmd, serverIdFlag), - BackupRetentionPeriod: flags.FlagToInt64Pointer(p, cmd, backupRetentionPeriodFlag), + BackupRetentionPeriod: flags.FlagToInt32Pointer(p, cmd, backupRetentionPeriodFlag), BackupScheduleName: flags.FlagToStringPointer(p, cmd, backupScheduleNameFlag), BackupName: flags.FlagToStringPointer(p, cmd, backupNameFlag), Rrule: flags.FlagToStringPointer(p, cmd, rruleFlag), @@ -144,25 +143,25 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *serverbackup.APIClient, old serverbackup.BackupSchedule) (serverbackup.ApiUpdateBackupScheduleRequest, error) { - req := apiClient.UpdateBackupSchedule(ctx, model.ProjectId, model.ServerId, model.Region, model.BackupScheduleId) + req := apiClient.DefaultAPI.UpdateBackupSchedule(ctx, model.ProjectId, model.ServerId, model.Region, model.BackupScheduleId) if model.BackupName != nil { - old.BackupProperties.Name = model.BackupName + old.BackupProperties.Name = *model.BackupName } if model.BackupRetentionPeriod != nil { - old.BackupProperties.RetentionPeriod = model.BackupRetentionPeriod + old.BackupProperties.RetentionPeriod = *model.BackupRetentionPeriod } if model.BackupVolumeIds != nil { - old.BackupProperties.VolumeIds = &model.BackupVolumeIds + old.BackupProperties.VolumeIds = model.BackupVolumeIds } if model.Enabled != nil { - old.Enabled = model.Enabled + old.Enabled = *model.Enabled } if model.BackupScheduleName != nil { - old.Name = model.BackupScheduleName + old.Name = *model.BackupScheduleName } if model.Rrule != nil { - old.Rrule = model.Rrule + old.Rrule = *model.Rrule } req = req.UpdateBackupSchedulePayload(serverbackup.UpdateBackupSchedulePayload{ @@ -176,7 +175,7 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient *serverbacku func outputResult(p *print.Printer, outputFormat string, resp serverbackup.BackupSchedule) error { return p.OutputResult(outputFormat, resp, func() error { - p.Info("Updated server backup schedule %s\n", utils.PtrString(resp.Id)) + p.Outputf("Updated server backup schedule %d\n", resp.Id) return nil }) } diff --git a/internal/cmd/server/backup/schedule/update/update_test.go b/internal/cmd/server/backup/schedule/update/update_test.go index 89213b4bb..95ad5bdbd 100644 --- a/internal/cmd/server/backup/schedule/update/update_test.go +++ b/internal/cmd/server/backup/schedule/update/update_test.go @@ -2,7 +2,6 @@ package update import ( "context" - "strconv" "testing" "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" @@ -12,22 +11,22 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/serverbackup" + serverbackup "github.com/stackitcloud/stackit-sdk-go/services/serverbackup/v2api" ) type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &serverbackup.APIClient{} +var testClient = &serverbackup.APIClient{DefaultAPI: &serverbackup.DefaultAPIService{}} var testProjectId = uuid.NewString() var testServerId = uuid.NewString() var testVolumeId = uuid.NewString() -var testBackupScheduleId = "5" +var testBackupScheduleId = int32(5) var testRegion = "eu01" func fixtureArgValues(mods ...func(argValues []string)) []string { argValues := []string{ - testBackupScheduleId, + string(testBackupScheduleId), } for _, mod := range mods { mod(argValues) @@ -60,13 +59,13 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { Region: testRegion, Verbosity: globalflags.VerbosityDefault, }, - BackupScheduleId: testBackupScheduleId, + BackupScheduleId: string(testBackupScheduleId), ServerId: testServerId, BackupScheduleName: utils.Ptr("example-backup-schedule-name"), Enabled: utils.Ptr(defaultEnabled), Rrule: utils.Ptr(defaultRrule), BackupName: utils.Ptr("example-backup-name"), - BackupRetentionPeriod: utils.Ptr(int64(14)), + BackupRetentionPeriod: utils.Ptr(int32(14)), BackupVolumeIds: []string{testVolumeId}, } for _, mod := range mods { @@ -76,16 +75,15 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureBackupSchedule(mods ...func(schedule *serverbackup.BackupSchedule)) *serverbackup.BackupSchedule { - id, _ := strconv.ParseInt(testBackupScheduleId, 10, 64) schedule := &serverbackup.BackupSchedule{ - Name: utils.Ptr("example-backup-schedule-name"), - Id: utils.Ptr(id), - Enabled: utils.Ptr(defaultEnabled), - Rrule: utils.Ptr(defaultRrule), + Name: "example-backup-schedule-name", + Id: testBackupScheduleId, + Enabled: defaultEnabled, + Rrule: defaultRrule, BackupProperties: &serverbackup.BackupProperties{ - Name: utils.Ptr("example-backup-name"), - RetentionPeriod: utils.Ptr(int64(14)), - VolumeIds: utils.Ptr([]string{testVolumeId}), + Name: "example-backup-name", + RetentionPeriod: int32(14), + VolumeIds: []string{testVolumeId}, }, } for _, mod := range mods { @@ -96,13 +94,13 @@ func fixtureBackupSchedule(mods ...func(schedule *serverbackup.BackupSchedule)) func fixturePayload(mods ...func(payload *serverbackup.UpdateBackupSchedulePayload)) serverbackup.UpdateBackupSchedulePayload { payload := serverbackup.UpdateBackupSchedulePayload{ - Name: utils.Ptr("example-backup-schedule-name"), - Enabled: utils.Ptr(defaultEnabled), - Rrule: utils.Ptr("DTSTART;TZID=Europe/Sofia:20200803T023000 RRULE:FREQ=DAILY;INTERVAL=1"), + Name: "example-backup-schedule-name", + Enabled: defaultEnabled, + Rrule: "DTSTART;TZID=Europe/Sofia:20200803T023000 RRULE:FREQ=DAILY;INTERVAL=1", BackupProperties: &serverbackup.BackupProperties{ - Name: utils.Ptr("example-backup-name"), - RetentionPeriod: utils.Ptr(int64(14)), - VolumeIds: utils.Ptr([]string{testVolumeId}), + Name: "example-backup-name", + RetentionPeriod: int32(14), + VolumeIds: []string{testVolumeId}, }, } for _, mod := range mods { @@ -112,7 +110,7 @@ func fixturePayload(mods ...func(payload *serverbackup.UpdateBackupSchedulePaylo } func fixtureRequest(mods ...func(request *serverbackup.ApiUpdateBackupScheduleRequest)) serverbackup.ApiUpdateBackupScheduleRequest { - request := testClient.UpdateBackupSchedule(testCtx, testProjectId, testServerId, testRegion, testBackupScheduleId) + request := testClient.DefaultAPI.UpdateBackupSchedule(testCtx, testProjectId, testServerId, testRegion, string(testBackupScheduleId)) request = request.UpdateBackupSchedulePayload(fixturePayload()) for _, mod := range mods { mod(&request) @@ -269,7 +267,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, serverbackup.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/server/backup/volume-backup/delete/delete.go b/internal/cmd/server/backup/volume-backup/delete/delete.go index 1a7241bba..3fa8aad34 100644 --- a/internal/cmd/server/backup/volume-backup/delete/delete.go +++ b/internal/cmd/server/backup/volume-backup/delete/delete.go @@ -16,7 +16,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/serverbackup" + serverbackup "github.com/stackitcloud/stackit-sdk-go/services/serverbackup/v2api" ) const ( @@ -105,6 +105,6 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *serverbackup.APIClient) serverbackup.ApiDeleteVolumeBackupRequest { - req := apiClient.DeleteVolumeBackup(ctx, model.ProjectId, model.ServerId, model.Region, model.BackupId, model.VolumeId) + req := apiClient.DefaultAPI.DeleteVolumeBackup(ctx, model.ProjectId, model.ServerId, model.Region, model.BackupId, model.VolumeId) return req } diff --git a/internal/cmd/server/backup/volume-backup/delete/delete_test.go b/internal/cmd/server/backup/volume-backup/delete/delete_test.go index 0a1da5857..6abc17480 100644 --- a/internal/cmd/server/backup/volume-backup/delete/delete_test.go +++ b/internal/cmd/server/backup/volume-backup/delete/delete_test.go @@ -10,13 +10,13 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/serverbackup" + serverbackup "github.com/stackitcloud/stackit-sdk-go/services/serverbackup/v2api" ) type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &serverbackup.APIClient{} +var testClient = &serverbackup.APIClient{DefaultAPI: &serverbackup.DefaultAPIService{}} var testProjectId = uuid.NewString() var testServerId = uuid.NewString() var testBackupId = uuid.NewString() @@ -64,7 +64,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *serverbackup.ApiDeleteVolumeBackupRequest)) serverbackup.ApiDeleteVolumeBackupRequest { - request := testClient.DeleteVolumeBackup(testCtx, testProjectId, testServerId, testRegion, testBackupId, testVolumeId) + request := testClient.DefaultAPI.DeleteVolumeBackup(testCtx, testProjectId, testServerId, testRegion, testBackupId, testVolumeId) for _, mod := range mods { mod(&request) } @@ -156,7 +156,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, serverbackup.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/cmd/server/backup/volume-backup/restore/restore.go b/internal/cmd/server/backup/volume-backup/restore/restore.go index 343f4ade8..e24beee15 100644 --- a/internal/cmd/server/backup/volume-backup/restore/restore.go +++ b/internal/cmd/server/backup/volume-backup/restore/restore.go @@ -16,7 +16,7 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/spf13/cobra" - "github.com/stackitcloud/stackit-sdk-go/services/serverbackup" + serverbackup "github.com/stackitcloud/stackit-sdk-go/services/serverbackup/v2api" ) const ( @@ -109,9 +109,9 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu } func buildRequest(ctx context.Context, model *inputModel, apiClient *serverbackup.APIClient) serverbackup.ApiRestoreVolumeBackupRequest { - req := apiClient.RestoreVolumeBackup(ctx, model.ProjectId, model.ServerId, model.Region, model.BackupId, model.VolumeBackupId) + req := apiClient.DefaultAPI.RestoreVolumeBackup(ctx, model.ProjectId, model.ServerId, model.Region, model.BackupId, model.VolumeBackupId) payload := serverbackup.RestoreVolumeBackupPayload{ - RestoreVolumeId: &model.RestoreVolumeId, + RestoreVolumeId: model.RestoreVolumeId, } req = req.RestoreVolumeBackupPayload(payload) return req diff --git a/internal/cmd/server/backup/volume-backup/restore/restore_test.go b/internal/cmd/server/backup/volume-backup/restore/restore_test.go index f329161db..b4beef3e7 100644 --- a/internal/cmd/server/backup/volume-backup/restore/restore_test.go +++ b/internal/cmd/server/backup/volume-backup/restore/restore_test.go @@ -10,13 +10,13 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/serverbackup" + serverbackup "github.com/stackitcloud/stackit-sdk-go/services/serverbackup/v2api" ) type testCtxKey struct{} var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") -var testClient = &serverbackup.APIClient{} +var testClient = &serverbackup.APIClient{DefaultAPI: &serverbackup.DefaultAPIService{}} var testProjectId = uuid.NewString() var testServerId = uuid.NewString() var testBackupId = uuid.NewString() @@ -67,9 +67,9 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { } func fixtureRequest(mods ...func(request *serverbackup.ApiRestoreVolumeBackupRequest)) serverbackup.ApiRestoreVolumeBackupRequest { - request := testClient.RestoreVolumeBackup(testCtx, testProjectId, testServerId, testRegion, testBackupId, testVolumeBackupId) + request := testClient.DefaultAPI.RestoreVolumeBackup(testCtx, testProjectId, testServerId, testRegion, testBackupId, testVolumeBackupId) request = request.RestoreVolumeBackupPayload(serverbackup.RestoreVolumeBackupPayload{ - RestoreVolumeId: &testRestoreVolumeId, + RestoreVolumeId: testRestoreVolumeId, }) for _, mod := range mods { mod(&request) @@ -162,7 +162,7 @@ func TestBuildRequest(t *testing.T) { diff := cmp.Diff(request, tt.expectedRequest, cmp.AllowUnexported(tt.expectedRequest), - cmpopts.EquateComparable(testCtx), + cmpopts.EquateComparable(testCtx, serverbackup.DefaultAPIService{}), ) if diff != "" { t.Fatalf("Data does not match: %s", diff) diff --git a/internal/pkg/services/serverbackup/client/client.go b/internal/pkg/services/serverbackup/client/client.go index c8726b392..2bc42f42f 100644 --- a/internal/pkg/services/serverbackup/client/client.go +++ b/internal/pkg/services/serverbackup/client/client.go @@ -6,9 +6,9 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/print" "github.com/spf13/viper" - "github.com/stackitcloud/stackit-sdk-go/services/serverbackup" + serverbackup "github.com/stackitcloud/stackit-sdk-go/services/serverbackup/v2api" ) func ConfigureClient(p *print.Printer, cliVersion string) (*serverbackup.APIClient, error) { - return genericclient.ConfigureClientGeneric(p, cliVersion, viper.GetString(config.ServerBackupCustomEndpointKey), true, genericclient.CreateApiClient[*serverbackup.APIClient](serverbackup.NewAPIClient)) + return genericclient.ConfigureClientGeneric(p, cliVersion, viper.GetString(config.ServerBackupCustomEndpointKey), false, genericclient.CreateApiClient[*serverbackup.APIClient](serverbackup.NewAPIClient)) } diff --git a/internal/pkg/services/serverbackup/utils/utils.go b/internal/pkg/services/serverbackup/utils/utils.go index d8ea83bdf..c74c3fa09 100644 --- a/internal/pkg/services/serverbackup/utils/utils.go +++ b/internal/pkg/services/serverbackup/utils/utils.go @@ -4,28 +4,23 @@ import ( "context" "fmt" - "github.com/stackitcloud/stackit-sdk-go/services/serverbackup" + serverbackup "github.com/stackitcloud/stackit-sdk-go/services/serverbackup/v2api" ) -type ServerBackupClient interface { - ListBackupSchedulesExecute(ctx context.Context, projectId, serverId, region string) (*serverbackup.GetBackupSchedulesResponse, error) - ListBackupsExecute(ctx context.Context, projectId, serverId, region string) (*serverbackup.GetBackupsListResponse, error) -} - -func CanDisableBackupService(ctx context.Context, client ServerBackupClient, projectId, serverId, region string) (bool, error) { - schedules, err := client.ListBackupSchedulesExecute(ctx, projectId, serverId, region) +func CanDisableBackupService(ctx context.Context, client serverbackup.DefaultAPI, projectId, serverId, region string) (bool, error) { + schedules, err := client.ListBackupSchedules(ctx, projectId, serverId, region).Execute() if err != nil { return false, fmt.Errorf("list backup schedules: %w", err) } - if len(*schedules.Items) > 0 { + if len(schedules.Items) > 0 { return false, nil } - backups, err := client.ListBackupsExecute(ctx, projectId, serverId, region) + backups, err := client.ListBackups(ctx, projectId, serverId, region).Execute() if err != nil { return false, fmt.Errorf("list backups: %w", err) } - if len(*backups.Items) > 0 { + if len(backups.Items) > 0 { return false, nil } diff --git a/internal/pkg/services/serverbackup/utils/utils_test.go b/internal/pkg/services/serverbackup/utils/utils_test.go index 7262fdd6e..23a8df1d1 100644 --- a/internal/pkg/services/serverbackup/utils/utils_test.go +++ b/internal/pkg/services/serverbackup/utils/utils_test.go @@ -8,108 +8,119 @@ import ( "github.com/stackitcloud/stackit-cli/internal/pkg/utils" "github.com/google/uuid" - "github.com/stackitcloud/stackit-sdk-go/services/serverbackup" + serverbackup "github.com/stackitcloud/stackit-sdk-go/services/serverbackup/v2api" ) +const testRegion = "eu01" + var ( testProjectId = uuid.NewString() testServerId = uuid.NewString() - testRegion = "eu01" ) -type serverbackupClientMocked struct { +type mockSettings struct { listBackupSchedulesFails bool listBackupSchedulesResp *serverbackup.GetBackupSchedulesResponse listBackupsFails bool listBackupsResp *serverbackup.GetBackupsListResponse } -func (m *serverbackupClientMocked) ListBackupSchedulesExecute(_ context.Context, _, _, _ string) (*serverbackup.GetBackupSchedulesResponse, error) { - if m.listBackupSchedulesFails { - return nil, fmt.Errorf("could not list backup schedules") - } - return m.listBackupSchedulesResp, nil -} - -func (m *serverbackupClientMocked) ListBackupsExecute(_ context.Context, _, _, _ string) (*serverbackup.GetBackupsListResponse, error) { - if m.listBackupsFails { - return nil, fmt.Errorf("could not list backups") +func newServerbackupClientMock(s mockSettings) serverbackup.DefaultAPI { + return &serverbackup.DefaultAPIServiceMock{ + ListBackupSchedulesExecuteMock: utils.Ptr(func(_ serverbackup.ApiListBackupSchedulesRequest) (*serverbackup.GetBackupSchedulesResponse, error) { + if s.listBackupSchedulesFails { + return nil, fmt.Errorf("could not list backup schedules") + } + return s.listBackupSchedulesResp, nil + }), + ListBackupsExecuteMock: utils.Ptr(func(_ serverbackup.ApiListBackupsRequest) (*serverbackup.GetBackupsListResponse, error) { + if s.listBackupsFails { + return nil, fmt.Errorf("could not list backups") + } + return s.listBackupsResp, nil + }), } - return m.listBackupsResp, nil } func TestCanDisableBackupService(t *testing.T) { tests := []struct { - description string - listBackupsFails bool - listBackupSchedulesFails bool - listBackups *serverbackup.GetBackupsListResponse - listBackupSchedules *serverbackup.GetBackupSchedulesResponse - isValid bool // isValid ==> err == nil - expectedOutput bool // expectedCanDisable + description string + mockSettings mockSettings + isValid bool // isValid ==> err == nil + expectedOutput bool // expectedCanDisable }{ { - description: "base-ok-can-disable-backups-service-no-backups-no-backup-schedules", - listBackupsFails: false, - listBackupSchedulesFails: false, - listBackups: &serverbackup.GetBackupsListResponse{Items: &[]serverbackup.Backup{}}, - listBackupSchedules: &serverbackup.GetBackupSchedulesResponse{Items: &[]serverbackup.BackupSchedule{}}, - isValid: true, - expectedOutput: true, + description: "base-ok-can-disable-backups-service-no-backups-no-backup-schedules", + mockSettings: mockSettings{ + listBackupsFails: false, + listBackupSchedulesFails: false, + listBackupsResp: &serverbackup.GetBackupsListResponse{Items: []serverbackup.Backup{}}, + listBackupSchedulesResp: &serverbackup.GetBackupSchedulesResponse{Items: []serverbackup.BackupSchedule{}}, + }, + isValid: true, + expectedOutput: true, }, { - description: "not-ok-api-error-list-backups", - listBackupsFails: true, - listBackupSchedulesFails: false, - listBackups: &serverbackup.GetBackupsListResponse{Items: &[]serverbackup.Backup{}}, - listBackupSchedules: &serverbackup.GetBackupSchedulesResponse{Items: &[]serverbackup.BackupSchedule{}}, - isValid: false, - expectedOutput: false, + description: "not-ok-api-error-list-backups", + mockSettings: mockSettings{ + listBackupsFails: true, + listBackupSchedulesFails: false, + listBackupsResp: &serverbackup.GetBackupsListResponse{Items: []serverbackup.Backup{}}, + listBackupSchedulesResp: &serverbackup.GetBackupSchedulesResponse{Items: []serverbackup.BackupSchedule{}}, + }, + isValid: false, + expectedOutput: false, }, { - description: "not-ok-api-error-list-backup-schedules", - listBackupsFails: true, - listBackupSchedulesFails: false, - listBackups: &serverbackup.GetBackupsListResponse{Items: &[]serverbackup.Backup{}}, - listBackupSchedules: &serverbackup.GetBackupSchedulesResponse{Items: &[]serverbackup.BackupSchedule{}}, - isValid: false, - expectedOutput: false, + description: "not-ok-api-error-list-backup-schedules", + mockSettings: mockSettings{ + listBackupsFails: true, + listBackupSchedulesFails: false, + listBackupsResp: &serverbackup.GetBackupsListResponse{Items: []serverbackup.Backup{}}, + listBackupSchedulesResp: &serverbackup.GetBackupSchedulesResponse{Items: []serverbackup.BackupSchedule{}}, + }, + isValid: false, + expectedOutput: false, }, { - description: "not-ok-has-backups-cannot-disable", - listBackupsFails: false, - listBackupSchedulesFails: false, - listBackups: &serverbackup.GetBackupsListResponse{ - Items: &[]serverbackup.Backup{ - { - CreatedAt: utils.Ptr("test timestamp"), - ExpireAt: utils.Ptr("test timestamp"), - Id: utils.Ptr("5"), - LastRestoredAt: utils.Ptr("test timestamp"), - Name: utils.Ptr("test name"), - Size: utils.Ptr(int64(5)), - Status: serverbackup.BACKUPSTATUS_IN_PROGRESS.Ptr(), - VolumeBackups: nil, + description: "not-ok-has-backups-cannot-disable", + mockSettings: mockSettings{ + listBackupsFails: false, + listBackupSchedulesFails: false, + listBackupsResp: &serverbackup.GetBackupsListResponse{ + Items: []serverbackup.Backup{ + { + CreatedAt: "test timestamp", + ExpireAt: "test timestamp", + Id: "5", + LastRestoredAt: utils.Ptr("test timestamp"), + Name: "test name", + Size: utils.Ptr(int32(5)), + Status: serverbackup.BACKUPSTATUS_IN_PROGRESS, + VolumeBackups: nil, + }, }, }, + listBackupSchedulesResp: &serverbackup.GetBackupSchedulesResponse{Items: []serverbackup.BackupSchedule{}}, }, - listBackupSchedules: &serverbackup.GetBackupSchedulesResponse{Items: &[]serverbackup.BackupSchedule{}}, - isValid: true, - expectedOutput: false, + isValid: true, + expectedOutput: false, }, { - description: "not-ok-has-backups-schedules-cannot-disable", - listBackupsFails: false, - listBackupSchedulesFails: false, - listBackups: &serverbackup.GetBackupsListResponse{Items: &[]serverbackup.Backup{}}, - listBackupSchedules: &serverbackup.GetBackupSchedulesResponse{ - Items: &[]serverbackup.BackupSchedule{ - { - BackupProperties: nil, - Enabled: utils.Ptr(false), - Id: utils.Ptr(int64(5)), - Name: utils.Ptr("some name"), - Rrule: utils.Ptr("some rrule"), + description: "not-ok-has-backups-schedules-cannot-disable", + mockSettings: mockSettings{ + listBackupsFails: false, + listBackupSchedulesFails: false, + listBackupsResp: &serverbackup.GetBackupsListResponse{Items: []serverbackup.Backup{}}, + listBackupSchedulesResp: &serverbackup.GetBackupSchedulesResponse{ + Items: []serverbackup.BackupSchedule{ + { + BackupProperties: nil, + Enabled: false, + Id: int32(5), + Name: "some name", + Rrule: "some rrule", + }, }, }, }, @@ -120,12 +131,7 @@ func TestCanDisableBackupService(t *testing.T) { for _, tt := range tests { t.Run(tt.description, func(t *testing.T) { - client := &serverbackupClientMocked{ - listBackupsFails: tt.listBackupsFails, - listBackupSchedulesFails: tt.listBackupSchedulesFails, - listBackupsResp: tt.listBackups, - listBackupSchedulesResp: tt.listBackupSchedules, - } + client := newServerbackupClientMock(tt.mockSettings) output, err := CanDisableBackupService(context.Background(), client, testProjectId, testServerId, testRegion) From e04c99789fd7d0b8fd4d3a09cf4bd3a7b99d6f5e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 22 Jul 2026 15:17:44 +0200 Subject: [PATCH 43/44] chore(deps): bump actions/setup-go from 6.5.0 to 7.0.0 (#1496) --- .github/workflows/ci.yaml | 2 +- .github/workflows/release.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 3b2e9d7a2..a944446b0 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -20,7 +20,7 @@ jobs: uses: actions/checkout@v7.0.0 - name: Install go - uses: actions/setup-go@v6.5.0 + uses: actions/setup-go@v7.0.0 with: go-version-file: "go.mod" cache: true diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index f8bb91e0c..5994f9280 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -29,7 +29,7 @@ jobs: fetch-depth: 0 - name: Install go - uses: actions/setup-go@v6.5.0 + uses: actions/setup-go@v7.0.0 with: go-version-file: "go.mod" cache: true From 5610837e4aa7eab9c665ae14c95240e6b08362e4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 22 Jul 2026 16:16:02 +0200 Subject: [PATCH 44/44] chore(deps): bump k8s.io/client-go from 0.35.1 to 0.36.2 (#1493) Bumps [k8s.io/client-go](https://github.com/kubernetes/client-go) from 0.35.1 to 0.36.2. - [Changelog](https://github.com/kubernetes/client-go/blob/master/CHANGELOG.md) - [Commits](https://github.com/kubernetes/client-go/compare/v0.35.1...v0.36.2) --- updated-dependencies: - dependency-name: k8s.io/client-go dependency-version: 0.36.2 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: cgoetz-inovex --- go.mod | 20 ++++++++++---------- go.sum | 40 ++++++++++++++++++++-------------------- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/go.mod b/go.mod index 1e5f5d164..ebe7634c8 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/stackitcloud/stackit-cli -go 1.25.0 +go 1.26.0 require ( github.com/fatih/color v1.19.0 @@ -43,13 +43,13 @@ require ( golang.org/x/oauth2 v0.36.0 golang.org/x/term v0.44.0 golang.org/x/text v0.40.0 - k8s.io/apimachinery v0.35.4 - k8s.io/client-go v0.35.1 + k8s.io/apimachinery v0.36.2 + k8s.io/client-go v0.36.2 ) require ( golang.org/x/net v0.56.0 // indirect - golang.org/x/time v0.11.0 // indirect + golang.org/x/time v0.14.0 // indirect gopkg.in/inf.v0 v0.9.1 // indirect ) @@ -236,13 +236,13 @@ require ( golang.org/x/sync v0.22.0 // indirect golang.org/x/telemetry v0.0.0-20260625142307-59b4966ccb57 // indirect golang.org/x/tools v0.47.0 // indirect - google.golang.org/protobuf v1.36.8 // indirect + google.golang.org/protobuf v1.36.12-0.20260120151049-f2248ac996af // indirect honnef.co/go/tools v0.7.0 // indirect - k8s.io/kube-openapi v0.0.0-20250910181357-589584f1c912 // indirect + k8s.io/kube-openapi v0.0.0-20260317180543-43fb72c5454a // indirect mvdan.cc/gofumpt v0.9.2 // indirect mvdan.cc/unparam v0.0.0-20251027182757-5beb8c8f8f15 // indirect sigs.k8s.io/randfill v1.0.0 // indirect - sigs.k8s.io/structured-merge-diff/v6 v6.3.0 // indirect + sigs.k8s.io/structured-merge-diff/v6 v6.3.2 // indirect ) require ( @@ -276,9 +276,9 @@ require ( github.com/subosito/gotenv v1.6.0 // indirect golang.org/x/sys v0.46.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - k8s.io/api v0.35.1 // indirect - k8s.io/klog/v2 v2.130.1 // indirect - k8s.io/utils v0.0.0-20251002143259-bc988d571ff4 + k8s.io/api v0.36.2 // indirect + k8s.io/klog/v2 v2.140.0 // indirect + k8s.io/utils v0.0.0-20260210185600-b8788abfbbc2 sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730 // indirect sigs.k8s.io/yaml v1.6.0 // indirect ) diff --git a/go.sum b/go.sum index 6505f944d..2624092d1 100644 --- a/go.sum +++ b/go.sum @@ -166,8 +166,8 @@ github.com/denis-tingaikin/go-header v0.5.0 h1:SRdnP5ZKvcO9KKRP1KJrhFR3RrlGuD+42 github.com/denis-tingaikin/go-header v0.5.0/go.mod h1:mMenU5bWrok6Wl2UsZjy+1okegmwQ3UgWl4V1D8gjlY= github.com/dlclark/regexp2 v1.11.5 h1:Q/sSnsKerHeCkc/jSTNq1oCm7KiVgUMZRDUoRu0JQZQ= github.com/dlclark/regexp2 v1.11.5/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= -github.com/emicklei/go-restful/v3 v3.12.2 h1:DhwDP0vY3k8ZzE0RunuJy8GhNpPL6zqLkDf9B/a0/xU= -github.com/emicklei/go-restful/v3 v3.12.2/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= +github.com/emicklei/go-restful/v3 v3.13.0 h1:C4Bl2xDndpU6nJ4bc1jXd+uTmYPVUwkD6bFY/oTyCes= +github.com/emicklei/go-restful/v3 v3.13.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= @@ -932,8 +932,8 @@ golang.org/x/text v0.40.0/go.mod h1:hpnzDAfGV753zIKo+wk3u1bVKCGPbrnF7+7LBF/UHVY= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.11.0 h1:/bpjEDfN9tkoN/ryeYHnv5hcMlc8ncjMcM4XBk5NWV0= -golang.org/x/time v0.11.0/go.mod h1:CDIdPxbZBQxdj6cxyCIdrNogrJKMJ7pr37NYpMcMDSg= +golang.org/x/time v0.14.0 h1:MRx4UaLrDotUKUdCIqzPC48t1Y9hANFKIRpNx+Te8PI= +golang.org/x/time v0.14.0/go.mod h1:eL/Oa2bBBK0TkX57Fyni+NgnyQQN4LitPmob2Hjnqw4= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= @@ -1069,8 +1069,8 @@ google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGj google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.36.8 h1:xHScyCOEuuwZEc6UtSOvPbAT4zRh0xcNRYekJwfqyMc= -google.golang.org/protobuf v1.36.8/go.mod h1:fuxRtAxBytpl4zzqUh6/eyUujkJdNiuEkXntxiD/uRU= +google.golang.org/protobuf v1.36.12-0.20260120151049-f2248ac996af h1:+5/Sw3GsDNlEmu7TfklWKPdQ0Ykja5VEmq2i817+jbI= +google.golang.org/protobuf v1.36.12-0.20260120151049-f2248ac996af/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= @@ -1099,18 +1099,18 @@ honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9 honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= honnef.co/go/tools v0.7.0 h1:w6WUp1VbkqPEgLz4rkBzH/CSU6HkoqNLp6GstyTx3lU= honnef.co/go/tools v0.7.0/go.mod h1:pm29oPxeP3P82ISxZDgIYeOaf9ta6Pi0EWvCFoLG2vc= -k8s.io/api v0.35.1 h1:0PO/1FhlK/EQNVK5+txc4FuhQibV25VLSdLMmGpDE/Q= -k8s.io/api v0.35.1/go.mod h1:28uR9xlXWml9eT0uaGo6y71xK86JBELShLy4wR1XtxM= -k8s.io/apimachinery v0.35.4 h1:xtdom9RG7e+yDp71uoXoJDWEE2eOiHgeO4GdBzwWpds= -k8s.io/apimachinery v0.35.4/go.mod h1:NNi1taPOpep0jOj+oRha3mBJPqvi0hGdaV8TCqGQ+cc= -k8s.io/client-go v0.35.1 h1:+eSfZHwuo/I19PaSxqumjqZ9l5XiTEKbIaJ+j1wLcLM= -k8s.io/client-go v0.35.1/go.mod h1:1p1KxDt3a0ruRfc/pG4qT/3oHmUj1AhSHEcxNSGg+OA= -k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk= -k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= -k8s.io/kube-openapi v0.0.0-20250910181357-589584f1c912 h1:Y3gxNAuB0OBLImH611+UDZcmKS3g6CthxToOb37KgwE= -k8s.io/kube-openapi v0.0.0-20250910181357-589584f1c912/go.mod h1:kdmbQkyfwUagLfXIad1y2TdrjPFWp2Q89B3qkRwf/pQ= -k8s.io/utils v0.0.0-20251002143259-bc988d571ff4 h1:SjGebBtkBqHFOli+05xYbK8YF1Dzkbzn+gDM4X9T4Ck= -k8s.io/utils v0.0.0-20251002143259-bc988d571ff4/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= +k8s.io/api v0.36.2 h1:TF6YDLIzKfccK7cq9YpTcGX8TJmEkHVRv78DM51fRYY= +k8s.io/api v0.36.2/go.mod h1:F4LbMO4brjZYh7yFkXWhynSvtB7YauxV4c+HHkNRGNg= +k8s.io/apimachinery v0.36.2 h1:0PE/W/WNy1UX61NLbXY5TMbJ6UwLL6E6lAPkYrKFxbQ= +k8s.io/apimachinery v0.36.2/go.mod h1:fvf/HOLXq9RId0rnDIbN1OEBvHXdQbLMM8nu0LcBUf4= +k8s.io/client-go v0.36.2 h1:bfgxmFKc9CgqsgX4xKLAAdmTQlWee7Ob/HlDOrJ5TBI= +k8s.io/client-go v0.36.2/go.mod h1:1vgO4OAlfPnoLcb+Rze2GF5rAr14w8qjrYMoyXJzQj0= +k8s.io/klog/v2 v2.140.0 h1:Tf+J3AH7xnUzZyVVXhTgGhEKnFqye14aadWv7bzXdzc= +k8s.io/klog/v2 v2.140.0/go.mod h1:o+/RWfJ6PwpnFn7OyAG3QnO47BFsymfEfrz6XyYSSp0= +k8s.io/kube-openapi v0.0.0-20260317180543-43fb72c5454a h1:xCeOEAOoGYl2jnJoHkC3hkbPJgdATINPMAxaynU2Ovg= +k8s.io/kube-openapi v0.0.0-20260317180543-43fb72c5454a/go.mod h1:uGBT7iTA6c6MvqUvSXIaYZo9ukscABYi2btjhvgKGZ0= +k8s.io/utils v0.0.0-20260210185600-b8788abfbbc2 h1:AZYQSJemyQB5eRxqcPky+/7EdBj0xi3g0ZcxxJ7vbWU= +k8s.io/utils v0.0.0-20260210185600-b8788abfbbc2/go.mod h1:xDxuJ0whA3d0I4mf/C4ppKHxXynQ+fxnkmQH0vTHnuk= mvdan.cc/gofumpt v0.9.2 h1:zsEMWL8SVKGHNztrx6uZrXdp7AX8r421Vvp23sz7ik4= mvdan.cc/gofumpt v0.9.2/go.mod h1:iB7Hn+ai8lPvofHd9ZFGVg2GOr8sBUw1QUWjNbmIL/s= mvdan.cc/unparam v0.0.0-20251027182757-5beb8c8f8f15 h1:ssMzja7PDPJV8FStj7hq9IKiuiKhgz9ErWw+m68e7DI= @@ -1122,7 +1122,7 @@ sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730 h1:IpInykpT6ceI+QxKBbEflcR5E sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730/go.mod h1:mdzfpAEoE6DHQEN0uh9ZbOCuHbLK5wOm7dK4ctXE9Tg= sigs.k8s.io/randfill v1.0.0 h1:JfjMILfT8A6RbawdsK2JXGBR5AQVfd+9TbzrlneTyrU= sigs.k8s.io/randfill v1.0.0/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY= -sigs.k8s.io/structured-merge-diff/v6 v6.3.0 h1:jTijUJbW353oVOd9oTlifJqOGEkUw2jB/fXCbTiQEco= -sigs.k8s.io/structured-merge-diff/v6 v6.3.0/go.mod h1:M3W8sfWvn2HhQDIbGWj3S099YozAsymCo/wrT5ohRUE= +sigs.k8s.io/structured-merge-diff/v6 v6.3.2 h1:kwVWMx5yS1CrnFWA/2QHyRVJ8jM6dBA80uLmm0wJkk8= +sigs.k8s.io/structured-merge-diff/v6 v6.3.2/go.mod h1:M3W8sfWvn2HhQDIbGWj3S099YozAsymCo/wrT5ohRUE= sigs.k8s.io/yaml v1.6.0 h1:G8fkbMSAFqgEFgh4b1wmtzDnioxFCUgTZhlbj5P9QYs= sigs.k8s.io/yaml v1.6.0/go.mod h1:796bPqUfzR/0jLAl6XjHl3Ck7MiyVv8dbTdyT3/pMf4=