Skip to content

Commit 6c43584

Browse files
committed
feat(credentials): fixed linter issues
1 parent efd3756 commit 6c43584

File tree

8 files changed

+15
-24
lines changed

8 files changed

+15
-24
lines changed

internal/cmd/beta/alb/credentials/create/create.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package create
22

33
import (
4+
"bytes"
45
"context"
56
"encoding/json"
67
"fmt"
@@ -110,7 +111,7 @@ func readPassword() (string, error) {
110111
return "", fmt.Errorf("cannot read password: %w", err)
111112
}
112113
fmt.Println()
113-
if string(password) != string(confirmation) {
114+
if bytes.Equal(password, confirmation) {
114115
return "", fmt.Errorf("the password and the confirmation do not match")
115116
}
116117

internal/cmd/beta/alb/credentials/create/create_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ type testCtxKey struct{}
1818
var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo")
1919
var testClient = &alb.APIClient{}
2020

21-
const passwordFlag = "password"
22-
2321
var (
2422
testProjectId = uuid.NewString()
2523
testRegion = "eu01"

internal/cmd/beta/alb/credentials/delete/delete.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
)
1616

1717
const (
18-
credentialRefArg = "CREDENTIAL_REF"
18+
credentialRefArg = "CREDENTIAL_REF" // nolint:gosec // false alert, this are not valid credentials
1919
)
2020

2121
type inputModel struct {

internal/cmd/beta/alb/credentials/delete/delete_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,9 @@ func TestParseInput(t *testing.T) {
9898
isValid: false,
9999
},
100100
{
101-
description: "no flags",
102-
argValues: fixtureArgValues(),
103-
flagValues: map[string]string{
101+
description: "no flags",
102+
argValues: fixtureArgValues(),
103+
flagValues: map[string]string{
104104
globalflags.ProjectIdFlag: testProjectId,
105105
globalflags.RegionFlag: testRegion,
106106
},

internal/cmd/beta/alb/credentials/describe/describe.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import (
2020
)
2121

2222
const (
23-
credentialRefArg = "CREDENTIAL_REF_ARG"
23+
credentialRefArg = "CREDENTIAL_REF" // nolint:gosec // false alert, this are not valid credentials
2424
)
2525

2626
type inputModel struct {
@@ -67,13 +67,9 @@ func NewCmd(p *print.Printer) *cobra.Command {
6767
return nil
6868
},
6969
}
70-
configureFlags(cmd)
7170
return cmd
7271
}
7372

74-
func configureFlags(cmd *cobra.Command) {
75-
}
76-
7773
func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inputModel, error) {
7874
globalFlags := globalflags.Parse(p, cmd)
7975

internal/cmd/beta/alb/credentials/list/list.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,6 @@ func outputResult(p *print.Printer, outputFormat string, items []alb.Credentials
149149
table.SetHeader("CREDENTIAL REF", "DISPLAYNAME", "USERNAME", "REGION")
150150

151151
for _, item := range items {
152-
153152
table.AddRow(
154153
utils.PtrString(item.CredentialsRef),
155154
utils.PtrString(item.DisplayName),

internal/cmd/beta/alb/credentials/list/list_test.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,10 @@ func TestParseInput(t *testing.T) {
110110
isValid: false,
111111
},
112112
{
113-
description: "label selector empty",
114-
flagValues: fixtureFlagValues(func(flagValues map[string]string) {
115-
}),
116-
isValid: true,
117-
expectedModel: fixtureInputModel(func(inputModel *inputModel) {
118-
}),
113+
description: "label selector empty",
114+
flagValues: fixtureFlagValues(),
115+
isValid: true,
116+
expectedModel: fixtureInputModel(),
119117
},
120118
}
121119

internal/cmd/beta/alb/credentials/update/update.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package update
22

33
import (
4+
"bytes"
45
"context"
56
"encoding/json"
67
"fmt"
@@ -20,13 +21,13 @@ import (
2021
"github.com/stackitcloud/stackit-sdk-go/services/alb"
2122
)
2223

23-
const passwordEnv = "ALB_CREDENTIALS_PASSWORD"
24+
const passwordEnv = "ALB_CREDENTIALS_PASSWORD" //nolint:gosec // false alert, this are not valid credentials
2425

2526
const (
2627
usernameFlag = "username"
2728
displaynameFlag = "displayname"
2829
passwordFlag = "password"
29-
credentialRefArg = "CREDENTIAL_REF_ARG"
30+
credentialRefArg = "CREDENTIAL_REF_ARG" //nolint:gosec // false alert, this are not valid credentials
3031
)
3132

3233
type inputModel struct {
@@ -99,7 +100,6 @@ func configureFlags(cmd *cobra.Command) {
99100
cmd.Flags().StringP(usernameFlag, "u", "", "the username for the credentials")
100101
cmd.Flags().StringP(displaynameFlag, "d", "", "the displayname for the credentials")
101102
cmd.Flags().BoolP(passwordFlag, "w", false, "change the password for the credentials")
102-
103103
}
104104

105105
func buildRequest(ctx context.Context, model *inputModel, apiClient *alb.APIClient, readPassword func() (string, error)) (req alb.ApiUpdateCredentialsRequest, err error) {
@@ -138,14 +138,13 @@ func readPassword() (string, error) {
138138
return "", fmt.Errorf("cannot read password: %w", err)
139139
}
140140
fmt.Println()
141-
if string(password) != string(confirmation) {
141+
if bytes.Equal(password, confirmation) {
142142
return "", fmt.Errorf("the password and the confirmation do not match")
143143
}
144144

145145
return string(password), nil
146146
}
147147
func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) inputModel {
148-
149148
model := inputModel{
150149
GlobalFlagModel: globalflags.Parse(p, cmd),
151150
Username: flags.FlagToStringPointer(p, cmd, usernameFlag),

0 commit comments

Comments
 (0)