Skip to content

Commit 82e5465

Browse files
authored
Merge pull request crossplane#6064 from turkenh/fix-warnings
Fix unknown fields warnings
2 parents eae6b41 + 6e2ae7e commit 82e5465

File tree

15 files changed

+86
-87
lines changed

15 files changed

+86
-87
lines changed

cmd/crank/beta/trace/internal/resource/xrm/client.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ func getResourceChildrenRefs(r *resource.Resource, getConnectionSecrets bool) []
120120
APIVersion: ref.APIVersion,
121121
Kind: ref.Kind,
122122
Name: ref.Name,
123-
Namespace: ref.Namespace,
124123
})
125124
}
126125
if getConnectionSecrets {

cmd/crank/beta/trace/internal/resource/xrm/client_test.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,14 @@ import (
2828
xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1"
2929
"github.com/crossplane/crossplane-runtime/pkg/resource/unstructured/claim"
3030
"github.com/crossplane/crossplane-runtime/pkg/resource/unstructured/composite"
31+
"github.com/crossplane/crossplane-runtime/pkg/resource/unstructured/reference"
3132

3233
resource2 "github.com/crossplane/crossplane/cmd/crank/beta/trace/internal/resource"
3334
)
3435

3536
type xrcOpt func(c *claim.Unstructured)
3637

37-
func withXRCRef(ref *v1.ObjectReference) xrcOpt {
38+
func withXRCRef(ref *reference.Composite) xrcOpt {
3839
return func(c *claim.Unstructured) {
3940
c.SetResourceReference(ref)
4041
}
@@ -96,7 +97,7 @@ func TestGetResourceChildrenRefs(t *testing.T) {
9697
reason: "Should return the XR child for an XRC.",
9798
args: args{
9899
resource: &resource2.Resource{
99-
Unstructured: *buildXRC("ns-1", "xrc", withXRCRef(&v1.ObjectReference{
100+
Unstructured: *buildXRC("ns-1", "xrc", withXRCRef(&reference.Composite{
100101
APIVersion: "example.com/v1",
101102
Kind: "XR",
102103
Name: "xr-1",
@@ -171,7 +172,7 @@ func TestGetResourceChildrenRefs(t *testing.T) {
171172
resource: &resource2.Resource{
172173
Unstructured: *buildXRC("ns-1", "xrc", withXRCSecretRef(&xpv1.LocalSecretReference{
173174
Name: "secret-1",
174-
}), withXRCRef(&v1.ObjectReference{
175+
}), withXRCRef(&reference.Composite{
175176
APIVersion: "example.com/v1",
176177
Kind: "XR",
177178
Name: "xr-1",
@@ -201,7 +202,7 @@ func TestGetResourceChildrenRefs(t *testing.T) {
201202
resource: &resource2.Resource{
202203
Unstructured: *buildXRC("ns-1", "xrc", withXRCSecretRef(&xpv1.LocalSecretReference{
203204
Name: "secret-1",
204-
}), withXRCRef(&v1.ObjectReference{
205+
}), withXRCRef(&reference.Composite{
205206
APIVersion: "example.com/v1",
206207
Kind: "XR",
207208
Name: "xr-1",

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ require (
77
github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24
88
github.com/Masterminds/semver v1.5.0
99
github.com/alecthomas/kong v0.9.0
10-
github.com/crossplane/crossplane-runtime v1.19.0-rc.0
10+
github.com/crossplane/crossplane-runtime v1.19.0-rc.0.0.20241105071456-19d95a69cc03
1111
github.com/docker/docker v27.1.1+incompatible
1212
github.com/docker/go-connections v0.5.0
1313
github.com/emicklei/dot v1.6.2

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,8 @@ github.com/cpuguy83/go-md2man/v2 v2.0.1/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46t
211211
github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
212212
github.com/creack/pty v1.1.18 h1:n56/Zwd5o6whRC5PMGretI4IdRLlmBXYNjScPaBgsbY=
213213
github.com/creack/pty v1.1.18/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4=
214-
github.com/crossplane/crossplane-runtime v1.19.0-rc.0 h1:VoQaT4qVTjeY7wAtvdSKtxcm4USqrczOeFMuQYq7aCQ=
215-
github.com/crossplane/crossplane-runtime v1.19.0-rc.0/go.mod h1:p7nVVsLn0CWjsLvLCtr7T40ErbTgNWKRxmYnwFdfXb4=
214+
github.com/crossplane/crossplane-runtime v1.19.0-rc.0.0.20241105071456-19d95a69cc03 h1:SjZIJeIE1AZYrzyAIhU3r9Kr9d71XQxlMrZO4xNGHqQ=
215+
github.com/crossplane/crossplane-runtime v1.19.0-rc.0.0.20241105071456-19d95a69cc03/go.mod h1:p7nVVsLn0CWjsLvLCtr7T40ErbTgNWKRxmYnwFdfXb4=
216216
github.com/cyberphone/json-canonicalization v0.0.0-20231011164504-785e29786b46 h1:2Dx4IHfC1yHWI12AxQDJM1QbRCDfk6M+blLzlZCXdrc=
217217
github.com/cyberphone/json-canonicalization v0.0.0-20231011164504-785e29786b46/go.mod h1:uzvlm1mxhHkdfqitSA92i7Se+S9ksOn3a3qmv/kyOCw=
218218
github.com/cyphar/filepath-securejoin v0.2.4 h1:Ugdm7cg7i6ZK6x3xDF1oEu1nfkyfH53EtKeQYTC3kyg=

internal/controller/apiextensions/claim/reconciler.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
kerrors "k8s.io/apimachinery/pkg/api/errors"
2727
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2828
"k8s.io/apimachinery/pkg/runtime/schema"
29+
"k8s.io/apimachinery/pkg/types"
2930
"sigs.k8s.io/controller-runtime/pkg/client"
3031
"sigs.k8s.io/controller-runtime/pkg/reconcile"
3132

@@ -348,7 +349,7 @@ func (r *Reconciler) Reconcile(ctx context.Context, req reconcile.Request) (reco
348349
record = record.WithAnnotations("composite-name", cm.GetResourceReference().Name)
349350
log = log.WithValues("composite-name", cm.GetResourceReference().Name)
350351

351-
if err := r.client.Get(ctx, meta.NamespacedNameOf(ref), xr); resource.IgnoreNotFound(err) != nil {
352+
if err := r.client.Get(ctx, types.NamespacedName{Name: ref.Name}, xr); resource.IgnoreNotFound(err) != nil {
352353
err = errors.Wrap(err, errGetComposite)
353354
record.Event(cm, event.Warning(reasonBind, err))
354355
cm.SetConditions(xpv1.ReconcileError(err))

internal/controller/apiextensions/claim/reconciler_test.go

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import (
3737
"github.com/crossplane/crossplane-runtime/pkg/resource"
3838
"github.com/crossplane/crossplane-runtime/pkg/resource/unstructured/claim"
3939
"github.com/crossplane/crossplane-runtime/pkg/resource/unstructured/composite"
40+
"github.com/crossplane/crossplane-runtime/pkg/resource/unstructured/reference"
4041
"github.com/crossplane/crossplane-runtime/pkg/test"
4142
)
4243

@@ -141,7 +142,7 @@ func TestReconcile(t *testing.T) {
141142
case *claim.Unstructured:
142143
// We won't try to get an XR unless the claim
143144
// references one.
144-
o.SetResourceReference(&corev1.ObjectReference{Name: "cool-composite"})
145+
o.SetResourceReference(&reference.Composite{Name: "cool-composite"})
145146
case *composite.Unstructured:
146147
// Return an error getting the XR.
147148
return errBoom
@@ -150,7 +151,7 @@ func TestReconcile(t *testing.T) {
150151
}),
151152
MockStatusUpdate: WantClaim(t, NewClaim(func(cm *claim.Unstructured) {
152153
// Check that we set our status condition.
153-
cm.SetResourceReference(&corev1.ObjectReference{Name: "cool-composite"})
154+
cm.SetResourceReference(&reference.Composite{Name: "cool-composite"})
154155
cm.SetConditions(xpv1.ReconcileError(errors.Wrap(errBoom, errGetComposite)))
155156
})),
156157
},
@@ -168,18 +169,18 @@ func TestReconcile(t *testing.T) {
168169
case *claim.Unstructured:
169170
// We won't try to get an XR unless the claim
170171
// references one.
171-
o.SetResourceReference(&corev1.ObjectReference{Name: "cool-composite"})
172+
o.SetResourceReference(&reference.Composite{Name: "cool-composite"})
172173
case *composite.Unstructured:
173174
// This XR was created, and references another
174175
// claim.
175176
o.SetCreationTimestamp(now)
176-
o.SetClaimReference(&claim.Reference{Name: "some-other-claim"})
177+
o.SetClaimReference(&reference.Claim{Name: "some-other-claim"})
177178
}
178179
return nil
179180
}),
180181
MockStatusUpdate: WantClaim(t, NewClaim(func(cm *claim.Unstructured) {
181182
// Check that we set our status condition.
182-
cm.SetResourceReference(&corev1.ObjectReference{Name: "cool-composite"})
183+
cm.SetResourceReference(&reference.Composite{Name: "cool-composite"})
183184
cm.SetConditions(xpv1.ReconcileError(errors.Errorf(errFmtUnbound, "", "some-other-claim")))
184185
})),
185186
},
@@ -198,7 +199,7 @@ func TestReconcile(t *testing.T) {
198199
o.SetDeletionTimestamp(&now)
199200
// We won't try to get an XR unless the claim
200201
// references one.
201-
o.SetResourceReference(&corev1.ObjectReference{Name: "cool-composite"})
202+
o.SetResourceReference(&reference.Composite{Name: "cool-composite"})
202203
case *composite.Unstructured:
203204
// Pretend the XR exists.
204205
o.SetCreationTimestamp(now)
@@ -209,7 +210,7 @@ func TestReconcile(t *testing.T) {
209210
MockStatusUpdate: WantClaim(t, NewClaim(func(cm *claim.Unstructured) {
210211
// Check that we set our status condition.
211212
cm.SetDeletionTimestamp(&now)
212-
cm.SetResourceReference(&corev1.ObjectReference{Name: "cool-composite"})
213+
cm.SetResourceReference(&reference.Composite{Name: "cool-composite"})
213214
cm.SetConditions(xpv1.Deleting())
214215
cm.SetConditions(xpv1.ReconcileError(errors.Wrap(errBoom, errDeleteComposite)))
215216
})),
@@ -312,14 +313,14 @@ func TestReconcile(t *testing.T) {
312313
o.SetDeletionTimestamp(&now)
313314
// We won't try to get an XR unless the claim
314315
// references one.
315-
o.SetResourceReference(&corev1.ObjectReference{Name: "cool-composite"})
316+
o.SetResourceReference(&reference.Composite{Name: "cool-composite"})
316317
// We want to foreground delete.
317318
fg := xpv1.CompositeDeleteForeground
318319
o.SetCompositeDeletePolicy(&fg)
319320
case *composite.Unstructured:
320321
// Pretend the XR exists and is bound.
321322
o.SetCreationTimestamp(now)
322-
o.SetClaimReference(&claim.Reference{})
323+
o.SetClaimReference(&reference.Claim{})
323324
}
324325
return nil
325326
}),
@@ -345,7 +346,7 @@ func TestReconcile(t *testing.T) {
345346
o.SetDeletionTimestamp(&now)
346347
// We won't try to get an XR unless the claim
347348
// references one.
348-
o.SetResourceReference(&corev1.ObjectReference{Name: "cool-composite"})
349+
o.SetResourceReference(&reference.Composite{Name: "cool-composite"})
349350
// We want to foreground delete.
350351
fg := xpv1.CompositeDeleteForeground
351352
o.SetCompositeDeletePolicy(&fg)
@@ -354,12 +355,12 @@ func TestReconcile(t *testing.T) {
354355
// being deleted.
355356
o.SetCreationTimestamp(now)
356357
o.SetDeletionTimestamp(&now)
357-
o.SetClaimReference(&claim.Reference{})
358+
o.SetClaimReference(&reference.Claim{})
358359
}
359360
return nil
360361
}),
361362
MockStatusUpdate: WantClaim(t, NewClaim(func(cm *claim.Unstructured) {
362-
cm.SetResourceReference(&corev1.ObjectReference{Name: "cool-composite"})
363+
cm.SetResourceReference(&reference.Composite{Name: "cool-composite"})
363364
// We want to foreground delete.
364365
fg := xpv1.CompositeDeleteForeground
365366
cm.SetCompositeDeletePolicy(&fg)
@@ -429,19 +430,19 @@ func TestReconcile(t *testing.T) {
429430
case *claim.Unstructured:
430431
// We won't try to get an XR unless the claim
431432
// references one.
432-
o.SetResourceReference(&corev1.ObjectReference{Name: "cool-composite"})
433+
o.SetResourceReference(&reference.Composite{Name: "cool-composite"})
433434
case *composite.Unstructured:
434435
// Pretend the XR exists and is bound, but is
435436
// still being created.
436437
o.SetCreationTimestamp(now)
437-
o.SetClaimReference(&claim.Reference{})
438+
o.SetClaimReference(&reference.Claim{})
438439
o.SetConditions(xpv1.Creating())
439440
}
440441
return nil
441442
}),
442443
MockStatusUpdate: WantClaim(t, NewClaim(func(cm *claim.Unstructured) {
443444
// Check that we set our status condition.
444-
cm.SetResourceReference(&corev1.ObjectReference{Name: "cool-composite"})
445+
cm.SetResourceReference(&reference.Composite{Name: "cool-composite"})
445446
cm.SetConditions(xpv1.ReconcileSuccess())
446447
cm.SetConditions(Waiting())
447448
})),
@@ -466,18 +467,18 @@ func TestReconcile(t *testing.T) {
466467
case *claim.Unstructured:
467468
// We won't try to get an XR unless the claim
468469
// references one.
469-
o.SetResourceReference(&corev1.ObjectReference{Name: "cool-composite"})
470+
o.SetResourceReference(&reference.Composite{Name: "cool-composite"})
470471
case *composite.Unstructured:
471472
// Pretend the XR exists and is available.
472473
o.SetCreationTimestamp(now)
473-
o.SetClaimReference(&claim.Reference{})
474+
o.SetClaimReference(&reference.Claim{})
474475
o.SetConditions(xpv1.Available())
475476
}
476477
return nil
477478
}),
478479
MockStatusUpdate: WantClaim(t, NewClaim(func(cm *claim.Unstructured) {
479480
// Check that we set our status condition.
480-
cm.SetResourceReference(&corev1.ObjectReference{Name: "cool-composite"})
481+
cm.SetResourceReference(&reference.Composite{Name: "cool-composite"})
481482
cm.SetConditions(xpv1.ReconcileError(errors.Wrap(errBoom, errPropagateCDs)))
482483
})),
483484
},
@@ -504,18 +505,18 @@ func TestReconcile(t *testing.T) {
504505
case *claim.Unstructured:
505506
// We won't try to get an XR unless the claim
506507
// references one.
507-
o.SetResourceReference(&corev1.ObjectReference{Name: "cool-composite"})
508+
o.SetResourceReference(&reference.Composite{Name: "cool-composite"})
508509
case *composite.Unstructured:
509510
// Pretend the XR exists and is available.
510511
o.SetCreationTimestamp(now)
511-
o.SetClaimReference(&claim.Reference{})
512+
o.SetClaimReference(&reference.Claim{})
512513
o.SetConditions(xpv1.Available())
513514
}
514515
return nil
515516
}),
516517
MockStatusUpdate: WantClaim(t, NewClaim(func(cm *claim.Unstructured) {
517518
// Check that we set our status condition.
518-
cm.SetResourceReference(&corev1.ObjectReference{Name: "cool-composite"})
519+
cm.SetResourceReference(&reference.Composite{Name: "cool-composite"})
519520
cm.SetConnectionDetailsLastPublishedTime(&now)
520521
cm.SetConditions(xpv1.ReconcileSuccess())
521522
cm.SetConditions(xpv1.Available())
@@ -544,7 +545,7 @@ func TestReconcile(t *testing.T) {
544545
case *claim.Unstructured:
545546
// We won't try to get an XR unless the claim
546547
// references one.
547-
o.SetResourceReference(&corev1.ObjectReference{Name: "cool-composite"})
548+
o.SetResourceReference(&reference.Composite{Name: "cool-composite"})
548549
// The system conditions are already set.
549550
o.SetConditions(xpv1.ReconcileSuccess())
550551
o.SetConditions(xpv1.Available())
@@ -557,7 +558,7 @@ func TestReconcile(t *testing.T) {
557558
case *composite.Unstructured:
558559
// Pretend the XR exists and is available.
559560
o.SetCreationTimestamp(now)
560-
o.SetClaimReference(&claim.Reference{})
561+
o.SetClaimReference(&reference.Claim{})
561562
o.SetConditions(xpv1.Available())
562563
o.SetConditions(
563564
// Database has become ready.
@@ -588,7 +589,7 @@ func TestReconcile(t *testing.T) {
588589
}),
589590
MockStatusUpdate: WantClaim(t, NewClaim(func(cm *claim.Unstructured) {
590591
// Check that we set our status condition.
591-
cm.SetResourceReference(&corev1.ObjectReference{Name: "cool-composite"})
592+
cm.SetResourceReference(&reference.Composite{Name: "cool-composite"})
592593
cm.SetConnectionDetailsLastPublishedTime(&now)
593594
cm.SetConditions(xpv1.ReconcileSuccess())
594595
cm.SetConditions(xpv1.Available())

internal/controller/apiextensions/claim/syncer_csa.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ func (s *ClientSideCompositeSyncer) Sync(ctx context.Context, cm *claim.Unstruct
150150
// then crashed before saving a reference to it. We'd create another XR on
151151
// the next reconcile.
152152
existing := cm.GetResourceReference()
153-
proposed := meta.ReferenceTo(xr, xr.GetObjectKind().GroupVersionKind())
153+
proposed := xr.GetReference()
154154
if !cmp.Equal(existing, proposed) {
155155
cm.SetResourceReference(proposed)
156156
if err := s.client.Update(ctx, cm); err != nil {

internal/controller/apiextensions/claim/syncer_csa_test.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import (
3030
"github.com/crossplane/crossplane-runtime/pkg/resource"
3131
"github.com/crossplane/crossplane-runtime/pkg/resource/unstructured/claim"
3232
"github.com/crossplane/crossplane-runtime/pkg/resource/unstructured/composite"
33+
"github.com/crossplane/crossplane-runtime/pkg/resource/unstructured/reference"
3334
"github.com/crossplane/crossplane-runtime/pkg/test"
3435

3536
"github.com/crossplane/crossplane/internal/names"
@@ -118,7 +119,7 @@ func TestClientSideSync(t *testing.T) {
118119
xcrd.LabelKeyClaimNamespace: "default",
119120
xcrd.LabelKeyClaimName: "cool-claim",
120121
})
121-
xr.SetClaimReference(&claim.Reference{
122+
xr.SetClaimReference(&reference.Claim{
122123
Namespace: "default",
123124
Name: "cool-claim",
124125
})
@@ -159,7 +160,7 @@ func TestClientSideSync(t *testing.T) {
159160
cm.SetCompositionReference(&corev1.ObjectReference{
160161
Name: "some-composition",
161162
})
162-
cm.SetResourceReference(&corev1.ObjectReference{
163+
cm.SetResourceReference(&reference.Composite{
163164
Name: "cool-claim-random",
164165
})
165166
}),
@@ -170,7 +171,7 @@ func TestClientSideSync(t *testing.T) {
170171
xcrd.LabelKeyClaimNamespace: "default",
171172
xcrd.LabelKeyClaimName: "cool-claim",
172173
})
173-
xr.SetClaimReference(&claim.Reference{
174+
xr.SetClaimReference(&reference.Claim{
174175
Namespace: "default",
175176
Name: "cool-claim",
176177
})
@@ -214,7 +215,7 @@ func TestClientSideSync(t *testing.T) {
214215
cm.SetCompositionReference(&corev1.ObjectReference{
215216
Name: "some-composition",
216217
})
217-
cm.SetResourceReference(&corev1.ObjectReference{
218+
cm.SetResourceReference(&reference.Composite{
218219
Name: "cool-claim-random",
219220
})
220221
}),
@@ -225,7 +226,7 @@ func TestClientSideSync(t *testing.T) {
225226
xcrd.LabelKeyClaimNamespace: "default",
226227
xcrd.LabelKeyClaimName: "cool-claim",
227228
})
228-
xr.SetClaimReference(&claim.Reference{
229+
xr.SetClaimReference(&reference.Claim{
229230
Namespace: "default",
230231
Name: "cool-claim",
231232
})
@@ -271,7 +272,7 @@ func TestClientSideSync(t *testing.T) {
271272
cm.SetCompositionReference(&corev1.ObjectReference{
272273
Name: "some-composition",
273274
})
274-
cm.SetResourceReference(&corev1.ObjectReference{
275+
cm.SetResourceReference(&reference.Composite{
275276
Name: "cool-claim-random",
276277
})
277278
}),
@@ -282,7 +283,7 @@ func TestClientSideSync(t *testing.T) {
282283
xcrd.LabelKeyClaimNamespace: "default",
283284
xcrd.LabelKeyClaimName: "cool-claim",
284285
})
285-
xr.SetClaimReference(&claim.Reference{
286+
xr.SetClaimReference(&reference.Claim{
286287
Namespace: "default",
287288
Name: "cool-claim",
288289
})
@@ -358,7 +359,7 @@ func TestClientSideSync(t *testing.T) {
358359
cm.SetCompositionReference(&corev1.ObjectReference{
359360
Name: "some-composition",
360361
})
361-
cm.SetResourceReference(&corev1.ObjectReference{
362+
cm.SetResourceReference(&reference.Composite{
362363
Name: "cool-claim-random",
363364
})
364365

@@ -377,7 +378,7 @@ func TestClientSideSync(t *testing.T) {
377378
"example.org/propagate-me": "true",
378379
})
379380

380-
xr.SetClaimReference(&claim.Reference{
381+
xr.SetClaimReference(&reference.Claim{
381382
Namespace: "default",
382383
Name: "cool-claim",
383384
})

internal/controller/apiextensions/claim/syncer_ssa.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ func (s *ServerSideCompositeSyncer) Sync(ctx context.Context, cm *claim.Unstruct
245245
// apply the claim before we create it. This ensures we don't leak an XR. We
246246
// could leak an XR if we created an XR then crashed before saving a
247247
// reference to it. We'd create another XR on the next reconcile.
248-
cm.SetResourceReference(meta.ReferenceTo(xrPatch, xrPatch.GroupVersionKind()))
248+
cm.SetResourceReference(xrPatch.GetReference())
249249

250250
// Propagate the actual external name back from the composite to the
251251
// claim if it's set. The name we're propagating here will may be a name

0 commit comments

Comments
 (0)