Skip to content

Commit a7a41c4

Browse files
author
Alexandre Catalan
committed
feat(config): support registry-custom-endpoint in config set and unset
1 parent 8f33dc1 commit a7a41c4

6 files changed

Lines changed: 17 additions & 0 deletions

File tree

‎docs/stackit_config_set.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ stackit config set [flags]
5454
--postgresflex-custom-endpoint string PostgreSQL Flex API base URL, used in calls to this API
5555
--rabbitmq-custom-endpoint string RabbitMQ API base URL, used in calls to this API
5656
--redis-custom-endpoint string Redis API base URL, used in calls to this API
57+
--registry-custom-endpoint string Registry API base URL, used in calls to this API
5758
--resource-manager-custom-endpoint string Resource Manager API base URL, used in calls to this API
5859
--runcommand-custom-endpoint string Run Command API base URL, used in calls to this API
5960
--secrets-manager-custom-endpoint string Secrets Manager API base URL, used in calls to this API

‎docs/stackit_config_unset.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ stackit config unset [flags]
5656
--rabbitmq-custom-endpoint RabbitMQ API base URL. If unset, uses the default base URL
5757
--redis-custom-endpoint Redis API base URL. If unset, uses the default base URL
5858
--region Region
59+
--registry-custom-endpoint Registry API base URL. If unset, uses the default base URL
5960
--resource-manager-custom-endpoint Resource Manager API base URL. If unset, uses the default base URL
6061
--runcommand-custom-endpoint Server Command base URL. If unset, uses the default base URL
6162
--secrets-manager-custom-endpoint Secrets Manager API base URL. If unset, uses the default base URL

‎internal/cmd/config/profile/import/template/profile.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"project_name": "",
2121
"rabbitmq_custom_endpoint": "",
2222
"redis_custom_endpoint": "",
23+
"registry_custom_endpoint": "",
2324
"resource_manager_custom_endpoint": "",
2425
"runcommand_custom_endpoint": "",
2526
"secrets_manager_custom_endpoint": "",

‎internal/cmd/config/set/set.go‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ const (
5757
sfsCustomEndpointFlag = "sfs-custom-endpoint"
5858
cdnCustomEndpointFlag = "cdn-custom-endpoint"
5959
vpnCustomEndpointFlag = "vpn-custom-endpoint"
60+
registryCustomEndpointFlag = "registry-custom-endpoint"
6061
)
6162

6263
type inputModel struct {
@@ -180,6 +181,7 @@ func configureFlags(cmd *cobra.Command) {
180181
cmd.Flags().String(sfsCustomEndpointFlag, "", "SFS API base URL, used in calls to this API")
181182
cmd.Flags().String(cdnCustomEndpointFlag, "", "CDN API base URL, used in calls to this API")
182183
cmd.Flags().String(vpnCustomEndpointFlag, "", "VPN API base URL, used in calls to this API")
184+
cmd.Flags().String(registryCustomEndpointFlag, "", "Registry API base URL, used in calls to this API")
183185

184186
err := viper.BindPFlag(config.SessionTimeLimitKey, cmd.Flags().Lookup(sessionTimeLimitFlag))
185187
cobra.CheckErr(err)
@@ -256,6 +258,8 @@ func configureFlags(cmd *cobra.Command) {
256258
cobra.CheckErr(err)
257259
err = viper.BindPFlag(config.VPNCustomEndpointKey, cmd.Flags().Lookup(vpnCustomEndpointFlag))
258260
cobra.CheckErr(err)
261+
err = viper.BindPFlag(config.RegistryCustomEndpointKey, cmd.Flags().Lookup(registryCustomEndpointFlag))
262+
cobra.CheckErr(err)
259263
}
260264

261265
func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, error) {

‎internal/cmd/config/unset/unset.go‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ const (
6060
logsCustomEndpointFlag = "logs-custom-endpoint"
6161
cdnCustomEndpointFlag = "cdn-custom-endpoint"
6262
vpnCustomEndpointFlag = "vpn-custom-endpoint"
63+
registryCustomEndpointFlag = "registry-custom-endpoint"
6364
)
6465

6566
var (
@@ -113,6 +114,7 @@ type inputModel struct {
113114
LogsCustomEndpoint bool
114115
CDNCustomEndpoint bool
115116
VpnCustomEndpoint bool
117+
RegistryCustomEndpoint bool
116118
}
117119

118120
func NewCmd(params *types.CmdParams) *cobra.Command {
@@ -266,6 +268,9 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
266268
if model.VpnCustomEndpoint {
267269
viper.Set(config.VPNCustomEndpointKey, "")
268270
}
271+
if model.RegistryCustomEndpoint {
272+
viper.Set(config.RegistryCustomEndpointKey, "")
273+
}
269274

270275
err := config.Write()
271276
if err != nil {
@@ -324,6 +329,7 @@ func configureFlags(cmd *cobra.Command) {
324329
cmd.Flags().Bool(sfsCustomEndpointFlag, false, "SFS API base URL. If unset, uses the default base URL")
325330
cmd.Flags().Bool(cdnCustomEndpointFlag, false, "Custom CDN endpoint URL. If unset, uses the default base URL")
326331
cmd.Flags().Bool(vpnCustomEndpointFlag, false, "VPN API base URL. If unset, uses the default base URL")
332+
cmd.Flags().Bool(registryCustomEndpointFlag, false, "Registry API base URL. If unset, uses the default base URL")
327333
}
328334

329335
func parseInput(p *print.Printer, cmd *cobra.Command) *inputModel {
@@ -373,6 +379,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command) *inputModel {
373379
LogsCustomEndpoint: flags.FlagToBoolValue(p, cmd, logsCustomEndpointFlag),
374380
CDNCustomEndpoint: flags.FlagToBoolValue(p, cmd, cdnCustomEndpointFlag),
375381
VpnCustomEndpoint: flags.FlagToBoolValue(p, cmd, vpnCustomEndpointFlag),
382+
RegistryCustomEndpoint: flags.FlagToBoolValue(p, cmd, registryCustomEndpointFlag),
376383
}
377384

378385
p.DebugInputModel(model)

‎internal/cmd/config/unset/unset_test.go‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ func fixtureFlagValues(mods ...func(flagValues map[string]bool)) map[string]bool
5252
logsCustomEndpointFlag: true,
5353
cdnCustomEndpointFlag: true,
5454
vpnCustomEndpointFlag: true,
55+
registryCustomEndpointFlag: true,
5556
}
5657
for _, mod := range mods {
5758
mod(flagValues)
@@ -102,6 +103,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
102103
LogsCustomEndpoint: true,
103104
CDNCustomEndpoint: true,
104105
VpnCustomEndpoint: true,
106+
RegistryCustomEndpoint: true,
105107
}
106108
for _, mod := range mods {
107109
mod(model)
@@ -168,6 +170,7 @@ func TestParseInput(t *testing.T) {
168170
model.LogsCustomEndpoint = false
169171
model.CDNCustomEndpoint = false
170172
model.VpnCustomEndpoint = false
173+
model.RegistryCustomEndpoint = false
171174
}),
172175
},
173176
{

0 commit comments

Comments
 (0)