Skip to content

Commit

Permalink
update scope, generate mocks, add privatedns to conditions summary
Browse files Browse the repository at this point in the history
  • Loading branch information
shysank committed Feb 2, 2022
1 parent 70b20ee commit 76b0c85
Show file tree
Hide file tree
Showing 3 changed files with 120 additions and 187 deletions.
58 changes: 40 additions & 18 deletions azure/scope/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import (
"strconv"
"strings"

"sigs.k8s.io/cluster-api-provider-azure/azure/services/privatedns"

"github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/to"
"github.com/pkg/errors"
Expand Down Expand Up @@ -375,35 +377,53 @@ func (s *ClusterScope) VNetSpec() azure.ResourceSpecGetter {
}

// PrivateDNSSpec returns the private dns zone spec.
func (s *ClusterScope) PrivateDNSSpec() *azure.PrivateDNSSpec {
var specs *azure.PrivateDNSSpec
func (s *ClusterScope) PrivateDNSSpec() (zoneSpec azure.ResourceSpecGetter, linkSpec, recordSpec []azure.ResourceSpecGetter) {
if s.IsAPIServerPrivate() {
links := make([]azure.PrivateDNSLinkSpec, 1+len(s.Vnet().Peerings))
links[0] = azure.PrivateDNSLinkSpec{
VNetName: s.Vnet().Name,
zone := privatedns.ZoneSpec{
Name: s.GetPrivateDNSZoneName(),
ResourceGroup: s.ResourceGroup(),
ClusterName: s.ClusterName(),
AdditionalTags: s.AdditionalTags(),
}

links := make([]azure.ResourceSpecGetter, 1+len(s.Vnet().Peerings))
links[0] = privatedns.LinkSpec{
Name: azure.GenerateVNetLinkName(s.Vnet().Name),
ZoneName: s.GetPrivateDNSZoneName(),
SubscriptionID: s.SubscriptionID(),
VNetResourceGroup: s.Vnet().ResourceGroup,
LinkName: azure.GenerateVNetLinkName(s.Vnet().Name),
VNetName: s.Vnet().Name,
ResourceGroup: s.ResourceGroup(),
ClusterName: s.ClusterName(),
AdditionalTags: s.AdditionalTags(),
}
for i, peering := range s.Vnet().Peerings {
links[i+1] = azure.PrivateDNSLinkSpec{
VNetName: peering.RemoteVnetName,
links[i+1] = privatedns.LinkSpec{
Name: azure.GenerateVNetLinkName(peering.RemoteVnetName),
ZoneName: s.GetPrivateDNSZoneName(),
SubscriptionID: s.SubscriptionID(),
VNetResourceGroup: peering.ResourceGroup,
LinkName: azure.GenerateVNetLinkName(peering.RemoteVnetName),
VNetName: peering.RemoteVnetName,
ResourceGroup: s.ResourceGroup(),
ClusterName: s.ClusterName(),
AdditionalTags: s.AdditionalTags(),
}
}
specs = &azure.PrivateDNSSpec{
ZoneName: s.GetPrivateDNSZoneName(),
Links: links,
Records: []infrav1.AddressRecord{
{
Hostname: azure.PrivateAPIServerHostname,
IP: s.APIServerPrivateIP(),
},

records := make([]azure.ResourceSpecGetter, 1)
records[0] = privatedns.RecordSpec{
Record: infrav1.AddressRecord{
Hostname: azure.PrivateAPIServerHostname,
IP: s.APIServerPrivateIP(),
},
ZoneName: s.GetPrivateDNSZoneName(),
ResourceGroup: s.ResourceGroup(),
}

return zone, links, records
}

return specs
return nil, nil, nil
}

// IsAzureBastionEnabled returns true if the azure bastion is enabled.
Expand Down Expand Up @@ -667,6 +687,7 @@ func (s *ClusterScope) PatchObject(ctx context.Context) error {
infrav1.LoadBalancersReadyCondition,
infrav1.BastionHostReadyCondition,
infrav1.VNetReadyCondition,
infrav1.PrivateDNSReadyCondition,
),
)

Expand All @@ -684,6 +705,7 @@ func (s *ClusterScope) PatchObject(ctx context.Context) error {
infrav1.LoadBalancersReadyCondition,
infrav1.BastionHostReadyCondition,
infrav1.VNetReadyCondition,
infrav1.PrivateDNSReadyCondition,
}})
}

Expand Down
166 changes: 0 additions & 166 deletions azure/services/privatedns/mock_privatedns/client_mock.go

This file was deleted.

83 changes: 80 additions & 3 deletions azure/services/privatedns/mock_privatedns/privatedns_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 76b0c85

Please sign in to comment.