sigs.k8s.io/cluster-api-provider-azure@v1.17.0/azure/services/privatedns/zone_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 privatedns 18 19 import ( 20 "context" 21 22 "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/privatedns/armprivatedns" 23 "github.com/pkg/errors" 24 "k8s.io/utils/ptr" 25 infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" 26 "sigs.k8s.io/cluster-api-provider-azure/azure" 27 "sigs.k8s.io/cluster-api-provider-azure/azure/converters" 28 ) 29 30 // ZoneSpec defines the specification for private dns zone. 31 type ZoneSpec struct { 32 Name string 33 ResourceGroup string 34 ClusterName string 35 AdditionalTags infrav1.Tags 36 } 37 38 // ResourceName returns the name of the private dns zone. 39 func (s ZoneSpec) ResourceName() string { 40 return s.Name 41 } 42 43 // OwnerResourceName is a no-op for private dns zone. 44 func (s ZoneSpec) OwnerResourceName() string { 45 return "" 46 } 47 48 // ResourceGroupName returns the name of the resource group of the private dns zone. 49 func (s ZoneSpec) ResourceGroupName() string { 50 return s.ResourceGroup 51 } 52 53 // Parameters returns the parameters for the private dns zone. 54 func (s ZoneSpec) Parameters(ctx context.Context, existing interface{}) (params interface{}, err error) { 55 if existing != nil { 56 _, ok := existing.(armprivatedns.PrivateZone) 57 if !ok { 58 return nil, errors.Errorf("%T is not an armprivatedns.PrivateZone", existing) 59 } 60 return nil, nil 61 } 62 63 return armprivatedns.PrivateZone{ 64 Location: ptr.To(azure.Global), 65 Tags: converters.TagsToMap(infrav1.Build(infrav1.BuildParams{ 66 ClusterName: s.ClusterName, 67 Lifecycle: infrav1.ResourceLifecycleOwned, 68 Additional: s.AdditionalTags, 69 })), 70 }, nil 71 }