Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

💎 cloud: Refactor Subnets scope to interface #768

Merged
merged 1 commit into from
Jul 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cloud/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ type ClusterDescriber interface {
Location() string
AdditionalTags() infrav1.Tags
Vnet() *infrav1.VnetSpec
IsVnetManaged() bool
NodeSubnet() *infrav1.SubnetSpec
ControlPlaneSubnet() *infrav1.SubnetSpec
RouteTable() *infrav1.RouteTable
Expand Down
28 changes: 28 additions & 0 deletions cloud/scope/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,39 @@ func (s *ClusterScope) RouteTableSpecs() []azure.RouteTableSpec {
}}
}

// 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
}

// IsVnetManaged returns true if the vnet is managed.
func (s *ClusterScope) IsVnetManaged() bool {
return s.Vnet().ID == "" || s.Vnet().Tags.HasOwned(s.ClusterName())
}

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

return []azure.DiskSpec{spec}
}

Expand Down
14 changes: 14 additions & 0 deletions cloud/services/disks/mock_disks/disks_mock.go

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

14 changes: 14 additions & 0 deletions cloud/services/groups/mock_groups/groups_mock.go

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

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

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

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

14 changes: 14 additions & 0 deletions cloud/services/publicips/mock_publicips/publicips_mock.go

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

14 changes: 14 additions & 0 deletions cloud/services/routetables/mock_routetables/routetables_mock.go

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

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