Skip to content

Commit d0f78e0

Browse files
authored
Merge pull request #4677 from willie-yao/fix-extension
Make AKS extension.Plan optional
2 parents 8be2ad2 + 2ace0a4 commit d0f78e0

12 files changed

+48
-40
lines changed

api/v1beta1/azuremanagedcontrolplane_default.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ func (m *AzureManagedControlPlane) setDefaultDNSPrefix() {
210210

211211
func (m *AzureManagedControlPlane) setDefaultAKSExtensions() {
212212
for _, extension := range m.Spec.Extensions {
213-
if extension.Plan.Name == "" {
213+
if extension.Plan != nil && extension.Plan.Name == "" {
214214
extension.Plan.Name = fmt.Sprintf("%s-%s", m.Name, extension.Plan.Product)
215215
}
216216
if extension.AutoUpgradeMinorVersion == nil {

api/v1beta1/azuremanagedcontrolplane_types.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,8 @@ type AKSExtension struct {
608608
ExtensionType *string `json:"extensionType"`
609609

610610
// Plan is the plan of the extension.
611-
Plan *ExtensionPlan `json:"plan"`
611+
// +optional
612+
Plan *ExtensionPlan `json:"plan,omitempty"`
612613

613614
// ReleaseTrain is the release train this extension participates in for auto-upgrade (e.g. Stable, Preview, etc.)
614615
// This is only used if autoUpgradeMinorVersion is ‘true’.

api/v1beta1/azuremanagedcontrolplane_webhook.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,12 +1002,6 @@ func validateAKSExtensions(extensions []AKSExtension, fldPath *field.Path) field
10021002
if extension.Version != nil && (extension.AutoUpgradeMinorVersion == nil || (extension.AutoUpgradeMinorVersion != nil && *extension.AutoUpgradeMinorVersion)) {
10031003
allErrs = append(allErrs, field.Forbidden(fldPath.Child("Version"), "Version must not be given if AutoUpgradeMinorVersion is true (or not provided, as it is true by default)"))
10041004
}
1005-
if extension.Plan.Product == "" {
1006-
allErrs = append(allErrs, field.Required(fldPath.Child("Plan", "Product"), "Product must be provided"))
1007-
}
1008-
if extension.Plan.Publisher == "" {
1009-
allErrs = append(allErrs, field.Required(fldPath.Child("Plan", "Publisher"), "Publisher must be provided"))
1010-
}
10111005
if extension.AutoUpgradeMinorVersion == ptr.To(false) && extension.ReleaseTrain != nil {
10121006
allErrs = append(allErrs, field.Forbidden(fldPath.Child("ReleaseTrain"), "ReleaseTrain must not be given if AutoUpgradeMinorVersion is false"))
10131007
}

api/v1beta1/types.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,14 +1119,16 @@ type ExtensionPlan struct {
11191119
Name string `json:"name,omitempty"`
11201120

11211121
// Product is the name of the 3rd Party artifact that is being procured.
1122-
Product string `json:"product"`
1122+
// +optional
1123+
Product string `json:"product,omitempty"`
11231124

11241125
// PromotionCode is a publisher-provided promotion code as provisioned in Data Market for the said product/artifact.
11251126
// +optional
11261127
PromotionCode string `json:"promotionCode,omitempty"`
11271128

11281129
// Publisher is the name of the publisher of the 3rd Party Artifact that is being bought.
1129-
Publisher string `json:"publisher"`
1130+
// +optional
1131+
Publisher string `json:"publisher,omitempty"`
11301132

11311133
// Version is the version of the plan.
11321134
// +optional

azure/scope/managedcontrolplane.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1030,7 +1030,7 @@ func (s *ManagedControlPlaneScope) AKSExtensionSpecs() []azure.ASOResourceSpecGe
10301030
ReleaseTrain: extension.ReleaseTrain,
10311031
Version: extension.Version,
10321032
Owner: azure.ManagedClusterID(s.SubscriptionID(), s.ResourceGroup(), s.ControlPlane.Name),
1033-
Plan: *extension.Plan,
1033+
Plan: extension.Plan,
10341034
AKSAssignedIdentityType: extension.AKSAssignedIdentityType,
10351035
ExtensionIdentity: extension.Identity,
10361036
}

azure/scope/managedcontrolplane_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1510,7 +1510,7 @@ func TestManagedControlPlaneScope_AKSExtensionSpecs(t *testing.T) {
15101510
ReleaseTrain: ptr.To("my-release-train"),
15111511
Version: ptr.To("my-version"),
15121512
Owner: "/subscriptions//resourceGroups//providers/Microsoft.ContainerService/managedClusters/my-cluster",
1513-
Plan: infrav1.ExtensionPlan{
1513+
Plan: &infrav1.ExtensionPlan{
15141514
Name: "my-plan-name",
15151515
Product: "my-product",
15161516
Publisher: "my-publisher",

azure/services/aksextensions/spec.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ type AKSExtensionSpec struct {
3939
Version *string
4040
Owner string
4141
OwnerRef metav1.OwnerReference
42-
Plan infrav1.ExtensionPlan
42+
Plan *infrav1.ExtensionPlan
4343
Scope infrav1.ExtensionScope
4444
}
4545

@@ -70,11 +70,14 @@ func (s *AKSExtensionSpec) Parameters(ctx context.Context, existingAKSExtension
7070
aksExtension.Spec.Owner = &genruntime.ArbitraryOwnerReference{
7171
ARMID: s.Owner,
7272
}
73-
aksExtension.Spec.Plan = &asokubernetesconfigurationv1.Plan{
74-
Name: ptr.To(s.Plan.Name),
75-
Product: ptr.To(s.Plan.Product),
76-
Publisher: ptr.To(s.Plan.Publisher),
77-
Version: ptr.To(s.Plan.Version),
73+
74+
if s.Plan != nil {
75+
aksExtension.Spec.Plan = &asokubernetesconfigurationv1.Plan{
76+
Name: ptr.To(s.Plan.Name),
77+
Product: ptr.To(s.Plan.Product),
78+
Publisher: ptr.To(s.Plan.Publisher),
79+
Version: ptr.To(s.Plan.Version),
80+
}
7881
}
7982
if s.ExtensionIdentity != "" {
8083
aksExtension.Spec.Identity = &asokubernetesconfigurationv1.Identity{

azure/services/aksextensions/spec_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ var (
6868
ReleaseTrain: ptr.To("fake-release-train"),
6969
Version: ptr.To("fake-version"),
7070
Owner: "fake-owner",
71-
Plan: infrav1.ExtensionPlan{
71+
Plan: &infrav1.ExtensionPlan{
7272
Name: "fake-plan-name",
7373
},
7474
ExtensionIdentity: "SystemAssigned",

config/crd/bases/infrastructure.cluster.x-k8s.io_azuremanagedcontrolplanes.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -367,9 +367,6 @@ spec:
367367
version:
368368
description: Version is the version of the plan.
369369
type: string
370-
required:
371-
- product
372-
- publisher
373370
type: object
374371
releaseTrain:
375372
description: ReleaseTrain is the release train this extension
@@ -405,7 +402,6 @@ spec:
405402
required:
406403
- extensionType
407404
- name
408-
- plan
409405
type: object
410406
type: array
411407
fleetsMember:

config/crd/bases/infrastructure.cluster.x-k8s.io_azuremanagedcontrolplanetemplates.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -351,9 +351,6 @@ spec:
351351
version:
352352
description: Version is the version of the plan.
353353
type: string
354-
required:
355-
- product
356-
- publisher
357354
type: object
358355
releaseTrain:
359356
description: ReleaseTrain is the release train this
@@ -392,7 +389,6 @@ spec:
392389
required:
393390
- extensionType
394391
- name
395-
- plan
396392
type: object
397393
type: array
398394
fleetsMember:

0 commit comments

Comments
 (0)