Skip to content

Commit

Permalink
address lint warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
mustyantsev committed Jun 20, 2024
1 parent ce5e138 commit 7eebf4a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions service/pkg/util/redact.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ func RedactSensitiveData(i interface{}, sensitiveFields []string) interface{} {
}

func redact(v reflect.Value, sensitiveFields []string) reflect.Value {
//nolint:exhaustive

Check failure on line 15 in service/pkg/util/redact.go

View workflow job for this annotation

GitHub Actions / go (service)

directive `//nolint:exhaustive` should provide explanation such as `//nolint:exhaustive // this is why` (nolintlint)
switch v.Kind() {
case reflect.Ptr:
if v.IsNil() {
Expand Down
11 changes: 7 additions & 4 deletions service/pkg/util/redact_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,16 @@ func TestRedactSensitiveData_WithSensitiveFieldsInNestedStruct(t *testing.T) {
}`

var config Config
json.Unmarshal([]byte(rawConfig), &config)
err := json.Unmarshal([]byte(rawConfig), &config)
if err != nil {
t.Fatalf("Failed to unmarshal rawConfig: %v", err)
}

sensitiveFields := []string{"Password", "clientsecret"}
redacted := RedactSensitiveData(config, sensitiveFields)

redactedConfig, ok := redacted.(Config)
if !ok {
redactedConfig, ok1 := redacted.(Config)
if !ok1 {
t.Fatalf("Expected redacted data to be of type Config")
}

Expand All @@ -123,7 +126,7 @@ func TestRedactSensitiveData_WithSensitiveFieldsInNestedStruct(t *testing.T) {
}

for _, service := range redactedConfig.Services {
if clientSecret, ok := service.ExtraProps["clientsecret"]; ok && clientSecret != "REDACTED" {
if clientSecret, ok2 := service.ExtraProps["clientsecret"]; ok2 && clientSecret != "REDACTED" {
t.Errorf("Expected Services.ExtraProps.ClientSecret to be redacted")
}
}
Expand Down

0 comments on commit 7eebf4a

Please sign in to comment.