@@ -52,10 +52,14 @@ var (
52
52
//go:embed assets/topology-test/modified-my-cluster.yaml
53
53
modifiedMyClusterYAML []byte
54
54
55
- // modifiedDockerMachineTemplateYAML adds metadat to the docker machine used by the control plane template..
55
+ // modifiedDockerMachineTemplateYAML adds metadata to the docker machine used by the control plane template..
56
56
//go:embed assets/topology-test/modified-CP-dockermachinetemplate.yaml
57
57
modifiedDockerMachineTemplateYAML []byte
58
58
59
+ // modifiedDockerMachinePoolTemplateYAML adds metadata to the docker machine pool used by the control plane template..
60
+ //go:embed assets/topology-test/modified-CP-dockermachinepooltemplate.yaml
61
+ modifiedDockerMachinePoolTemplateYAML []byte
62
+
59
63
//go:embed assets/topology-test/objects-in-different-namespaces.yaml
60
64
objsInDifferentNamespacesYAML []byte
61
65
)
@@ -97,11 +101,15 @@ func Test_topologyClient_Plan(t *testing.T) {
97
101
{kind : "DockerMachineTemplate" , namespace : "default" , namePrefix : "my-cluster-md-0-" },
98
102
{kind : "DockerMachineTemplate" , namespace : "default" , namePrefix : "my-cluster-md-1-" },
99
103
{kind : "DockerMachineTemplate" , namespace : "default" , namePrefix : "my-cluster-" },
104
+ {kind : "DockerMachinePool" , namespace : "default" , namePrefix : "my-cluster-mp-0-" },
105
+ {kind : "DockerMachinePool" , namespace : "default" , namePrefix : "my-cluster-mp-1-" },
100
106
{kind : "KubeadmConfigTemplate" , namespace : "default" , namePrefix : "my-cluster-md-0-" },
101
107
{kind : "KubeadmConfigTemplate" , namespace : "default" , namePrefix : "my-cluster-md-1-" },
102
108
{kind : "KubeadmControlPlane" , namespace : "default" , namePrefix : "my-cluster-" },
103
109
{kind : "MachineDeployment" , namespace : "default" , namePrefix : "my-cluster-md-0-" },
104
110
{kind : "MachineDeployment" , namespace : "default" , namePrefix : "my-cluster-md-1-" },
111
+ {kind : "MachinePool" , namespace : "default" , namePrefix : "my-cluster-mp-0-" },
112
+ {kind : "MachinePool" , namespace : "default" , namePrefix : "my-cluster-mp-1-" },
105
113
},
106
114
modified : []item {
107
115
{kind : "Cluster" , namespace : "default" , namePrefix : "my-cluster" },
@@ -205,6 +213,35 @@ func Test_topologyClient_Plan(t *testing.T) {
205
213
},
206
214
wantErr : false ,
207
215
},
216
+ {
217
+ name : "Modifying an existing DockerMachinePoolTemplate. Affects multiple clusters. Target Cluster not specified." ,
218
+ existingObjects : mustToUnstructured (
219
+ mockCRDsYAML ,
220
+ existingMyClusterClassYAML ,
221
+ existingMyClusterYAML ,
222
+ existingMySecondClusterYAML ,
223
+ ),
224
+ args : args {
225
+ in : & TopologyPlanInput {
226
+ Objs : mustToUnstructured (modifiedDockerMachinePoolTemplateYAML ),
227
+ },
228
+ },
229
+ want : out {
230
+ affectedClusters : func () []client.ObjectKey {
231
+ cluster := client.ObjectKey {Namespace : "default" , Name : "my-cluster" }
232
+ cluster2 := client.ObjectKey {Namespace : "default" , Name : "my-second-cluster" }
233
+ return []client.ObjectKey {cluster , cluster2 }
234
+ }(),
235
+ affectedClusterClasses : func () []client.ObjectKey {
236
+ cc := client.ObjectKey {Namespace : "default" , Name : "my-cluster-class" }
237
+ return []client.ObjectKey {cc }
238
+ }(),
239
+ modified : []item {},
240
+ created : []item {},
241
+ reconciledCluster : nil ,
242
+ },
243
+ wantErr : false ,
244
+ },
208
245
{
209
246
name : "Modifying an existing DockerMachineTemplate. Affects multiple clusters. Target Cluster specified." ,
210
247
existingObjects : mustToUnstructured (
@@ -241,6 +278,37 @@ func Test_topologyClient_Plan(t *testing.T) {
241
278
},
242
279
wantErr : false ,
243
280
},
281
+ {
282
+ name : "Modifying an existing DockerMachinePoolTemplate. Affects multiple clusters. Target Cluster specified." ,
283
+ existingObjects : mustToUnstructured (
284
+ mockCRDsYAML ,
285
+ existingMyClusterClassYAML ,
286
+ existingMyClusterYAML ,
287
+ existingMySecondClusterYAML ,
288
+ ),
289
+ args : args {
290
+ in : & TopologyPlanInput {
291
+ Objs : mustToUnstructured (modifiedDockerMachinePoolTemplateYAML ),
292
+ TargetClusterName : "my-cluster" ,
293
+ },
294
+ },
295
+ want : out {
296
+ affectedClusters : func () []client.ObjectKey {
297
+ cluster := client.ObjectKey {Namespace : "default" , Name : "my-cluster" }
298
+ cluster2 := client.ObjectKey {Namespace : "default" , Name : "my-second-cluster" }
299
+ return []client.ObjectKey {cluster , cluster2 }
300
+ }(),
301
+ affectedClusterClasses : func () []client.ObjectKey {
302
+ cc := client.ObjectKey {Namespace : "default" , Name : "my-cluster-class" }
303
+ return []client.ObjectKey {cc }
304
+ }(),
305
+ created : []item {
306
+ {kind : "DockerMachinePool" , namespace : "default" , namePrefix : "my-cluster-" },
307
+ },
308
+ reconciledCluster : & client.ObjectKey {Namespace : "default" , Name : "my-cluster" },
309
+ },
310
+ wantErr : false ,
311
+ },
244
312
{
245
313
name : "Input with objects in different namespaces should return error" ,
246
314
args : args {
0 commit comments