Skip to content

Commit

Permalink
Trim template field to object
Browse files Browse the repository at this point in the history
  • Loading branch information
willie-yao committed Nov 13, 2023
1 parent 990f115 commit 1908aa2
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions test/e2e/clusterclass_changes.go
Original file line number Diff line number Diff line change
Expand Up @@ -518,14 +518,16 @@ func modifyMachinePoolViaClusterClassAndWait(ctx context.Context, input modifyMa
assertMachinePoolTopologyFields(g, mp, mpTopology)

if mpClass.Template.Bootstrap.Ref != nil {
// Get the corresponding BootstrapConfigTemplate.
bootstrapConfigTemplateRef := mp.Spec.Template.Spec.Bootstrap.ConfigRef
bootstrapConfigTemplate, err := external.Get(ctx, mgmtClient, bootstrapConfigTemplateRef, input.Cluster.Namespace)
// Get the corresponding BootstrapConfig object.
bootstrapConfigObjectRef := mp.Spec.Template.Spec.Bootstrap.ConfigRef
bootstrapConfigObject, err := external.Get(ctx, mgmtClient, bootstrapConfigObjectRef, input.Cluster.Namespace)
g.Expect(err).ToNot(HaveOccurred())

// Verify that ModifyBootstrapConfigTemplateFields have been set.
// Verify that ModifyBootstrapConfigTemplateFields have been set and propagates to the BootstrapConfig.
for fieldPath, expectedValue := range input.ModifyBootstrapConfigTemplateFields {
currentValue, ok, err := unstructured.NestedFieldNoCopy(bootstrapConfigTemplate.Object, strings.Split(fieldPath, ".")...)
// MachinePools have a BootstrapConfig, not a BootstrapConfigTemplate, so we need to convert the fieldPath so it can find it on the object.
fieldPath = strings.TrimPrefix(fieldPath, "spec.template.")
currentValue, ok, err := unstructured.NestedFieldNoCopy(bootstrapConfigObject.Object, strings.Split(fieldPath, ".")...)
g.Expect(err).ToNot(HaveOccurred(), fmt.Sprintf("failed to get field %q", fieldPath))
g.Expect(ok).To(BeTrue(), fmt.Sprintf("failed to get field %q", fieldPath))
g.Expect(currentValue).To(Equal(expectedValue), fmt.Sprintf("field %q should be equal", fieldPath))
Expand Down

0 comments on commit 1908aa2

Please sign in to comment.