sigs.k8s.io/cluster-api-provider-azure@v1.14.3/azure/services/aksextensions/aksextensions.go (about)

     1  /*
     2  Copyright 2024 The Kubernetes Authors.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8      http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  package aksextensions
    18  
    19  import (
    20  	asokubernetesconfigurationv1 "github.com/Azure/azure-service-operator/v2/api/kubernetesconfiguration/v1api20230501"
    21  	infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1"
    22  	"sigs.k8s.io/cluster-api-provider-azure/azure"
    23  	"sigs.k8s.io/cluster-api-provider-azure/azure/services/aso"
    24  )
    25  
    26  const serviceName = "extension"
    27  
    28  // AKSExtensionScope defines the scope interface for an AKS extensions service.
    29  type AKSExtensionScope interface {
    30  	azure.ClusterScoper
    31  	aso.Scope
    32  	AKSExtensionSpecs() []azure.ASOResourceSpecGetter[*asokubernetesconfigurationv1.Extension]
    33  }
    34  
    35  // Service provides operations on Azure resources.
    36  type Service struct {
    37  	Scope AKSExtensionScope
    38  	*aso.Service[*asokubernetesconfigurationv1.Extension, AKSExtensionScope]
    39  }
    40  
    41  // New creates a new service.
    42  func New(scope AKSExtensionScope) *Service {
    43  	svc := aso.NewService[*asokubernetesconfigurationv1.Extension, AKSExtensionScope](serviceName, scope)
    44  	svc.Specs = scope.AKSExtensionSpecs()
    45  	svc.ConditionType = infrav1.AKSExtensionsReadyCondition
    46  	return &Service{
    47  		Scope:   scope,
    48  		Service: svc,
    49  	}
    50  }