diff --git a/api/v1beta2/awsmachine_webhook.go b/api/v1beta2/awsmachine_webhook.go index f63e2707ff..931ecd5df2 100644 --- a/api/v1beta2/awsmachine_webhook.go +++ b/api/v1beta2/awsmachine_webhook.go @@ -451,14 +451,14 @@ func (*awsMachineWebhook) Default(_ context.Context, obj runtime.Object) error { r.Spec.CloudInit.SecureSecretsBackend = SecretBackendSecretsManager } + if r.ignitionEnabled() && r.Spec.Ignition.StorageType == "" { + r.Spec.Ignition.StorageType = DefaultIgnitionStorageType + } // Defaults the version field if StorageType is not set to `UnencryptedUserData`. // When using `UnencryptedUserData` the version field is ignored because the userdata defines its version itself. if r.ignitionEnabled() && r.Spec.Ignition.Version == "" && r.Spec.Ignition.StorageType != IgnitionStorageTypeOptionUnencryptedUserData { r.Spec.Ignition.Version = DefaultIgnitionVersion } - if r.ignitionEnabled() && r.Spec.Ignition.StorageType == "" { - r.Spec.Ignition.StorageType = DefaultIgnitionStorageType - } return nil } diff --git a/exp/api/v1beta2/awsmachinepool_webhook.go b/exp/api/v1beta2/awsmachinepool_webhook.go index eac0f675fa..8ebed9ad91 100644 --- a/exp/api/v1beta2/awsmachinepool_webhook.go +++ b/exp/api/v1beta2/awsmachinepool_webhook.go @@ -314,14 +314,14 @@ func (*AWSMachinePoolWebhook) Default(ctx context.Context, obj runtime.Object) e r.Spec.DefaultInstanceWarmup.Duration = 300 * time.Second } + if r.ignitionEnabled() && r.Spec.Ignition.StorageType == "" { + r.Spec.Ignition.StorageType = infrav1.DefaultMachinePoolIgnitionStorageType + } // Defaults the version field if StorageType is not set to `UnencryptedUserData`. // When using `UnencryptedUserData` the version field is ignored because the userdata defines its version itself. if r.ignitionEnabled() && r.Spec.Ignition.Version == "" && r.Spec.Ignition.StorageType != infrav1.IgnitionStorageTypeOptionUnencryptedUserData { r.Spec.Ignition.Version = infrav1.DefaultIgnitionVersion } - if r.ignitionEnabled() && r.Spec.Ignition.StorageType == "" { - r.Spec.Ignition.StorageType = infrav1.DefaultMachinePoolIgnitionStorageType - } return nil }