Skip to content

Commit

Permalink
updated package structure
Browse files Browse the repository at this point in the history
  • Loading branch information
killianmuldoon committed Sep 23, 2021
1 parent e3f32a6 commit a5fa1c9
Show file tree
Hide file tree
Showing 24 changed files with 294 additions and 282 deletions.
6 changes: 3 additions & 3 deletions controllers/cluster_controller_phases_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/client/fake"

"sigs.k8s.io/cluster-api/internal/testtypes"
"sigs.k8s.io/cluster-api/internal/builder"
)

func TestClusterReconcilePhases(t *testing.T) {
Expand Down Expand Up @@ -129,11 +129,11 @@ func TestClusterReconcilePhases(t *testing.T) {
if tt.infraRef != nil {
infraConfig := &unstructured.Unstructured{Object: tt.infraRef}
c = fake.NewClientBuilder().
WithObjects(testtypes.GenericInfrastructureMachineCRD.DeepCopy(), tt.cluster, infraConfig).
WithObjects(builder.GenericInfrastructureMachineCRD.DeepCopy(), tt.cluster, infraConfig).
Build()
} else {
c = fake.NewClientBuilder().
WithObjects(testtypes.GenericInfrastructureMachineCRD.DeepCopy(), tt.cluster).
WithObjects(builder.GenericInfrastructureMachineCRD.DeepCopy(), tt.cluster).
Build()
}
r := &ClusterReconciler{
Expand Down
42 changes: 21 additions & 21 deletions controllers/machine_controller_phases_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import (

clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
"sigs.k8s.io/cluster-api/controllers/remote"
"sigs.k8s.io/cluster-api/internal/testtypes"
"sigs.k8s.io/cluster-api/internal/builder"
"sigs.k8s.io/cluster-api/util/conditions"
"sigs.k8s.io/cluster-api/util/kubeconfig"
)
Expand Down Expand Up @@ -122,8 +122,8 @@ func TestReconcileMachinePhases(t *testing.T) {
WithObjects(defaultCluster,
defaultKubeconfigSecret,
machine,
testtypes.GenericBootstrapConfigCRD.DeepCopy(),
testtypes.GenericInfrastructureMachineCRD.DeepCopy(),
builder.GenericBootstrapConfigCRD.DeepCopy(),
builder.GenericInfrastructureMachineCRD.DeepCopy(),
bootstrapConfig,
infraConfig,
).Build(),
Expand Down Expand Up @@ -160,8 +160,8 @@ func TestReconcileMachinePhases(t *testing.T) {
WithObjects(defaultCluster,
defaultKubeconfigSecret,
machine,
testtypes.GenericBootstrapConfigCRD.DeepCopy(),
testtypes.GenericInfrastructureMachineCRD.DeepCopy(),
builder.GenericBootstrapConfigCRD.DeepCopy(),
builder.GenericInfrastructureMachineCRD.DeepCopy(),
bootstrapConfig,
infraConfig,
).Build(),
Expand Down Expand Up @@ -203,8 +203,8 @@ func TestReconcileMachinePhases(t *testing.T) {
WithObjects(defaultCluster,
defaultKubeconfigSecret,
machine,
testtypes.GenericBootstrapConfigCRD.DeepCopy(),
testtypes.GenericInfrastructureMachineCRD.DeepCopy(),
builder.GenericBootstrapConfigCRD.DeepCopy(),
builder.GenericInfrastructureMachineCRD.DeepCopy(),
bootstrapConfig,
infraConfig,
).Build(),
Expand Down Expand Up @@ -278,8 +278,8 @@ func TestReconcileMachinePhases(t *testing.T) {
WithObjects(defaultCluster,
machine,
node,
testtypes.GenericBootstrapConfigCRD.DeepCopy(),
testtypes.GenericInfrastructureMachineCRD.DeepCopy(),
builder.GenericBootstrapConfigCRD.DeepCopy(),
builder.GenericInfrastructureMachineCRD.DeepCopy(),
bootstrapConfig,
infraConfig,
defaultKubeconfigSecret,
Expand Down Expand Up @@ -344,8 +344,8 @@ func TestReconcileMachinePhases(t *testing.T) {
WithObjects(defaultCluster,
machine,
node,
testtypes.GenericBootstrapConfigCRD.DeepCopy(),
testtypes.GenericInfrastructureMachineCRD.DeepCopy(),
builder.GenericBootstrapConfigCRD.DeepCopy(),
builder.GenericInfrastructureMachineCRD.DeepCopy(),
bootstrapConfig,
infraConfig,
defaultKubeconfigSecret,
Expand Down Expand Up @@ -420,8 +420,8 @@ func TestReconcileMachinePhases(t *testing.T) {
WithObjects(defaultCluster,
machine,
node,
testtypes.GenericBootstrapConfigCRD.DeepCopy(),
testtypes.GenericInfrastructureMachineCRD.DeepCopy(),
builder.GenericBootstrapConfigCRD.DeepCopy(),
builder.GenericInfrastructureMachineCRD.DeepCopy(),
bootstrapConfig,
infraConfig,
defaultKubeconfigSecret,
Expand Down Expand Up @@ -480,8 +480,8 @@ func TestReconcileMachinePhases(t *testing.T) {
WithObjects(defaultCluster,
defaultKubeconfigSecret,
machine,
testtypes.GenericBootstrapConfigCRD.DeepCopy(),
testtypes.GenericInfrastructureMachineCRD.DeepCopy(),
builder.GenericBootstrapConfigCRD.DeepCopy(),
builder.GenericInfrastructureMachineCRD.DeepCopy(),
bootstrapConfig,
infraConfig,
).Build()
Expand Down Expand Up @@ -562,8 +562,8 @@ func TestReconcileMachinePhases(t *testing.T) {
defaultKubeconfigSecret,
machine,
machineSecond,
testtypes.GenericBootstrapConfigCRD.DeepCopy(),
testtypes.GenericInfrastructureMachineCRD.DeepCopy(),
builder.GenericBootstrapConfigCRD.DeepCopy(),
builder.GenericInfrastructureMachineCRD.DeepCopy(),
bootstrapConfig,
infraConfig,
).Build()
Expand Down Expand Up @@ -869,8 +869,8 @@ func TestReconcileBootstrap(t *testing.T) {
r := &MachineReconciler{
Client: fake.NewClientBuilder().
WithObjects(tc.machine,
testtypes.GenericBootstrapConfigCRD.DeepCopy(),
testtypes.GenericInfrastructureMachineCRD.DeepCopy(),
builder.GenericBootstrapConfigCRD.DeepCopy(),
builder.GenericInfrastructureMachineCRD.DeepCopy(),
bootstrapConfig,
).Build(),
}
Expand Down Expand Up @@ -1079,8 +1079,8 @@ func TestReconcileInfrastructure(t *testing.T) {
r := &MachineReconciler{
Client: fake.NewClientBuilder().
WithObjects(tc.machine,
testtypes.GenericBootstrapConfigCRD.DeepCopy(),
testtypes.GenericInfrastructureMachineCRD.DeepCopy(),
builder.GenericBootstrapConfigCRD.DeepCopy(),
builder.GenericInfrastructureMachineCRD.DeepCopy(),
infraConfig,
).Build(),
}
Expand Down
8 changes: 4 additions & 4 deletions controllers/machine_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import (

clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
"sigs.k8s.io/cluster-api/controllers/remote"
"sigs.k8s.io/cluster-api/internal/testtypes"
"sigs.k8s.io/cluster-api/internal/builder"
"sigs.k8s.io/cluster-api/util"
"sigs.k8s.io/cluster-api/util/conditions"
"sigs.k8s.io/cluster-api/util/patch"
Expand Down Expand Up @@ -715,7 +715,7 @@ func TestReconcileRequest(t *testing.T) {
node,
&testCluster,
&tc.machine,
testtypes.GenericInfrastructureMachineCRD.DeepCopy(),
builder.GenericInfrastructureMachineCRD.DeepCopy(),
&infraConfig,
).Build()

Expand Down Expand Up @@ -957,9 +957,9 @@ func TestMachineConditions(t *testing.T) {
clientFake := fake.NewClientBuilder().WithObjects(
&testCluster,
m,
testtypes.GenericInfrastructureMachineCRD.DeepCopy(),
builder.GenericInfrastructureMachineCRD.DeepCopy(),
infra,
testtypes.GenericBootstrapConfigCRD.DeepCopy(),
builder.GenericBootstrapConfigCRD.DeepCopy(),
bootstrap,
node,
).Build()
Expand Down
18 changes: 9 additions & 9 deletions controllers/machinehealthcheck_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"time"

. "github.com/onsi/gomega"
"sigs.k8s.io/cluster-api/internal/testtypes"
"sigs.k8s.io/cluster-api/internal/builder"

corev1 "k8s.io/api/core/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
Expand Down Expand Up @@ -1462,7 +1462,7 @@ func TestMachineHealthCheck_Reconcile(t *testing.T) {
// Create remediation template resource.
infraRemediationResource := map[string]interface{}{
"kind": "GenericExternalRemediation",
"apiVersion": testtypes.RemediationGroupVersion.String(),
"apiVersion": builder.RemediationGroupVersion.String(),
"metadata": map[string]interface{}{},
"spec": map[string]interface{}{
"size": "3xlarge",
Expand All @@ -1476,13 +1476,13 @@ func TestMachineHealthCheck_Reconcile(t *testing.T) {
},
}
infraRemediationTmpl.SetKind("GenericExternalRemediationTemplate")
infraRemediationTmpl.SetAPIVersion(testtypes.RemediationGroupVersion.String())
infraRemediationTmpl.SetAPIVersion(builder.RemediationGroupVersion.String())
infraRemediationTmpl.SetGenerateName("remediation-template-name-")
infraRemediationTmpl.SetNamespace(cluster.Namespace)
g.Expect(env.Create(ctx, infraRemediationTmpl)).To(Succeed())

remediationTemplate := &corev1.ObjectReference{
APIVersion: testtypes.RemediationGroupVersion.String(),
APIVersion: builder.RemediationGroupVersion.String(),
Kind: "GenericExternalRemediationTemplate",
Name: infraRemediationTmpl.GetName(),
}
Expand Down Expand Up @@ -1582,7 +1582,7 @@ func TestMachineHealthCheck_Reconcile(t *testing.T) {
}).Should(Equal(1))

ref := corev1.ObjectReference{
APIVersion: testtypes.RemediationGroupVersion.String(),
APIVersion: builder.RemediationGroupVersion.String(),
Kind: "GenericExternalRemediation",
}

Expand Down Expand Up @@ -1610,7 +1610,7 @@ func TestMachineHealthCheck_Reconcile(t *testing.T) {
// Create remediation template resource.
infraRemediationResource := map[string]interface{}{
"kind": "GenericExternalRemediation",
"apiVersion": testtypes.RemediationGroupVersion.String(),
"apiVersion": builder.RemediationGroupVersion.String(),
"metadata": map[string]interface{}{},
"spec": map[string]interface{}{
"size": "3xlarge",
Expand All @@ -1624,13 +1624,13 @@ func TestMachineHealthCheck_Reconcile(t *testing.T) {
},
}
infraRemediationTmpl.SetKind("GenericExternalRemediationTemplate")
infraRemediationTmpl.SetAPIVersion(testtypes.RemediationGroupVersion.String())
infraRemediationTmpl.SetAPIVersion(builder.RemediationGroupVersion.String())
infraRemediationTmpl.SetGenerateName("remediation-template-name-")
infraRemediationTmpl.SetNamespace(cluster.Namespace)
g.Expect(env.Create(ctx, infraRemediationTmpl)).To(Succeed())

remediationTemplate := &corev1.ObjectReference{
APIVersion: testtypes.RemediationGroupVersion.String(),
APIVersion: builder.RemediationGroupVersion.String(),
Kind: "GenericExternalRemediationTemplate",
Name: infraRemediationTmpl.GetName(),
}
Expand Down Expand Up @@ -1781,7 +1781,7 @@ func TestMachineHealthCheck_Reconcile(t *testing.T) {
}).Should(Equal(0))

ref := corev1.ObjectReference{
APIVersion: testtypes.RemediationGroupVersion.String(),
APIVersion: builder.RemediationGroupVersion.String(),
Kind: "GenericExternalRemediation",
}

Expand Down
8 changes: 4 additions & 4 deletions controllers/machineset_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import (

clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
"sigs.k8s.io/cluster-api/controllers/external"
"sigs.k8s.io/cluster-api/internal/testtypes"
"sigs.k8s.io/cluster-api/internal/builder"
"sigs.k8s.io/cluster-api/util"
"sigs.k8s.io/cluster-api/util/conditions"
)
Expand Down Expand Up @@ -772,8 +772,8 @@ func TestMachineSetReconcile_MachinesCreatedConditionFalseOnBadInfraRef(t *testi
},
Spec: clusterv1.MachineSpec{
InfrastructureRef: corev1.ObjectReference{
Kind: testtypes.GenericInfrastructureMachineTemplateCRD.Kind,
APIVersion: testtypes.GenericInfrastructureMachineTemplateCRD.APIVersion,
Kind: builder.GenericInfrastructureMachineTemplateCRD.Kind,
APIVersion: builder.GenericInfrastructureMachineTemplateCRD.APIVersion,
// Try to break Infra Cloning
Name: "something_invalid",
Namespace: cluster.Namespace,
Expand All @@ -793,7 +793,7 @@ func TestMachineSetReconcile_MachinesCreatedConditionFalseOnBadInfraRef(t *testi
request := reconcile.Request{
NamespacedName: key,
}
fakeClient := fake.NewClientBuilder().WithObjects(cluster, ms, testtypes.GenericInfrastructureMachineTemplateCRD.DeepCopy()).Build()
fakeClient := fake.NewClientBuilder().WithObjects(cluster, ms, builder.GenericInfrastructureMachineTemplateCRD.DeepCopy()).Build()

msr := &MachineSetReconciler{
Client: fakeClient,
Expand Down
Loading

0 comments on commit a5fa1c9

Please sign in to comment.