sigs.k8s.io/cluster-api-provider-azure@v1.17.0/azure/services/fleetsmembers/fleetsmembers.go (about) 1 /* 2 Copyright 2023 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 fleetsmembers 18 19 import ( 20 "context" 21 22 asocontainerservicev1 "github.com/Azure/azure-service-operator/v2/api/containerservice/v1api20230315preview" 23 infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" 24 "sigs.k8s.io/cluster-api-provider-azure/azure" 25 "sigs.k8s.io/cluster-api-provider-azure/azure/services/aso" 26 "sigs.k8s.io/cluster-api-provider-azure/util/slice" 27 "sigs.k8s.io/controller-runtime/pkg/client" 28 ) 29 30 const serviceName = "fleetsmember" 31 32 // FleetsMemberScope defines the scope interface for a Fleet host service. 33 type FleetsMemberScope interface { 34 aso.Scope 35 AzureFleetsMemberSpec() []azure.ASOResourceSpecGetter[*asocontainerservicev1.FleetsMember] 36 } 37 38 // New creates a new service. 39 func New(scope FleetsMemberScope) *aso.Service[*asocontainerservicev1.FleetsMember, FleetsMemberScope] { 40 svc := aso.NewService[*asocontainerservicev1.FleetsMember, FleetsMemberScope](serviceName, scope) 41 svc.ListFunc = list 42 svc.Specs = scope.AzureFleetsMemberSpec() 43 svc.ConditionType = infrav1.FleetReadyCondition 44 return svc 45 } 46 47 func list(ctx context.Context, client client.Client, opts ...client.ListOption) ([]*asocontainerservicev1.FleetsMember, error) { 48 list := &asocontainerservicev1.FleetsMemberList{} 49 err := client.List(ctx, list, opts...) 50 return slice.ToPtrs(list.Items), err 51 }