sigs.k8s.io/cluster-api-provider-azure@v1.14.3/azure/services/scalesets/vmssextension_spec.go (about) 1 /* 2 Copyright 2022 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 scalesets 18 19 import ( 20 "context" 21 22 "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v5" 23 "github.com/pkg/errors" 24 "k8s.io/utils/ptr" 25 "sigs.k8s.io/cluster-api-provider-azure/azure" 26 ) 27 28 // VMSSExtensionSpec defines the specification for a VM or VMScaleSet extension. 29 type VMSSExtensionSpec struct { 30 azure.ExtensionSpec 31 ResourceGroup string 32 } 33 34 // ResourceName returns the name of the VMSS extension. 35 func (s *VMSSExtensionSpec) ResourceName() string { 36 return s.Name 37 } 38 39 // ResourceGroupName returns the name of the resource group. 40 func (s *VMSSExtensionSpec) ResourceGroupName() string { 41 return s.ResourceGroup 42 } 43 44 // OwnerResourceName returns the name of the VMSS that owns this VMSS extension. 45 func (s *VMSSExtensionSpec) OwnerResourceName() string { 46 return s.VMName 47 } 48 49 // Parameters returns the parameters for the VMSS extension. 50 func (s *VMSSExtensionSpec) Parameters(ctx context.Context, existing interface{}) (interface{}, error) { 51 if existing != nil { 52 _, ok := existing.(armcompute.VirtualMachineScaleSetExtension) 53 if !ok { 54 return nil, errors.Errorf("%T is not an armcompute.VirtualMachineScaleSetExtension", existing) 55 } 56 57 // VMSS extension already exists, nothing to update. 58 return nil, nil 59 } 60 61 return armcompute.VirtualMachineScaleSetExtension{ 62 Name: ptr.To(s.Name), 63 Properties: &armcompute.VirtualMachineScaleSetExtensionProperties{ 64 Publisher: ptr.To(s.Publisher), 65 Type: ptr.To(s.Name), 66 TypeHandlerVersion: ptr.To(s.Version), 67 Settings: s.Settings, 68 ProtectedSettings: s.ProtectedSettings, 69 }, 70 }, nil 71 }