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 26, 2022
1 parent f8bdf24 commit 03a1542
Show file tree
Hide file tree
Showing 3 changed files with 116 additions and 23 deletions.
54 changes: 36 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,49 @@ 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: nil,
}

links := make([]azure.ResourceSpecGetter, 1+len(s.Vnet().Peerings))
links[0] = privatedns.LinkSpec{
Name: azure.GenerateVNetLinkName(s.Vnet().Name),
ZoneName: s.GetPrivateDNSZoneName(),
VNetResourceGroup: s.Vnet().ResourceGroup,
LinkName: azure.GenerateVNetLinkName(s.Vnet().Name),
VNetName: s.Vnet().Name,
ResourceGroup: s.ResourceGroup(),
ClusterName: s.ClusterName(),
}
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(),
VNetResourceGroup: peering.ResourceGroup,
LinkName: azure.GenerateVNetLinkName(peering.RemoteVnetName),
VNetName: peering.RemoteVnetName,
ResourceGroup: s.ResourceGroup(),
ClusterName: s.ClusterName(),
}
}
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 +678,7 @@ func (s *ClusterScope) PatchObject(ctx context.Context) error {
infrav1.NATGatewaysReadyCondition,
infrav1.LoadBalancersReadyCondition,
infrav1.BastionHostReadyCondition,
infrav1.PrivateDNSReadyCondition,
),
)

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

Expand Down
2 changes: 0 additions & 2 deletions azure/services/privatedns/mock_privatedns/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ 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 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"
package mock_privatedns //nolint
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 03a1542

Please sign in to comment.