Skip to content

Commit eade2a3

Browse files
chore: Upgrade crossplane (#116)
* fix(deps): update module github.com/crossplane/crossplane-runtime/v2 to v2.1.0-rc.1 * Upgrade crossplane and remove workaround for namespace propagation; also add a different workaround for namespace propagation Signed-off-by: Jonathan Ogilvie <[email protected]> * Fail fast if CRD not found (this is already covered by validation code path) Signed-off-by: Jonathan Ogilvie <[email protected]> * Lint Signed-off-by: Jonathan Ogilvie <[email protected]> * Fix kubeconfig test for local (was already working on earthly) Signed-off-by: Jonathan Ogilvie <[email protected]> --------- Signed-off-by: Jonathan Ogilvie <[email protected]> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
1 parent e9e6d69 commit eade2a3

20 files changed

+418
-463
lines changed

cmd/diff/client/crossplane/composition_client.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ func (c *DefaultCompositionClient) getXRTypeFromXRD(xrdForClaim *un.Unstructured
361361
if versionsFound && len(versions) > 0 {
362362
// Look for the one version that is marked referenceable
363363
for _, versionObj := range versions {
364-
if version, ok := versionObj.(map[string]interface{}); ok {
364+
if version, ok := versionObj.(map[string]any); ok {
365365
ref, refFound, _ := un.NestedBool(version, "referenceable")
366366
if refFound && ref {
367367
name, nameFound, _ := un.NestedString(version, "name")
@@ -481,6 +481,7 @@ func (c *DefaultCompositionClient) findByLabelSelector(ctx context.Context, xrd,
481481

482482
// Convert matchLabels to string map for comparison
483483
stringLabels := make(map[string]string)
484+
484485
for k, v := range matchLabels {
485486
if strVal, ok := v.(string); ok {
486487
stringLabels[k] = strVal

cmd/diff/client/crossplane/composition_client_test.go

Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -481,24 +481,24 @@ func TestDefaultCompositionClient_FindMatchingComposition(t *testing.T) {
481481
return []*un.Unstructured{
482482
tu.NewResource(CrossplaneAPIExtGroupV1, CompositeResourceDefinitionKind, "xexampleresources.example.org").
483483
WithSpecField("group", "example.org").
484-
WithSpecField("names", map[string]interface{}{
484+
WithSpecField("names", map[string]any{
485485
"kind": "XExampleResource",
486486
}).
487-
WithSpecField("claimNames", map[string]interface{}{
487+
WithSpecField("claimNames", map[string]any{
488488
"kind": "ExampleResourceClaim",
489489
}).
490-
WithSpecField("versions", []interface{}{
491-
map[string]interface{}{
490+
WithSpecField("versions", []any{
491+
map[string]any{
492492
"name": "v1",
493493
"served": true,
494494
"referenceable": false,
495495
},
496-
map[string]interface{}{
496+
map[string]any{
497497
"name": "v2",
498498
"served": true,
499499
"referenceable": true, // This is the version compositions should reference
500500
},
501-
map[string]interface{}{
501+
map[string]any{
502502
"name": "v3alpha1",
503503
"served": true,
504504
"referenceable": false,
@@ -516,24 +516,24 @@ func TestDefaultCompositionClient_FindMatchingComposition(t *testing.T) {
516516
WithXRDForClaim(
517517
tu.NewResource(CrossplaneAPIExtGroupV1, CompositeResourceDefinitionKind, "xexampleresources.example.org").
518518
WithSpecField("group", "example.org").
519-
WithSpecField("names", map[string]interface{}{
519+
WithSpecField("names", map[string]any{
520520
"kind": "XExampleResource",
521521
}).
522-
WithSpecField("claimNames", map[string]interface{}{
522+
WithSpecField("claimNames", map[string]any{
523523
"kind": "ExampleResourceClaim",
524524
}).
525-
WithSpecField("versions", []interface{}{
526-
map[string]interface{}{
525+
WithSpecField("versions", []any{
526+
map[string]any{
527527
"name": "v1",
528528
"served": true,
529529
"referenceable": false,
530530
},
531-
map[string]interface{}{
531+
map[string]any{
532532
"name": "v2",
533533
"served": true,
534534
"referenceable": true, // This is the version compositions should reference
535535
},
536-
map[string]interface{}{
536+
map[string]any{
537537
"name": "v3alpha1",
538538
"served": true,
539539
"referenceable": false,
@@ -559,7 +559,7 @@ func TestDefaultCompositionClient_FindMatchingComposition(t *testing.T) {
559559
args: args{
560560
ctx: t.Context(),
561561
res: tu.NewResource("example.org/v1", "ExampleResourceClaim", "test-claim").
562-
WithSpecField("compositionRef", map[string]interface{}{
562+
WithSpecField("compositionRef", map[string]any{
563563
"name": "matching-comp",
564564
}).
565565
Build(),
@@ -590,19 +590,19 @@ func TestDefaultCompositionClient_FindMatchingComposition(t *testing.T) {
590590
tu.NewResource(
591591
CrossplaneAPIExtGroupV1, CompositeResourceDefinitionKind, "xexampleresources.example.org").
592592
WithSpecField("group", "example.org").
593-
WithSpecField("names", map[string]interface{}{
593+
WithSpecField("names", map[string]any{
594594
"kind": "XExampleResource",
595595
}).
596-
WithSpecField("claimNames", map[string]interface{}{
596+
WithSpecField("claimNames", map[string]any{
597597
"kind": "ExampleResourceClaim",
598598
}).
599-
WithSpecField("versions", []interface{}{
600-
map[string]interface{}{
599+
WithSpecField("versions", []any{
600+
map[string]any{
601601
"name": "v1",
602602
"served": true,
603603
"referenceable": false, // No referenceable version
604604
},
605-
map[string]interface{}{
605+
map[string]any{
606606
"name": "v2",
607607
"served": true,
608608
"referenceable": false, // No referenceable version
@@ -620,19 +620,19 @@ func TestDefaultCompositionClient_FindMatchingComposition(t *testing.T) {
620620
tu.NewResource(
621621
CrossplaneAPIExtGroupV1, CompositeResourceDefinitionKind, "xexampleresources.example.org").
622622
WithSpecField("group", "example.org").
623-
WithSpecField("names", map[string]interface{}{
623+
WithSpecField("names", map[string]any{
624624
"kind": "XExampleResource",
625625
}).
626-
WithSpecField("claimNames", map[string]interface{}{
626+
WithSpecField("claimNames", map[string]any{
627627
"kind": "ExampleResourceClaim",
628628
}).
629-
WithSpecField("versions", []interface{}{
630-
map[string]interface{}{
629+
WithSpecField("versions", []any{
630+
map[string]any{
631631
"name": "v1",
632632
"served": true,
633633
"referenceable": false, // No referenceable version
634634
},
635-
map[string]interface{}{
635+
map[string]any{
636636
"name": "v2",
637637
"served": true,
638638
"referenceable": false, // No referenceable version
@@ -657,7 +657,7 @@ func TestDefaultCompositionClient_FindMatchingComposition(t *testing.T) {
657657
args: args{
658658
ctx: t.Context(),
659659
res: tu.NewResource("example.org/v1", "ExampleResourceClaim", "test-claim").
660-
WithSpecField("compositionRef", map[string]interface{}{
660+
WithSpecField("compositionRef", map[string]any{
661661
"name": "matching-comp",
662662
}).
663663
Build(),
@@ -678,21 +678,21 @@ func TestDefaultCompositionClient_FindMatchingComposition(t *testing.T) {
678678
return []*un.Unstructured{
679679
tu.NewResource(CrossplaneAPIExtGroupV1, CompositeResourceDefinitionKind, "xexampleresources.example.org").
680680
WithSpecField("group", "example.org").
681-
WithSpecField("names", map[string]interface{}{
681+
WithSpecField("names", map[string]any{
682682
"kind": "XExampleResource",
683683
}).
684-
WithSpecField("versions", []interface{}{
685-
map[string]interface{}{
684+
WithSpecField("versions", []any{
685+
map[string]any{
686686
"name": "v1",
687687
"served": true,
688688
"referenceable": false,
689689
},
690-
map[string]interface{}{
690+
map[string]any{
691691
"name": "v2",
692692
"served": true,
693693
"referenceable": true, // This is the version compositions should reference
694694
},
695-
map[string]interface{}{
695+
map[string]any{
696696
"name": "v3alpha1",
697697
"served": true,
698698
"referenceable": false,
@@ -727,8 +727,8 @@ func TestDefaultCompositionClient_FindMatchingComposition(t *testing.T) {
727727
args: args{
728728
ctx: t.Context(),
729729
res: tu.NewResource("example.org/v2", "XExampleResource", "my-xr").
730-
WithSpecField("crossplane", map[string]interface{}{
731-
"compositionRef": map[string]interface{}{
730+
WithSpecField("crossplane", map[string]any{
731+
"compositionRef": map[string]any{
732732
"name": "matching-comp",
733733
},
734734
}).
@@ -1142,11 +1142,11 @@ func TestDefaultCompositionClient_ResolveCompositionFromRevisions(t *testing.T)
11421142
// Create test XRD
11431143
v1XRD := tu.NewResource(CrossplaneAPIExtGroupV1, CompositeResourceDefinitionKind, "xr1s.example.org").
11441144
WithSpecField("group", "example.org").
1145-
WithSpecField("names", map[string]interface{}{
1145+
WithSpecField("names", map[string]any{
11461146
"kind": "XR1",
11471147
}).
1148-
WithSpecField("versions", []interface{}{
1149-
map[string]interface{}{
1148+
WithSpecField("versions", []any{
1149+
map[string]any{
11501150
"name": "v1",
11511151
"served": true,
11521152
"referenceable": true,
@@ -1155,11 +1155,11 @@ func TestDefaultCompositionClient_ResolveCompositionFromRevisions(t *testing.T)
11551155

11561156
v2XRD := tu.NewResource(CrossplaneAPIExtGroupV1, CompositeResourceDefinitionKind, "xr1s.example.org").
11571157
WithSpecField("group", "example.org").
1158-
WithSpecField("names", map[string]interface{}{
1158+
WithSpecField("names", map[string]any{
11591159
"kind": "XR1",
11601160
}).
1161-
WithSpecField("versions", []interface{}{
1162-
map[string]interface{}{
1161+
WithSpecField("versions", []any{
1162+
map[string]any{
11631163
"name": "v2",
11641164
"served": true,
11651165
"referenceable": true,
@@ -1181,7 +1181,7 @@ func TestDefaultCompositionClient_ResolveCompositionFromRevisions(t *testing.T)
11811181
reason: "Should use latest revision when update policy is Automatic",
11821182
xrd: v1XRD,
11831183
res: tu.NewResource("example.org/v1", "XR1", "my-xr").
1184-
WithSpecField("compositionRef", map[string]interface{}{
1184+
WithSpecField("compositionRef", map[string]any{
11851185
"name": "test-comp",
11861186
}).
11871187
WithSpecField("compositionUpdatePolicy", "Automatic").
@@ -1210,10 +1210,10 @@ func TestDefaultCompositionClient_ResolveCompositionFromRevisions(t *testing.T)
12101210
reason: "Should use specified revision when update policy is Manual with revision ref",
12111211
xrd: v1XRD,
12121212
res: tu.NewResource("example.org/v1", "XR1", "my-xr").
1213-
WithSpecField("compositionRef", map[string]interface{}{
1213+
WithSpecField("compositionRef", map[string]any{
12141214
"name": "test-comp",
12151215
}).
1216-
WithSpecField("compositionRevisionRef", map[string]interface{}{
1216+
WithSpecField("compositionRevisionRef", map[string]any{
12171217
"name": "test-comp-rev1",
12181218
}).
12191219
WithSpecField("compositionUpdatePolicy", "Manual").
@@ -1246,7 +1246,7 @@ func TestDefaultCompositionClient_ResolveCompositionFromRevisions(t *testing.T)
12461246
reason: "Should use latest revision when update policy is Manual without revision ref (net new XR case)",
12471247
xrd: v1XRD,
12481248
res: tu.NewResource("example.org/v1", "XR1", "my-xr").
1249-
WithSpecField("compositionRef", map[string]interface{}{
1249+
WithSpecField("compositionRef", map[string]any{
12501250
"name": "test-comp",
12511251
}).
12521252
WithSpecField("compositionUpdatePolicy", "Manual").
@@ -1275,8 +1275,8 @@ func TestDefaultCompositionClient_ResolveCompositionFromRevisions(t *testing.T)
12751275
reason: "Should use latest revision for v2 XR with Automatic policy",
12761276
xrd: v2XRD,
12771277
res: tu.NewResource("example.org/v2", "XR1", "my-xr").
1278-
WithSpecField("crossplane", map[string]interface{}{
1279-
"compositionRef": map[string]interface{}{
1278+
WithSpecField("crossplane", map[string]any{
1279+
"compositionRef": map[string]any{
12801280
"name": "test-comp",
12811281
},
12821282
"compositionUpdatePolicy": "Automatic",
@@ -1306,8 +1306,8 @@ func TestDefaultCompositionClient_ResolveCompositionFromRevisions(t *testing.T)
13061306
reason: "Should use latest revision for v2 XR with Manual policy but no revision ref",
13071307
xrd: v2XRD,
13081308
res: tu.NewResource("example.org/v2", "XR1", "my-xr").
1309-
WithSpecField("crossplane", map[string]interface{}{
1310-
"compositionRef": map[string]interface{}{
1309+
WithSpecField("crossplane", map[string]any{
1310+
"compositionRef": map[string]any{
13111311
"name": "test-comp",
13121312
},
13131313
"compositionUpdatePolicy": "Manual",
@@ -1337,7 +1337,7 @@ func TestDefaultCompositionClient_ResolveCompositionFromRevisions(t *testing.T)
13371337
reason: "Should return nil when no revisions exist (unpublished composition)",
13381338
xrd: v1XRD,
13391339
res: tu.NewResource("example.org/v1", "XR1", "my-xr").
1340-
WithSpecField("compositionRef", map[string]interface{}{
1340+
WithSpecField("compositionRef", map[string]any{
13411341
"name": "test-comp",
13421342
}).
13431343
WithSpecField("compositionUpdatePolicy", "Automatic").
@@ -1354,10 +1354,10 @@ func TestDefaultCompositionClient_ResolveCompositionFromRevisions(t *testing.T)
13541354
reason: "Should return error when specified revision doesn't exist",
13551355
xrd: v1XRD,
13561356
res: tu.NewResource("example.org/v1", "XR1", "my-xr").
1357-
WithSpecField("compositionRef", map[string]interface{}{
1357+
WithSpecField("compositionRef", map[string]any{
13581358
"name": "test-comp",
13591359
}).
1360-
WithSpecField("compositionRevisionRef", map[string]interface{}{
1360+
WithSpecField("compositionRevisionRef", map[string]any{
13611361
"name": "nonexistent-rev",
13621362
}).
13631363
WithSpecField("compositionUpdatePolicy", "Manual").
@@ -1376,10 +1376,10 @@ func TestDefaultCompositionClient_ResolveCompositionFromRevisions(t *testing.T)
13761376
reason: "Should return error when revision belongs to different composition",
13771377
xrd: v1XRD,
13781378
res: tu.NewResource("example.org/v1", "XR1", "my-xr").
1379-
WithSpecField("compositionRef", map[string]interface{}{
1379+
WithSpecField("compositionRef", map[string]any{
13801380
"name": "test-comp",
13811381
}).
1382-
WithSpecField("compositionRevisionRef", map[string]interface{}{
1382+
WithSpecField("compositionRevisionRef", map[string]any{
13831383
"name": "other-comp-rev1",
13841384
}).
13851385
WithSpecField("compositionUpdatePolicy", "Manual").

cmd/diff/client/crossplane/definition_client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ func (c *DefaultDefinitionClient) GetXRDForXR(ctx context.Context, gvk schema.Gr
195195
versionMatches := false
196196

197197
for _, v := range versions {
198-
version, ok := v.(map[string]interface{})
198+
version, ok := v.(map[string]any)
199199
if !ok {
200200
continue
201201
}

0 commit comments

Comments
 (0)