Skip to content

Commit 9fdc475

Browse files
awesomenixk8s-ci-robot
authored andcommitted
fix: Restructure machine actuator for unittests, and add unittests (#145)
* fix: Restructure machine actuator for unittests, and add unittests fix: Restructure machine actuator for unittests, and add unittests Remove MachineRole its not used anywhere and used constants for Node and ControlPlane due to lint failure * Add more tests, increasing overall coverage
1 parent 592c6c2 commit 9fdc475

File tree

13 files changed

+764
-507
lines changed

13 files changed

+764
-507
lines changed

Gopkg.lock

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/apis/azureprovider/v1alpha1/azuremachineproviderconfig_types.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,12 @@ type AzureMachineProviderSpec struct {
3434
metav1.TypeMeta `json:",inline"`
3535
metav1.ObjectMeta `json:"metadata,omitempty"`
3636

37-
Roles []MachineRole `json:"roles,omitempty"`
38-
Location string `json:"location"`
39-
VMSize string `json:"vmSize"`
40-
Image Image `json:"image"`
41-
OSDisk OSDisk `json:"osDisk"`
42-
SSHPublicKey string `json:"sshPublicKey"`
43-
SSHPrivateKey string `json:"sshPrivateKey"`
37+
Location string `json:"location"`
38+
VMSize string `json:"vmSize"`
39+
Image Image `json:"image"`
40+
OSDisk OSDisk `json:"osDisk"`
41+
SSHPublicKey string `json:"sshPublicKey"`
42+
SSHPrivateKey string `json:"sshPrivateKey"`
4443
}
4544

4645
// KubeadmConfiguration holds the various configurations that kubeadm uses.

pkg/apis/azureprovider/v1alpha1/types.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,11 @@ type AzureMachineProviderCondition struct {
6565
Message string `json:"message"`
6666
}
6767

68-
type MachineRole string
69-
7068
const (
71-
// TODO: Change references to "controlplane", instead of "Master" and lowercase both roles.
72-
Master MachineRole = "Master"
73-
Node MachineRole = "Node"
69+
// ControlPlane machine label
70+
ControlPlane string = "controlplane"
71+
// Node machine label
72+
Node string = "node"
7473
)
7574

7675
// Network encapsulates Azure networking resources.
@@ -112,10 +111,10 @@ var (
112111
SecurityGroupBastion = SecurityGroupRole("bastion")
113112

114113
// SecurityGroupNode defines a Kubernetes workload node role
115-
SecurityGroupNode = SecurityGroupRole("node")
114+
SecurityGroupNode = SecurityGroupRole(Node)
116115

117116
// SecurityGroupControlPlane defines a Kubernetes control plane node role
118-
SecurityGroupControlPlane = SecurityGroupRole("controlplane")
117+
SecurityGroupControlPlane = SecurityGroupRole(ControlPlane)
119118
)
120119

121120
// SecurityGroup defines an Azure security group.

pkg/apis/azureprovider/v1alpha1/zz_generated.deepcopy.go

Lines changed: 0 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/cloud/azure/actuators/machine/BUILD.bazel

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ go_library(
55
srcs = [
66
"actuator.go",
77
"annotations.go",
8+
"reconciler.go",
89
],
910
importpath = "sigs.k8s.io/cluster-api-provider-azure/pkg/cloud/azure/actuators/machine",
1011
visibility = ["//visibility:public"],
@@ -29,12 +30,25 @@ go_library(
2930
"//vendor/sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1:go_default_library",
3031
"//vendor/sigs.k8s.io/cluster-api/pkg/client/clientset_generated/clientset/typed/cluster/v1alpha1:go_default_library",
3132
"//vendor/sigs.k8s.io/cluster-api/pkg/controller/error:go_default_library",
33+
"//vendor/sigs.k8s.io/cluster-api/pkg/util:go_default_library",
3234
],
3335
)
3436

3537
go_test(
3638
name = "go_default_test",
3739
srcs = ["actuator_test.go"],
3840
embed = [":go_default_library"],
39-
deps = ["//vendor/sigs.k8s.io/cluster-api/pkg/controller/machine:go_default_library"],
41+
deps = [
42+
"//pkg/apis/azureprovider/v1alpha1:go_default_library",
43+
"//pkg/cloud/azure:go_default_library",
44+
"//pkg/cloud/azure/actuators:go_default_library",
45+
"//vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-10-01/compute:go_default_library",
46+
"//vendor/github.com/Azure/go-autorest/autorest/to:go_default_library",
47+
"//vendor/github.com/ghodss/yaml:go_default_library",
48+
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
49+
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
50+
"//vendor/sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1:go_default_library",
51+
"//vendor/sigs.k8s.io/cluster-api/pkg/client/clientset_generated/clientset/fake:go_default_library",
52+
"//vendor/sigs.k8s.io/cluster-api/pkg/controller/machine:go_default_library",
53+
],
4054
)

0 commit comments

Comments
 (0)