diff --git a/api/v1beta1/azuremanagedcontrolplane_default.go b/api/v1beta1/azuremanagedcontrolplane_default.go index 6431f08c5c8b..772a44ba62e2 100644 --- a/api/v1beta1/azuremanagedcontrolplane_default.go +++ b/api/v1beta1/azuremanagedcontrolplane_default.go @@ -218,9 +218,3 @@ func (m *AzureManagedControlPlane) setDefaultAKSExtensions() { } } } - -func (m *AzureManagedControlPlane) setDefaultEnablePreviewFeatures() { - if m.Spec.EnablePreviewFeatures == nil { - m.Spec.EnablePreviewFeatures = ptr.To(false) - } -} diff --git a/api/v1beta1/azuremanagedcontrolplane_webhook.go b/api/v1beta1/azuremanagedcontrolplane_webhook.go index ae263c839699..0d206dfed0cc 100644 --- a/api/v1beta1/azuremanagedcontrolplane_webhook.go +++ b/api/v1beta1/azuremanagedcontrolplane_webhook.go @@ -81,6 +81,7 @@ func (mw *azureManagedControlPlaneWebhook) Default(ctx context.Context, obj runt setDefault[*Identity](&m.Spec.Identity, &Identity{ Type: ManagedControlPlaneIdentityTypeSystemAssigned, }) + setDefault[*bool](&m.Spec.EnablePreviewFeatures, ptr.To(false)) m.Spec.Version = setDefaultVersion(m.Spec.Version) m.Spec.SKU = setDefaultSku(m.Spec.SKU) m.Spec.AutoScalerProfile = setDefaultAutoScalerProfile(m.Spec.AutoScalerProfile) @@ -97,7 +98,6 @@ func (mw *azureManagedControlPlaneWebhook) Default(ctx context.Context, obj runt m.setDefaultOIDCIssuerProfile() m.setDefaultDNSPrefix() m.setDefaultAKSExtensions() - m.setDefaultEnablePreviewFeatures() return nil } diff --git a/api/v1beta1/azuremanagedcontrolplanetemplate_default.go b/api/v1beta1/azuremanagedcontrolplanetemplate_default.go index fce6a8182d08..e7fd7f394cea 100644 --- a/api/v1beta1/azuremanagedcontrolplanetemplate_default.go +++ b/api/v1beta1/azuremanagedcontrolplanetemplate_default.go @@ -25,6 +25,7 @@ import ( func (mcp *AzureManagedControlPlaneTemplate) setDefaults() { setDefault[*string](&mcp.Spec.Template.Spec.NetworkPlugin, ptr.To(AzureNetworkPluginName)) setDefault[*string](&mcp.Spec.Template.Spec.LoadBalancerSKU, ptr.To("Standard")) + setDefault[*bool](&mcp.Spec.Template.Spec.EnablePreviewFeatures, ptr.To(false)) if mcp.Spec.Template.Spec.Version != "" && !strings.HasPrefix(mcp.Spec.Template.Spec.Version, "v") { mcp.Spec.Template.Spec.Version = setDefaultVersion(mcp.Spec.Template.Spec.Version) diff --git a/api/v1beta1/azuremanagedcontrolplanetemplate_webhook_test.go b/api/v1beta1/azuremanagedcontrolplanetemplate_webhook_test.go index b33c4d10d0d5..2657f61d4200 100644 --- a/api/v1beta1/azuremanagedcontrolplanetemplate_webhook_test.go +++ b/api/v1beta1/azuremanagedcontrolplanetemplate_webhook_test.go @@ -41,6 +41,7 @@ func TestControlPlaneTemplateDefaultingWebhook(t *testing.T) { g.Expect(amcpt.Spec.Template.Spec.VirtualNetwork.Subnet.Name).To(Equal("fooName")) g.Expect(amcpt.Spec.Template.Spec.VirtualNetwork.Subnet.CIDRBlock).To(Equal(defaultAKSNodeSubnetCIDR)) g.Expect(amcpt.Spec.Template.Spec.SKU.Tier).To(Equal(FreeManagedControlPlaneTier)) + g.Expect(*amcpt.Spec.Template.Spec.EnablePreviewFeatures).To(BeFalse()) t.Logf("Testing amcp defaulting webhook with baseline") netPlug := "kubenet" @@ -53,6 +54,7 @@ func TestControlPlaneTemplateDefaultingWebhook(t *testing.T) { amcpt.Spec.Template.Spec.VirtualNetwork.Name = "fooVnetName" amcpt.Spec.Template.Spec.VirtualNetwork.Subnet.Name = "fooSubnetName" amcpt.Spec.Template.Spec.SKU.Tier = PaidManagedControlPlaneTier + amcpt.Spec.Template.Spec.EnablePreviewFeatures = ptr.To(true) err = mcptw.Default(context.Background(), amcpt) g.Expect(err).NotTo(HaveOccurred()) @@ -63,6 +65,7 @@ func TestControlPlaneTemplateDefaultingWebhook(t *testing.T) { g.Expect(amcpt.Spec.Template.Spec.VirtualNetwork.Name).To(Equal("fooVnetName")) g.Expect(amcpt.Spec.Template.Spec.VirtualNetwork.Subnet.Name).To(Equal("fooSubnetName")) g.Expect(amcpt.Spec.Template.Spec.SKU.Tier).To(Equal(StandardManagedControlPlaneTier)) + g.Expect(*amcpt.Spec.Template.Spec.EnablePreviewFeatures).To(BeTrue()) } func TestControlPlaneTemplateUpdateWebhook(t *testing.T) { diff --git a/azure/scope/managedcontrolplane.go b/azure/scope/managedcontrolplane.go index 479cd5647dd0..58c8633ce886 100644 --- a/azure/scope/managedcontrolplane.go +++ b/azure/scope/managedcontrolplane.go @@ -564,6 +564,7 @@ func (s *ManagedControlPlaneScope) ManagedClusterSpec() azure.ASOResourceSpecGet NetworkPluginMode: s.ControlPlane.Spec.NetworkPluginMode, DNSPrefix: s.ControlPlane.Spec.DNSPrefix, Patches: s.ControlPlane.Spec.ASOManagedClusterPatches, + Preview: ptr.Deref(s.ControlPlane.Spec.EnablePreviewFeatures, false), } if s.ControlPlane.Spec.SSHPublicKey != nil { @@ -686,10 +687,6 @@ func (s *ManagedControlPlaneScope) ManagedClusterSpec() azure.ASOResourceSpecGet managedClusterSpec.SecurityProfile = s.getManagedClusterSecurityProfile() } - if s.ControlPlane.Spec.EnablePreviewFeatures != nil { - managedClusterSpec.Preview = *s.ControlPlane.Spec.EnablePreviewFeatures - } - return &managedClusterSpec } diff --git a/azure/scope/managedmachinepool.go b/azure/scope/managedmachinepool.go index 650a12c71295..d25b21ecaad2 100644 --- a/azure/scope/managedmachinepool.go +++ b/azure/scope/managedmachinepool.go @@ -198,6 +198,7 @@ func buildAgentPoolSpec(managedControlPlane *infrav1.AzureManagedControlPlane, EnableFIPS: managedMachinePool.Spec.EnableFIPS, EnableEncryptionAtHost: managedMachinePool.Spec.EnableEncryptionAtHost, Patches: managedMachinePool.Spec.ASOManagedClustersAgentPoolPatches, + Preview: ptr.Deref(managedControlPlane.Spec.EnablePreviewFeatures, false), } if managedMachinePool.Spec.OSDiskSizeGB != nil { @@ -240,10 +241,6 @@ func buildAgentPoolSpec(managedControlPlane *infrav1.AzureManagedControlPlane, } } - if managedControlPlane.Spec.EnablePreviewFeatures != nil { - agentPoolSpec.Preview = *managedControlPlane.Spec.EnablePreviewFeatures - } - return agentPoolSpec } diff --git a/azure/scope/managedmachinepool_test.go b/azure/scope/managedmachinepool_test.go index ea3423f04724..ea27b7a704b8 100644 --- a/azure/scope/managedmachinepool_test.go +++ b/azure/scope/managedmachinepool_test.go @@ -900,107 +900,42 @@ func TestManagedMachinePoolScope_KubeletDiskType(t *testing.T) { } func TestManagedMachinePoolScope_EnablePreviewFeatures(t *testing.T) { - scheme := runtime.NewScheme() - _ = expv1.AddToScheme(scheme) - _ = infrav1.AddToScheme(scheme) - cases := []struct { - Name string - Input ManagedMachinePoolScopeParams - Expected bool + Name string + previewEnabled *bool + Expected bool }{ { - Name: "Without EnablePreviewFeatures", - Input: ManagedMachinePoolScopeParams{ - Cluster: &clusterv1.Cluster{ - ObjectMeta: metav1.ObjectMeta{ - Name: "cluster1", - Namespace: "default", - }, - }, - ControlPlane: &infrav1.AzureManagedControlPlane{ - ObjectMeta: metav1.ObjectMeta{ - Name: "cluster1", - Namespace: "default", - }, - Spec: infrav1.AzureManagedControlPlaneSpec{ - AzureManagedControlPlaneClassSpec: infrav1.AzureManagedControlPlaneClassSpec{ - SubscriptionID: "00000000-0000-0000-0000-000000000000", - }, - }, - }, - ManagedMachinePool: ManagedMachinePool{ - MachinePool: getMachinePool("pool1"), - InfraMachinePool: getAzureMachinePool("pool1", infrav1.NodePoolModeUser), - }, - }, - Expected: false, + Name: "Without EnablePreviewFeatures", + previewEnabled: nil, + Expected: false, }, { - Name: "With EnablePreviewFeatures false", - Input: ManagedMachinePoolScopeParams{ - Cluster: &clusterv1.Cluster{ - ObjectMeta: metav1.ObjectMeta{ - Name: "cluster1", - Namespace: "default", - }, - }, - ControlPlane: &infrav1.AzureManagedControlPlane{ - ObjectMeta: metav1.ObjectMeta{ - Name: "cluster1", - Namespace: "default", - }, - Spec: infrav1.AzureManagedControlPlaneSpec{ - AzureManagedControlPlaneClassSpec: infrav1.AzureManagedControlPlaneClassSpec{ - SubscriptionID: "00000000-0000-0000-0000-000000000000", - EnablePreviewFeatures: ptr.To(false), - }, - }, - }, - ManagedMachinePool: ManagedMachinePool{ - MachinePool: getMachinePool("pool1"), - InfraMachinePool: getAzureMachinePool("pool1", infrav1.NodePoolModeUser), - }, - }, - Expected: false, + Name: "With EnablePreviewFeatures false", + previewEnabled: ptr.To(false), + Expected: false, }, { - Name: "With EnablePreviewFeatures true", - Input: ManagedMachinePoolScopeParams{ - Cluster: &clusterv1.Cluster{ - ObjectMeta: metav1.ObjectMeta{ - Name: "cluster1", - Namespace: "default", - }, - }, - ControlPlane: &infrav1.AzureManagedControlPlane{ - ObjectMeta: metav1.ObjectMeta{ - Name: "cluster1", - Namespace: "default", - }, - Spec: infrav1.AzureManagedControlPlaneSpec{ - AzureManagedControlPlaneClassSpec: infrav1.AzureManagedControlPlaneClassSpec{ - SubscriptionID: "00000000-0000-0000-0000-000000000000", - EnablePreviewFeatures: ptr.To(true), - }, - }, - }, - ManagedMachinePool: ManagedMachinePool{ - MachinePool: getMachinePool("pool1"), - InfraMachinePool: getAzureMachinePool("pool1", infrav1.NodePoolModeUser), - }, - }, - Expected: true, + Name: "With EnablePreviewFeatures true", + previewEnabled: ptr.To(true), + Expected: true, }, } for _, c := range cases { c := c t.Run(c.Name, func(t *testing.T) { g := NewWithT(t) - fakeClient := fake.NewClientBuilder().WithScheme(scheme).WithObjects(c.Input.MachinePool, c.Input.InfraMachinePool, c.Input.ControlPlane).Build() - c.Input.Client = fakeClient - s, err := NewManagedMachinePoolScope(context.TODO(), c.Input) - g.Expect(err).To(Succeed()) + s := &ManagedMachinePoolScope{ + ControlPlane: &infrav1.AzureManagedControlPlane{ + Spec: infrav1.AzureManagedControlPlaneSpec{ + AzureManagedControlPlaneClassSpec: infrav1.AzureManagedControlPlaneClassSpec{ + EnablePreviewFeatures: c.previewEnabled, + }, + }, + }, + MachinePool: &expv1.MachinePool{}, + InfraMachinePool: &infrav1.AzureManagedMachinePool{}, + } agentPoolGetter := s.AgentPoolSpec() agentPool, ok := agentPoolGetter.(*agentpools.AgentPoolSpec) g.Expect(ok).To(BeTrue()) diff --git a/azure/services/agentpools/agentpools_test.go b/azure/services/agentpools/agentpools_test.go index 650322b7bc4b..aab1217b12c0 100644 --- a/azure/services/agentpools/agentpools_test.go +++ b/azure/services/agentpools/agentpools_test.go @@ -87,13 +87,13 @@ func TestPostCreateOrUpdateResourceHook(t *testing.T) { scope.EXPECT().SetCAPIMachinePoolReplicas(ptr.To(1234)) scope.EXPECT().IsPreviewEnabled().Return(true) - managedCluster := &asocontainerservicev1preview.ManagedClustersAgentPool{ + agentPool := &asocontainerservicev1preview.ManagedClustersAgentPool{ Status: asocontainerservicev1preview.ManagedClusters_AgentPool_STATUS{ EnableAutoScaling: ptr.To(true), Count: ptr.To(1234), }, } - g.Expect(postCreateOrUpdateResourceHook(context.Background(), scope, managedCluster, nil)).To(Succeed()) + g.Expect(postCreateOrUpdateResourceHook(context.Background(), scope, agentPool, nil)).To(Succeed()) }) } diff --git a/azure/services/managedclusters/spec_test.go b/azure/services/managedclusters/spec_test.go index 4daeb0fa068d..de4e54259d14 100644 --- a/azure/services/managedclusters/spec_test.go +++ b/azure/services/managedclusters/spec_test.go @@ -296,20 +296,8 @@ func TestParameters(t *testing.T) { g := NewGomegaWithT(t) spec := &ManagedClusterSpec{ - Name: "name", - ResourceGroup: "rg", - NodeResourceGroup: "node rg", - ClusterName: "cluster", - VnetSubnetID: "vnet subnet id", - Location: "location", - Tags: map[string]string{"additional": "tags"}, - Version: "version", - LoadBalancerSKU: "lb sku", - NetworkPlugin: "network plugin", - NetworkPluginMode: ptr.To(infrav1.NetworkPluginMode("network plugin mode")), - NetworkPolicy: "network policy", - OutboundType: ptr.To(infrav1.ManagedControlPlaneOutboundType("outbound type")), - SSHPublicKey: base64.StdEncoding.EncodeToString([]byte("ssh")), + Name: "name", + Preview: true, GetAllAgentPools: func() ([]azure.ASOResourceSpecGetter[genruntime.MetaObject], error) { return []azure.ASOResourceSpecGetter[genruntime.MetaObject]{ &agentpools.AgentPoolSpec{ @@ -321,235 +309,12 @@ func TestParameters(t *testing.T) { }, }, nil }, - PodCIDR: "pod cidr", - ServiceCIDR: "0.0.0.0/10", - DNSServiceIP: nil, - AddonProfiles: []AddonProfile{ - { - Name: "addon name", - Enabled: true, - Config: map[string]string{"addon": "config"}, - }, - }, - AADProfile: &AADProfile{ - Managed: true, - }, - SKU: &SKU{ - Tier: "sku tier", - }, - LoadBalancerProfile: &LoadBalancerProfile{ - ManagedOutboundIPs: ptr.To(16), - OutboundIPPrefixes: []string{"outbound ip prefixes"}, - OutboundIPs: []string{"outbound ips"}, - }, - APIServerAccessProfile: &APIServerAccessProfile{ - AuthorizedIPRanges: []string{"authorized ip ranges"}, - }, - AutoScalerProfile: &AutoScalerProfile{ - Expander: ptr.To("expander"), - }, - AutoUpgradeProfile: &ManagedClusterAutoUpgradeProfile{ - UpgradeChannel: ptr.To(infrav1.UpgradeChannelRapid), - }, - Identity: &infrav1.Identity{ - Type: infrav1.ManagedControlPlaneIdentityType(asocontainerservicev1.ManagedClusterIdentity_Type_UserAssigned), - UserAssignedIdentityResourceID: "user assigned id", - }, - KubeletUserAssignedIdentity: "kubelet id", - HTTPProxyConfig: &HTTPProxyConfig{ - NoProxy: []string{"noproxy"}, - }, - OIDCIssuerProfile: &OIDCIssuerProfile{ - Enabled: ptr.To(true), - }, - DNSPrefix: ptr.To("dns prefix"), - DisableLocalAccounts: ptr.To(true), - SecurityProfile: &ManagedClusterSecurityProfile{ - AzureKeyVaultKms: &AzureKeyVaultKms{ - Enabled: ptr.To(true), - KeyID: ptr.To("KeyID"), - KeyVaultNetworkAccess: ptr.To(infrav1.KeyVaultNetworkAccessTypesPublic), - }, - Defender: &ManagedClusterSecurityProfileDefender{ - LogAnalyticsWorkspaceResourceID: ptr.To("LogAnalyticsWorkspaceResourceID"), - SecurityMonitoring: &ManagedClusterSecurityProfileDefenderSecurityMonitoring{ - Enabled: ptr.To(true), - }, - }, - ImageCleaner: &ManagedClusterSecurityProfileImageCleaner{ - Enabled: ptr.To(true), - IntervalHours: ptr.To(24), - }, - WorkloadIdentity: &ManagedClusterSecurityProfileWorkloadIdentity{ - Enabled: ptr.To(true), - }, - }, - Preview: true, - } - - expected := &asocontainerservicev1preview.ManagedCluster{ - Spec: asocontainerservicev1preview.ManagedCluster_Spec{ - AadProfile: &asocontainerservicev1preview.ManagedClusterAADProfile{ - EnableAzureRBAC: ptr.To(false), - Managed: ptr.To(true), - }, - AddonProfiles: map[string]asocontainerservicev1preview.ManagedClusterAddonProfile{ - "addon name": { - Config: map[string]string{"addon": "config"}, - Enabled: ptr.To(true), - }, - }, - AgentPoolProfiles: []asocontainerservicev1preview.ManagedClusterAgentPoolProfile{ - { - Count: ptr.To(5), - EnableAutoScaling: ptr.To(false), - Mode: ptr.To(asocontainerservicev1preview.AgentPoolMode("mode")), - Name: ptr.To("agentpool"), - OsDiskSizeGB: ptr.To(asocontainerservicev1preview.ContainerServiceOSDisk(0)), - Type: ptr.To(asocontainerservicev1preview.AgentPoolType_VirtualMachineScaleSets), - Tags: map[string]string{"from": "patches"}, - }, - }, - ApiServerAccessProfile: &asocontainerservicev1preview.ManagedClusterAPIServerAccessProfile{ - AuthorizedIPRanges: []string{"authorized ip ranges"}, - }, - AutoScalerProfile: &asocontainerservicev1preview.ManagedClusterProperties_AutoScalerProfile{ - Expander: ptr.To(asocontainerservicev1preview.ManagedClusterProperties_AutoScalerProfile_Expander("expander")), - }, - AutoUpgradeProfile: &asocontainerservicev1preview.ManagedClusterAutoUpgradeProfile{ - UpgradeChannel: ptr.To(asocontainerservicev1preview.ManagedClusterAutoUpgradeProfile_UpgradeChannel_Rapid), - }, - AzureName: "name", - DisableLocalAccounts: ptr.To(true), - DnsPrefix: ptr.To("dns prefix"), - EnableRBAC: ptr.To(true), - HttpProxyConfig: &asocontainerservicev1preview.ManagedClusterHTTPProxyConfig{ - NoProxy: []string{"noproxy"}, - }, - Identity: &asocontainerservicev1preview.ManagedClusterIdentity{ - Type: ptr.To(asocontainerservicev1preview.ManagedClusterIdentity_Type_UserAssigned), - UserAssignedIdentities: []asocontainerservicev1preview.UserAssignedIdentityDetails{ - { - Reference: genruntime.ResourceReference{ - ARMID: "user assigned id", - }, - }, - }, - }, - IdentityProfile: map[string]asocontainerservicev1preview.UserAssignedIdentity{ - kubeletIdentityKey: { - ResourceReference: &genruntime.ResourceReference{ - ARMID: "kubelet id", - }, - }, - }, - KubernetesVersion: ptr.To("version"), - LinuxProfile: &asocontainerservicev1preview.ContainerServiceLinuxProfile{ - AdminUsername: ptr.To(azure.DefaultAKSUserName), - Ssh: &asocontainerservicev1preview.ContainerServiceSshConfiguration{ - PublicKeys: []asocontainerservicev1preview.ContainerServiceSshPublicKey{ - { - KeyData: ptr.To("ssh"), - }, - }, - }, - }, - Location: ptr.To("location"), - NetworkProfile: &asocontainerservicev1preview.ContainerServiceNetworkProfile{ - DnsServiceIP: ptr.To("0.0.0.10"), - LoadBalancerProfile: &asocontainerservicev1preview.ManagedClusterLoadBalancerProfile{ - ManagedOutboundIPs: &asocontainerservicev1preview.ManagedClusterLoadBalancerProfile_ManagedOutboundIPs{ - Count: ptr.To(16), - }, - OutboundIPPrefixes: &asocontainerservicev1preview.ManagedClusterLoadBalancerProfile_OutboundIPPrefixes{ - PublicIPPrefixes: []asocontainerservicev1preview.ResourceReference{ - { - Reference: &genruntime.ResourceReference{ - ARMID: "outbound ip prefixes", - }, - }, - }, - }, - OutboundIPs: &asocontainerservicev1preview.ManagedClusterLoadBalancerProfile_OutboundIPs{ - PublicIPs: []asocontainerservicev1preview.ResourceReference{ - { - Reference: &genruntime.ResourceReference{ - ARMID: "outbound ips", - }, - }, - }, - }, - }, - LoadBalancerSku: ptr.To(asocontainerservicev1preview.LoadBalancerSku("lb sku")), - NetworkPlugin: ptr.To(asocontainerservicev1preview.NetworkPlugin("network plugin")), - NetworkPluginMode: ptr.To(asocontainerservicev1preview.NetworkPluginMode("network plugin mode")), - NetworkPolicy: ptr.To(asocontainerservicev1preview.NetworkPolicy("network policy")), - OutboundType: ptr.To(asocontainerservicev1preview.ContainerServiceNetworkProfile_OutboundType("outbound type")), - PodCidr: ptr.To("pod cidr"), - ServiceCidr: ptr.To("0.0.0.0/10"), - }, - NodeResourceGroup: ptr.To("node rg"), - OidcIssuerProfile: &asocontainerservicev1preview.ManagedClusterOIDCIssuerProfile{ - Enabled: ptr.To(true), - }, - OperatorSpec: &asocontainerservicev1preview.ManagedClusterOperatorSpec{ - Secrets: &asocontainerservicev1preview.ManagedClusterOperatorSecrets{ - UserCredentials: &genruntime.SecretDestination{ - Name: userKubeconfigSecretName("cluster"), - Key: secret.KubeconfigDataName, - }, - }, - ConfigMaps: &asocontainerservicev1preview.ManagedClusterOperatorConfigMaps{ - OIDCIssuerProfile: &genruntime.ConfigMapDestination{ - Name: oidcIssuerURLConfigMapName("cluster"), - Key: oidcIssuerProfileURL, - }, - }, - }, - Owner: &genruntime.KnownResourceReference{ - Name: "rg", - }, - ServicePrincipalProfile: &asocontainerservicev1preview.ManagedClusterServicePrincipalProfile{ - ClientId: ptr.To("msi"), - }, - Sku: &asocontainerservicev1preview.ManagedClusterSKU{ - Name: ptr.To(asocontainerservicev1preview.ManagedClusterSKU_Name_Base), - Tier: ptr.To(asocontainerservicev1preview.ManagedClusterSKU_Tier("sku tier")), - }, - Tags: map[string]string{ - "Name": "name", - "sigs.k8s.io_cluster-api-provider-azure_cluster_cluster": "owned", - "sigs.k8s.io_cluster-api-provider-azure_role": "common", - }, - SecurityProfile: &asocontainerservicev1preview.ManagedClusterSecurityProfile{ - AzureKeyVaultKms: &asocontainerservicev1preview.AzureKeyVaultKms{ - Enabled: ptr.To(true), - KeyId: ptr.To("KeyID"), - KeyVaultNetworkAccess: ptr.To(asocontainerservicev1preview.AzureKeyVaultKms_KeyVaultNetworkAccess_Public), - }, - Defender: &asocontainerservicev1preview.ManagedClusterSecurityProfileDefender{ - LogAnalyticsWorkspaceResourceReference: &genruntime.ResourceReference{ - ARMID: "LogAnalyticsWorkspaceResourceID", - }, - SecurityMonitoring: &asocontainerservicev1preview.ManagedClusterSecurityProfileDefenderSecurityMonitoring{ - Enabled: ptr.To(true), - }, - }, - ImageCleaner: &asocontainerservicev1preview.ManagedClusterSecurityProfileImageCleaner{ - Enabled: ptr.To(true), - IntervalHours: ptr.To(24), - }, - WorkloadIdentity: &asocontainerservicev1preview.ManagedClusterSecurityProfileWorkloadIdentity{ - Enabled: ptr.To(true), - }, - }, - }, } actual, err := spec.Parameters(context.Background(), nil) - g.Expect(err).NotTo(HaveOccurred()) - g.Expect(cmp.Diff(actual, expected)).To(BeEmpty()) + _, ok := actual.(*asocontainerservicev1preview.ManagedCluster) + g.Expect(ok).To(BeTrue()) }) t.Run("with existing managed cluster", func(t *testing.T) { @@ -584,39 +349,6 @@ func TestParameters(t *testing.T) { g.Expect(*actual.Spec.KubernetesVersion).To(Equal("1.26.6")) }) - t.Run("with existing preview managed cluster", func(t *testing.T) { - g := NewGomegaWithT(t) - - spec := &ManagedClusterSpec{ - DNSPrefix: ptr.To("managed by CAPZ"), - Tags: map[string]string{"additional": "tags"}, - Version: "1.25.9", - Preview: true, - } - existing := &asocontainerservicev1preview.ManagedCluster{ - Spec: asocontainerservicev1preview.ManagedCluster_Spec{ - DnsPrefix: ptr.To("set by the user"), - EnablePodSecurityPolicy: ptr.To(true), // set by the user - }, - Status: asocontainerservicev1preview.ManagedCluster_STATUS{ - AgentPoolProfiles: []asocontainerservicev1preview.ManagedClusterAgentPoolProfile_STATUS{}, - Tags: map[string]string{}, - CurrentKubernetesVersion: ptr.To("1.26.6"), - }, - } - - actualObj, err := spec.Parameters(context.Background(), existing) - actual := actualObj.(*asocontainerservicev1preview.ManagedCluster) - - g.Expect(err).NotTo(HaveOccurred()) - g.Expect(actual.Spec.AgentPoolProfiles).To(BeNil()) - g.Expect(actual.Spec.Tags).To(BeNil()) - g.Expect(actual.Spec.DnsPrefix).To(Equal(ptr.To("managed by CAPZ"))) - g.Expect(actual.Spec.EnablePodSecurityPolicy).To(Equal(ptr.To(true))) - g.Expect(actual.Spec.KubernetesVersion).NotTo(BeNil()) - g.Expect(*actual.Spec.KubernetesVersion).To(Equal("1.26.6")) - }) - t.Run("updating existing managed cluster to a non nil DNS Service IP", func(t *testing.T) { g := NewGomegaWithT(t) diff --git a/azure/services/virtualmachines/mock_virtualmachines/client_mock.go b/azure/services/virtualmachines/mock_virtualmachines/client_mock.go index be2156892062..5c0eddac3137 100644 --- a/azure/services/virtualmachines/mock_virtualmachines/client_mock.go +++ b/azure/services/virtualmachines/mock_virtualmachines/client_mock.go @@ -1,3 +1,19 @@ +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + // Code generated by MockGen. DO NOT EDIT. // Source: ../client.go //