Skip to content

Commit 8d715ce

Browse files
authored
Add sqlserverflex client and configuration logic (and instance list command) (#345)
* Setup client and config for new sqlserverflex commands * Implement sqlserverflex instance list command * Generate docs
1 parent cb4912b commit 8d715ce

File tree

18 files changed

+590
-4
lines changed

18 files changed

+590
-4
lines changed

docs/stackit.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,5 @@ stackit [flags]
4545
* [stackit secrets-manager](./stackit_secrets-manager.md) - Provides functionality for Secrets Manager
4646
* [stackit service-account](./stackit_service-account.md) - Provides functionality for service accounts
4747
* [stackit ske](./stackit_ske.md) - Provides functionality for SKE
48+
* [stackit sqlserverflex](./stackit_sqlserverflex.md) - Provides functionality for SQLServer Flex
4849

docs/stackit_config_set.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ stackit config set [flags]
4747
--service-account-custom-endpoint string Service Account API base URL, used in calls to this API
4848
--session-time-limit string Maximum time before authentication is required again. After this time, you will be prompted to login again to execute commands that require authentication. Can't be larger than 24h. Requires authentication after being set to take effect. Examples: 3h, 5h30m40s (BETA: currently values greater than 2h have no effect)
4949
--ske-custom-endpoint string SKE API base URL, used in calls to this API
50+
--sqlserverflex-custom-endpoint string SQLServer Flex API base URL, used in calls to this API
5051
```
5152

5253
### Options inherited from parent commands

docs/stackit_config_unset.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ stackit config unset [flags]
4747
--service-account-custom-endpoint SKE API base URL. If unset, uses the default base URL
4848
--session-time-limit Maximum time before authentication is required again. If unset, defaults to 2h
4949
--ske-custom-endpoint SKE API base URL. If unset, uses the default base URL
50+
--sqlserverflex-custom-endpoint SQLServer Flex API base URL. If unset, uses the default base URL
5051
--verbosity Verbosity of the CLI
5152
```
5253

docs/stackit_sqlserverflex.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
## stackit sqlserverflex
2+
3+
Provides functionality for SQLServer Flex
4+
5+
### Synopsis
6+
7+
Provides functionality for SQLServer Flex.
8+
9+
```
10+
stackit sqlserverflex [flags]
11+
```
12+
13+
### Options
14+
15+
```
16+
-h, --help Help for "stackit sqlserverflex"
17+
```
18+
19+
### Options inherited from parent commands
20+
21+
```
22+
-y, --assume-yes If set, skips all confirmation prompts
23+
--async If set, runs the command asynchronously
24+
-o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"]
25+
-p, --project-id string Project ID
26+
--verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info")
27+
```
28+
29+
### SEE ALSO
30+
31+
* [stackit](./stackit.md) - Manage STACKIT resources using the command line
32+
* [stackit sqlserverflex instance](./stackit_sqlserverflex_instance.md) - Provides functionality for SQLServer Flex instances
33+
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
## stackit sqlserverflex instance
2+
3+
Provides functionality for SQLServer Flex instances
4+
5+
### Synopsis
6+
7+
Provides functionality for SQLServer Flex instances.
8+
9+
```
10+
stackit sqlserverflex instance [flags]
11+
```
12+
13+
### Options
14+
15+
```
16+
-h, --help Help for "stackit sqlserverflex instance"
17+
```
18+
19+
### Options inherited from parent commands
20+
21+
```
22+
-y, --assume-yes If set, skips all confirmation prompts
23+
--async If set, runs the command asynchronously
24+
-o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"]
25+
-p, --project-id string Project ID
26+
--verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info")
27+
```
28+
29+
### SEE ALSO
30+
31+
* [stackit sqlserverflex](./stackit_sqlserverflex.md) - Provides functionality for SQLServer Flex
32+
* [stackit sqlserverflex instance list](./stackit_sqlserverflex_instance_list.md) - Lists all SQLServer Flex instances
33+
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
## stackit sqlserverflex instance list
2+
3+
Lists all SQLServer Flex instances
4+
5+
### Synopsis
6+
7+
Lists all SQLServer Flex instances.
8+
9+
```
10+
stackit sqlserverflex instance list [flags]
11+
```
12+
13+
### Examples
14+
15+
```
16+
List all SQLServer Flex instances
17+
$ stackit sqlserverflex instance list
18+
19+
List all SQLServer Flex instances in JSON format
20+
$ stackit sqlserverflex instance list --output-format json
21+
22+
List up to 10 SQLServer Flex instances
23+
$ stackit sqlserverflex instance list --limit 10
24+
```
25+
26+
### Options
27+
28+
```
29+
-h, --help Help for "stackit sqlserverflex instance list"
30+
--limit int Maximum number of entries to list
31+
```
32+
33+
### Options inherited from parent commands
34+
35+
```
36+
-y, --assume-yes If set, skips all confirmation prompts
37+
--async If set, runs the command asynchronously
38+
-o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"]
39+
-p, --project-id string Project ID
40+
--verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info")
41+
```
42+
43+
### SEE ALSO
44+
45+
* [stackit sqlserverflex instance](./stackit_sqlserverflex_instance.md) - Provides functionality for SQLServer Flex instances
46+

go.mod

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ module github.com/stackitcloud/stackit-cli
33
go 1.22
44

55
require (
6+
github.com/fatih/color v1.14.1
67
github.com/goccy/go-yaml v1.11.3
78
github.com/golang-jwt/jwt/v5 v5.2.1
89
github.com/google/go-cmp v0.6.0
@@ -24,6 +25,7 @@ require (
2425
github.com/stackitcloud/stackit-sdk-go/services/secretsmanager v0.7.0
2526
github.com/stackitcloud/stackit-sdk-go/services/serviceaccount v0.4.0
2627
github.com/stackitcloud/stackit-sdk-go/services/ske v0.15.0
28+
github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex v0.2.0
2729
github.com/zalando/go-keyring v0.2.4
2830
golang.org/x/mod v0.17.0
2931
golang.org/x/oauth2 v0.20.0
@@ -40,7 +42,6 @@ require (
4042
)
4143

4244
require (
43-
github.com/fatih/color v1.14.1 // indirect
4445
github.com/mattn/go-isatty v0.0.17 // indirect
4546
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
4647
)

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,8 @@ github.com/stackitcloud/stackit-sdk-go/services/serviceaccount v0.4.0 h1:JB1O0E9
156156
github.com/stackitcloud/stackit-sdk-go/services/serviceaccount v0.4.0/go.mod h1:Ni9RBJvcaXRIrDIuQBpJcuQvCQSj27crQSyc+WM4p0c=
157157
github.com/stackitcloud/stackit-sdk-go/services/ske v0.15.0 h1:7iTzdiglvJmKMaHlr4JUPvNOmA730rAniry74cnZ8zI=
158158
github.com/stackitcloud/stackit-sdk-go/services/ske v0.15.0/go.mod h1:0fFs4R7kg+gU7FNAIzzFvlCZJz6gyZ8CFhbK3eSrAwQ=
159+
github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex v0.2.0 h1:aIXxXx6u4+6C02MPb+hdItigeKeen7m+hEEG+Ej9sNs=
160+
github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex v0.2.0/go.mod h1:fQJOQMfasStZ8J9iGX0vTjyJoQtLqMXJ5Npb03QJk84=
159161
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
160162
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
161163
github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c=

internal/cmd/config/set/set.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ const (
3535
secretsManagerCustomEndpointFlag = "secrets-manager-custom-endpoint"
3636
serviceAccountCustomEndpointFlag = "service-account-custom-endpoint"
3737
skeCustomEndpointFlag = "ske-custom-endpoint"
38+
sqlServerFlexCustomEndpointFlag = "sqlserverflex-custom-endpoint"
3839
)
3940

4041
type inputModel struct {
@@ -139,6 +140,7 @@ func configureFlags(cmd *cobra.Command) {
139140
cmd.Flags().String(secretsManagerCustomEndpointFlag, "", "Secrets Manager API base URL, used in calls to this API")
140141
cmd.Flags().String(serviceAccountCustomEndpointFlag, "", "Service Account API base URL, used in calls to this API")
141142
cmd.Flags().String(skeCustomEndpointFlag, "", "SKE API base URL, used in calls to this API")
143+
cmd.Flags().String(sqlServerFlexCustomEndpointFlag, "", "SQLServer Flex API base URL, used in calls to this API")
142144

143145
err := viper.BindPFlag(config.ArgusCustomEndpointKey, cmd.Flags().Lookup(argusCustomEndpointFlag))
144146
cobra.CheckErr(err)
@@ -160,6 +162,10 @@ func configureFlags(cmd *cobra.Command) {
160162
cobra.CheckErr(err)
161163
err = viper.BindPFlag(config.PostgresFlexCustomEndpointKey, cmd.Flags().Lookup(postgresFlexCustomEndpointFlag))
162164
cobra.CheckErr(err)
165+
err = viper.BindPFlag(config.RabbitMQCustomEndpointKey, cmd.Flags().Lookup(rabbitMQCustomEndpointFlag))
166+
cobra.CheckErr(err)
167+
err = viper.BindPFlag(config.RedisCustomEndpointKey, cmd.Flags().Lookup(redisCustomEndpointFlag))
168+
cobra.CheckErr(err)
163169
err = viper.BindPFlag(config.ResourceManagerEndpointKey, cmd.Flags().Lookup(skeCustomEndpointFlag))
164170
cobra.CheckErr(err)
165171
err = viper.BindPFlag(config.SecretsManagerCustomEndpointKey, cmd.Flags().Lookup(secretsManagerCustomEndpointFlag))
@@ -168,9 +174,7 @@ func configureFlags(cmd *cobra.Command) {
168174
cobra.CheckErr(err)
169175
err = viper.BindPFlag(config.SKECustomEndpointKey, cmd.Flags().Lookup(skeCustomEndpointFlag))
170176
cobra.CheckErr(err)
171-
err = viper.BindPFlag(config.RedisCustomEndpointKey, cmd.Flags().Lookup(redisCustomEndpointFlag))
172-
cobra.CheckErr(err)
173-
err = viper.BindPFlag(config.RabbitMQCustomEndpointKey, cmd.Flags().Lookup(rabbitMQCustomEndpointFlag))
177+
err = viper.BindPFlag(config.SQLServerFlexCustomEndpointKey, cmd.Flags().Lookup(sqlServerFlexCustomEndpointFlag))
174178
cobra.CheckErr(err)
175179
}
176180

internal/cmd/config/unset/unset.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ const (
3838
secretsManagerCustomEndpointFlag = "secrets-manager-custom-endpoint"
3939
serviceAccountCustomEndpointFlag = "service-account-custom-endpoint"
4040
skeCustomEndpointFlag = "ske-custom-endpoint"
41+
sqlServerFlexCustomEndpointFlag = "sqlserverflex-custom-endpoint"
4142
)
4243

4344
type inputModel struct {
@@ -63,6 +64,7 @@ type inputModel struct {
6364
SecretsManagerCustomEndpoint bool
6465
ServiceAccountCustomEndpoint bool
6566
SKECustomEndpoint bool
67+
SQLServerFlexCustomEndpoint bool
6668
}
6769

6870
func NewCmd(p *print.Printer) *cobra.Command {
@@ -149,6 +151,9 @@ func NewCmd(p *print.Printer) *cobra.Command {
149151
if model.SKECustomEndpoint {
150152
viper.Set(config.SKECustomEndpointKey, "")
151153
}
154+
if model.SQLServerFlexCustomEndpoint {
155+
viper.Set(config.SQLServerFlexCustomEndpointKey, "")
156+
}
152157

153158
err := config.Write()
154159
if err != nil {
@@ -184,6 +189,7 @@ func configureFlags(cmd *cobra.Command) {
184189
cmd.Flags().Bool(secretsManagerCustomEndpointFlag, false, "Secrets Manager API base URL. If unset, uses the default base URL")
185190
cmd.Flags().Bool(serviceAccountCustomEndpointFlag, false, "SKE API base URL. If unset, uses the default base URL")
186191
cmd.Flags().Bool(skeCustomEndpointFlag, false, "SKE API base URL. If unset, uses the default base URL")
192+
cmd.Flags().Bool(sqlServerFlexCustomEndpointFlag, false, "SQLServer Flex API base URL. If unset, uses the default base URL")
187193
}
188194

189195
func parseInput(p *print.Printer, cmd *cobra.Command) *inputModel {
@@ -210,6 +216,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command) *inputModel {
210216
SecretsManagerCustomEndpoint: flags.FlagToBoolValue(p, cmd, secretsManagerCustomEndpointFlag),
211217
ServiceAccountCustomEndpoint: flags.FlagToBoolValue(p, cmd, serviceAccountCustomEndpointFlag),
212218
SKECustomEndpoint: flags.FlagToBoolValue(p, cmd, skeCustomEndpointFlag),
219+
SQLServerFlexCustomEndpoint: flags.FlagToBoolValue(p, cmd, sqlServerFlexCustomEndpointFlag),
213220
}
214221

215222
if p.IsVerbosityDebug() {

0 commit comments

Comments
 (0)