diff --git a/pkg/handlers/generic/mutation/containerdrestart/inject.go b/pkg/handlers/generic/mutation/containerdrestart/inject.go index adf8b99b6..92edab3de 100644 --- a/pkg/handlers/generic/mutation/containerdrestart/inject.go +++ b/pkg/handlers/generic/mutation/containerdrestart/inject.go @@ -17,13 +17,13 @@ import ( "github.com/d2iq-labs/cluster-api-runtime-extensions-nutanix/common/pkg/capi/clustertopology/patches/selectors" ) -type globalMirrorPatchHandler struct{} +type containerdRestartPatchHandler struct{} -func NewPatch() *globalMirrorPatchHandler { - return &globalMirrorPatchHandler{} +func NewPatch() *containerdRestartPatchHandler { + return &containerdRestartPatchHandler{} } -func (h *globalMirrorPatchHandler) Mutate( +func (h *containerdRestartPatchHandler) Mutate( ctx context.Context, obj *unstructured.Unstructured, vars map[string]apiextensionsv1.JSON, diff --git a/pkg/handlers/generic/mutation/containerdrestart/tests/generate_patches.go b/pkg/handlers/generic/mutation/containerdrestart/tests/generate_patches.go index e2e757234..9ef570535 100644 --- a/pkg/handlers/generic/mutation/containerdrestart/tests/generate_patches.go +++ b/pkg/handlers/generic/mutation/containerdrestart/tests/generate_patches.go @@ -7,6 +7,7 @@ import ( "testing" "github.com/onsi/gomega" + runtimehooksv1 "sigs.k8s.io/cluster-api/exp/runtime/hooks/api/v1alpha1" "github.com/d2iq-labs/cluster-api-runtime-extensions-nutanix/common/pkg/capi/clustertopology/handlers/mutation" "github.com/d2iq-labs/cluster-api-runtime-extensions-nutanix/common/pkg/testutils/capitest" @@ -46,12 +47,22 @@ func TestGeneratePatches( }, }, capitest.PatchTestDef{ - Name: "restart script and command added to worker node kubeadm config template", - RequestItem: request.NewKubeadmControlPlaneTemplateRequestItem(""), + Name: "restart script and command added to worker node kubeadm config template", + Vars: []runtimehooksv1.Variable{ + capitest.VariableWithValue( + "builtin", + map[string]any{ + "machineDeployment": map[string]any{ + "class": "*", + }, + }, + ), + }, + RequestItem: request.NewKubeadmConfigTemplateRequestItem(""), ExpectedPatchMatchers: []capitest.JSONPatchMatcher{ { Operation: "add", - Path: "/spec/template/spec/kubeadmConfigSpec/files", + Path: "/spec/template/spec/files", ValueMatcher: gomega.ContainElements( gomega.HaveKeyWithValue( "path", containerdrestart.ContainerdRestartScriptOnRemote, @@ -60,7 +71,7 @@ func TestGeneratePatches( }, { Operation: "add", - Path: "/spec/template/spec/kubeadmConfigSpec/preKubeadmCommands", + Path: "/spec/template/spec/preKubeadmCommands", ValueMatcher: gomega.ContainElements( containerdrestart.ContainerdRestartScriptOnRemoteCommand, ),