sigs.k8s.io/cluster-api-provider-azure@v1.14.3/azure/converters/extendedlocation.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 converters
    18  
    19  import (
    20  	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v5"
    21  	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v4"
    22  	asonetworkv1 "github.com/Azure/azure-service-operator/v2/api/network/v1api20201101"
    23  	"k8s.io/utils/ptr"
    24  	infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1"
    25  )
    26  
    27  // ExtendedLocationToNetworkSDK converts an infrav1.ExtendedLocationSpec to an armnetwork.ExtendedLocation.
    28  func ExtendedLocationToNetworkSDK(src *infrav1.ExtendedLocationSpec) *armnetwork.ExtendedLocation {
    29  	if src == nil {
    30  		return nil
    31  	}
    32  	return &armnetwork.ExtendedLocation{
    33  		Name: ptr.To(src.Name),
    34  		Type: ptr.To(armnetwork.ExtendedLocationTypes(src.Type)),
    35  	}
    36  }
    37  
    38  // ExtendedLocationToNetworkASO converts an infrav1.ExtendedLocationSpec to an asonetworkv1.ExtendedLocation.
    39  func ExtendedLocationToNetworkASO(src *infrav1.ExtendedLocationSpec) *asonetworkv1.ExtendedLocation {
    40  	if src == nil {
    41  		return nil
    42  	}
    43  	return &asonetworkv1.ExtendedLocation{
    44  		Name: ptr.To(src.Name),
    45  		Type: ptr.To(asonetworkv1.ExtendedLocationType(src.Type)),
    46  	}
    47  }
    48  
    49  // ExtendedLocationToComputeSDK converts an infrav1.ExtendedLocationSpec to an armcompute.ExtendedLocation.
    50  func ExtendedLocationToComputeSDK(src *infrav1.ExtendedLocationSpec) *armcompute.ExtendedLocation {
    51  	if src == nil {
    52  		return nil
    53  	}
    54  	return &armcompute.ExtendedLocation{
    55  		Name: ptr.To(src.Name),
    56  		Type: ptr.To(armcompute.ExtendedLocationTypes(src.Type)),
    57  	}
    58  }