sigs.k8s.io/cluster-api-provider-azure@v1.17.0/azure/services/scalesetvms/spec.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 scalesetvms
    18  
    19  import (
    20  	"context"
    21  )
    22  
    23  // ScaleSetVMSpec defines the specification for a VMSS VM.
    24  type ScaleSetVMSpec struct {
    25  	Name          string
    26  	InstanceID    string
    27  	ResourceGroup string
    28  	ScaleSetName  string
    29  	ProviderID    string
    30  	ResourceID    string
    31  	IsFlex        bool
    32  }
    33  
    34  // ResourceName returns the instance ID of the VMSS VM. This is because the it is identified by the instance ID in Azure instead of the name.
    35  func (s *ScaleSetVMSpec) ResourceName() string {
    36  	return s.InstanceID
    37  }
    38  
    39  // ResourceGroupName returns the name of the resource group the VMSS that owns this VM.
    40  func (s *ScaleSetVMSpec) ResourceGroupName() string {
    41  	return s.ResourceGroup
    42  }
    43  
    44  // OwnerResourceName returns the name of the VMSS that owns this VM.
    45  func (s *ScaleSetVMSpec) OwnerResourceName() string {
    46  	return s.ScaleSetName
    47  }
    48  
    49  // Parameters is a no-op for VMSS VMs as this spec is only used to Get().
    50  func (s *ScaleSetVMSpec) Parameters(ctx context.Context, existing interface{}) (params interface{}, err error) {
    51  	return nil, nil
    52  }
    53  
    54  // VMSSFlexGetter defines the specification for a VMSS flex VM.
    55  type VMSSFlexGetter struct {
    56  	Name          string
    57  	ResourceGroup string
    58  }
    59  
    60  // ResourceName returns the name of the flex VM.
    61  func (s *VMSSFlexGetter) ResourceName() string {
    62  	return s.Name
    63  }
    64  
    65  // ResourceGroupName returns the name of the flex VM.
    66  func (s *VMSSFlexGetter) ResourceGroupName() string {
    67  	return s.ResourceGroup
    68  }
    69  
    70  // OwnerResourceName is a no-op for flex VMs.
    71  func (s *VMSSFlexGetter) OwnerResourceName() string {
    72  	return ""
    73  }
    74  
    75  // Parameters is a no-op for flex VMs as this spec is only used to Get().
    76  func (s *VMSSFlexGetter) Parameters(ctx context.Context, existing interface{}) (params interface{}, err error) {
    77  	return nil, nil
    78  }