Skip to content

Commit ef755c5

Browse files
authored
Merge pull request kubernetes-sigs#9694 from archerwu9425/main
🐛 fix provider namespace secret not included in clusterctl move
2 parents cade6fb + 327b470 commit ef755c5

File tree

3 files changed

+14
-26
lines changed

3 files changed

+14
-26
lines changed

cmd/clusterctl/client/cluster/mover_test.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,7 @@ func Test_objectMover_backupTargetObject(t *testing.T) {
735735
graph := getObjectGraphWithObjs(tt.fields.objs)
736736

737737
// Get all the types to be considered for discovery
738-
g.Expect(getFakeDiscoveryTypes(ctx, graph)).To(Succeed())
738+
g.Expect(graph.getDiscoveryTypes(ctx)).To(Succeed())
739739

740740
// trigger discovery the content of the source cluster
741741
g.Expect(graph.Discovery(ctx, "")).To(Succeed())
@@ -826,7 +826,7 @@ func Test_objectMover_restoreTargetObject(t *testing.T) {
826826
graph := getObjectGraph()
827827

828828
// Get all the types to be considered for discovery
829-
g.Expect(getFakeDiscoveryTypes(ctx, graph)).To(Succeed())
829+
g.Expect(graph.getDiscoveryTypes(ctx)).To(Succeed())
830830

831831
// trigger discovery the content of the source cluster
832832
g.Expect(graph.Discovery(ctx, "")).To(Succeed())
@@ -934,7 +934,7 @@ func Test_objectMover_toDirectory(t *testing.T) {
934934
graph := getObjectGraphWithObjs(tt.fields.objs)
935935

936936
// Get all the types to be considered for discovery
937-
g.Expect(getFakeDiscoveryTypes(ctx, graph)).To(Succeed())
937+
g.Expect(graph.getDiscoveryTypes(ctx)).To(Succeed())
938938

939939
// trigger discovery the content of the source cluster
940940
g.Expect(graph.Discovery(ctx, "")).To(Succeed())
@@ -1077,7 +1077,7 @@ func Test_objectMover_fromDirectory(t *testing.T) {
10771077
graph := getObjectGraph()
10781078

10791079
// Get all the types to be considered for discovery
1080-
g.Expect(getFakeDiscoveryTypes(ctx, graph)).To(Succeed())
1080+
g.Expect(graph.getDiscoveryTypes(ctx)).To(Succeed())
10811081

10821082
// gets a fakeProxy to an empty cluster with all the required CRDs
10831083
toProxy := getFakeProxyWithCRDs()
@@ -1155,7 +1155,7 @@ func Test_getMoveSequence(t *testing.T) {
11551155
graph := getObjectGraphWithObjs(tt.fields.objs)
11561156

11571157
// Get all the types to be considered for discovery
1158-
g.Expect(getFakeDiscoveryTypes(ctx, graph)).To(Succeed())
1158+
g.Expect(graph.getDiscoveryTypes(ctx)).To(Succeed())
11591159

11601160
// trigger discovery the content of the source cluster
11611161
g.Expect(graph.Discovery(ctx, "")).To(Succeed())
@@ -1188,7 +1188,7 @@ func Test_objectMover_move_dryRun(t *testing.T) {
11881188
graph := getObjectGraphWithObjs(tt.fields.objs)
11891189

11901190
// Get all the types to be considered for discovery
1191-
g.Expect(getFakeDiscoveryTypes(ctx, graph)).To(Succeed())
1191+
g.Expect(graph.getDiscoveryTypes(ctx)).To(Succeed())
11921192

11931193
// trigger discovery the content of the source cluster
11941194
g.Expect(graph.Discovery(ctx, "")).To(Succeed())
@@ -1263,7 +1263,7 @@ func Test_objectMover_move(t *testing.T) {
12631263
graph := getObjectGraphWithObjs(tt.fields.objs)
12641264

12651265
// Get all the types to be considered for discovery
1266-
g.Expect(getFakeDiscoveryTypes(ctx, graph)).To(Succeed())
1266+
g.Expect(graph.getDiscoveryTypes(ctx)).To(Succeed())
12671267

12681268
// trigger discovery the content of the source cluster
12691269
g.Expect(graph.Discovery(ctx, "")).To(Succeed())
@@ -1375,7 +1375,7 @@ func Test_objectMover_move_with_Mutator(t *testing.T) {
13751375
graph := getObjectGraphWithObjs(tt.fields.objs)
13761376

13771377
// Get all the types to be considered for discovery
1378-
g.Expect(getFakeDiscoveryTypes(ctx, graph)).To(Succeed())
1378+
g.Expect(graph.getDiscoveryTypes(ctx)).To(Succeed())
13791379

13801380
// trigger discovery the content of the source cluster
13811381
g.Expect(graph.Discovery(ctx, "")).To(Succeed())
@@ -1660,7 +1660,7 @@ func Test_objectMover_checkProvisioningCompleted(t *testing.T) {
16601660
graph := getObjectGraphWithObjs(tt.fields.objs)
16611661

16621662
// Get all the types to be considered for discovery
1663-
g.Expect(getFakeDiscoveryTypes(ctx, graph)).To(Succeed())
1663+
g.Expect(graph.getDiscoveryTypes(ctx)).To(Succeed())
16641664

16651665
// trigger discovery the content of the source cluster
16661666
g.Expect(graph.Discovery(ctx, "")).To(Succeed())
@@ -1906,7 +1906,7 @@ func Test_objectMoverService_ensureNamespaces(t *testing.T) {
19061906
graph := getObjectGraphWithObjs(tt.fields.objs)
19071907

19081908
// Get all the types to be considered for discovery
1909-
g.Expect(getFakeDiscoveryTypes(ctx, graph)).To(Succeed())
1909+
g.Expect(graph.getDiscoveryTypes(ctx)).To(Succeed())
19101910

19111911
// Trigger discovery the content of the source cluster
19121912
g.Expect(graph.Discovery(ctx, "")).To(Succeed())
@@ -2385,7 +2385,7 @@ func TestWaitReadyForMove(t *testing.T) {
23852385
}
23862386

23872387
// Get all the types to be considered for discovery
2388-
g.Expect(getFakeDiscoveryTypes(ctx, graph)).To(Succeed())
2388+
g.Expect(graph.getDiscoveryTypes(ctx)).To(Succeed())
23892389

23902390
// trigger discovery the content of the source cluster
23912391
g.Expect(graph.Discovery(ctx, "")).To(Succeed())

cmd/clusterctl/client/cluster/objectgraph.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ func (o *objectGraph) Discovery(ctx context.Context, namespace string) error {
439439
}
440440

441441
// if we are discovering Secrets, also secrets from the providers namespace should be included.
442-
if discoveryType.typeMeta.GetObjectKind().GroupVersionKind().GroupKind() == corev1.SchemeGroupVersion.WithKind("SecretList").GroupKind() {
442+
if discoveryType.typeMeta.GetObjectKind().GroupVersionKind().GroupKind() == corev1.SchemeGroupVersion.WithKind("Secret").GroupKind() {
443443
providers, err := o.providerInventory.List(ctx)
444444
if err != nil {
445445
return err

cmd/clusterctl/client/cluster/objectgraph_test.go

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1774,18 +1774,6 @@ func getFakeProxyWithCRDs() *test.FakeProxy {
17741774
return proxy
17751775
}
17761776

1777-
func getFakeDiscoveryTypes(ctx context.Context, graph *objectGraph) error {
1778-
if err := graph.getDiscoveryTypes(ctx); err != nil {
1779-
return err
1780-
}
1781-
1782-
// Given that the Fake client behaves in a different way than real client, for this test we are required to add the List suffix to all the types.
1783-
for _, discoveryType := range graph.types {
1784-
discoveryType.typeMeta.Kind = fmt.Sprintf("%sList", discoveryType.typeMeta.Kind)
1785-
}
1786-
return nil
1787-
}
1788-
17891777
func TestObjectGraph_Discovery(t *testing.T) {
17901778
// NB. we are testing the graph is properly built starting from objects (TestGraphBuilder_addObj_WithFakeObjects) or from the same objects read from the cluster (this test).
17911779
for _, tt := range objectGraphsTests {
@@ -1798,7 +1786,7 @@ func TestObjectGraph_Discovery(t *testing.T) {
17981786
graph := getObjectGraphWithObjs(tt.args.objs)
17991787

18001788
// Get all the types to be considered for discovery
1801-
err := getFakeDiscoveryTypes(ctx, graph)
1789+
err := graph.getDiscoveryTypes(ctx)
18021790
g.Expect(err).ToNot(HaveOccurred())
18031791

18041792
// finally test discovery
@@ -1956,7 +1944,7 @@ func TestObjectGraph_DiscoveryByNamespace(t *testing.T) {
19561944
graph := getObjectGraphWithObjs(tt.args.objs)
19571945

19581946
// Get all the types to be considered for discovery
1959-
err := getFakeDiscoveryTypes(ctx, graph)
1947+
err := graph.getDiscoveryTypes(ctx)
19601948
g.Expect(err).ToNot(HaveOccurred())
19611949

19621950
// finally test discovery

0 commit comments

Comments
 (0)