Skip to content

Commit 5bedc33

Browse files
committed
resolve linter issues
Signed-off-by: Atif Ali <[email protected]>
1 parent 8b51f31 commit 5bedc33

File tree

2 files changed

+82
-82
lines changed

2 files changed

+82
-82
lines changed

pkg/sync/sync_context.go

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1031,16 +1031,16 @@ func (sc *syncContext) shouldUseServerSideApply(targetObj *unstructured.Unstruct
10311031
return sc.serverSideApply || resourceutil.HasAnnotationOption(targetObj, common.AnnotationSyncOptions, common.SyncOptionServerSideApply)
10321032
}
10331033

1034-
func formatValue(v interface{}) string {
1034+
func formatValue(v any) string {
10351035
if v == nil {
10361036
return "<nil>"
10371037
}
10381038

10391039
// Special case for volumeClaimTemplates
1040-
if templates, ok := v.([]interface{}); ok {
1040+
if templates, ok := v.([]any); ok {
10411041
// For a single volumeClaimTemplate field change
10421042
if len(templates) == 1 {
1043-
if template, ok := templates[0].(map[string]interface{}); ok {
1043+
if template, ok := templates[0].(map[string]any); ok {
10441044
if storage := getTemplateStorage(template); storage != "" {
10451045
return fmt.Sprintf("%q", storage)
10461046
}
@@ -1049,8 +1049,8 @@ func formatValue(v interface{}) string {
10491049
// For multiple templates or other array types format
10501050
var names []string
10511051
for _, t := range templates {
1052-
if template, ok := t.(map[string]interface{}); ok {
1053-
if metadata, ok := template["metadata"].(map[string]interface{}); ok {
1052+
if template, ok := t.(map[string]any); ok {
1053+
if metadata, ok := template["metadata"].(map[string]any); ok {
10541054
if name, ok := metadata["name"].(string); ok {
10551055
if storage := getTemplateStorage(template); storage != "" {
10561056
names = append(names, fmt.Sprintf("%s(%s)", name, storage))
@@ -1065,8 +1065,8 @@ func formatValue(v interface{}) string {
10651065
}
10661066

10671067
// Special case for selector matchLabels
1068-
if m, ok := v.(map[string]interface{}); ok {
1069-
if matchLabels, exists := m["matchLabels"].(map[string]interface{}); exists {
1068+
if m, ok := v.(map[string]any); ok {
1069+
if matchLabels, exists := m["matchLabels"].(map[string]any); exists {
10701070
var labels []string
10711071
for k, v := range matchLabels {
10721072
labels = append(labels, fmt.Sprintf("%s:%s", k, v))
@@ -1084,16 +1084,16 @@ func formatValue(v interface{}) string {
10841084
}
10851085

10861086
// Get storage size from template
1087-
func getTemplateStorage(template map[string]interface{}) string {
1088-
spec, ok := template["spec"].(map[string]interface{})
1087+
func getTemplateStorage(template map[string]any) string {
1088+
spec, ok := template["spec"].(map[string]any)
10891089
if !ok {
10901090
return ""
10911091
}
1092-
resources, ok := spec["resources"].(map[string]interface{})
1092+
resources, ok := spec["resources"].(map[string]any)
10931093
if !ok {
10941094
return ""
10951095
}
1096-
requests, ok := resources["requests"].(map[string]interface{})
1096+
requests, ok := resources["requests"].(map[string]any)
10971097
if !ok {
10981098
return ""
10991099
}
@@ -1105,7 +1105,7 @@ func getTemplateStorage(template map[string]interface{}) string {
11051105
}
11061106

11071107
// Format field changes for error messages
1108-
func formatFieldChange(field string, currentVal, desiredVal interface{}) string {
1108+
func formatFieldChange(field string, currentVal, desiredVal any) string {
11091109
return fmt.Sprintf(" - %s:\n from: %s\n to: %s",
11101110
field, formatValue(currentVal), formatValue(desiredVal))
11111111
}
@@ -1177,8 +1177,8 @@ func (sc *syncContext) applyObject(t *syncTask, dryRun, validate bool) (common.R
11771177
} else if !reflect.DeepEqual(currentVal, desiredVal) {
11781178
if k == "volumeClaimTemplates" {
11791179
// Handle volumeClaimTemplates specially
1180-
currentTemplates := currentVal.([]interface{})
1181-
desiredTemplates := desiredVal.([]interface{})
1180+
currentTemplates := currentVal.([]any)
1181+
desiredTemplates := desiredVal.([]any)
11821182

11831183
// If template count differs or we're adding/removing templates,
11841184
// use the standard array format
@@ -1188,10 +1188,10 @@ func (sc *syncContext) applyObject(t *syncTask, dryRun, validate bool) (common.R
11881188
// Compare each template
11891189
for i, desired := range desiredTemplates {
11901190
current := currentTemplates[i]
1191-
desiredTemplate := desired.(map[string]interface{})
1192-
currentTemplate := current.(map[string]interface{})
1191+
desiredTemplate := desired.(map[string]any)
1192+
currentTemplate := current.(map[string]any)
11931193

1194-
name := desiredTemplate["metadata"].(map[string]interface{})["name"].(string)
1194+
name := desiredTemplate["metadata"].(map[string]any)["name"].(string)
11951195
desiredStorage := getTemplateStorage(desiredTemplate)
11961196
currentStorage := getTemplateStorage(currentTemplate)
11971197

pkg/sync/sync_context_test.go

Lines changed: 65 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -2072,14 +2072,14 @@ func TestWaitForCleanUpBeforeNextWave(t *testing.T) {
20722072
assert.Equal(t, synccommon.ResultCodePruned, result[2].Status)
20732073
}
20742074

2075-
func templateWithStorage(name, storage string) map[string]interface{} {
2076-
return map[string]interface{}{
2077-
"metadata": map[string]interface{}{
2075+
func templateWithStorage(name, storage string) map[string]any {
2076+
return map[string]any{
2077+
"metadata": map[string]any{
20782078
"name": name,
20792079
},
2080-
"spec": map[string]interface{}{
2081-
"resources": map[string]interface{}{
2082-
"requests": map[string]interface{}{
2080+
"spec": map[string]any{
2081+
"resources": map[string]any{
2082+
"requests": map[string]any{
20832083
"storage": storage,
20842084
},
20852085
},
@@ -2090,16 +2090,16 @@ func templateWithStorage(name, storage string) map[string]interface{} {
20902090
func TestStatefulSetImmutableFieldErrors(t *testing.T) {
20912091
tests := []struct {
20922092
name string
2093-
currentSpec map[string]interface{}
2094-
desiredSpec map[string]interface{}
2093+
currentSpec map[string]any
2094+
desiredSpec map[string]any
20952095
expectedMessage string
20962096
}{
20972097
{
20982098
name: "single field change - serviceName",
2099-
currentSpec: map[string]interface{}{
2099+
currentSpec: map[string]any{
21002100
"serviceName": "old-svc",
21012101
},
2102-
desiredSpec: map[string]interface{}{
2102+
desiredSpec: map[string]any{
21032103
"serviceName": "new-svc",
21042104
},
21052105
expectedMessage: `attempting to change immutable fields:
@@ -2111,31 +2111,31 @@ Forbidden: updates to statefulset spec for fields other than 'replicas', 'ordina
21112111
},
21122112
{
21132113
name: "volumeClaimTemplates change with storage size",
2114-
currentSpec: map[string]interface{}{
2115-
"volumeClaimTemplates": []interface{}{
2116-
map[string]interface{}{
2117-
"metadata": map[string]interface{}{
2114+
currentSpec: map[string]any{
2115+
"volumeClaimTemplates": []any{
2116+
map[string]any{
2117+
"metadata": map[string]any{
21182118
"name": "data",
21192119
},
2120-
"spec": map[string]interface{}{
2121-
"resources": map[string]interface{}{
2122-
"requests": map[string]interface{}{
2120+
"spec": map[string]any{
2121+
"resources": map[string]any{
2122+
"requests": map[string]any{
21232123
"storage": "1Gi",
21242124
},
21252125
},
21262126
},
21272127
},
21282128
},
21292129
},
2130-
desiredSpec: map[string]interface{}{
2131-
"volumeClaimTemplates": []interface{}{
2132-
map[string]interface{}{
2133-
"metadata": map[string]interface{}{
2130+
desiredSpec: map[string]any{
2131+
"volumeClaimTemplates": []any{
2132+
map[string]any{
2133+
"metadata": map[string]any{
21342134
"name": "data",
21352135
},
2136-
"spec": map[string]interface{}{
2137-
"resources": map[string]interface{}{
2138-
"requests": map[string]interface{}{
2136+
"spec": map[string]any{
2137+
"resources": map[string]any{
2138+
"requests": map[string]any{
21392139
"storage": "2Gi",
21402140
},
21412141
},
@@ -2152,16 +2152,16 @@ Forbidden: updates to statefulset spec for fields other than 'replicas', 'ordina
21522152
},
21532153
{
21542154
name: "selector change",
2155-
currentSpec: map[string]interface{}{
2156-
"selector": map[string]interface{}{
2157-
"matchLabels": map[string]interface{}{
2155+
currentSpec: map[string]any{
2156+
"selector": map[string]any{
2157+
"matchLabels": map[string]any{
21582158
"app": "old-app",
21592159
},
21602160
},
21612161
},
2162-
desiredSpec: map[string]interface{}{
2163-
"selector": map[string]interface{}{
2164-
"matchLabels": map[string]interface{}{
2162+
desiredSpec: map[string]any{
2163+
"selector": map[string]any{
2164+
"matchLabels": map[string]any{
21652165
"app": "new-app",
21662166
},
21672167
},
@@ -2175,14 +2175,14 @@ Forbidden: updates to statefulset spec for fields other than 'replicas', 'ordina
21752175
},
21762176
{
21772177
name: "volumeClaimTemplates change from nil",
2178-
currentSpec: map[string]interface{}{
2178+
currentSpec: map[string]any{
21792179
"serviceName": "test-svc",
21802180
},
2181-
desiredSpec: map[string]interface{}{
2181+
desiredSpec: map[string]any{
21822182
"serviceName": "test-svc",
2183-
"volumeClaimTemplates": []interface{}{
2184-
map[string]interface{}{
2185-
"metadata": map[string]interface{}{
2183+
"volumeClaimTemplates": []any{
2184+
map[string]any{
2185+
"metadata": map[string]any{
21862186
"name": "data",
21872187
},
21882188
},
@@ -2197,24 +2197,24 @@ Forbidden: updates to statefulset spec for fields other than 'replicas', 'ordina
21972197
},
21982198
{
21992199
name: "complex volumeClaimTemplates change",
2200-
currentSpec: map[string]interface{}{
2201-
"volumeClaimTemplates": []interface{}{
2202-
map[string]interface{}{
2203-
"metadata": map[string]interface{}{
2200+
currentSpec: map[string]any{
2201+
"volumeClaimTemplates": []any{
2202+
map[string]any{
2203+
"metadata": map[string]any{
22042204
"name": "data1",
22052205
},
22062206
},
22072207
},
22082208
},
2209-
desiredSpec: map[string]interface{}{
2210-
"volumeClaimTemplates": []interface{}{
2211-
map[string]interface{}{
2212-
"metadata": map[string]interface{}{
2209+
desiredSpec: map[string]any{
2210+
"volumeClaimTemplates": []any{
2211+
map[string]any{
2212+
"metadata": map[string]any{
22132213
"name": "data1",
22142214
},
22152215
},
2216-
map[string]interface{}{
2217-
"metadata": map[string]interface{}{
2216+
map[string]any{
2217+
"metadata": map[string]any{
22182218
"name": "data2",
22192219
},
22202220
},
@@ -2229,27 +2229,27 @@ Forbidden: updates to statefulset spec for fields other than 'replicas', 'ordina
22292229
},
22302230
{
22312231
name: "multiple volumeClaimTemplate change",
2232-
currentSpec: map[string]interface{}{
2232+
currentSpec: map[string]any{
22332233
"serviceName": postgresqlSvc,
2234-
"selector": map[string]interface{}{
2235-
"matchLabels": map[string]interface{}{
2234+
"selector": map[string]any{
2235+
"matchLabels": map[string]any{
22362236
"app": "postgresql",
22372237
},
22382238
},
2239-
"volumeClaimTemplates": []interface{}{
2239+
"volumeClaimTemplates": []any{
22402240
templateWithStorage(staticFiles, "1Gi"),
22412241
templateWithStorage(dexconfig, "1Gi"),
22422242
templateWithStorage(argocdDexServerTLS, "1Gi"),
22432243
},
22442244
},
2245-
desiredSpec: map[string]interface{}{
2245+
desiredSpec: map[string]any{
22462246
"serviceName": postgresqlSvc,
2247-
"selector": map[string]interface{}{
2248-
"matchLabels": map[string]interface{}{
2247+
"selector": map[string]any{
2248+
"matchLabels": map[string]any{
22492249
"app": "postgresql",
22502250
},
22512251
},
2252-
"volumeClaimTemplates": []interface{}{
2252+
"volumeClaimTemplates": []any{
22532253
templateWithStorage(staticFiles, "2Gi"),
22542254
templateWithStorage(dexconfig, "3Gi"),
22552255
templateWithStorage(argocdDexServerTLS, "4Gi"),
@@ -2270,27 +2270,27 @@ Forbidden: updates to statefulset spec for fields other than 'replicas', 'ordina
22702270
},
22712271
{
22722272
name: "multiple field changes",
2273-
currentSpec: map[string]interface{}{
2273+
currentSpec: map[string]any{
22742274
"serviceName": postgresqlSvc,
2275-
"selector": map[string]interface{}{
2276-
"matchLabels": map[string]interface{}{
2275+
"selector": map[string]any{
2276+
"matchLabels": map[string]any{
22772277
"app": "postgresql",
22782278
},
22792279
},
2280-
"volumeClaimTemplates": []interface{}{
2280+
"volumeClaimTemplates": []any{
22812281
templateWithStorage(staticFiles, "1Gi"),
22822282
templateWithStorage(dexconfig, "1Gi"),
22832283
templateWithStorage(argocdDexServerTLS, "1Gi"),
22842284
},
22852285
},
2286-
desiredSpec: map[string]interface{}{
2286+
desiredSpec: map[string]any{
22872287
"serviceName": "postgresql-svc-new",
2288-
"selector": map[string]interface{}{
2289-
"matchLabels": map[string]interface{}{
2288+
"selector": map[string]any{
2289+
"matchLabels": map[string]any{
22902290
"app": "postgresql-new",
22912291
},
22922292
},
2293-
"volumeClaimTemplates": []interface{}{
2293+
"volumeClaimTemplates": []any{
22942294
templateWithStorage(staticFiles, "2Gi"),
22952295
templateWithStorage(dexconfig, "1Gi"),
22962296
templateWithStorage(argocdDexServerTLS, "1Gi"),
@@ -2314,10 +2314,10 @@ Forbidden: updates to statefulset spec for fields other than 'replicas', 'ordina
23142314
for _, tt := range tests {
23152315
t.Run(tt.name, func(t *testing.T) {
23162316
current := &unstructured.Unstructured{
2317-
Object: map[string]interface{}{
2317+
Object: map[string]any{
23182318
"apiVersion": testAPIVersion,
23192319
"kind": "StatefulSet",
2320-
"metadata": map[string]interface{}{
2320+
"metadata": map[string]any{
23212321
"name": testStatefulSet,
23222322
"namespace": testNamespace,
23232323
},
@@ -2326,10 +2326,10 @@ Forbidden: updates to statefulset spec for fields other than 'replicas', 'ordina
23262326
}
23272327

23282328
desired := &unstructured.Unstructured{
2329-
Object: map[string]interface{}{
2329+
Object: map[string]any{
23302330
"apiVersion": testAPIVersion,
23312331
"kind": "StatefulSet",
2332-
"metadata": map[string]interface{}{
2332+
"metadata": map[string]any{
23332333
"name": testStatefulSet,
23342334
"namespace": testNamespace,
23352335
},

0 commit comments

Comments
 (0)