Skip to content

Commit 06e19e2

Browse files
authored
Fix staticcheck linter complains (#6159)
1 parent cfc04b3 commit 06e19e2

File tree

2 files changed

+33
-33
lines changed

2 files changed

+33
-33
lines changed

internal/k8s/appprotect/app_protect_configuration.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ const timeLayout = time.RFC3339
1717

1818
// reasons for invalidity
1919
const (
20-
failedValidationErrorMsg = "Validation Failed"
21-
missingUserSigErrorMsg = "Policy has unsatisfied signature requirements"
22-
duplicatedTagsErrorMsg = "Duplicate tag set"
23-
invalidTimestampErrorMsg = "Invalid timestamp"
20+
failedValidationErrorMsg = "validation failed"
21+
missingUserSigErrorMsg = "policy has unsatisfied signature requirements"
22+
duplicatedTagsErrorMsg = "duplicate tag set"
23+
invalidTimestampErrorMsg = "invalid timestamp"
2424
)
2525

2626
var (
@@ -399,25 +399,25 @@ func (ci *ConfigurationImpl) GetAppResource(kind, key string) (*unstructured.Uns
399399
}
400400
return nil, fmt.Errorf(obj.ErrorMsg)
401401
}
402-
return nil, fmt.Errorf("App Protect Policy %s not found", key)
402+
return nil, fmt.Errorf("app protect Policy %s not found", key)
403403
case LogConfGVK.Kind:
404404
if obj, ok := ci.LogConfs[key]; ok {
405405
if obj.IsValid {
406406
return obj.Obj, nil
407407
}
408408
return nil, fmt.Errorf(obj.ErrorMsg)
409409
}
410-
return nil, fmt.Errorf("App Protect LogConf %s not found", key)
410+
return nil, fmt.Errorf("app protect LogConf %s not found", key)
411411
case UserSigGVK.Kind:
412412
if obj, ok := ci.UserSigs[key]; ok {
413413
if obj.IsValid {
414414
return obj.Obj, nil
415415
}
416416
return nil, fmt.Errorf(obj.ErrorMsg)
417417
}
418-
return nil, fmt.Errorf("App Protect UserSig %s not found", key)
418+
return nil, fmt.Errorf("app protect UserSig %s not found", key)
419419
}
420-
return nil, fmt.Errorf("Unknown App Protect resource kind %s", kind)
420+
return nil, fmt.Errorf("unknown app protect resource kind %s", kind)
421421
}
422422

423423
// DeletePolicy deletes an App Protect Policy from App Protect Configuration
@@ -599,14 +599,14 @@ func (fc *FakeConfiguration) GetAppResource(kind, key string) (*unstructured.Uns
599599
if obj, ok := fc.Policies[key]; ok {
600600
return obj.Obj, nil
601601
}
602-
return nil, fmt.Errorf("App Protect Policy %s not found", key)
602+
return nil, fmt.Errorf("app protect Policy %s not found", key)
603603
case LogConfGVK.Kind:
604604
if obj, ok := fc.LogConfs[key]; ok {
605605
return obj.Obj, nil
606606
}
607-
return nil, fmt.Errorf("App Protect LogConf %s not found", key)
607+
return nil, fmt.Errorf("app protect LogConf %s not found", key)
608608
}
609-
return nil, fmt.Errorf("Unknown App Protect resource kind %s", kind)
609+
return nil, fmt.Errorf("unknown app protect resource kind %s", kind)
610610
}
611611

612612
// DeletePolicy deletes an App Protect Policy from App Protect Configuration

internal/k8s/appprotect/app_protect_configuration_test.go

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ func TestCreateAppProtectPolicyEx(t *testing.T) {
107107
expectedPolicyEx: &PolicyEx{
108108
SignatureReqs: nil,
109109
IsValid: false,
110-
ErrorMsg: "Invalid timestamp",
110+
ErrorMsg: "invalid timestamp",
111111
},
112112
wantErr: true,
113113
msg: "policy with invalid min timestamp",
@@ -131,7 +131,7 @@ func TestCreateAppProtectPolicyEx(t *testing.T) {
131131
expectedPolicyEx: &PolicyEx{
132132
SignatureReqs: nil,
133133
IsValid: false,
134-
ErrorMsg: "Invalid timestamp",
134+
ErrorMsg: "invalid timestamp",
135135
},
136136
wantErr: true,
137137
msg: "policy with invalid max timestamp",
@@ -145,7 +145,7 @@ func TestCreateAppProtectPolicyEx(t *testing.T) {
145145
expectedPolicyEx: &PolicyEx{
146146
SignatureReqs: nil,
147147
IsValid: false,
148-
ErrorMsg: "Validation Failed",
148+
ErrorMsg: "validation failed",
149149
},
150150
wantErr: true,
151151
msg: "policy empty spec",
@@ -563,7 +563,7 @@ func TestAddOrUpdatePolicy(t *testing.T) {
563563
Resource: &PolicyEx{
564564
Obj: invalidTestPolicy,
565565
IsValid: false,
566-
ErrorMsg: "Validation Failed",
566+
ErrorMsg: "validation failed",
567567
},
568568
Op: Delete,
569569
},
@@ -584,7 +584,7 @@ func TestAddOrUpdatePolicy(t *testing.T) {
584584
Resource: &PolicyEx{
585585
Obj: testPolicyUnsatisfied,
586586
IsValid: false,
587-
ErrorMsg: "Policy has unsatisfied signature requirements",
587+
ErrorMsg: "policy has unsatisfied signature requirements",
588588
SignatureReqs: []SignatureReq{
589589
{
590590
Tag: "test",
@@ -601,7 +601,7 @@ func TestAddOrUpdatePolicy(t *testing.T) {
601601
{
602602
Object: testPolicyUnsatisfied,
603603
Reason: "Rejected",
604-
Message: "Policy has unsatisfied signature requirements",
604+
Message: "policy has unsatisfied signature requirements",
605605
},
606606
},
607607
msg: "Missing sig reqs",
@@ -671,7 +671,7 @@ func TestAddOrUpdateLogConf(t *testing.T) {
671671
Resource: &LogConfEx{
672672
Obj: invalidLogConf,
673673
IsValid: false,
674-
ErrorMsg: "Validation Failed",
674+
ErrorMsg: "validation failed",
675675
},
676676
Op: Delete,
677677
},
@@ -802,7 +802,7 @@ func TestAddOrUpdateUserSig(t *testing.T) {
802802
appProtectConfiguration.Policies["testing/testpolicy"] = &PolicyEx{
803803
Obj: &unstructured.Unstructured{Object: map[string]interface{}{}},
804804
IsValid: false,
805-
ErrorMsg: "Policy has unsatisfied signature requirements",
805+
ErrorMsg: "policy has unsatisfied signature requirements",
806806
SignatureReqs: []SignatureReq{
807807
{
808808
Tag: "test3",
@@ -839,7 +839,7 @@ func TestAddOrUpdateUserSig(t *testing.T) {
839839
{
840840
Object: invalidTestUserSig2,
841841
Reason: "Rejected",
842-
Message: "Validation Failed",
842+
Message: "validation failed",
843843
},
844844
},
845845
msg: "validation failed",
@@ -854,7 +854,7 @@ func TestAddOrUpdateUserSig(t *testing.T) {
854854
expectedProblems: []Problem{
855855
{
856856
Object: testUserSigDupTag,
857-
Message: "Duplicate tag set",
857+
Message: "duplicate tag set",
858858
Reason: "Rejected",
859859
},
860860
},
@@ -870,7 +870,7 @@ func TestAddOrUpdateUserSig(t *testing.T) {
870870
expectedProblems: []Problem{
871871
{
872872
Object: testUserSig1Invalid,
873-
Message: "Validation Failed",
873+
Message: "validation failed",
874874
Reason: "Rejected",
875875
},
876876
},
@@ -1061,7 +1061,7 @@ func TestDeleteUserSig(t *testing.T) {
10611061
expectedProblems: []Problem{
10621062
{
10631063
Reason: "Rejected",
1064-
Message: "Policy has unsatisfied signature requirements",
1064+
Message: "policy has unsatisfied signature requirements",
10651065
Object: &unstructured.Unstructured{
10661066
Object: map[string]interface{}{},
10671067
},
@@ -1107,14 +1107,14 @@ func TestGetAppProtectResource(t *testing.T) {
11071107
kind: "APPolicy",
11081108
key: "testing/test2",
11091109
wantErr: true,
1110-
errMsg: "Validation Failed",
1110+
errMsg: "validation failed",
11111111
msg: "Policy, Negative, invalid object",
11121112
},
11131113
{
11141114
kind: "APPolicy",
11151115
key: "testing/test3",
11161116
wantErr: true,
1117-
errMsg: "App Protect Policy testing/test3 not found",
1117+
errMsg: "app protect Policy testing/test3 not found",
11181118
msg: "Policy, Negative, Object Does not exist",
11191119
},
11201120
{
@@ -1127,14 +1127,14 @@ func TestGetAppProtectResource(t *testing.T) {
11271127
kind: "APLogConf",
11281128
key: "testing/test2",
11291129
wantErr: true,
1130-
errMsg: "Validation Failed",
1130+
errMsg: "validation failed",
11311131
msg: "LogConf, Negative, invalid object",
11321132
},
11331133
{
11341134
kind: "APLogConf",
11351135
key: "testing/test3",
11361136
wantErr: true,
1137-
errMsg: "App Protect LogConf testing/test3 not found",
1137+
errMsg: "app protect LogConf testing/test3 not found",
11381138
msg: "LogConf, Negative, Object Does not exist",
11391139
},
11401140
{
@@ -1147,31 +1147,31 @@ func TestGetAppProtectResource(t *testing.T) {
11471147
kind: "APUserSig",
11481148
key: "testing/test2",
11491149
wantErr: true,
1150-
errMsg: "Validation Failed",
1150+
errMsg: "validation failed",
11511151
msg: "UserSig, Negative, invalid object",
11521152
},
11531153
{
11541154
kind: "APUserSig",
11551155
key: "testing/test3",
11561156
wantErr: true,
1157-
errMsg: "App Protect UserSig testing/test3 not found",
1157+
errMsg: "app protect UserSig testing/test3 not found",
11581158
msg: "UserSig, Negative, Object Does not exist",
11591159
},
11601160
{
11611161
kind: "Notreal",
11621162
key: "testing/test3",
11631163
wantErr: true,
1164-
errMsg: "Unknown App Protect resource kind Notreal",
1164+
errMsg: "unknown app protect resource kind Notreal",
11651165
msg: "Invalid kind, Negative",
11661166
},
11671167
}
11681168
appProtectConfiguration := newConfigurationImpl()
11691169
appProtectConfiguration.Policies["testing/test1"] = &PolicyEx{IsValid: true, Obj: &unstructured.Unstructured{}}
1170-
appProtectConfiguration.Policies["testing/test2"] = &PolicyEx{IsValid: false, Obj: &unstructured.Unstructured{}, ErrorMsg: "Validation Failed"}
1170+
appProtectConfiguration.Policies["testing/test2"] = &PolicyEx{IsValid: false, Obj: &unstructured.Unstructured{}, ErrorMsg: "validation failed"}
11711171
appProtectConfiguration.LogConfs["testing/test1"] = &LogConfEx{IsValid: true, Obj: &unstructured.Unstructured{}}
1172-
appProtectConfiguration.LogConfs["testing/test2"] = &LogConfEx{IsValid: false, Obj: &unstructured.Unstructured{}, ErrorMsg: "Validation Failed"}
1172+
appProtectConfiguration.LogConfs["testing/test2"] = &LogConfEx{IsValid: false, Obj: &unstructured.Unstructured{}, ErrorMsg: "validation failed"}
11731173
appProtectConfiguration.UserSigs["testing/test1"] = &UserSigEx{IsValid: true, Obj: &unstructured.Unstructured{}}
1174-
appProtectConfiguration.UserSigs["testing/test2"] = &UserSigEx{IsValid: false, Obj: &unstructured.Unstructured{}, ErrorMsg: "Validation Failed"}
1174+
appProtectConfiguration.UserSigs["testing/test2"] = &UserSigEx{IsValid: false, Obj: &unstructured.Unstructured{}, ErrorMsg: "validation failed"}
11751175

11761176
for _, test := range tests {
11771177
_, err := appProtectConfiguration.GetAppResource(test.kind, test.key)

0 commit comments

Comments
 (0)