Skip to content

Commit

Permalink
cloud: Refactor Subnets scope to interface
Browse files Browse the repository at this point in the history
  • Loading branch information
cpanato committed Jul 8, 2020
1 parent b4faf16 commit 91f6469
Show file tree
Hide file tree
Showing 10 changed files with 680 additions and 339 deletions.
24 changes: 24 additions & 0 deletions cloud/scope/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package scope
import (
"context"
"fmt"

"github.com/Azure/go-autorest/autorest"
"github.com/go-logr/logr"
"github.com/pkg/errors"
Expand Down Expand Up @@ -117,6 +118,29 @@ func (s *ClusterScope) PublicIPSpecs() []azure.PublicIPSpec {
}
}

// SubnetSpecs returns the subnets specs.
func (s *ClusterScope) SubnetSpecs() []azure.SubnetSpec {
return []azure.SubnetSpec{
{
Name: s.ControlPlaneSubnet().Name,
CIDR: s.ControlPlaneSubnet().CidrBlock,
VNetName: s.Vnet().Name,
SecurityGroupName: s.ControlPlaneSubnet().SecurityGroup.Name,
Role: s.ControlPlaneSubnet().Role,
RouteTableName: s.ControlPlaneSubnet().RouteTable.Name,
InternalLBIPAddress: s.ControlPlaneSubnet().InternalLBIPAddress,
},
{
Name: s.NodeSubnet().Name,
CIDR: s.NodeSubnet().CidrBlock,
VNetName: s.Vnet().Name,
SecurityGroupName: s.NodeSubnet().SecurityGroup.Name,
RouteTableName: s.NodeSubnet().RouteTable.Name,
Role: s.NodeSubnet().Role,
},
}
}

// Vnet returns the cluster Vnet.
func (s *ClusterScope) Vnet() *infrav1.VnetSpec {
return &s.AzureCluster.Spec.NetworkSpec.Vnet
Expand Down
1 change: 1 addition & 0 deletions cloud/scope/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ func (m *MachineScope) DiskSpecs() []azure.DiskSpec {
spec := azure.DiskSpec{
Name: azure.GenerateOSDiskName(m.Name()),
}

return []azure.DiskSpec{spec}
}

Expand Down
94 changes: 94 additions & 0 deletions cloud/services/subnets/mock_subnets/client_mock.go

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

4 changes: 3 additions & 1 deletion cloud/services/subnets/mock_subnets/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ limitations under the License.
*/

// Run go generate to regenerate this mock.
//go:generate ../../../../hack/tools/bin/mockgen -destination subnets_mock.go -package mock_subnets -source ../client.go Client
//go:generate ../../../../hack/tools/bin/mockgen -destination client_mock.go -package mock_subnets -source ../client.go Client
//go:generate ../../../../hack/tools/bin/mockgen -destination subnets_mock.go -package mock_subnets -source ../service.go SubnetScope
//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 subnets_mock.go > _subnets_mock.go && mv _subnets_mock.go subnets_mock.go"
package mock_subnets //nolint
Loading

0 comments on commit 91f6469

Please sign in to comment.