Skip to content

Commit 2a210a3

Browse files
committed
resolve linter issues
Signed-off-by: Atif Ali <[email protected]>
1 parent 3cfb4fe commit 2a210a3

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
@@ -1147,16 +1147,16 @@ func (sc *syncContext) performClientSideApplyMigration(targetObj *unstructured.U
11471147
return nil
11481148
}
11491149

1150-
func formatValue(v interface{}) string {
1150+
func formatValue(v any) string {
11511151
if v == nil {
11521152
return "<nil>"
11531153
}
11541154

11551155
// Special case for volumeClaimTemplates
1156-
if templates, ok := v.([]interface{}); ok {
1156+
if templates, ok := v.([]any); ok {
11571157
// For a single volumeClaimTemplate field change
11581158
if len(templates) == 1 {
1159-
if template, ok := templates[0].(map[string]interface{}); ok {
1159+
if template, ok := templates[0].(map[string]any); ok {
11601160
if storage := getTemplateStorage(template); storage != "" {
11611161
return fmt.Sprintf("%q", storage)
11621162
}
@@ -1165,8 +1165,8 @@ func formatValue(v interface{}) string {
11651165
// For multiple templates or other array types format
11661166
var names []string
11671167
for _, t := range templates {
1168-
if template, ok := t.(map[string]interface{}); ok {
1169-
if metadata, ok := template["metadata"].(map[string]interface{}); ok {
1168+
if template, ok := t.(map[string]any); ok {
1169+
if metadata, ok := template["metadata"].(map[string]any); ok {
11701170
if name, ok := metadata["name"].(string); ok {
11711171
if storage := getTemplateStorage(template); storage != "" {
11721172
names = append(names, fmt.Sprintf("%s(%s)", name, storage))
@@ -1181,8 +1181,8 @@ func formatValue(v interface{}) string {
11811181
}
11821182

11831183
// Special case for selector matchLabels
1184-
if m, ok := v.(map[string]interface{}); ok {
1185-
if matchLabels, exists := m["matchLabels"].(map[string]interface{}); exists {
1184+
if m, ok := v.(map[string]any); ok {
1185+
if matchLabels, exists := m["matchLabels"].(map[string]any); exists {
11861186
var labels []string
11871187
for k, v := range matchLabels {
11881188
labels = append(labels, fmt.Sprintf("%s:%s", k, v))
@@ -1200,16 +1200,16 @@ func formatValue(v interface{}) string {
12001200
}
12011201

12021202
// Get storage size from template
1203-
func getTemplateStorage(template map[string]interface{}) string {
1204-
spec, ok := template["spec"].(map[string]interface{})
1203+
func getTemplateStorage(template map[string]any) string {
1204+
spec, ok := template["spec"].(map[string]any)
12051205
if !ok {
12061206
return ""
12071207
}
1208-
resources, ok := spec["resources"].(map[string]interface{})
1208+
resources, ok := spec["resources"].(map[string]any)
12091209
if !ok {
12101210
return ""
12111211
}
1212-
requests, ok := resources["requests"].(map[string]interface{})
1212+
requests, ok := resources["requests"].(map[string]any)
12131213
if !ok {
12141214
return ""
12151215
}
@@ -1221,7 +1221,7 @@ func getTemplateStorage(template map[string]interface{}) string {
12211221
}
12221222

12231223
// Format field changes for error messages
1224-
func formatFieldChange(field string, currentVal, desiredVal interface{}) string {
1224+
func formatFieldChange(field string, currentVal, desiredVal any) string {
12251225
return fmt.Sprintf(" - %s:\n from: %s\n to: %s",
12261226
field, formatValue(currentVal), formatValue(desiredVal))
12271227
}
@@ -1304,8 +1304,8 @@ func (sc *syncContext) applyObject(t *syncTask, dryRun, validate bool) (common.R
13041304
} else if !reflect.DeepEqual(currentVal, desiredVal) {
13051305
if k == "volumeClaimTemplates" {
13061306
// Handle volumeClaimTemplates specially
1307-
currentTemplates := currentVal.([]interface{})
1308-
desiredTemplates := desiredVal.([]interface{})
1307+
currentTemplates := currentVal.([]any)
1308+
desiredTemplates := desiredVal.([]any)
13091309

13101310
// If template count differs or we're adding/removing templates,
13111311
// use the standard array format
@@ -1315,10 +1315,10 @@ func (sc *syncContext) applyObject(t *syncTask, dryRun, validate bool) (common.R
13151315
// Compare each template
13161316
for i, desired := range desiredTemplates {
13171317
current := currentTemplates[i]
1318-
desiredTemplate := desired.(map[string]interface{})
1319-
currentTemplate := current.(map[string]interface{})
1318+
desiredTemplate := desired.(map[string]any)
1319+
currentTemplate := current.(map[string]any)
13201320

1321-
name := desiredTemplate["metadata"].(map[string]interface{})["name"].(string)
1321+
name := desiredTemplate["metadata"].(map[string]any)["name"].(string)
13221322
desiredStorage := getTemplateStorage(desiredTemplate)
13231323
currentStorage := getTemplateStorage(currentTemplate)
13241324

pkg/sync/sync_context_test.go

Lines changed: 65 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -2272,14 +2272,14 @@ func TestNeedsClientSideApplyMigration(t *testing.T) {
22722272
}
22732273
}
22742274

2275-
func templateWithStorage(name, storage string) map[string]interface{} {
2276-
return map[string]interface{}{
2277-
"metadata": map[string]interface{}{
2275+
func templateWithStorage(name, storage string) map[string]any {
2276+
return map[string]any{
2277+
"metadata": map[string]any{
22782278
"name": name,
22792279
},
2280-
"spec": map[string]interface{}{
2281-
"resources": map[string]interface{}{
2282-
"requests": map[string]interface{}{
2280+
"spec": map[string]any{
2281+
"resources": map[string]any{
2282+
"requests": map[string]any{
22832283
"storage": storage,
22842284
},
22852285
},
@@ -2290,16 +2290,16 @@ func templateWithStorage(name, storage string) map[string]interface{} {
22902290
func TestStatefulSetImmutableFieldErrors(t *testing.T) {
22912291
tests := []struct {
22922292
name string
2293-
currentSpec map[string]interface{}
2294-
desiredSpec map[string]interface{}
2293+
currentSpec map[string]any
2294+
desiredSpec map[string]any
22952295
expectedMessage string
22962296
}{
22972297
{
22982298
name: "single field change - serviceName",
2299-
currentSpec: map[string]interface{}{
2299+
currentSpec: map[string]any{
23002300
"serviceName": "old-svc",
23012301
},
2302-
desiredSpec: map[string]interface{}{
2302+
desiredSpec: map[string]any{
23032303
"serviceName": "new-svc",
23042304
},
23052305
expectedMessage: `attempting to change immutable fields:
@@ -2311,31 +2311,31 @@ Forbidden: updates to statefulset spec for fields other than 'replicas', 'ordina
23112311
},
23122312
{
23132313
name: "volumeClaimTemplates change with storage size",
2314-
currentSpec: map[string]interface{}{
2315-
"volumeClaimTemplates": []interface{}{
2316-
map[string]interface{}{
2317-
"metadata": map[string]interface{}{
2314+
currentSpec: map[string]any{
2315+
"volumeClaimTemplates": []any{
2316+
map[string]any{
2317+
"metadata": map[string]any{
23182318
"name": "data",
23192319
},
2320-
"spec": map[string]interface{}{
2321-
"resources": map[string]interface{}{
2322-
"requests": map[string]interface{}{
2320+
"spec": map[string]any{
2321+
"resources": map[string]any{
2322+
"requests": map[string]any{
23232323
"storage": "1Gi",
23242324
},
23252325
},
23262326
},
23272327
},
23282328
},
23292329
},
2330-
desiredSpec: map[string]interface{}{
2331-
"volumeClaimTemplates": []interface{}{
2332-
map[string]interface{}{
2333-
"metadata": map[string]interface{}{
2330+
desiredSpec: map[string]any{
2331+
"volumeClaimTemplates": []any{
2332+
map[string]any{
2333+
"metadata": map[string]any{
23342334
"name": "data",
23352335
},
2336-
"spec": map[string]interface{}{
2337-
"resources": map[string]interface{}{
2338-
"requests": map[string]interface{}{
2336+
"spec": map[string]any{
2337+
"resources": map[string]any{
2338+
"requests": map[string]any{
23392339
"storage": "2Gi",
23402340
},
23412341
},
@@ -2352,16 +2352,16 @@ Forbidden: updates to statefulset spec for fields other than 'replicas', 'ordina
23522352
},
23532353
{
23542354
name: "selector change",
2355-
currentSpec: map[string]interface{}{
2356-
"selector": map[string]interface{}{
2357-
"matchLabels": map[string]interface{}{
2355+
currentSpec: map[string]any{
2356+
"selector": map[string]any{
2357+
"matchLabels": map[string]any{
23582358
"app": "old-app",
23592359
},
23602360
},
23612361
},
2362-
desiredSpec: map[string]interface{}{
2363-
"selector": map[string]interface{}{
2364-
"matchLabels": map[string]interface{}{
2362+
desiredSpec: map[string]any{
2363+
"selector": map[string]any{
2364+
"matchLabels": map[string]any{
23652365
"app": "new-app",
23662366
},
23672367
},
@@ -2375,14 +2375,14 @@ Forbidden: updates to statefulset spec for fields other than 'replicas', 'ordina
23752375
},
23762376
{
23772377
name: "volumeClaimTemplates change from nil",
2378-
currentSpec: map[string]interface{}{
2378+
currentSpec: map[string]any{
23792379
"serviceName": "test-svc",
23802380
},
2381-
desiredSpec: map[string]interface{}{
2381+
desiredSpec: map[string]any{
23822382
"serviceName": "test-svc",
2383-
"volumeClaimTemplates": []interface{}{
2384-
map[string]interface{}{
2385-
"metadata": map[string]interface{}{
2383+
"volumeClaimTemplates": []any{
2384+
map[string]any{
2385+
"metadata": map[string]any{
23862386
"name": "data",
23872387
},
23882388
},
@@ -2397,24 +2397,24 @@ Forbidden: updates to statefulset spec for fields other than 'replicas', 'ordina
23972397
},
23982398
{
23992399
name: "complex volumeClaimTemplates change",
2400-
currentSpec: map[string]interface{}{
2401-
"volumeClaimTemplates": []interface{}{
2402-
map[string]interface{}{
2403-
"metadata": map[string]interface{}{
2400+
currentSpec: map[string]any{
2401+
"volumeClaimTemplates": []any{
2402+
map[string]any{
2403+
"metadata": map[string]any{
24042404
"name": "data1",
24052405
},
24062406
},
24072407
},
24082408
},
2409-
desiredSpec: map[string]interface{}{
2410-
"volumeClaimTemplates": []interface{}{
2411-
map[string]interface{}{
2412-
"metadata": map[string]interface{}{
2409+
desiredSpec: map[string]any{
2410+
"volumeClaimTemplates": []any{
2411+
map[string]any{
2412+
"metadata": map[string]any{
24132413
"name": "data1",
24142414
},
24152415
},
2416-
map[string]interface{}{
2417-
"metadata": map[string]interface{}{
2416+
map[string]any{
2417+
"metadata": map[string]any{
24182418
"name": "data2",
24192419
},
24202420
},
@@ -2429,27 +2429,27 @@ Forbidden: updates to statefulset spec for fields other than 'replicas', 'ordina
24292429
},
24302430
{
24312431
name: "multiple volumeClaimTemplate change",
2432-
currentSpec: map[string]interface{}{
2432+
currentSpec: map[string]any{
24332433
"serviceName": postgresqlSvc,
2434-
"selector": map[string]interface{}{
2435-
"matchLabels": map[string]interface{}{
2434+
"selector": map[string]any{
2435+
"matchLabels": map[string]any{
24362436
"app": "postgresql",
24372437
},
24382438
},
2439-
"volumeClaimTemplates": []interface{}{
2439+
"volumeClaimTemplates": []any{
24402440
templateWithStorage(staticFiles, "1Gi"),
24412441
templateWithStorage(dexconfig, "1Gi"),
24422442
templateWithStorage(argocdDexServerTLS, "1Gi"),
24432443
},
24442444
},
2445-
desiredSpec: map[string]interface{}{
2445+
desiredSpec: map[string]any{
24462446
"serviceName": postgresqlSvc,
2447-
"selector": map[string]interface{}{
2448-
"matchLabels": map[string]interface{}{
2447+
"selector": map[string]any{
2448+
"matchLabels": map[string]any{
24492449
"app": "postgresql",
24502450
},
24512451
},
2452-
"volumeClaimTemplates": []interface{}{
2452+
"volumeClaimTemplates": []any{
24532453
templateWithStorage(staticFiles, "2Gi"),
24542454
templateWithStorage(dexconfig, "3Gi"),
24552455
templateWithStorage(argocdDexServerTLS, "4Gi"),
@@ -2470,27 +2470,27 @@ Forbidden: updates to statefulset spec for fields other than 'replicas', 'ordina
24702470
},
24712471
{
24722472
name: "multiple field changes",
2473-
currentSpec: map[string]interface{}{
2473+
currentSpec: map[string]any{
24742474
"serviceName": postgresqlSvc,
2475-
"selector": map[string]interface{}{
2476-
"matchLabels": map[string]interface{}{
2475+
"selector": map[string]any{
2476+
"matchLabels": map[string]any{
24772477
"app": "postgresql",
24782478
},
24792479
},
2480-
"volumeClaimTemplates": []interface{}{
2480+
"volumeClaimTemplates": []any{
24812481
templateWithStorage(staticFiles, "1Gi"),
24822482
templateWithStorage(dexconfig, "1Gi"),
24832483
templateWithStorage(argocdDexServerTLS, "1Gi"),
24842484
},
24852485
},
2486-
desiredSpec: map[string]interface{}{
2486+
desiredSpec: map[string]any{
24872487
"serviceName": "postgresql-svc-new",
2488-
"selector": map[string]interface{}{
2489-
"matchLabels": map[string]interface{}{
2488+
"selector": map[string]any{
2489+
"matchLabels": map[string]any{
24902490
"app": "postgresql-new",
24912491
},
24922492
},
2493-
"volumeClaimTemplates": []interface{}{
2493+
"volumeClaimTemplates": []any{
24942494
templateWithStorage(staticFiles, "2Gi"),
24952495
templateWithStorage(dexconfig, "1Gi"),
24962496
templateWithStorage(argocdDexServerTLS, "1Gi"),
@@ -2514,10 +2514,10 @@ Forbidden: updates to statefulset spec for fields other than 'replicas', 'ordina
25142514
for _, tt := range tests {
25152515
t.Run(tt.name, func(t *testing.T) {
25162516
current := &unstructured.Unstructured{
2517-
Object: map[string]interface{}{
2517+
Object: map[string]any{
25182518
"apiVersion": testAPIVersion,
25192519
"kind": "StatefulSet",
2520-
"metadata": map[string]interface{}{
2520+
"metadata": map[string]any{
25212521
"name": testStatefulSet,
25222522
"namespace": testNamespace,
25232523
},
@@ -2526,10 +2526,10 @@ Forbidden: updates to statefulset spec for fields other than 'replicas', 'ordina
25262526
}
25272527

25282528
desired := &unstructured.Unstructured{
2529-
Object: map[string]interface{}{
2529+
Object: map[string]any{
25302530
"apiVersion": testAPIVersion,
25312531
"kind": "StatefulSet",
2532-
"metadata": map[string]interface{}{
2532+
"metadata": map[string]any{
25332533
"name": testStatefulSet,
25342534
"namespace": testNamespace,
25352535
},

0 commit comments

Comments
 (0)