Skip to content
This repository was archived by the owner on Sep 24, 2021. It is now read-only.

Commit 6c5172b

Browse files
committed
add type meta to objects
Signed-off-by: Chuck Ha <[email protected]>
1 parent d338042 commit 6c5172b

File tree

1 file changed

+36
-24
lines changed

1 file changed

+36
-24
lines changed

objects/cluster.go

Lines changed: 36 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,36 +17,40 @@ limitations under the License.
1717
package objects
1818

1919
import (
20-
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
21-
capi "sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1"
20+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21+
clusterv1alpha1 "sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1"
2222
)
2323

2424
const controlPlaneSet = "controlplane"
2525

2626
// GetMachineDeployment returns a worker node machine deployment object
27-
func GetMachineDeployment(name, namespace, clusterName, kubeletVersion string, replicas int32) capi.MachineDeployment {
27+
func GetMachineDeployment(name, namespace, clusterName, kubeletVersion string, replicas int32) clusterv1alpha1.MachineDeployment {
2828
labels := map[string]string{
2929
"cluster.k8s.io/cluster-name": clusterName,
3030
"set": "node",
3131
}
32-
return capi.MachineDeployment{
33-
ObjectMeta: meta.ObjectMeta{
32+
return clusterv1alpha1.MachineDeployment{
33+
TypeMeta: metav1.TypeMeta{
34+
Kind: "MachineDeployment",
35+
APIVersion: "cluster.k8s.io/v1alpha1",
36+
},
37+
ObjectMeta: metav1.ObjectMeta{
3438
Name: name,
3539
Namespace: namespace,
3640
Labels: labels,
3741
},
38-
Spec: capi.MachineDeploymentSpec{
42+
Spec: clusterv1alpha1.MachineDeploymentSpec{
3943
Replicas: &replicas,
40-
Selector: meta.LabelSelector{
44+
Selector: metav1.LabelSelector{
4145
MatchLabels: labels,
4246
},
43-
Template: capi.MachineTemplateSpec{
44-
ObjectMeta: meta.ObjectMeta{
47+
Template: clusterv1alpha1.MachineTemplateSpec{
48+
ObjectMeta: metav1.ObjectMeta{
4549
Labels: labels,
4650
},
47-
Spec: capi.MachineSpec{
48-
ProviderSpec: capi.ProviderSpec{},
49-
Versions: capi.MachineVersionInfo{
51+
Spec: clusterv1alpha1.MachineSpec{
52+
ProviderSpec: clusterv1alpha1.ProviderSpec{},
53+
Versions: clusterv1alpha1.MachineVersionInfo{
5054
Kubelet: kubeletVersion,
5155
},
5256
},
@@ -56,18 +60,22 @@ func GetMachineDeployment(name, namespace, clusterName, kubeletVersion string, r
5660
}
5761

5862
// GetCluster returns a cluster object with the given name and namespace
59-
func GetCluster(clusterName, namespace string) capi.Cluster {
60-
return capi.Cluster{
61-
ObjectMeta: meta.ObjectMeta{
63+
func GetCluster(clusterName, namespace string) clusterv1alpha1.Cluster {
64+
return clusterv1alpha1.Cluster{
65+
TypeMeta: metav1.TypeMeta{
66+
Kind: "Cluster",
67+
APIVersion: "cluster.k8s.io/v1alpha1",
68+
},
69+
ObjectMeta: metav1.ObjectMeta{
6270
Name: clusterName,
6371
Namespace: namespace,
6472
},
65-
Spec: capi.ClusterSpec{
66-
ClusterNetwork: capi.ClusterNetworkingConfig{
67-
Services: capi.NetworkRanges{
73+
Spec: clusterv1alpha1.ClusterSpec{
74+
ClusterNetwork: clusterv1alpha1.ClusterNetworkingConfig{
75+
Services: clusterv1alpha1.NetworkRanges{
6876
CIDRBlocks: []string{"10.96.0.0/12"},
6977
},
70-
Pods: capi.NetworkRanges{
78+
Pods: clusterv1alpha1.NetworkRanges{
7179
CIDRBlocks: []string{"192.168.0.0/16"},
7280
},
7381
ServiceDomain: "cluster.local",
@@ -77,18 +85,22 @@ func GetCluster(clusterName, namespace string) capi.Cluster {
7785
}
7886

7987
// GetMachine returns a machine with the given parameters
80-
func GetMachine(name, namespace, clusterName, set, version string) capi.Machine {
81-
machine := capi.Machine{
82-
ObjectMeta: meta.ObjectMeta{
88+
func GetMachine(name, namespace, clusterName, set, version string) clusterv1alpha1.Machine {
89+
machine := clusterv1alpha1.Machine{
90+
TypeMeta: metav1.TypeMeta{
91+
Kind: "Machine",
92+
APIVersion: "cluster.k8s.io/v1alpha1",
93+
},
94+
ObjectMeta: metav1.ObjectMeta{
8395
Name: name,
8496
Namespace: namespace,
8597
Labels: map[string]string{
8698
"cluster.k8s.io/cluster-name": clusterName,
8799
"set": set,
88100
},
89101
},
90-
Spec: capi.MachineSpec{
91-
ProviderSpec: capi.ProviderSpec{},
102+
Spec: clusterv1alpha1.MachineSpec{
103+
ProviderSpec: clusterv1alpha1.ProviderSpec{},
92104
},
93105
}
94106
if set == controlPlaneSet {

0 commit comments

Comments
 (0)