Skip to content
This repository was archived by the owner on Oct 6, 2025. It is now read-only.

Commit f32f3ad

Browse files
committed
resolve linter issues
Signed-off-by: Atif Ali <[email protected]>
1 parent 9ed0ce7 commit f32f3ad

File tree

2 files changed

+85
-79
lines changed

2 files changed

+85
-79
lines changed

pkg/sync/sync_context.go

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1156,16 +1156,16 @@ func (sc *syncContext) performClientSideApplyMigration(targetObj *unstructured.U
11561156
return nil
11571157
}
11581158

1159-
func formatValue(v interface{}) string {
1159+
func formatValue(v any) string {
11601160
if v == nil {
11611161
return "<nil>"
11621162
}
11631163

11641164
// Special case for volumeClaimTemplates
1165-
if templates, ok := v.([]interface{}); ok {
1165+
if templates, ok := v.([]any); ok {
11661166
// For a single volumeClaimTemplate field change
11671167
if len(templates) == 1 {
1168-
if template, ok := templates[0].(map[string]interface{}); ok {
1168+
if template, ok := templates[0].(map[string]any); ok {
11691169
if storage := getTemplateStorage(template); storage != "" {
11701170
return fmt.Sprintf("%q", storage)
11711171
}
@@ -1174,8 +1174,8 @@ func formatValue(v interface{}) string {
11741174
// For multiple templates or other array types format
11751175
var names []string
11761176
for _, t := range templates {
1177-
if template, ok := t.(map[string]interface{}); ok {
1178-
if metadata, ok := template["metadata"].(map[string]interface{}); ok {
1177+
if template, ok := t.(map[string]any); ok {
1178+
if metadata, ok := template["metadata"].(map[string]any); ok {
11791179
if name, ok := metadata["name"].(string); ok {
11801180
if storage := getTemplateStorage(template); storage != "" {
11811181
names = append(names, fmt.Sprintf("%s(%s)", name, storage))
@@ -1190,8 +1190,8 @@ func formatValue(v interface{}) string {
11901190
}
11911191

11921192
// Special case for selector matchLabels
1193-
if m, ok := v.(map[string]interface{}); ok {
1194-
if matchLabels, exists := m["matchLabels"].(map[string]interface{}); exists {
1193+
if m, ok := v.(map[string]any); ok {
1194+
if matchLabels, exists := m["matchLabels"].(map[string]any); exists {
11951195
var labels []string
11961196
for k, v := range matchLabels {
11971197
labels = append(labels, fmt.Sprintf("%s:%s", k, v))
@@ -1209,16 +1209,16 @@ func formatValue(v interface{}) string {
12091209
}
12101210

12111211
// Get storage size from template
1212-
func getTemplateStorage(template map[string]interface{}) string {
1213-
spec, ok := template["spec"].(map[string]interface{})
1212+
func getTemplateStorage(template map[string]any) string {
1213+
spec, ok := template["spec"].(map[string]any)
12141214
if !ok {
12151215
return ""
12161216
}
1217-
resources, ok := spec["resources"].(map[string]interface{})
1217+
resources, ok := spec["resources"].(map[string]any)
12181218
if !ok {
12191219
return ""
12201220
}
1221-
requests, ok := resources["requests"].(map[string]interface{})
1221+
requests, ok := resources["requests"].(map[string]any)
12221222
if !ok {
12231223
return ""
12241224
}
@@ -1230,7 +1230,7 @@ func getTemplateStorage(template map[string]interface{}) string {
12301230
}
12311231

12321232
// Format field changes for error messages
1233-
func formatFieldChange(field string, currentVal, desiredVal interface{}) string {
1233+
func formatFieldChange(field string, currentVal, desiredVal any) string {
12341234
return fmt.Sprintf(" - %s:\n from: %s\n to: %s",
12351235
field, formatValue(currentVal), formatValue(desiredVal))
12361236
}
@@ -1313,8 +1313,8 @@ func (sc *syncContext) applyObject(t *syncTask, dryRun, validate bool) (common.R
13131313
} else if !reflect.DeepEqual(currentVal, desiredVal) {
13141314
if k == "volumeClaimTemplates" {
13151315
// Handle volumeClaimTemplates specially
1316-
currentTemplates := currentVal.([]interface{})
1317-
desiredTemplates := desiredVal.([]interface{})
1316+
currentTemplates := currentVal.([]any)
1317+
desiredTemplates := desiredVal.([]any)
13181318

13191319
// If template count differs or we're adding/removing templates,
13201320
// use the standard array format
@@ -1324,10 +1324,10 @@ func (sc *syncContext) applyObject(t *syncTask, dryRun, validate bool) (common.R
13241324
// Compare each template
13251325
for i, desired := range desiredTemplates {
13261326
current := currentTemplates[i]
1327-
desiredTemplate := desired.(map[string]interface{})
1328-
currentTemplate := current.(map[string]interface{})
1327+
desiredTemplate := desired.(map[string]any)
1328+
currentTemplate := current.(map[string]any)
13291329

1330-
name := desiredTemplate["metadata"].(map[string]interface{})["name"].(string)
1330+
name := desiredTemplate["metadata"].(map[string]any)["name"].(string)
13311331
desiredStorage := getTemplateStorage(desiredTemplate)
13321332
currentStorage := getTemplateStorage(currentTemplate)
13331333

pkg/sync/sync_context_test.go

Lines changed: 68 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -2434,6 +2434,7 @@ func TestNeedsClientSideApplyMigration(t *testing.T) {
24342434
}
24352435
}
24362436

2437+
<<<<<<< HEAD
24372438
<<<<<<< HEAD
24382439
func diffResultListClusterResource() *diff.DiffResultList {
24392440
ns1 := testingutils.NewNamespace()
@@ -2462,11 +2463,16 @@ func diffResultListClusterResource() *diff.DiffResultList {
24622463
func templateWithStorage(name, storage string) map[string]interface{} {
24632464
return map[string]interface{}{
24642465
"metadata": map[string]interface{}{
2466+
=======
2467+
func templateWithStorage(name, storage string) map[string]any {
2468+
return map[string]any{
2469+
"metadata": map[string]any{
2470+
>>>>>>> 2a210a3 (resolve linter issues)
24652471
"name": name,
24662472
},
2467-
"spec": map[string]interface{}{
2468-
"resources": map[string]interface{}{
2469-
"requests": map[string]interface{}{
2473+
"spec": map[string]any{
2474+
"resources": map[string]any{
2475+
"requests": map[string]any{
24702476
"storage": storage,
24712477
},
24722478
},
@@ -2477,16 +2483,16 @@ func templateWithStorage(name, storage string) map[string]interface{} {
24772483
func TestStatefulSetImmutableFieldErrors(t *testing.T) {
24782484
tests := []struct {
24792485
name string
2480-
currentSpec map[string]interface{}
2481-
desiredSpec map[string]interface{}
2486+
currentSpec map[string]any
2487+
desiredSpec map[string]any
24822488
expectedMessage string
24832489
}{
24842490
{
24852491
name: "single field change - serviceName",
2486-
currentSpec: map[string]interface{}{
2492+
currentSpec: map[string]any{
24872493
"serviceName": "old-svc",
24882494
},
2489-
desiredSpec: map[string]interface{}{
2495+
desiredSpec: map[string]any{
24902496
"serviceName": "new-svc",
24912497
},
24922498
expectedMessage: `attempting to change immutable fields:
@@ -2498,31 +2504,31 @@ Forbidden: updates to statefulset spec for fields other than 'replicas', 'ordina
24982504
},
24992505
{
25002506
name: "volumeClaimTemplates change with storage size",
2501-
currentSpec: map[string]interface{}{
2502-
"volumeClaimTemplates": []interface{}{
2503-
map[string]interface{}{
2504-
"metadata": map[string]interface{}{
2507+
currentSpec: map[string]any{
2508+
"volumeClaimTemplates": []any{
2509+
map[string]any{
2510+
"metadata": map[string]any{
25052511
"name": "data",
25062512
},
2507-
"spec": map[string]interface{}{
2508-
"resources": map[string]interface{}{
2509-
"requests": map[string]interface{}{
2513+
"spec": map[string]any{
2514+
"resources": map[string]any{
2515+
"requests": map[string]any{
25102516
"storage": "1Gi",
25112517
},
25122518
},
25132519
},
25142520
},
25152521
},
25162522
},
2517-
desiredSpec: map[string]interface{}{
2518-
"volumeClaimTemplates": []interface{}{
2519-
map[string]interface{}{
2520-
"metadata": map[string]interface{}{
2523+
desiredSpec: map[string]any{
2524+
"volumeClaimTemplates": []any{
2525+
map[string]any{
2526+
"metadata": map[string]any{
25212527
"name": "data",
25222528
},
2523-
"spec": map[string]interface{}{
2524-
"resources": map[string]interface{}{
2525-
"requests": map[string]interface{}{
2529+
"spec": map[string]any{
2530+
"resources": map[string]any{
2531+
"requests": map[string]any{
25262532
"storage": "2Gi",
25272533
},
25282534
},
@@ -2539,16 +2545,16 @@ Forbidden: updates to statefulset spec for fields other than 'replicas', 'ordina
25392545
},
25402546
{
25412547
name: "selector change",
2542-
currentSpec: map[string]interface{}{
2543-
"selector": map[string]interface{}{
2544-
"matchLabels": map[string]interface{}{
2548+
currentSpec: map[string]any{
2549+
"selector": map[string]any{
2550+
"matchLabels": map[string]any{
25452551
"app": "old-app",
25462552
},
25472553
},
25482554
},
2549-
desiredSpec: map[string]interface{}{
2550-
"selector": map[string]interface{}{
2551-
"matchLabels": map[string]interface{}{
2555+
desiredSpec: map[string]any{
2556+
"selector": map[string]any{
2557+
"matchLabels": map[string]any{
25522558
"app": "new-app",
25532559
},
25542560
},
@@ -2562,14 +2568,14 @@ Forbidden: updates to statefulset spec for fields other than 'replicas', 'ordina
25622568
},
25632569
{
25642570
name: "volumeClaimTemplates change from nil",
2565-
currentSpec: map[string]interface{}{
2571+
currentSpec: map[string]any{
25662572
"serviceName": "test-svc",
25672573
},
2568-
desiredSpec: map[string]interface{}{
2574+
desiredSpec: map[string]any{
25692575
"serviceName": "test-svc",
2570-
"volumeClaimTemplates": []interface{}{
2571-
map[string]interface{}{
2572-
"metadata": map[string]interface{}{
2576+
"volumeClaimTemplates": []any{
2577+
map[string]any{
2578+
"metadata": map[string]any{
25732579
"name": "data",
25742580
},
25752581
},
@@ -2584,24 +2590,24 @@ Forbidden: updates to statefulset spec for fields other than 'replicas', 'ordina
25842590
},
25852591
{
25862592
name: "complex volumeClaimTemplates change",
2587-
currentSpec: map[string]interface{}{
2588-
"volumeClaimTemplates": []interface{}{
2589-
map[string]interface{}{
2590-
"metadata": map[string]interface{}{
2593+
currentSpec: map[string]any{
2594+
"volumeClaimTemplates": []any{
2595+
map[string]any{
2596+
"metadata": map[string]any{
25912597
"name": "data1",
25922598
},
25932599
},
25942600
},
25952601
},
2596-
desiredSpec: map[string]interface{}{
2597-
"volumeClaimTemplates": []interface{}{
2598-
map[string]interface{}{
2599-
"metadata": map[string]interface{}{
2602+
desiredSpec: map[string]any{
2603+
"volumeClaimTemplates": []any{
2604+
map[string]any{
2605+
"metadata": map[string]any{
26002606
"name": "data1",
26012607
},
26022608
},
2603-
map[string]interface{}{
2604-
"metadata": map[string]interface{}{
2609+
map[string]any{
2610+
"metadata": map[string]any{
26052611
"name": "data2",
26062612
},
26072613
},
@@ -2616,27 +2622,27 @@ Forbidden: updates to statefulset spec for fields other than 'replicas', 'ordina
26162622
},
26172623
{
26182624
name: "multiple volumeClaimTemplate change",
2619-
currentSpec: map[string]interface{}{
2625+
currentSpec: map[string]any{
26202626
"serviceName": postgresqlSvc,
2621-
"selector": map[string]interface{}{
2622-
"matchLabels": map[string]interface{}{
2627+
"selector": map[string]any{
2628+
"matchLabels": map[string]any{
26232629
"app": "postgresql",
26242630
},
26252631
},
2626-
"volumeClaimTemplates": []interface{}{
2632+
"volumeClaimTemplates": []any{
26272633
templateWithStorage(staticFiles, "1Gi"),
26282634
templateWithStorage(dexconfig, "1Gi"),
26292635
templateWithStorage(argocdDexServerTLS, "1Gi"),
26302636
},
26312637
},
2632-
desiredSpec: map[string]interface{}{
2638+
desiredSpec: map[string]any{
26332639
"serviceName": postgresqlSvc,
2634-
"selector": map[string]interface{}{
2635-
"matchLabels": map[string]interface{}{
2640+
"selector": map[string]any{
2641+
"matchLabels": map[string]any{
26362642
"app": "postgresql",
26372643
},
26382644
},
2639-
"volumeClaimTemplates": []interface{}{
2645+
"volumeClaimTemplates": []any{
26402646
templateWithStorage(staticFiles, "2Gi"),
26412647
templateWithStorage(dexconfig, "3Gi"),
26422648
templateWithStorage(argocdDexServerTLS, "4Gi"),
@@ -2657,27 +2663,27 @@ Forbidden: updates to statefulset spec for fields other than 'replicas', 'ordina
26572663
},
26582664
{
26592665
name: "multiple field changes",
2660-
currentSpec: map[string]interface{}{
2666+
currentSpec: map[string]any{
26612667
"serviceName": postgresqlSvc,
2662-
"selector": map[string]interface{}{
2663-
"matchLabels": map[string]interface{}{
2668+
"selector": map[string]any{
2669+
"matchLabels": map[string]any{
26642670
"app": "postgresql",
26652671
},
26662672
},
2667-
"volumeClaimTemplates": []interface{}{
2673+
"volumeClaimTemplates": []any{
26682674
templateWithStorage(staticFiles, "1Gi"),
26692675
templateWithStorage(dexconfig, "1Gi"),
26702676
templateWithStorage(argocdDexServerTLS, "1Gi"),
26712677
},
26722678
},
2673-
desiredSpec: map[string]interface{}{
2679+
desiredSpec: map[string]any{
26742680
"serviceName": "postgresql-svc-new",
2675-
"selector": map[string]interface{}{
2676-
"matchLabels": map[string]interface{}{
2681+
"selector": map[string]any{
2682+
"matchLabels": map[string]any{
26772683
"app": "postgresql-new",
26782684
},
26792685
},
2680-
"volumeClaimTemplates": []interface{}{
2686+
"volumeClaimTemplates": []any{
26812687
templateWithStorage(staticFiles, "2Gi"),
26822688
templateWithStorage(dexconfig, "1Gi"),
26832689
templateWithStorage(argocdDexServerTLS, "1Gi"),
@@ -2701,10 +2707,10 @@ Forbidden: updates to statefulset spec for fields other than 'replicas', 'ordina
27012707
for _, tt := range tests {
27022708
t.Run(tt.name, func(t *testing.T) {
27032709
current := &unstructured.Unstructured{
2704-
Object: map[string]interface{}{
2710+
Object: map[string]any{
27052711
"apiVersion": testAPIVersion,
27062712
"kind": "StatefulSet",
2707-
"metadata": map[string]interface{}{
2713+
"metadata": map[string]any{
27082714
"name": testStatefulSet,
27092715
"namespace": testNamespace,
27102716
},
@@ -2713,10 +2719,10 @@ Forbidden: updates to statefulset spec for fields other than 'replicas', 'ordina
27132719
}
27142720

27152721
desired := &unstructured.Unstructured{
2716-
Object: map[string]interface{}{
2722+
Object: map[string]any{
27172723
"apiVersion": testAPIVersion,
27182724
"kind": "StatefulSet",
2719-
"metadata": map[string]interface{}{
2725+
"metadata": map[string]any{
27202726
"name": testStatefulSet,
27212727
"namespace": testNamespace,
27222728
},

0 commit comments

Comments
 (0)