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 Jan 28, 2022
1 parent 8324433 commit 34814ce
Show file tree
Hide file tree
Showing 5 changed files with 141 additions and 140 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 @@ -371,35 +373,53 @@ func (s *ClusterScope) VNetSpec() azure.VNetSpec {
}

// 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 @@ -662,6 +682,7 @@ func (s *ClusterScope) PatchObject(ctx context.Context) error {
infrav1.NATGatewaysReadyCondition,
infrav1.LoadBalancersReadyCondition,
infrav1.BastionHostReadyCondition,
infrav1.PrivateDNSReadyCondition,
),
)

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

Expand Down
1 change: 1 addition & 0 deletions azure/services/privatedns/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package privatedns

import (
"context"

"sigs.k8s.io/cluster-api-provider-azure/azure"
)

Expand Down
137 changes: 19 additions & 118 deletions azure/services/privatedns/mock_privatedns/client_mock.go

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

2 changes: 1 addition & 1 deletion azure/services/privatedns/mock_privatedns/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ limitations under the License.
*/

// Run go generate to regenerate this mock.
//go:generate ../../../../hack/tools/bin/mockgen -destination client_mock.go -package mock_privatedns -source ../client.go Client
//go:generate ../../../../hack/tools/bin/mockgen -destination client_mock.go -package mock_privatedns -source ../client.go Getter
//go:generate ../../../../hack/tools/bin/mockgen -destination privatedns_mock.go -package mock_privatedns -source ../privatedns.go Scope
//go:generate /usr/bin/env bash -c "cat ../../../../hack/boilerplate/boilerplate.generatego.txt client_mock.go > _client_mock.go && mv _client_mock.go client_mock.go"
//go:generate /usr/bin/env bash -c "cat ../../../../hack/boilerplate/boilerplate.generatego.txt privatedns_mock.go > _privatedns_mock.go && mv _privatedns_mock.go privatedns_mock.go"
Expand Down
Loading

0 comments on commit 34814ce

Please sign in to comment.