Skip to content

Commit a58c462

Browse files
committed
refactor(credential): Add Int64Flag for priority
1 parent 30c509d commit a58c462

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

cmd/browsers.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,12 @@ type BoolFlag struct {
108108
Value bool
109109
}
110110

111+
// Int64Flag captures whether an int64 flag was set explicitly and its value.
112+
type Int64Flag struct {
113+
Set bool
114+
Value int64
115+
}
116+
111117
// Regular expression to validate CUID2 identifiers (24 lowercase alphanumeric characters).
112118
var cuidRegex = regexp.MustCompile(`^[a-z0-9]{24}$`)
113119

cmd/credential_providers.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ type CredentialProvidersUpdateInput struct {
4848
Token string
4949
CacheTtlSeconds int64
5050
Enabled BoolFlag
51-
Priority int64
51+
Priority Int64Flag
5252
Output string
5353
}
5454

@@ -200,8 +200,8 @@ func (c CredentialProvidersCmd) Update(ctx context.Context, in CredentialProvide
200200
if in.Enabled.Set {
201201
params.UpdateCredentialProviderRequest.Enabled = kernel.Opt(in.Enabled.Value)
202202
}
203-
if in.Priority > 0 {
204-
params.UpdateCredentialProviderRequest.Priority = kernel.Opt(in.Priority)
203+
if in.Priority.Set {
204+
params.UpdateCredentialProviderRequest.Priority = kernel.Opt(in.Priority.Value)
205205
}
206206

207207
if in.Output != "json" {
@@ -436,7 +436,7 @@ func runCredentialProvidersUpdate(cmd *cobra.Command, args []string) error {
436436
Token: token,
437437
CacheTtlSeconds: cacheTtl,
438438
Enabled: BoolFlag{Set: cmd.Flags().Changed("enabled"), Value: enabled},
439-
Priority: priority,
439+
Priority: Int64Flag{Set: cmd.Flags().Changed("priority"), Value: priority},
440440
Output: output,
441441
})
442442
}

0 commit comments

Comments
 (0)