Skip to content

Commit ecb85c2

Browse files
author
Yago Carlos Fernandez Gou
committed
address review comments: be able to configure custom endpoints
1 parent a4efb91 commit ecb85c2

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

internal/cmd/config/set/set.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ const (
4646
sqlServerFlexCustomEndpointFlag = "sqlserverflex-custom-endpoint"
4747
iaasCustomEndpointFlag = "iaas-custom-endpoint"
4848
tokenCustomEndpointFlag = "token-custom-endpoint"
49+
intakeCustomEndpointFlag = "intake-custom-endpoint"
4950
)
5051

5152
type inputModel struct {
@@ -159,6 +160,7 @@ func configureFlags(cmd *cobra.Command) {
159160
cmd.Flags().String(sqlServerFlexCustomEndpointFlag, "", "SQLServer Flex API base URL, used in calls to this API")
160161
cmd.Flags().String(iaasCustomEndpointFlag, "", "IaaS API base URL, used in calls to this API")
161162
cmd.Flags().String(tokenCustomEndpointFlag, "", "Custom token endpoint of the Service Account API, which is used to request access tokens when the service account authentication is activated. Not relevant for user authentication.")
163+
cmd.Flags().String(intakeCustomEndpointFlag, "", "Intake API base URL, used in calls to this API")
162164

163165
err := viper.BindPFlag(config.SessionTimeLimitKey, cmd.Flags().Lookup(sessionTimeLimitFlag))
164166
cobra.CheckErr(err)
@@ -215,6 +217,8 @@ func configureFlags(cmd *cobra.Command) {
215217
cobra.CheckErr(err)
216218
err = viper.BindPFlag(config.TokenCustomEndpointKey, cmd.Flags().Lookup(tokenCustomEndpointFlag))
217219
cobra.CheckErr(err)
220+
err = viper.BindPFlag(config.IntakeCustomEndpointKey, cmd.Flags().Lookup(intakeCustomEndpointFlag))
221+
cobra.CheckErr(err)
218222
}
219223

220224
func parseInput(p *print.Printer, cmd *cobra.Command) (*inputModel, error) {

internal/cmd/config/unset/unset.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ const (
5050
sqlServerFlexCustomEndpointFlag = "sqlserverflex-custom-endpoint"
5151
iaasCustomEndpointFlag = "iaas-custom-endpoint"
5252
tokenCustomEndpointFlag = "token-custom-endpoint"
53+
intakeCustomEndpointFlag = "intake-custom-endpoint"
5354
)
5455

5556
type inputModel struct {
@@ -87,6 +88,7 @@ type inputModel struct {
8788
SQLServerFlexCustomEndpoint bool
8889
IaaSCustomEndpoint bool
8990
TokenCustomEndpoint bool
91+
IntakeCustomEndpoint bool
9092
}
9193

9294
func NewCmd(params *params.CmdParams) *cobra.Command {
@@ -207,6 +209,9 @@ func NewCmd(params *params.CmdParams) *cobra.Command {
207209
if model.TokenCustomEndpoint {
208210
viper.Set(config.TokenCustomEndpointKey, "")
209211
}
212+
if model.IntakeCustomEndpoint {
213+
viper.Set(config.IntakeCustomEndpointKey, "")
214+
}
210215

211216
err := config.Write()
212217
if err != nil {
@@ -254,6 +259,7 @@ func configureFlags(cmd *cobra.Command) {
254259
cmd.Flags().Bool(sqlServerFlexCustomEndpointFlag, false, "SQLServer Flex API base URL. If unset, uses the default base URL")
255260
cmd.Flags().Bool(iaasCustomEndpointFlag, false, "IaaS API base URL. If unset, uses the default base URL")
256261
cmd.Flags().Bool(tokenCustomEndpointFlag, false, "Custom token endpoint of the Service Account API, which is used to request access tokens when the service account authentication is activated. Not relevant for user authentication.")
262+
cmd.Flags().Bool(intakeCustomEndpointFlag, false, "Intake API base URL. If unset, uses the default base URL")
257263
}
258264

259265
func parseInput(p *print.Printer, cmd *cobra.Command) *inputModel {
@@ -292,6 +298,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command) *inputModel {
292298
SQLServerFlexCustomEndpoint: flags.FlagToBoolValue(p, cmd, sqlServerFlexCustomEndpointFlag),
293299
IaaSCustomEndpoint: flags.FlagToBoolValue(p, cmd, iaasCustomEndpointFlag),
294300
TokenCustomEndpoint: flags.FlagToBoolValue(p, cmd, tokenCustomEndpointFlag),
301+
IntakeCustomEndpoint: flags.FlagToBoolValue(p, cmd, intakeCustomEndpointFlag),
295302
}
296303

297304
if p.IsVerbosityDebug() {

internal/cmd/config/unset/unset_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ func fixtureFlagValues(mods ...func(flagValues map[string]bool)) map[string]bool
4343
sqlServerFlexCustomEndpointFlag: true,
4444
iaasCustomEndpointFlag: true,
4545
tokenCustomEndpointFlag: true,
46+
intakeCustomEndpointFlag: true,
4647
}
4748
for _, mod := range mods {
4849
mod(flagValues)
@@ -82,6 +83,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
8283
SQLServerFlexCustomEndpoint: true,
8384
IaaSCustomEndpoint: true,
8485
TokenCustomEndpoint: true,
86+
IntakeCustomEndpoint: true,
8587
}
8688
for _, mod := range mods {
8789
mod(model)
@@ -137,6 +139,7 @@ func TestParseInput(t *testing.T) {
137139
model.SQLServerFlexCustomEndpoint = false
138140
model.IaaSCustomEndpoint = false
139141
model.TokenCustomEndpoint = false
142+
model.IntakeCustomEndpoint = false
140143
}),
141144
},
142145
{

0 commit comments

Comments
 (0)