diff --git a/bootstrap/kubeadm/internal/builder/builders.go b/bootstrap/kubeadm/internal/builder/builders.go index e92bddee11d7..63157414e0bb 100644 --- a/bootstrap/kubeadm/internal/builder/builders.go +++ b/bootstrap/kubeadm/internal/builder/builders.go @@ -73,10 +73,6 @@ func (k *KubeadmConfigBuilder) Unstructured() *unstructured.Unstructured { // Build produces a KubeadmConfig from the variable in the KubeadmConfigBuilder. func (k *KubeadmConfigBuilder) Build() *bootstrapv1.KubeadmConfig { config := &bootstrapv1.KubeadmConfig{ - TypeMeta: metav1.TypeMeta{ - Kind: "KubeadmConfig", - APIVersion: bootstrapv1.GroupVersion.String(), - }, ObjectMeta: metav1.ObjectMeta{ Namespace: k.namespace, Name: k.name, diff --git a/bootstrap/util/configowner_test.go b/bootstrap/util/configowner_test.go index aba7f1e6e794..7e873969f231 100644 --- a/bootstrap/util/configowner_test.go +++ b/bootstrap/util/configowner_test.go @@ -187,10 +187,6 @@ func TestHasNodeRefs(t *testing.T) { t.Run("should return false if there is no nodeRef", func(t *testing.T) { g := NewWithT(t) machine := &clusterv1.Machine{ - TypeMeta: metav1.TypeMeta{ - APIVersion: clusterv1.GroupVersion.String(), - Kind: "Machine", - }, ObjectMeta: metav1.ObjectMeta{ Name: "machine-name", Namespace: metav1.NamespaceDefault, @@ -209,10 +205,6 @@ func TestHasNodeRefs(t *testing.T) { t.Run("should return true if there is a nodeRef for Machine", func(t *testing.T) { g := NewWithT(t) machine := &clusterv1.Machine{ - TypeMeta: metav1.TypeMeta{ - APIVersion: clusterv1.GroupVersion.String(), - Kind: "Machine", - }, ObjectMeta: metav1.ObjectMeta{ Name: "machine-name", Namespace: metav1.NamespaceDefault, @@ -242,10 +234,6 @@ func TestHasNodeRefs(t *testing.T) { machinePools := []clusterv1.MachinePool{ { // No replicas specified (default is 1). No nodeRefs either. - TypeMeta: metav1.TypeMeta{ - APIVersion: clusterv1.GroupVersion.String(), - Kind: "MachinePool", - }, ObjectMeta: metav1.ObjectMeta{ Namespace: metav1.NamespaceDefault, Name: "machine-pool-name", @@ -253,10 +241,6 @@ func TestHasNodeRefs(t *testing.T) { }, { // 1 replica but no nodeRefs - TypeMeta: metav1.TypeMeta{ - APIVersion: clusterv1.GroupVersion.String(), - Kind: "MachinePool", - }, ObjectMeta: metav1.ObjectMeta{ Namespace: metav1.NamespaceDefault, Name: "machine-pool-name", @@ -267,10 +251,6 @@ func TestHasNodeRefs(t *testing.T) { }, { // 2 replicas but only 1 nodeRef - TypeMeta: metav1.TypeMeta{ - APIVersion: clusterv1.GroupVersion.String(), - Kind: "MachinePool", - }, ObjectMeta: metav1.ObjectMeta{ Namespace: metav1.NamespaceDefault, Name: "machine-pool-name", @@ -308,10 +288,6 @@ func TestHasNodeRefs(t *testing.T) { machinePools := []clusterv1.MachinePool{ { // 1 replica (default) and 1 nodeRef - TypeMeta: metav1.TypeMeta{ - APIVersion: clusterv1.GroupVersion.String(), - Kind: "MachinePool", - }, ObjectMeta: metav1.ObjectMeta{ Namespace: metav1.NamespaceDefault, Name: "machine-pool-name", @@ -328,10 +304,6 @@ func TestHasNodeRefs(t *testing.T) { }, { // 2 replicas and nodeRefs - TypeMeta: metav1.TypeMeta{ - APIVersion: clusterv1.GroupVersion.String(), - Kind: "MachinePool", - }, ObjectMeta: metav1.ObjectMeta{ Namespace: metav1.NamespaceDefault, Name: "machine-pool-name", @@ -356,10 +328,6 @@ func TestHasNodeRefs(t *testing.T) { }, { // 0 replicas and 0 nodeRef - TypeMeta: metav1.TypeMeta{ - APIVersion: clusterv1.GroupVersion.String(), - Kind: "MachinePool", - }, ObjectMeta: metav1.ObjectMeta{ Namespace: metav1.NamespaceDefault, Name: "machine-pool-name", diff --git a/controllers/external/tracker_test.go b/controllers/external/tracker_test.go index e24d69296731..92966d2c82bb 100644 --- a/controllers/external/tracker_test.go +++ b/controllers/external/tracker_test.go @@ -22,7 +22,6 @@ import ( "github.com/go-logr/logr" . "github.com/onsi/gomega" "github.com/pkg/errors" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/utils/ptr" "sigs.k8s.io/controller-runtime/pkg/cache/informertest" @@ -83,12 +82,7 @@ func TestWatchMultipleTimes(t *testing.T) { ctrl := &watchCountController{} tracker := ObjectTracker{Controller: ctrl, Scheme: runtime.NewScheme(), Cache: &informertest.FakeInformers{}, PredicateLogger: ptr.To(logr.New(log.NullLogSink{}))} - obj := &clusterv1.Cluster{ - TypeMeta: metav1.TypeMeta{ - Kind: "Cluster", - APIVersion: clusterv1.GroupVersion.Version, - }, - } + obj := &clusterv1.Cluster{} err := tracker.Watch(logger, obj, nil) g.Expect(err).ToNot(HaveOccurred()) g.Expect(ctrl.count).Should(Equal(1)) diff --git a/controlplane/kubeadm/internal/cluster_test.go b/controlplane/kubeadm/internal/cluster_test.go index e0bb39d1c47c..cf6d23feccff 100644 --- a/controlplane/kubeadm/internal/cluster_test.go +++ b/controlplane/kubeadm/internal/cluster_test.go @@ -301,7 +301,6 @@ func machineListForTestGetMachinesForCluster() *clusterv1.MachineList { } machine := func(name string) clusterv1.Machine { return clusterv1.Machine{ - TypeMeta: metav1.TypeMeta{}, ObjectMeta: metav1.ObjectMeta{ Name: name, Namespace: metav1.NamespaceDefault, diff --git a/controlplane/kubeadm/internal/controllers/controller_test.go b/controlplane/kubeadm/internal/controllers/controller_test.go index b993d6bc9fcd..80b3d7d81e54 100644 --- a/controlplane/kubeadm/internal/controllers/controller_test.go +++ b/controlplane/kubeadm/internal/controllers/controller_test.go @@ -602,10 +602,6 @@ func TestKubeadmControlPlaneReconciler_adoption(t *testing.T) { }, } cfg := &bootstrapv1.KubeadmConfig{ - TypeMeta: metav1.TypeMeta{ - APIVersion: bootstrapv1.GroupVersion.String(), - Kind: "KubeadmConfig", - }, ObjectMeta: metav1.ObjectMeta{ Namespace: cluster.Namespace, Name: name, @@ -1744,10 +1740,6 @@ func TestKubeadmControlPlaneReconciler_syncMachines(t *testing.T) { JoinConfiguration: &bootstrapv1.JoinConfiguration{}, } existingKubeadmConfig := &bootstrapv1.KubeadmConfig{ - TypeMeta: metav1.TypeMeta{ - Kind: "KubeadmConfig", - APIVersion: bootstrapv1.GroupVersion.String(), - }, ObjectMeta: metav1.ObjectMeta{ Name: "existing-kubeadmconfig", Namespace: namespace.Name, @@ -1775,10 +1767,6 @@ func TestKubeadmControlPlaneReconciler_syncMachines(t *testing.T) { // Existing Machine to validate in-place mutation fd := "fd1" inPlaceMutatingMachine := &clusterv1.Machine{ - TypeMeta: metav1.TypeMeta{ - Kind: "Machine", - APIVersion: clusterv1.GroupVersion.String(), - }, ObjectMeta: metav1.ObjectMeta{ Name: "existing-machine", Namespace: namespace.Name, @@ -1814,10 +1802,6 @@ func TestKubeadmControlPlaneReconciler_syncMachines(t *testing.T) { // Existing machine that is in deleting state deletingMachine := &clusterv1.Machine{ - TypeMeta: metav1.TypeMeta{ - APIVersion: clusterv1.GroupVersion.String(), - Kind: "Machine", - }, ObjectMeta: metav1.ObjectMeta{ Name: "deleting-machine", Namespace: namespace.Name, @@ -1856,10 +1840,6 @@ func TestKubeadmControlPlaneReconciler_syncMachines(t *testing.T) { // Existing machine that has a InfrastructureRef which does not exist. nilInfraMachineMachine := &clusterv1.Machine{ - TypeMeta: metav1.TypeMeta{ - APIVersion: clusterv1.GroupVersion.String(), - Kind: "Machine", - }, ObjectMeta: metav1.ObjectMeta{ Name: "nil-infra-machine-machine", Namespace: namespace.Name, @@ -1883,10 +1863,6 @@ func TestKubeadmControlPlaneReconciler_syncMachines(t *testing.T) { // Delete the machine to put it in the deleting state kcp := &controlplanev1.KubeadmControlPlane{ - TypeMeta: metav1.TypeMeta{ - Kind: "KubeadmControlPlane", - APIVersion: controlplanev1.GroupVersion.String(), - }, ObjectMeta: metav1.ObjectMeta{ UID: types.UID("abc-123-control-plane"), Name: "existing-kcp", @@ -3798,10 +3774,6 @@ func createClusterWithControlPlane(namespace string) (*clusterv1.Cluster, *contr } kcp := &controlplanev1.KubeadmControlPlane{ - TypeMeta: metav1.TypeMeta{ - APIVersion: controlplanev1.GroupVersion.String(), - Kind: "KubeadmControlPlane", - }, ObjectMeta: metav1.ObjectMeta{ Name: kcpName, Namespace: namespace, @@ -3866,10 +3838,6 @@ func setKCPHealthy(kcp *controlplanev1.KubeadmControlPlane) { func createMachineNodePair(name string, cluster *clusterv1.Cluster, kcp *controlplanev1.KubeadmControlPlane, ready bool) (*clusterv1.Machine, *corev1.Node) { machine := &clusterv1.Machine{ - TypeMeta: metav1.TypeMeta{ - Kind: "Machine", - APIVersion: clusterv1.GroupVersion.String(), - }, ObjectMeta: metav1.ObjectMeta{ Namespace: cluster.Namespace, Name: name, @@ -3931,10 +3899,6 @@ func setMachineHealthy(m *clusterv1.Machine) { // newCluster return a CAPI cluster object. func newCluster(namespacedName *types.NamespacedName) *clusterv1.Cluster { return &clusterv1.Cluster{ - TypeMeta: metav1.TypeMeta{ - Kind: "Cluster", - APIVersion: clusterv1.GroupVersion.String(), - }, ObjectMeta: metav1.ObjectMeta{ Namespace: namespacedName.Namespace, Name: namespacedName.Name, diff --git a/controlplane/kubeadm/internal/controllers/helpers.go b/controlplane/kubeadm/internal/controllers/helpers.go index 7bbd3a9141dc..f5357562175b 100644 --- a/controlplane/kubeadm/internal/controllers/helpers.go +++ b/controlplane/kubeadm/internal/controllers/helpers.go @@ -428,10 +428,6 @@ func (r *KubeadmControlPlaneReconciler) computeDesiredMachine(kcp *controlplanev // Construct the basic Machine. desiredMachine := &clusterv1.Machine{ - TypeMeta: metav1.TypeMeta{ - APIVersion: clusterv1.GroupVersion.String(), - Kind: "Machine", - }, ObjectMeta: metav1.ObjectMeta{ UID: machineUID, Name: machineName, diff --git a/controlplane/kubeadm/internal/controllers/helpers_test.go b/controlplane/kubeadm/internal/controllers/helpers_test.go index 36d519a309b6..d99b1171573d 100644 --- a/controlplane/kubeadm/internal/controllers/helpers_test.go +++ b/controlplane/kubeadm/internal/controllers/helpers_test.go @@ -46,10 +46,6 @@ func TestReconcileKubeconfigEmptyAPIEndpoints(t *testing.T) { g := NewWithT(t) cluster := &clusterv1.Cluster{ - TypeMeta: metav1.TypeMeta{ - Kind: "Cluster", - APIVersion: clusterv1.GroupVersion.String(), - }, ObjectMeta: metav1.ObjectMeta{ Name: "foo", Namespace: metav1.NamespaceDefault, @@ -60,10 +56,6 @@ func TestReconcileKubeconfigEmptyAPIEndpoints(t *testing.T) { } kcp := &controlplanev1.KubeadmControlPlane{ - TypeMeta: metav1.TypeMeta{ - Kind: "KubeadmControlPlane", - APIVersion: controlplanev1.GroupVersion.String(), - }, ObjectMeta: metav1.ObjectMeta{ Name: "foo", Namespace: metav1.NamespaceDefault, @@ -102,10 +94,6 @@ func TestReconcileKubeconfigMissingCACertificate(t *testing.T) { g := NewWithT(t) cluster := &clusterv1.Cluster{ - TypeMeta: metav1.TypeMeta{ - Kind: "Cluster", - APIVersion: clusterv1.GroupVersion.String(), - }, ObjectMeta: metav1.ObjectMeta{ Name: "foo", Namespace: metav1.NamespaceDefault, @@ -116,10 +104,6 @@ func TestReconcileKubeconfigMissingCACertificate(t *testing.T) { } kcp := &controlplanev1.KubeadmControlPlane{ - TypeMeta: metav1.TypeMeta{ - Kind: "KubeadmControlPlane", - APIVersion: controlplanev1.GroupVersion.String(), - }, ObjectMeta: metav1.ObjectMeta{ Name: "foo", Namespace: metav1.NamespaceDefault, @@ -157,10 +141,6 @@ func TestReconcileKubeconfigSecretDoesNotAdoptsUserSecrets(t *testing.T) { g := NewWithT(t) cluster := &clusterv1.Cluster{ - TypeMeta: metav1.TypeMeta{ - Kind: "Cluster", - APIVersion: clusterv1.GroupVersion.String(), - }, ObjectMeta: metav1.ObjectMeta{ Name: "foo", Namespace: metav1.NamespaceDefault, @@ -171,10 +151,6 @@ func TestReconcileKubeconfigSecretDoesNotAdoptsUserSecrets(t *testing.T) { } kcp := &controlplanev1.KubeadmControlPlane{ - TypeMeta: metav1.TypeMeta{ - Kind: "KubeadmControlPlane", - APIVersion: controlplanev1.GroupVersion.String(), - }, ObjectMeta: metav1.ObjectMeta{ Name: "foo", Namespace: metav1.NamespaceDefault, @@ -232,10 +208,6 @@ func TestKubeadmControlPlaneReconciler_reconcileKubeconfig(t *testing.T) { g := NewWithT(t) cluster := &clusterv1.Cluster{ - TypeMeta: metav1.TypeMeta{ - Kind: "Cluster", - APIVersion: clusterv1.GroupVersion.String(), - }, ObjectMeta: metav1.ObjectMeta{ Name: "foo", Namespace: metav1.NamespaceDefault, @@ -246,10 +218,6 @@ func TestKubeadmControlPlaneReconciler_reconcileKubeconfig(t *testing.T) { } kcp := &controlplanev1.KubeadmControlPlane{ - TypeMeta: metav1.TypeMeta{ - Kind: "KubeadmControlPlane", - APIVersion: controlplanev1.GroupVersion.String(), - }, ObjectMeta: metav1.ObjectMeta{ Name: "foo", Namespace: metav1.NamespaceDefault, @@ -1075,10 +1043,6 @@ func TestKubeadmControlPlaneReconciler_adoptKubeconfigSecret(t *testing.T) { userProvidedKubeadmConfigSecretOtherOwner.OwnerReferences = []metav1.OwnerReference{otherOwner} kcp := &controlplanev1.KubeadmControlPlane{ - TypeMeta: metav1.TypeMeta{ - Kind: "KubeadmControlPlane", - APIVersion: controlplanev1.GroupVersion.String(), - }, ObjectMeta: metav1.ObjectMeta{ Name: "testControlPlane", Namespace: metav1.NamespaceDefault, diff --git a/controlplane/kubeadm/internal/controllers/status_test.go b/controlplane/kubeadm/internal/controllers/status_test.go index 662bd973c5f3..5ef75462d643 100644 --- a/controlplane/kubeadm/internal/controllers/status_test.go +++ b/controlplane/kubeadm/internal/controllers/status_test.go @@ -1966,10 +1966,6 @@ func TestKubeadmControlPlaneReconciler_updateStatusNoMachines(t *testing.T) { } kcp := &controlplanev1.KubeadmControlPlane{ - TypeMeta: metav1.TypeMeta{ - Kind: "KubeadmControlPlane", - APIVersion: controlplanev1.GroupVersion.String(), - }, ObjectMeta: metav1.ObjectMeta{ Namespace: cluster.Namespace, Name: "foo", @@ -2120,10 +2116,6 @@ func TestKubeadmControlPlaneReconciler_updateStatusAllMachinesNotReady(t *testin } kcp := &controlplanev1.KubeadmControlPlane{ - TypeMeta: metav1.TypeMeta{ - Kind: "KubeadmControlPlane", - APIVersion: controlplanev1.GroupVersion.String(), - }, ObjectMeta: metav1.ObjectMeta{ Namespace: cluster.Namespace, Name: "foo", @@ -2192,10 +2184,6 @@ func TestKubeadmControlPlaneReconciler_updateStatusAllMachinesReady(t *testing.T } kcp := &controlplanev1.KubeadmControlPlane{ - TypeMeta: metav1.TypeMeta{ - Kind: "KubeadmControlPlane", - APIVersion: controlplanev1.GroupVersion.String(), - }, ObjectMeta: metav1.ObjectMeta{ Namespace: cluster.Namespace, Name: "foo", @@ -2271,10 +2259,6 @@ func TestKubeadmControlPlaneReconciler_updateStatusMachinesReadyMixed(t *testing } kcp := &controlplanev1.KubeadmControlPlane{ - TypeMeta: metav1.TypeMeta{ - Kind: "KubeadmControlPlane", - APIVersion: controlplanev1.GroupVersion.String(), - }, ObjectMeta: metav1.ObjectMeta{ Namespace: cluster.Namespace, Name: "foo", @@ -2349,10 +2333,6 @@ func TestKubeadmControlPlaneReconciler_machinesCreatedIsIsTrueEvenWhenTheNodesAr } kcp := &controlplanev1.KubeadmControlPlane{ - TypeMeta: metav1.TypeMeta{ - Kind: "KubeadmControlPlane", - APIVersion: controlplanev1.GroupVersion.String(), - }, ObjectMeta: metav1.ObjectMeta{ Namespace: cluster.Namespace, Name: "foo", diff --git a/controlplane/kubeadm/internal/filters_test.go b/controlplane/kubeadm/internal/filters_test.go index 584d731b6b9a..30571dc124fc 100644 --- a/controlplane/kubeadm/internal/filters_test.go +++ b/controlplane/kubeadm/internal/filters_test.go @@ -502,10 +502,6 @@ func TestMatchInitOrJoinConfiguration(t *testing.T) { }, } m := &clusterv1.Machine{ - TypeMeta: metav1.TypeMeta{ - Kind: "Machine", - APIVersion: clusterv1.GroupVersion.String(), - }, ObjectMeta: metav1.ObjectMeta{ Namespace: "default", Name: "test", @@ -522,10 +518,6 @@ func TestMatchInitOrJoinConfiguration(t *testing.T) { } machineConfigs := map[string]*bootstrapv1.KubeadmConfig{ m.Name: { - TypeMeta: metav1.TypeMeta{ - Kind: "KubeadmConfig", - APIVersion: bootstrapv1.GroupVersion.String(), - }, ObjectMeta: metav1.ObjectMeta{ Namespace: "default", Name: "test", @@ -552,10 +544,6 @@ func TestMatchInitOrJoinConfiguration(t *testing.T) { }, } m := &clusterv1.Machine{ - TypeMeta: metav1.TypeMeta{ - Kind: "Machine", - APIVersion: clusterv1.GroupVersion.String(), - }, ObjectMeta: metav1.ObjectMeta{ Namespace: "default", Name: "test", @@ -572,10 +560,6 @@ func TestMatchInitOrJoinConfiguration(t *testing.T) { } machineConfigs := map[string]*bootstrapv1.KubeadmConfig{ m.Name: { - TypeMeta: metav1.TypeMeta{ - Kind: "KubeadmConfig", - APIVersion: bootstrapv1.GroupVersion.String(), - }, ObjectMeta: metav1.ObjectMeta{ Namespace: "default", Name: "test", @@ -602,10 +586,6 @@ func TestMatchInitOrJoinConfiguration(t *testing.T) { }, } m := &clusterv1.Machine{ - TypeMeta: metav1.TypeMeta{ - Kind: "Machine", - APIVersion: clusterv1.GroupVersion.String(), - }, ObjectMeta: metav1.ObjectMeta{ Namespace: "default", Name: "test", @@ -622,10 +602,6 @@ func TestMatchInitOrJoinConfiguration(t *testing.T) { } machineConfigs := map[string]*bootstrapv1.KubeadmConfig{ m.Name: { - TypeMeta: metav1.TypeMeta{ - Kind: "KubeadmConfig", - APIVersion: bootstrapv1.GroupVersion.String(), - }, ObjectMeta: metav1.ObjectMeta{ Namespace: "default", Name: "test", @@ -656,10 +632,6 @@ func TestMatchInitOrJoinConfiguration(t *testing.T) { }, } m := &clusterv1.Machine{ - TypeMeta: metav1.TypeMeta{ - Kind: "Machine", - APIVersion: clusterv1.GroupVersion.String(), - }, ObjectMeta: metav1.ObjectMeta{ Namespace: "default", Name: "test", @@ -676,10 +648,6 @@ func TestMatchInitOrJoinConfiguration(t *testing.T) { } machineConfigs := map[string]*bootstrapv1.KubeadmConfig{ m.Name: { - TypeMeta: metav1.TypeMeta{ - Kind: "KubeadmConfig", - APIVersion: bootstrapv1.GroupVersion.String(), - }, ObjectMeta: metav1.ObjectMeta{ Namespace: "default", Name: "test", @@ -724,10 +692,6 @@ func TestMatchInitOrJoinConfiguration(t *testing.T) { }, } m := &clusterv1.Machine{ - TypeMeta: metav1.TypeMeta{ - Kind: "Machine", - APIVersion: clusterv1.GroupVersion.String(), - }, ObjectMeta: metav1.ObjectMeta{ Namespace: "default", Name: "test", @@ -744,10 +708,6 @@ func TestMatchInitOrJoinConfiguration(t *testing.T) { } machineConfigs := map[string]*bootstrapv1.KubeadmConfig{ m.Name: { - TypeMeta: metav1.TypeMeta{ - Kind: "KubeadmConfig", - APIVersion: bootstrapv1.GroupVersion.String(), - }, ObjectMeta: metav1.ObjectMeta{ Namespace: "default", Name: "test", @@ -778,10 +738,6 @@ func TestMatchInitOrJoinConfiguration(t *testing.T) { }, } m := &clusterv1.Machine{ - TypeMeta: metav1.TypeMeta{ - Kind: "Machine", - APIVersion: clusterv1.GroupVersion.String(), - }, ObjectMeta: metav1.ObjectMeta{ Namespace: "default", Name: "test", @@ -798,10 +754,6 @@ func TestMatchInitOrJoinConfiguration(t *testing.T) { } machineConfigs := map[string]*bootstrapv1.KubeadmConfig{ m.Name: { - TypeMeta: metav1.TypeMeta{ - Kind: "KubeadmConfig", - APIVersion: bootstrapv1.GroupVersion.String(), - }, ObjectMeta: metav1.ObjectMeta{ Namespace: "default", Name: "test", @@ -847,10 +799,6 @@ func TestMatchInitOrJoinConfiguration(t *testing.T) { }, } m := &clusterv1.Machine{ - TypeMeta: metav1.TypeMeta{ - Kind: "Machine", - APIVersion: clusterv1.GroupVersion.String(), - }, ObjectMeta: metav1.ObjectMeta{ Namespace: "default", Name: "test", @@ -867,10 +815,6 @@ func TestMatchInitOrJoinConfiguration(t *testing.T) { } machineConfigs := map[string]*bootstrapv1.KubeadmConfig{ m.Name: { - TypeMeta: metav1.TypeMeta{ - Kind: "KubeadmConfig", - APIVersion: bootstrapv1.GroupVersion.String(), - }, ObjectMeta: metav1.ObjectMeta{ Namespace: "default", Name: "test", @@ -898,10 +842,6 @@ func TestMatchInitOrJoinConfiguration(t *testing.T) { }, } m := &clusterv1.Machine{ - TypeMeta: metav1.TypeMeta{ - Kind: "Machine", - APIVersion: clusterv1.GroupVersion.String(), - }, ObjectMeta: metav1.ObjectMeta{ Namespace: "default", Name: "test", @@ -918,10 +858,6 @@ func TestMatchInitOrJoinConfiguration(t *testing.T) { } machineConfigs := map[string]*bootstrapv1.KubeadmConfig{ m.Name: { - TypeMeta: metav1.TypeMeta{ - Kind: "KubeadmConfig", - APIVersion: bootstrapv1.GroupVersion.String(), - }, ObjectMeta: metav1.ObjectMeta{ Namespace: "default", Name: "test", @@ -1020,10 +956,6 @@ func TestMatchesKubeadmBootstrapConfig(t *testing.T) { }, } m := &clusterv1.Machine{ - TypeMeta: metav1.TypeMeta{ - Kind: "Machine", - APIVersion: clusterv1.GroupVersion.String(), - }, ObjectMeta: metav1.ObjectMeta{ Namespace: "default", Name: "test", @@ -1040,10 +972,6 @@ func TestMatchesKubeadmBootstrapConfig(t *testing.T) { } machineConfigs := map[string]*bootstrapv1.KubeadmConfig{ m.Name: { - TypeMeta: metav1.TypeMeta{ - Kind: "KubeadmConfig", - APIVersion: bootstrapv1.GroupVersion.String(), - }, ObjectMeta: metav1.ObjectMeta{ Namespace: "default", Name: "test", @@ -1074,10 +1002,6 @@ func TestMatchesKubeadmBootstrapConfig(t *testing.T) { }, } m := &clusterv1.Machine{ - TypeMeta: metav1.TypeMeta{ - Kind: "Machine", - APIVersion: clusterv1.GroupVersion.String(), - }, ObjectMeta: metav1.ObjectMeta{ Namespace: "default", Name: "test", @@ -1094,10 +1018,6 @@ func TestMatchesKubeadmBootstrapConfig(t *testing.T) { } machineConfigs := map[string]*bootstrapv1.KubeadmConfig{ m.Name: { - TypeMeta: metav1.TypeMeta{ - Kind: "KubeadmConfig", - APIVersion: bootstrapv1.GroupVersion.String(), - }, ObjectMeta: metav1.ObjectMeta{ Namespace: "default", Name: "test", @@ -1142,10 +1062,6 @@ func TestMatchesKubeadmBootstrapConfig(t *testing.T) { }, } m := &clusterv1.Machine{ - TypeMeta: metav1.TypeMeta{ - Kind: "Machine", - APIVersion: clusterv1.GroupVersion.String(), - }, ObjectMeta: metav1.ObjectMeta{ Namespace: "default", Name: "test", @@ -1162,10 +1078,6 @@ func TestMatchesKubeadmBootstrapConfig(t *testing.T) { } machineConfigs := map[string]*bootstrapv1.KubeadmConfig{ m.Name: { - TypeMeta: metav1.TypeMeta{ - Kind: "KubeadmConfig", - APIVersion: bootstrapv1.GroupVersion.String(), - }, ObjectMeta: metav1.ObjectMeta{ Namespace: "default", Name: "test", @@ -1196,10 +1108,6 @@ func TestMatchesKubeadmBootstrapConfig(t *testing.T) { }, } m := &clusterv1.Machine{ - TypeMeta: metav1.TypeMeta{ - Kind: "Machine", - APIVersion: clusterv1.GroupVersion.String(), - }, ObjectMeta: metav1.ObjectMeta{ Namespace: "default", Name: "test", @@ -1216,10 +1124,6 @@ func TestMatchesKubeadmBootstrapConfig(t *testing.T) { } machineConfigs := map[string]*bootstrapv1.KubeadmConfig{ m.Name: { - TypeMeta: metav1.TypeMeta{ - Kind: "KubeadmConfig", - APIVersion: bootstrapv1.GroupVersion.String(), - }, ObjectMeta: metav1.ObjectMeta{ Namespace: "default", Name: "test", @@ -1265,10 +1169,6 @@ func TestMatchesKubeadmBootstrapConfig(t *testing.T) { }, } m := &clusterv1.Machine{ - TypeMeta: metav1.TypeMeta{ - Kind: "Machine", - APIVersion: clusterv1.GroupVersion.String(), - }, ObjectMeta: metav1.ObjectMeta{ Namespace: "default", Name: "test", @@ -1285,10 +1185,6 @@ func TestMatchesKubeadmBootstrapConfig(t *testing.T) { } machineConfigs := map[string]*bootstrapv1.KubeadmConfig{ m.Name: { - TypeMeta: metav1.TypeMeta{ - Kind: "KubeadmConfig", - APIVersion: bootstrapv1.GroupVersion.String(), - }, ObjectMeta: metav1.ObjectMeta{ Namespace: "default", Name: "test", @@ -1316,10 +1212,6 @@ func TestMatchesKubeadmBootstrapConfig(t *testing.T) { }, } m := &clusterv1.Machine{ - TypeMeta: metav1.TypeMeta{ - Kind: "Machine", - APIVersion: clusterv1.GroupVersion.String(), - }, ObjectMeta: metav1.ObjectMeta{ Namespace: "default", Name: "test", @@ -1336,10 +1228,6 @@ func TestMatchesKubeadmBootstrapConfig(t *testing.T) { } machineConfigs := map[string]*bootstrapv1.KubeadmConfig{ m.Name: { - TypeMeta: metav1.TypeMeta{ - Kind: "KubeadmConfig", - APIVersion: bootstrapv1.GroupVersion.String(), - }, ObjectMeta: metav1.ObjectMeta{ Namespace: "default", Name: "test", @@ -1384,10 +1272,6 @@ func TestMatchesKubeadmBootstrapConfig(t *testing.T) { }, } m := &clusterv1.Machine{ - TypeMeta: metav1.TypeMeta{ - Kind: "Machine", - APIVersion: clusterv1.GroupVersion.String(), - }, ObjectMeta: metav1.ObjectMeta{ Namespace: "default", Name: "test", @@ -1404,10 +1288,6 @@ func TestMatchesKubeadmBootstrapConfig(t *testing.T) { } machineConfigs := map[string]*bootstrapv1.KubeadmConfig{ m.Name: { - TypeMeta: metav1.TypeMeta{ - Kind: "KubeadmConfig", - APIVersion: bootstrapv1.GroupVersion.String(), - }, ObjectMeta: metav1.ObjectMeta{ Namespace: "default", Name: "test", diff --git a/controlplane/kubeadm/internal/workload_cluster_coredns_test.go b/controlplane/kubeadm/internal/workload_cluster_coredns_test.go index a459b025b42e..614f80ee2b7b 100644 --- a/controlplane/kubeadm/internal/workload_cluster_coredns_test.go +++ b/controlplane/kubeadm/internal/workload_cluster_coredns_test.go @@ -65,10 +65,6 @@ func TestUpdateCoreDNS(t *testing.T) { } depl := &appsv1.Deployment{ - TypeMeta: metav1.TypeMeta{ - Kind: "Deployment", - APIVersion: "apps/v1", - }, ObjectMeta: metav1.ObjectMeta{ Name: coreDNSKey, Namespace: metav1.NamespaceSystem, @@ -1185,10 +1181,6 @@ func (m *fakeMigrator) Migrate(_, _, _ string, _ bool) (string, error) { func newCoreDNSInfoDeploymentWithimage(image string) *appsv1.Deployment { return &appsv1.Deployment{ - TypeMeta: metav1.TypeMeta{ - Kind: "Deployment", - APIVersion: "apps/v1", - }, ObjectMeta: metav1.ObjectMeta{ Name: coreDNSKey, Namespace: metav1.NamespaceSystem, diff --git a/exp/internal/controllers/machinepool_controller_noderef_test.go b/exp/internal/controllers/machinepool_controller_noderef_test.go index 7065b80865ad..2eaa8a521e2b 100644 --- a/exp/internal/controllers/machinepool_controller_noderef_test.go +++ b/exp/internal/controllers/machinepool_controller_noderef_test.go @@ -391,9 +391,6 @@ func TestMachinePoolPatchNodes(t *testing.T) { { name: "Node with uninitialized taint should be patched", machinePool: &clusterv1.MachinePool{ - TypeMeta: metav1.TypeMeta{ - Kind: "MachinePool", - }, ObjectMeta: metav1.ObjectMeta{ Name: "machinepool-1", Namespace: "my-namespace", @@ -426,9 +423,6 @@ func TestMachinePoolPatchNodes(t *testing.T) { { name: "Node with existing annotations and taints should be patched", machinePool: &clusterv1.MachinePool{ - TypeMeta: metav1.TypeMeta{ - Kind: "MachinePool", - }, ObjectMeta: metav1.ObjectMeta{ Name: "machinepool-2", Namespace: "my-namespace", diff --git a/exp/internal/controllers/machinepool_controller_test.go b/exp/internal/controllers/machinepool_controller_test.go index 8a551b15ba48..5ec5986f264a 100644 --- a/exp/internal/controllers/machinepool_controller_test.go +++ b/exp/internal/controllers/machinepool_controller_test.go @@ -149,7 +149,6 @@ func TestMachinePoolFinalizer(t *testing.T) { func TestMachinePoolOwnerReference(t *testing.T) { bootstrapData := "some valid machinepool bootstrap data" testCluster := &clusterv1.Cluster{ - TypeMeta: metav1.TypeMeta{Kind: "Cluster", APIVersion: clusterv1.GroupVersion.String()}, ObjectMeta: metav1.ObjectMeta{Namespace: metav1.NamespaceDefault, Name: "test-cluster"}, } @@ -311,7 +310,6 @@ func TestReconcileMachinePoolRequest(t *testing.T) { } testCluster := clusterv1.Cluster{ - TypeMeta: metav1.TypeMeta{Kind: "Cluster", APIVersion: clusterv1.GroupVersion.String()}, ObjectMeta: metav1.ObjectMeta{Namespace: metav1.NamespaceDefault, Name: "test-cluster"}, } diff --git a/exp/ipam/internal/webhooks/ipaddress_test.go b/exp/ipam/internal/webhooks/ipaddress_test.go index 8ca5746068d2..06228e9d2f5a 100644 --- a/exp/ipam/internal/webhooks/ipaddress_test.go +++ b/exp/ipam/internal/webhooks/ipaddress_test.go @@ -31,10 +31,6 @@ import ( func TestIPAddressValidateCreate(t *testing.T) { claim := &ipamv1.IPAddressClaim{ - TypeMeta: metav1.TypeMeta{ - APIVersion: ipamv1.GroupVersion.String(), - Kind: "IPAddressClaim", - }, ObjectMeta: metav1.ObjectMeta{ Name: "claim", Namespace: "default", diff --git a/exp/runtime/internal/controllers/extensionconfig_controller_test.go b/exp/runtime/internal/controllers/extensionconfig_controller_test.go index 49bfba2b8a3d..ca71e0658e7a 100644 --- a/exp/runtime/internal/controllers/extensionconfig_controller_test.go +++ b/exp/runtime/internal/controllers/extensionconfig_controller_test.go @@ -386,10 +386,6 @@ func discoveryHandler(handlerList ...string) func(http.ResponseWriter, *http.Req }) } response := &runtimehooksv1.DiscoveryResponse{ - TypeMeta: metav1.TypeMeta{ - Kind: "DiscoveryResponse", - APIVersion: runtimehooksv1.GroupVersion.String(), - }, Handlers: handlers, } respBody, err := json.Marshal(response) @@ -405,10 +401,6 @@ func discoveryHandler(handlerList ...string) func(http.ResponseWriter, *http.Req func fakeExtensionConfigForURL(namespace, name, url string) *runtimev1.ExtensionConfig { return &runtimev1.ExtensionConfig{ - TypeMeta: metav1.TypeMeta{ - Kind: "ExtensionConfig", - APIVersion: runtimehooksv1.GroupVersion.String(), - }, ObjectMeta: metav1.ObjectMeta{ Name: name, Namespace: namespace, diff --git a/exp/runtime/topologymutation/walker_test.go b/exp/runtime/topologymutation/walker_test.go index fad450a60ef7..007fdc6d6765 100644 --- a/exp/runtime/topologymutation/walker_test.go +++ b/exp/runtime/topologymutation/walker_test.go @@ -25,7 +25,6 @@ import ( . "github.com/onsi/gomega" apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/serializer" "k8s.io/apimachinery/pkg/types" @@ -60,18 +59,8 @@ func Test_WalkTemplates(t *testing.T) { } return nil } - kubeadmControlPlaneTemplate := controlplanev1.KubeadmControlPlaneTemplate{ - TypeMeta: metav1.TypeMeta{ - Kind: "KubeadmControlPlaneTemplate", - APIVersion: controlplanev1.GroupVersion.String(), - }, - } - kubeadmConfigTemplate := bootstrapv1.KubeadmConfigTemplate{ - TypeMeta: metav1.TypeMeta{ - Kind: "KubeadmConfigTemplate", - APIVersion: bootstrapv1.GroupVersion.String(), - }, - } + kubeadmControlPlaneTemplate := controlplanev1.KubeadmControlPlaneTemplate{} + kubeadmConfigTemplate := bootstrapv1.KubeadmConfigTemplate{} tests := []struct { name string globalVariables []runtimehooksv1.Variable diff --git a/exp/topology/desiredstate/desired_state.go b/exp/topology/desiredstate/desired_state.go index 41b28b203be9..a5553e4a602c 100644 --- a/exp/topology/desiredstate/desired_state.go +++ b/exp/topology/desiredstate/desired_state.go @@ -870,10 +870,6 @@ func (g *generator) computeMachineDeployment(ctx context.Context, s *scope.Scope } desiredMachineDeploymentObj := &clusterv1.MachineDeployment{ - TypeMeta: metav1.TypeMeta{ - APIVersion: clusterv1.GroupVersion.String(), - Kind: "MachineDeployment", - }, ObjectMeta: metav1.ObjectMeta{ Name: name, Namespace: s.Current.Cluster.Namespace, @@ -1194,10 +1190,6 @@ func (g *generator) computeMachinePool(_ context.Context, s *scope.Scope, machin } desiredMachinePoolObj := &clusterv1.MachinePool{ - TypeMeta: metav1.TypeMeta{ - APIVersion: clusterv1.GroupVersion.String(), - Kind: "MachinePool", - }, ObjectMeta: metav1.ObjectMeta{ Name: name, Namespace: s.Current.Cluster.Namespace, @@ -1478,10 +1470,6 @@ func templateToTemplate(in templateToInput) (*unstructured.Unstructured, error) func computeMachineHealthCheck(ctx context.Context, healthCheckTarget client.Object, selector *metav1.LabelSelector, cluster *clusterv1.Cluster, mhcChecks clusterv1.MachineHealthCheckChecks, mhcRemediation clusterv1.MachineHealthCheckRemediation) *clusterv1.MachineHealthCheck { // Create a MachineHealthCheck with the spec given in the ClusterClass. mhc := &clusterv1.MachineHealthCheck{ - TypeMeta: metav1.TypeMeta{ - APIVersion: clusterv1.GroupVersion.String(), - Kind: "MachineHealthCheck", - }, ObjectMeta: metav1.ObjectMeta{ Name: healthCheckTarget.GetName(), Namespace: healthCheckTarget.GetNamespace(), diff --git a/exp/topology/desiredstate/desired_state_test.go b/exp/topology/desiredstate/desired_state_test.go index 59514a89c5dc..a043cb41a3b7 100644 --- a/exp/topology/desiredstate/desired_state_test.go +++ b/exp/topology/desiredstate/desired_state_test.go @@ -3427,10 +3427,6 @@ func Test_computeMachineHealthCheck(t *testing.T) { healthCheckTarget := builder.MachineDeployment("ns1", "md1").Build() cluster := builder.Cluster("ns1", "cluster1").Build() want := &clusterv1.MachineHealthCheck{ - TypeMeta: metav1.TypeMeta{ - APIVersion: clusterv1.GroupVersion.String(), - Kind: "MachineHealthCheck", - }, ObjectMeta: metav1.ObjectMeta{ Name: "md1", Namespace: "ns1", diff --git a/exp/topology/scope/hookresponsetracker_test.go b/exp/topology/scope/hookresponsetracker_test.go index 797f0b46c36c..e022e2e19863 100644 --- a/exp/topology/scope/hookresponsetracker_test.go +++ b/exp/topology/scope/hookresponsetracker_test.go @@ -21,7 +21,6 @@ import ( "time" . "github.com/onsi/gomega" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtimehooksv1 "sigs.k8s.io/cluster-api/api/runtime/hooks/v1alpha1" runtimecatalog "sigs.k8s.io/cluster-api/exp/runtime/catalog" @@ -166,7 +165,6 @@ func TestHookResponseTracker_IsBlocking(t *testing.T) { } afterClusterUpgradeResponse := &runtimehooksv1.AfterClusterUpgradeResponse{ - TypeMeta: metav1.TypeMeta{}, CommonResponse: runtimehooksv1.CommonResponse{}, } diff --git a/hack/tools/internal/tilt-prepare/main.go b/hack/tools/internal/tilt-prepare/main.go index a747a680f3a7..dc5bca5deaae 100644 --- a/hack/tools/internal/tilt-prepare/main.go +++ b/hack/tools/internal/tilt-prepare/main.go @@ -947,10 +947,6 @@ func getProviderObj(version *string) func(prefix string, objs []unstructured.Uns } provider := &clusterctlv1.Provider{ - TypeMeta: metav1.TypeMeta{ - Kind: "Provider", - APIVersion: clusterctlv1.GroupVersion.String(), - }, ObjectMeta: metav1.ObjectMeta{ Name: manifestLabel, Namespace: namespace, diff --git a/internal/controllers/cluster/cluster_controller_status_test.go b/internal/controllers/cluster/cluster_controller_status_test.go index 01593ce057de..e856afc726f3 100644 --- a/internal/controllers/cluster/cluster_controller_status_test.go +++ b/internal/controllers/cluster/cluster_controller_status_test.go @@ -2904,11 +2904,6 @@ type fakeClusterOption interface { func fakeCluster(name string, options ...fakeClusterOption) *clusterv1.Cluster { c := &clusterv1.Cluster{ - TypeMeta: metav1.TypeMeta{ - // Note: this is required by ownerRef checks - APIVersion: clusterv1.GroupVersion.String(), - Kind: "Cluster", - }, ObjectMeta: metav1.ObjectMeta{ Name: name, }, diff --git a/internal/controllers/cluster/cluster_controller_test.go b/internal/controllers/cluster/cluster_controller_test.go index 90da16cb5c3b..685378b59ec1 100644 --- a/internal/controllers/cluster/cluster_controller_test.go +++ b/internal/controllers/cluster/cluster_controller_test.go @@ -557,9 +557,6 @@ func TestClusterReconciler_reconcileDelete(t *testing.T) { func TestClusterReconcilerNodeRef(t *testing.T) { t.Run("machine to cluster", func(t *testing.T) { cluster := &clusterv1.Cluster{ - TypeMeta: metav1.TypeMeta{ - Kind: "Cluster", - }, ObjectMeta: metav1.ObjectMeta{ Name: "test-cluster", Namespace: "test", @@ -569,9 +566,6 @@ func TestClusterReconcilerNodeRef(t *testing.T) { } controlPlaneWithNoderef := &clusterv1.Machine{ - TypeMeta: metav1.TypeMeta{ - Kind: "Machine", - }, ObjectMeta: metav1.ObjectMeta{ Name: "controlPlaneWithNoderef", Namespace: "test", @@ -588,9 +582,6 @@ func TestClusterReconcilerNodeRef(t *testing.T) { }, } controlPlaneWithoutNoderef := &clusterv1.Machine{ - TypeMeta: metav1.TypeMeta{ - Kind: "Machine", - }, ObjectMeta: metav1.ObjectMeta{ Name: "controlPlaneWithoutNoderef", Namespace: "test", @@ -604,9 +595,6 @@ func TestClusterReconcilerNodeRef(t *testing.T) { }, } nonControlPlaneWithNoderef := &clusterv1.Machine{ - TypeMeta: metav1.TypeMeta{ - Kind: "Machine", - }, ObjectMeta: metav1.ObjectMeta{ Name: "nonControlPlaneWitNoderef", Namespace: "test", @@ -622,9 +610,6 @@ func TestClusterReconcilerNodeRef(t *testing.T) { }, } nonControlPlaneWithoutNoderef := &clusterv1.Machine{ - TypeMeta: metav1.TypeMeta{ - Kind: "Machine", - }, ObjectMeta: metav1.ObjectMeta{ Name: "nonControlPlaneWithoutNoderef", Namespace: "test", @@ -795,10 +780,6 @@ func TestFilterOwnedDescendants(t *testing.T) { utilfeature.SetFeatureGateDuringTest(t, feature.Gates, feature.MachinePool, true) c := clusterv1.Cluster{ - TypeMeta: metav1.TypeMeta{ - APIVersion: clusterv1.GroupVersion.String(), - Kind: "Cluster", - }, ObjectMeta: metav1.ObjectMeta{ Name: "c", }, diff --git a/internal/controllers/clusterclass/clusterclass_controller_test.go b/internal/controllers/clusterclass/clusterclass_controller_test.go index d3cf1956e3df..355cd8dbf3d8 100644 --- a/internal/controllers/clusterclass/clusterclass_controller_test.go +++ b/internal/controllers/clusterclass/clusterclass_controller_test.go @@ -1200,10 +1200,6 @@ func TestReconciler_extensionConfigToClusterClass(t *testing.T) { ObjectMeta: metav1.ObjectMeta{ Name: "runtime1", }, - TypeMeta: metav1.TypeMeta{ - Kind: "ExtensionConfig", - APIVersion: runtimev1.GroupVersion.String(), - }, Spec: runtimev1.ExtensionConfigSpec{ NamespaceSelector: &metav1.LabelSelector{}, }, @@ -1212,10 +1208,6 @@ func TestReconciler_extensionConfigToClusterClass(t *testing.T) { ObjectMeta: metav1.ObjectMeta{ Name: "runtime2", }, - TypeMeta: metav1.TypeMeta{ - Kind: "ExtensionConfig", - APIVersion: runtimev1.GroupVersion.String(), - }, Spec: runtimev1.ExtensionConfigSpec{ NamespaceSelector: &metav1.LabelSelector{}, }, diff --git a/internal/controllers/clusterresourceset/clusterresourceset_controller_test.go b/internal/controllers/clusterresourceset/clusterresourceset_controller_test.go index da5417746e5e..671105c20ad9 100644 --- a/internal/controllers/clusterresourceset/clusterresourceset_controller_test.go +++ b/internal/controllers/clusterresourceset/clusterresourceset_controller_test.go @@ -944,7 +944,6 @@ metadata: defer teardown(t, g, ns) fakeService := &corev1.Service{ - TypeMeta: metav1.TypeMeta{Kind: "Service", APIVersion: "v1"}, ObjectMeta: metav1.ObjectMeta{ Name: "fake", Namespace: metav1.NamespaceDefault, @@ -1137,10 +1136,6 @@ func configMapHasBeenUpdated(env *envtest.Environment, key client.ObjectKey, new func configMap(name, namespace string, data map[string]string) *corev1.ConfigMap { return &corev1.ConfigMap{ - TypeMeta: metav1.TypeMeta{ - APIVersion: "v1", - Kind: "ConfigMap", - }, ObjectMeta: metav1.ObjectMeta{ Name: name, Namespace: namespace, diff --git a/internal/controllers/clusterresourceset/clusterresourceset_helpers_test.go b/internal/controllers/clusterresourceset/clusterresourceset_helpers_test.go index 63d51c1a4c8a..f999f59c39ce 100644 --- a/internal/controllers/clusterresourceset/clusterresourceset_helpers_test.go +++ b/internal/controllers/clusterresourceset/clusterresourceset_helpers_test.go @@ -116,7 +116,6 @@ func TestGetorCreateClusterResourceSetBinding(t *testing.T) { func TestGetSecretFromNamespacedName(t *testing.T) { existingSecretName := types.NamespacedName{Name: "my-secret", Namespace: metav1.NamespaceDefault} existingSecret := &corev1.Secret{ - TypeMeta: metav1.TypeMeta{Kind: "Secret", APIVersion: "v1"}, ObjectMeta: metav1.ObjectMeta{ Name: existingSecretName.Name, Namespace: existingSecretName.Namespace, @@ -172,7 +171,6 @@ func TestGetConfigMapFromNamespacedName(t *testing.T) { existingConfigMapName := types.NamespacedName{Name: "my-configmap", Namespace: metav1.NamespaceDefault} existingConfigMap := &corev1.ConfigMap{ - TypeMeta: metav1.TypeMeta{Kind: "ConfigMap", APIVersion: "v1"}, ObjectMeta: metav1.ObjectMeta{ Name: existingConfigMapName.Name, Namespace: existingConfigMapName.Namespace, @@ -228,7 +226,6 @@ func TestEnsureKubernetesServiceCreated(t *testing.T) { g.Expect(corev1.AddToScheme(scheme)).To(Succeed()) kubernetesAPIServerService := &corev1.Service{ - TypeMeta: metav1.TypeMeta{Kind: "Service", APIVersion: "v1"}, ObjectMeta: metav1.ObjectMeta{ Name: "kubernetes", Namespace: metav1.NamespaceDefault, diff --git a/internal/controllers/machine/machine_controller_test.go b/internal/controllers/machine/machine_controller_test.go index b30f60c91a24..0595866a4664 100644 --- a/internal/controllers/machine/machine_controller_test.go +++ b/internal/controllers/machine/machine_controller_test.go @@ -640,7 +640,6 @@ func TestMachineFinalizer(t *testing.T) { func TestMachineOwnerReference(t *testing.T) { bootstrapData := "some valid data" testCluster := &clusterv1.Cluster{ - TypeMeta: metav1.TypeMeta{Kind: "Cluster", APIVersion: clusterv1.GroupVersion.String()}, ObjectMeta: metav1.ObjectMeta{Namespace: metav1.NamespaceDefault, Name: "test-cluster"}, } @@ -1407,7 +1406,6 @@ func TestRemoveMachineFinalizerAfterDeleteReconcile(t *testing.T) { func TestIsNodeDrainedAllowed(t *testing.T) { testCluster := &clusterv1.Cluster{ - TypeMeta: metav1.TypeMeta{Kind: "Cluster", APIVersion: clusterv1.GroupVersion.String()}, ObjectMeta: metav1.ObjectMeta{Namespace: metav1.NamespaceDefault, Name: "test-cluster"}, } @@ -1972,7 +1970,6 @@ func TestDrainNode_withCaching(t *testing.T) { func TestIsNodeVolumeDetachingAllowed(t *testing.T) { testCluster := &clusterv1.Cluster{ - TypeMeta: metav1.TypeMeta{Kind: "Cluster", APIVersion: clusterv1.GroupVersion.String()}, ObjectMeta: metav1.ObjectMeta{Namespace: metav1.NamespaceDefault, Name: "test-cluster"}, } @@ -2144,7 +2141,6 @@ func TestShouldWaitForNodeVolumes(t *testing.T) { g.Expect(err).ToNot(HaveOccurred()) testCluster := &clusterv1.Cluster{ - TypeMeta: metav1.TypeMeta{Kind: "Cluster", APIVersion: clusterv1.GroupVersion.String()}, ObjectMeta: metav1.ObjectMeta{Namespace: metav1.NamespaceDefault, Name: "test-cluster"}, } diff --git a/internal/controllers/machinedeployment/machinedeployment_controller_test.go b/internal/controllers/machinedeployment/machinedeployment_controller_test.go index dd5485720af4..16539efb902a 100644 --- a/internal/controllers/machinedeployment/machinedeployment_controller_test.go +++ b/internal/controllers/machinedeployment/machinedeployment_controller_test.go @@ -631,10 +631,6 @@ func TestMachineDeploymentReconciler_CleanUpManagedFieldsForSSAAdoption(t *testi // Create a MachineSet for the MachineDeployment. classicManagerMS := &clusterv1.MachineSet{ - TypeMeta: metav1.TypeMeta{ - Kind: "MachineSet", - APIVersion: clusterv1.GroupVersion.String(), - }, ObjectMeta: metav1.ObjectMeta{ Name: deployment.Name + "-" + "classic-ms", Namespace: testCluster.Namespace, @@ -711,9 +707,6 @@ func TestMachineSetToDeployments(t *testing.T) { machineDeplopymentList := []client.Object{machineDeployment} ms1 := clusterv1.MachineSet{ - TypeMeta: metav1.TypeMeta{ - Kind: "MachineSet", - }, ObjectMeta: metav1.ObjectMeta{ Name: "withOwnerRef", Namespace: metav1.NamespaceDefault, @@ -726,9 +719,6 @@ func TestMachineSetToDeployments(t *testing.T) { }, } ms2 := clusterv1.MachineSet{ - TypeMeta: metav1.TypeMeta{ - Kind: "MachineSet", - }, ObjectMeta: metav1.ObjectMeta{ Name: "noOwnerRefNoLabels", Namespace: metav1.NamespaceDefault, @@ -738,9 +728,6 @@ func TestMachineSetToDeployments(t *testing.T) { }, } ms3 := clusterv1.MachineSet{ - TypeMeta: metav1.TypeMeta{ - Kind: "MachineSet", - }, ObjectMeta: metav1.ObjectMeta{ Name: "withMatchingLabels", Namespace: metav1.NamespaceDefault, @@ -805,18 +792,12 @@ func TestGetMachineDeploymentsForMachineSet(t *testing.T) { machineDeploymentList := []client.Object{machineDeployment} ms1 := clusterv1.MachineSet{ - TypeMeta: metav1.TypeMeta{ - Kind: "MachineSet", - }, ObjectMeta: metav1.ObjectMeta{ Name: "NoMatchingLabels", Namespace: metav1.NamespaceDefault, }, } ms2 := clusterv1.MachineSet{ - TypeMeta: metav1.TypeMeta{ - Kind: "MachineSet", - }, ObjectMeta: metav1.ObjectMeta{ Name: "withMatchingLabels", Namespace: metav1.NamespaceDefault, @@ -900,9 +881,6 @@ func TestGetMachineSetsForDeployment(t *testing.T) { } ms1 := clusterv1.MachineSet{ - TypeMeta: metav1.TypeMeta{ - Kind: "MachineSet", - }, ObjectMeta: metav1.ObjectMeta{ Name: "withNoOwnerRefShouldBeAdopted2", Namespace: metav1.NamespaceDefault, @@ -912,9 +890,6 @@ func TestGetMachineSetsForDeployment(t *testing.T) { }, } ms2 := clusterv1.MachineSet{ - TypeMeta: metav1.TypeMeta{ - Kind: "MachineSet", - }, ObjectMeta: metav1.ObjectMeta{ Name: "withOwnerRefAndLabels", Namespace: metav1.NamespaceDefault, @@ -927,9 +902,6 @@ func TestGetMachineSetsForDeployment(t *testing.T) { }, } ms3 := clusterv1.MachineSet{ - TypeMeta: metav1.TypeMeta{ - Kind: "MachineSet", - }, ObjectMeta: metav1.ObjectMeta{ Name: "withNoOwnerRefShouldBeAdopted1", Namespace: metav1.NamespaceDefault, @@ -939,9 +911,6 @@ func TestGetMachineSetsForDeployment(t *testing.T) { }, } ms4 := clusterv1.MachineSet{ - TypeMeta: metav1.TypeMeta{ - Kind: "MachineSet", - }, ObjectMeta: metav1.ObjectMeta{ Name: "withNoOwnerRefNoMatch", Namespace: metav1.NamespaceDefault, @@ -951,9 +920,6 @@ func TestGetMachineSetsForDeployment(t *testing.T) { }, } ms5 := clusterv1.MachineSet{ - TypeMeta: metav1.TypeMeta{ - Kind: "MachineSet", - }, ObjectMeta: metav1.ObjectMeta{ Name: "withOwnerRefAndNoMatchLabels", Namespace: metav1.NamespaceDefault, diff --git a/internal/controllers/machinedeployment/machinedeployment_sync.go b/internal/controllers/machinedeployment/machinedeployment_sync.go index e146507a393d..958807ebd7ee 100644 --- a/internal/controllers/machinedeployment/machinedeployment_sync.go +++ b/internal/controllers/machinedeployment/machinedeployment_sync.go @@ -274,10 +274,6 @@ func (r *Reconciler) computeDesiredMachineSet(ctx context.Context, deployment *c // Construct the basic MachineSet. desiredMS := &clusterv1.MachineSet{ - TypeMeta: metav1.TypeMeta{ - APIVersion: clusterv1.GroupVersion.String(), - Kind: "MachineSet", - }, ObjectMeta: metav1.ObjectMeta{ Name: name, Namespace: deployment.Namespace, diff --git a/internal/controllers/machinehealthcheck/machinehealthcheck_controller_test.go b/internal/controllers/machinehealthcheck/machinehealthcheck_controller_test.go index f5070c22cc24..97510f1fa980 100644 --- a/internal/controllers/machinehealthcheck/machinehealthcheck_controller_test.go +++ b/internal/controllers/machinehealthcheck/machinehealthcheck_controller_test.go @@ -2495,10 +2495,6 @@ func createCluster(g *WithT, namespaceName string) *clusterv1.Cluster { // newRunningMachine creates a Machine object with a Status.Phase == Running. func newRunningMachine(c *clusterv1.Cluster, labels map[string]string) *clusterv1.Machine { return &clusterv1.Machine{ - TypeMeta: metav1.TypeMeta{ - APIVersion: clusterv1.GroupVersion.String(), - Kind: "Machine", - }, ObjectMeta: metav1.ObjectMeta{ GenerateName: "test-mhc-machine-", Namespace: c.Namespace, diff --git a/internal/controllers/machinehealthcheck/machinehealthcheck_targets_test.go b/internal/controllers/machinehealthcheck/machinehealthcheck_targets_test.go index 03e2540e8077..2f4a010d7d41 100644 --- a/internal/controllers/machinehealthcheck/machinehealthcheck_targets_test.go +++ b/internal/controllers/machinehealthcheck/machinehealthcheck_targets_test.go @@ -582,10 +582,6 @@ func newTestMachine(name, namespace, clusterName, nodeName string, labels map[st bootstrap := "bootstrap" return &clusterv1.Machine{ - TypeMeta: metav1.TypeMeta{ - APIVersion: clusterv1.GroupVersion.String(), - Kind: "Machine", - }, ObjectMeta: metav1.ObjectMeta{ Name: name, Namespace: namespace, @@ -612,10 +608,6 @@ func newTestMachine(name, namespace, clusterName, nodeName string, labels map[st func newTestNode(name string) *corev1.Node { return &corev1.Node{ - TypeMeta: metav1.TypeMeta{ - APIVersion: "v1", - Kind: "Node", - }, ObjectMeta: metav1.ObjectMeta{ Name: name, }, diff --git a/internal/controllers/machineset/machineset_controller.go b/internal/controllers/machineset/machineset_controller.go index 79ffd39e63a8..fa258c9cb948 100644 --- a/internal/controllers/machineset/machineset_controller.go +++ b/internal/controllers/machineset/machineset_controller.go @@ -886,10 +886,6 @@ func (r *Reconciler) computeDesiredMachine(machineSet *clusterv1.MachineSet, exi } desiredMachine := &clusterv1.Machine{ - TypeMeta: metav1.TypeMeta{ - APIVersion: clusterv1.GroupVersion.String(), - Kind: "Machine", - }, ObjectMeta: metav1.ObjectMeta{ Name: generatedMachineName, Namespace: machineSet.Namespace, diff --git a/internal/controllers/machineset/machineset_controller_test.go b/internal/controllers/machineset/machineset_controller_test.go index d8d41edeba1b..3c2952d7bc6e 100644 --- a/internal/controllers/machineset/machineset_controller_test.go +++ b/internal/controllers/machineset/machineset_controller_test.go @@ -502,7 +502,6 @@ func TestMachineSetReconciler(t *testing.T) { func TestMachineSetOwnerReference(t *testing.T) { testCluster := &clusterv1.Cluster{ - TypeMeta: metav1.TypeMeta{Kind: "Cluster", APIVersion: clusterv1.GroupVersion.String()}, ObjectMeta: metav1.ObjectMeta{Namespace: metav1.NamespaceDefault, Name: testClusterName}, } @@ -1236,10 +1235,6 @@ func TestMachineSetReconciler_syncMachines(t *testing.T) { g.Expect(env.Create(ctx, bootstrapConfig, client.FieldOwner(classicManager))).To(Succeed()) inPlaceMutatingMachine := &clusterv1.Machine{ - TypeMeta: metav1.TypeMeta{ - APIVersion: clusterv1.GroupVersion.String(), - Kind: "Machine", - }, ObjectMeta: metav1.ObjectMeta{ UID: "abc-123-uid", Name: "in-place-mutating-machine", @@ -1274,10 +1269,6 @@ func TestMachineSetReconciler_syncMachines(t *testing.T) { g.Expect(env.Create(ctx, inPlaceMutatingMachine, client.FieldOwner(classicManager))).To(Succeed()) deletingMachine := &clusterv1.Machine{ - TypeMeta: metav1.TypeMeta{ - APIVersion: clusterv1.GroupVersion.String(), - Kind: "Machine", - }, ObjectMeta: metav1.ObjectMeta{ UID: "abc-123-uid", Name: "deleting-machine", diff --git a/internal/controllers/topology/cluster/patches/engine_test.go b/internal/controllers/topology/cluster/patches/engine_test.go index 1ce61e49de05..dea328069170 100644 --- a/internal/controllers/topology/cluster/patches/engine_test.go +++ b/internal/controllers/topology/cluster/patches/engine_test.go @@ -1072,10 +1072,6 @@ func setupTestObjects() (*scope.ClusterBlueprint, *scope.ClusterState) { // Note: we depend on TypeMeta being set to calculate HolderReferences correctly. // We also set TypeMeta explicitly in the topology/cluster/cluster_controller.go. cluster := &clusterv1.Cluster{ - TypeMeta: metav1.TypeMeta{ - APIVersion: clusterv1.GroupVersion.String(), - Kind: "Cluster", - }, ObjectMeta: metav1.ObjectMeta{ Name: "cluster1", Namespace: metav1.NamespaceDefault, diff --git a/internal/runtime/client/client_test.go b/internal/runtime/client/client_test.go index 25a43bc05d6e..e214a5169d67 100644 --- a/internal/runtime/client/client_test.go +++ b/internal/runtime/client/client_test.go @@ -87,13 +87,8 @@ func TestClient_httpCall(t *testing.T) { wantErr: true, }, { - name: "succeed for valid request and response objects", - request: &fakev1alpha1.FakeRequest{ - TypeMeta: metav1.TypeMeta{ - Kind: "FakeRequest", - APIVersion: fakev1alpha1.GroupVersion.Identifier(), - }, - }, + name: "succeed for valid request and response objects", + request: &fakev1alpha1.FakeRequest{}, response: &fakev1alpha1.FakeResponse{}, opts: func() *httpCallOptions { c := runtimecatalog.New() @@ -112,13 +107,8 @@ func TestClient_httpCall(t *testing.T) { wantErr: false, }, { - name: "success if request and response are valid objects - with conversion", - request: &fakev1alpha2.FakeRequest{ - TypeMeta: metav1.TypeMeta{ - Kind: "FakeRequest", - APIVersion: fakev1alpha2.GroupVersion.Identifier(), - }, - }, + name: "success if request and response are valid objects - with conversion", + request: &fakev1alpha2.FakeRequest{}, response: &fakev1alpha2.FakeResponse{}, opts: func() *httpCallOptions { c := runtimecatalog.New() @@ -215,10 +205,6 @@ func TestClient_httpCall(t *testing.T) { func fakeHookHandler(w http.ResponseWriter, _ *http.Request) { response := &fakev1alpha1.FakeResponse{ - TypeMeta: metav1.TypeMeta{ - Kind: "FakeHookResponse", - APIVersion: fakev1alpha1.GroupVersion.Identifier(), - }, Second: "", First: 1, } @@ -352,10 +338,6 @@ func Test_defaultAndValidateDiscoveryResponse(t *testing.T) { { name: "succeed with valid skeleton DiscoveryResponse", discovery: &runtimehooksv1.DiscoveryResponse{ - TypeMeta: metav1.TypeMeta{ - Kind: "DiscoveryResponse", - APIVersion: runtimehooksv1.GroupVersion.String(), - }, Handlers: []runtimehooksv1.ExtensionHandler{{ Name: "extension", RequestHook: runtimehooksv1.GroupVersionHook{ @@ -369,10 +351,6 @@ func Test_defaultAndValidateDiscoveryResponse(t *testing.T) { { name: "error if handler name has capital letters", discovery: &runtimehooksv1.DiscoveryResponse{ - TypeMeta: metav1.TypeMeta{ - Kind: "DiscoveryResponse", - APIVersion: runtimehooksv1.GroupVersion.String(), - }, Handlers: []runtimehooksv1.ExtensionHandler{{ Name: "HAS-CAPITAL-LETTERS", RequestHook: runtimehooksv1.GroupVersionHook{ @@ -386,10 +364,6 @@ func Test_defaultAndValidateDiscoveryResponse(t *testing.T) { { name: "error if handler name has full stops", discovery: &runtimehooksv1.DiscoveryResponse{ - TypeMeta: metav1.TypeMeta{ - Kind: "DiscoveryResponse", - APIVersion: runtimehooksv1.GroupVersion.String(), - }, Handlers: []runtimehooksv1.ExtensionHandler{{ Name: "has.full.stops", RequestHook: runtimehooksv1.GroupVersionHook{ @@ -403,10 +377,6 @@ func Test_defaultAndValidateDiscoveryResponse(t *testing.T) { { name: "error with TimeoutSeconds of over 30 seconds", discovery: &runtimehooksv1.DiscoveryResponse{ - TypeMeta: metav1.TypeMeta{ - Kind: "DiscoveryResponse", - APIVersion: runtimehooksv1.GroupVersion.String(), - }, Handlers: []runtimehooksv1.ExtensionHandler{{ Name: "ext1", RequestHook: runtimehooksv1.GroupVersionHook{ @@ -421,10 +391,6 @@ func Test_defaultAndValidateDiscoveryResponse(t *testing.T) { { name: "error with TimeoutSeconds of less than 0", discovery: &runtimehooksv1.DiscoveryResponse{ - TypeMeta: metav1.TypeMeta{ - Kind: "DiscoveryResponse", - APIVersion: runtimehooksv1.GroupVersion.String(), - }, Handlers: []runtimehooksv1.ExtensionHandler{{ Name: "ext1", RequestHook: runtimehooksv1.GroupVersionHook{ @@ -439,10 +405,6 @@ func Test_defaultAndValidateDiscoveryResponse(t *testing.T) { { name: "error with FailurePolicy not Fail or Ignore", discovery: &runtimehooksv1.DiscoveryResponse{ - TypeMeta: metav1.TypeMeta{ - Kind: "DiscoveryResponse", - APIVersion: runtimehooksv1.GroupVersion.String(), - }, Handlers: []runtimehooksv1.ExtensionHandler{{ Name: "ext1", RequestHook: runtimehooksv1.GroupVersionHook{ @@ -458,10 +420,6 @@ func Test_defaultAndValidateDiscoveryResponse(t *testing.T) { { name: "error when handler name is duplicated", discovery: &runtimehooksv1.DiscoveryResponse{ - TypeMeta: metav1.TypeMeta{ - Kind: "DiscoveryResponse", - APIVersion: runtimehooksv1.GroupVersion.String(), - }, Handlers: []runtimehooksv1.ExtensionHandler{ { Name: "ext1", @@ -491,10 +449,6 @@ func Test_defaultAndValidateDiscoveryResponse(t *testing.T) { { name: "error if handler GroupVersionHook is not registered", discovery: &runtimehooksv1.DiscoveryResponse{ - TypeMeta: metav1.TypeMeta{ - Kind: "DiscoveryResponse", - APIVersion: runtimehooksv1.GroupVersion.String(), - }, Handlers: []runtimehooksv1.ExtensionHandler{{ Name: "ext1", RequestHook: runtimehooksv1.GroupVersionHook{ @@ -509,10 +463,6 @@ func Test_defaultAndValidateDiscoveryResponse(t *testing.T) { { name: "error if handler GroupVersion can not be parsed", discovery: &runtimehooksv1.DiscoveryResponse{ - TypeMeta: metav1.TypeMeta{ - Kind: "DiscoveryResponse", - APIVersion: runtimehooksv1.GroupVersion.String(), - }, Handlers: []runtimehooksv1.ExtensionHandler{{ Name: "ext1", RequestHook: runtimehooksv1.GroupVersionHook{ @@ -536,10 +486,6 @@ func Test_defaultAndValidateDiscoveryResponse(t *testing.T) { func TestClient_CallExtension(t *testing.T) { ns := &corev1.Namespace{ - TypeMeta: metav1.TypeMeta{ - Kind: "Namespace", - APIVersion: corev1.SchemeGroupVersion.String(), - }, ObjectMeta: metav1.ObjectMeta{ Name: "foo", }, @@ -845,10 +791,6 @@ func TestClient_CallExtension(t *testing.T) { func TestClient_CallExtensionWithClientAuthentication(t *testing.T) { ns := &corev1.Namespace{ - TypeMeta: metav1.TypeMeta{ - Kind: "Namespace", - APIVersion: corev1.SchemeGroupVersion.String(), - }, ObjectMeta: metav1.ObjectMeta{ Name: "foo", }, @@ -1029,10 +971,6 @@ func TestPrepareRequest(t *testing.T) { func TestClient_CallAllExtensions(t *testing.T) { ns := &corev1.Namespace{ - TypeMeta: metav1.TypeMeta{ - Kind: "Namespace", - APIVersion: corev1.SchemeGroupVersion.String(), - }, ObjectMeta: metav1.ObjectMeta{ Name: "foo", }, @@ -1234,10 +1172,6 @@ func TestClient_CallAllExtensions(t *testing.T) { func Test_client_matchNamespace(t *testing.T) { g := NewWithT(t) foo := &corev1.Namespace{ - TypeMeta: metav1.TypeMeta{ - Kind: "Namespace", - APIVersion: corev1.SchemeGroupVersion.String(), - }, ObjectMeta: metav1.ObjectMeta{ Name: "foo", Labels: map[string]string{ @@ -1246,10 +1180,6 @@ func Test_client_matchNamespace(t *testing.T) { }, } bar := &corev1.Namespace{ - TypeMeta: metav1.TypeMeta{ - Kind: "Namespace", - APIVersion: corev1.SchemeGroupVersion.String(), - }, ObjectMeta: metav1.ObjectMeta{ Name: "bar", Labels: map[string]string{ @@ -1457,10 +1387,6 @@ func registry(configs []runtimev1.ExtensionConfig) runtimeregistry.ExtensionRegi func fakeSuccessResponse(message string) *fakev1alpha1.FakeResponse { return &fakev1alpha1.FakeResponse{ - TypeMeta: metav1.TypeMeta{ - Kind: "FakeResponse", - APIVersion: "v1alpha1", - }, CommonResponse: runtimehooksv1.CommonResponse{ Message: message, Status: runtimehooksv1.ResponseStatusSuccess, @@ -1470,10 +1396,6 @@ func fakeSuccessResponse(message string) *fakev1alpha1.FakeResponse { func fakeRetryableSuccessResponse(retryAfterSeconds int32, message string) *fakev1alpha1.RetryableFakeResponse { return &fakev1alpha1.RetryableFakeResponse{ - TypeMeta: metav1.TypeMeta{ - Kind: "FakeResponse", - APIVersion: "v1alpha1", - }, CommonResponse: runtimehooksv1.CommonResponse{ Message: message, Status: runtimehooksv1.ResponseStatusSuccess, diff --git a/internal/topology/clustershim/clustershim.go b/internal/topology/clustershim/clustershim.go index d75a7af6f13b..c2ed8fcd5406 100644 --- a/internal/topology/clustershim/clustershim.go +++ b/internal/topology/clustershim/clustershim.go @@ -30,10 +30,6 @@ import ( // New creates a new clustershim. func New(c *clusterv1.Cluster) *corev1.Secret { shim := &corev1.Secret{ - TypeMeta: metav1.TypeMeta{ - Kind: "Secret", - APIVersion: corev1.SchemeGroupVersion.String(), - }, ObjectMeta: metav1.ObjectMeta{ Name: fmt.Sprintf("%s-shim", c.Name), Namespace: c.Namespace, diff --git a/internal/util/ssa/patch_test.go b/internal/util/ssa/patch_test.go index b1eadd3f7428..bf6a52fd4249 100644 --- a/internal/util/ssa/patch_test.go +++ b/internal/util/ssa/patch_test.go @@ -90,10 +90,6 @@ func TestPatch(t *testing.T) { t.Run("Test patch with Machine", func(*testing.T) { // Build the test object to work with. initialObject := &clusterv1.Machine{ - TypeMeta: metav1.TypeMeta{ - APIVersion: clusterv1.GroupVersion.String(), - Kind: "Machine", - }, ObjectMeta: metav1.ObjectMeta{ Name: "machine-1", Namespace: ns.Name, @@ -126,8 +122,6 @@ func TestPatch(t *testing.T) { // 1. Create the object createObject := initialObject.DeepCopy() g.Expect(Patch(ctx, env.GetClient(), fieldManager, createObject)).To(Succeed()) - // Verify that gvk is still set - g.Expect(createObject.GroupVersionKind()).To(Equal(initialObject.GroupVersionKind())) // 2. Update the object and verify that the request was not cached as the object was changed. // Get the original object. @@ -143,8 +137,6 @@ func TestPatch(t *testing.T) { g.Expect(err).ToNot(HaveOccurred()) // Update the object g.Expect(Patch(ctx, env.GetClient(), fieldManager, modifiedObject, WithCachingProxy{Cache: ssaCache, Original: originalObject})).To(Succeed()) - // Verify that gvk is still set - g.Expect(modifiedObject.GroupVersionKind()).To(Equal(initialObject.GroupVersionKind())) // Verify that request was not cached (as it changed the object) g.Expect(ssaCache.Has(requestIdentifier, initialObject.GetObjectKind().GroupVersionKind().Kind)).To(BeFalse()) @@ -172,7 +164,5 @@ func TestPatch(t *testing.T) { g.Expect(Patch(ctx, env.GetClient(), fieldManager, modifiedObject, WithCachingProxy{Cache: ssaCache, Original: originalObject})).To(Succeed()) // Verify that request was cached (as it did not change the object) g.Expect(ssaCache.Has(requestIdentifier, initialObject.GetObjectKind().GroupVersionKind().Kind)).To(BeTrue()) - // Verify that gvk is still set - g.Expect(modifiedObject.GroupVersionKind()).To(Equal(initialObject.GroupVersionKind())) }) } diff --git a/test/extension/handlers/topologymutation/handler_test.go b/test/extension/handlers/topologymutation/handler_test.go index 68dcb14fa42b..8eeb3feb1b67 100644 --- a/test/extension/handlers/topologymutation/handler_test.go +++ b/test/extension/handlers/topologymutation/handler_test.go @@ -24,7 +24,6 @@ import ( . "github.com/onsi/gomega" apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/intstr" @@ -310,30 +309,10 @@ func TestHandler_GeneratePatches(t *testing.T) { }, }), } - kubeadmControlPlaneTemplate := controlplanev1.KubeadmControlPlaneTemplate{ - TypeMeta: metav1.TypeMeta{ - Kind: "KubeadmControlPlaneTemplate", - APIVersion: controlplanev1.GroupVersion.String(), - }, - } - dockerMachineTemplate := infrav1.DockerMachineTemplate{ - TypeMeta: metav1.TypeMeta{ - Kind: "DockerMachineTemplate", - APIVersion: infrav1.GroupVersion.String(), - }, - } - dockerMachinePoolTemplate := infraexpv1.DockerMachinePoolTemplate{ - TypeMeta: metav1.TypeMeta{ - Kind: "DockerMachinePoolTemplate", - APIVersion: infrav1.GroupVersion.String(), - }, - } - dockerClusterTemplate := infrav1.DockerClusterTemplate{ - TypeMeta: metav1.TypeMeta{ - Kind: "DockerClusterTemplate", - APIVersion: infrav1.GroupVersion.String(), - }, - } + kubeadmControlPlaneTemplate := controlplanev1.KubeadmControlPlaneTemplate{} + dockerMachineTemplate := infrav1.DockerMachineTemplate{} + dockerMachinePoolTemplate := infraexpv1.DockerMachinePoolTemplate{} + dockerClusterTemplate := infrav1.DockerClusterTemplate{} tests := []struct { name string requestItems []runtimehooksv1.GeneratePatchesRequestItem diff --git a/test/framework/bootstrap/kind_provider.go b/test/framework/bootstrap/kind_provider.go index 78bcca0ee73d..4b5bc8546806 100644 --- a/test/framework/bootstrap/kind_provider.go +++ b/test/framework/bootstrap/kind_provider.go @@ -142,10 +142,6 @@ func (k *KindClusterProvider) createKindCluster() { } cfg := &kindv1.Cluster{ - TypeMeta: kindv1.TypeMeta{ - APIVersion: "kind.x-k8s.io/v1alpha4", - Kind: "Cluster", - }, Nodes: []kindv1.Node{ { Role: kindv1.ControlPlaneRole, diff --git a/test/infrastructure/docker/internal/controllers/dockermachine_controller_test.go b/test/infrastructure/docker/internal/controllers/dockermachine_controller_test.go index 81ff0a142a56..08ef205bbb87 100644 --- a/test/infrastructure/docker/internal/controllers/dockermachine_controller_test.go +++ b/test/infrastructure/docker/internal/controllers/dockermachine_controller_test.go @@ -67,7 +67,6 @@ func TestDockerMachineReconciler_DockerClusterToDockerMachines(t *testing.T) { func newCluster(clusterName string, dockerCluster *infrav1.DockerCluster) *clusterv1.Cluster { cluster := &clusterv1.Cluster{ - TypeMeta: metav1.TypeMeta{}, ObjectMeta: metav1.ObjectMeta{ Name: clusterName, }, @@ -84,7 +83,6 @@ func newCluster(clusterName string, dockerCluster *infrav1.DockerCluster) *clust func newDockerCluster(clusterName, dockerName string) *infrav1.DockerCluster { return &infrav1.DockerCluster{ - TypeMeta: metav1.TypeMeta{}, ObjectMeta: metav1.ObjectMeta{ Name: dockerName, OwnerReferences: []metav1.OwnerReference{ @@ -119,7 +117,6 @@ func newMachine(clusterName, machineName string, dockerMachine *infrav1.DockerMa func newDockerMachine(dockerMachineName, machineName string) *infrav1.DockerMachine { return &infrav1.DockerMachine{ - TypeMeta: metav1.TypeMeta{}, ObjectMeta: metav1.ObjectMeta{ Name: dockerMachineName, ResourceVersion: "999", diff --git a/util/collections/machine_filters_test.go b/util/collections/machine_filters_test.go index ef4ad8815452..886b4b2aba09 100644 --- a/util/collections/machine_filters_test.go +++ b/util/collections/machine_filters_test.go @@ -541,7 +541,6 @@ func testControlPlaneMachine(name string) *clusterv1.Machine { func testMachine(name string) *clusterv1.Machine { return &clusterv1.Machine{ - TypeMeta: metav1.TypeMeta{}, ObjectMeta: metav1.ObjectMeta{ Name: name, Namespace: "my-namespace", diff --git a/util/conditions/deprecated/v1beta1/merge_strategies_test.go b/util/conditions/deprecated/v1beta1/merge_strategies_test.go index 4d9ea302b7d9..6d1d6ab4c1f7 100644 --- a/util/conditions/deprecated/v1beta1/merge_strategies_test.go +++ b/util/conditions/deprecated/v1beta1/merge_strategies_test.go @@ -71,9 +71,6 @@ func TestGetFirstReasonAndMessage(t *testing.T) { bar := FalseCondition("bar", "falseBar", clusterv1.ConditionSeverityInfo, "message falseBar") getter := &clusterv1.Cluster{ - TypeMeta: metav1.TypeMeta{ - Kind: "Cluster", - }, ObjectMeta: metav1.ObjectMeta{ Name: "test-cluster", }, diff --git a/util/deprecated/v1beta1/conditions/merge_strategies_test.go b/util/deprecated/v1beta1/conditions/merge_strategies_test.go index b198d0a83821..d1afe7b919ab 100644 --- a/util/deprecated/v1beta1/conditions/merge_strategies_test.go +++ b/util/deprecated/v1beta1/conditions/merge_strategies_test.go @@ -71,9 +71,6 @@ func TestGetFirstReasonAndMessage(t *testing.T) { bar := FalseCondition("bar", "falseBar", clusterv1.ConditionSeverityInfo, "message falseBar") getter := &clusterv1.Cluster{ - TypeMeta: metav1.TypeMeta{ - Kind: "Cluster", - }, ObjectMeta: metav1.ObjectMeta{ Name: "test-cluster", }, diff --git a/util/log/log_test.go b/util/log/log_test.go index 265ea5394bb8..3bcdf3364dca 100644 --- a/util/log/log_test.go +++ b/util/log/log_test.go @@ -41,26 +41,18 @@ func Test_AddObjectHierarchy(t *testing.T) { g.Expect(clusterv1.AddToScheme(scheme)).To(Succeed()) md := &clusterv1.MachineSet{ - TypeMeta: metav1.TypeMeta{ - APIVersion: clusterv1.GroupVersion.String(), - Kind: "MachineDeployment", - }, ObjectMeta: metav1.ObjectMeta{ Namespace: metav1.NamespaceDefault, Name: "development-3961-md-0-l4zn6", }, } mdOwnerRef := metav1.OwnerReference{ - APIVersion: md.APIVersion, - Kind: md.Kind, + APIVersion: clusterv1.GroupVersion.String(), + Kind: "MachineDeployment", Name: md.Name, } ms := &clusterv1.MachineSet{ - TypeMeta: metav1.TypeMeta{ - APIVersion: clusterv1.GroupVersion.String(), - Kind: "MachineSet", - }, ObjectMeta: metav1.ObjectMeta{ Namespace: metav1.NamespaceDefault, Name: "development-3961-md-0-l4zn6-758c9b7677", @@ -68,8 +60,8 @@ func Test_AddObjectHierarchy(t *testing.T) { }, } msOwnerRef := metav1.OwnerReference{ - APIVersion: ms.APIVersion, - Kind: ms.Kind, + APIVersion: clusterv1.GroupVersion.String(), + Kind: "MachineSet", Name: ms.Name, } diff --git a/util/test/builder/builders.go b/util/test/builder/builders.go index 48a1e649a79f..a8ee12a62786 100644 --- a/util/test/builder/builders.go +++ b/util/test/builder/builders.go @@ -89,10 +89,6 @@ func (c *ClusterBuilder) WithTopology(topology *clusterv1.Topology) *ClusterBuil // Build returns a Cluster with the attributes added to the ClusterBuilder. func (c *ClusterBuilder) Build() *clusterv1.Cluster { obj := &clusterv1.Cluster{ - TypeMeta: metav1.TypeMeta{ - Kind: "Cluster", - APIVersion: clusterv1.GroupVersion.String(), - }, ObjectMeta: metav1.ObjectMeta{ Name: c.name, Namespace: c.namespace, @@ -481,10 +477,6 @@ func (c *ClusterClassBuilder) WithWorkerMachinePoolClasses(mpcs ...clusterv1.Mac // Build takes the objects and variables in the ClusterClass builder and uses them to create a ClusterClass object. func (c *ClusterClassBuilder) Build() *clusterv1.ClusterClass { obj := &clusterv1.ClusterClass{ - TypeMeta: metav1.TypeMeta{ - Kind: "ClusterClass", - APIVersion: clusterv1.GroupVersion.String(), - }, ObjectMeta: metav1.ObjectMeta{ Name: c.name, Namespace: c.namespace, @@ -1701,10 +1693,6 @@ func (m *MachinePoolBuilder) WithMinReadySeconds(minReadySeconds int32) *Machine // Build creates a new MachinePool with the variables and objects passed to the MachinePoolBuilder. func (m *MachinePoolBuilder) Build() *clusterv1.MachinePool { obj := &clusterv1.MachinePool{ - TypeMeta: metav1.TypeMeta{ - Kind: "MachinePool", - APIVersion: clusterv1.GroupVersion.String(), - }, ObjectMeta: metav1.ObjectMeta{ Name: m.name, Namespace: m.namespace, @@ -1831,10 +1819,6 @@ func (m *MachineDeploymentBuilder) WithMinReadySeconds(minReadySeconds int32) *M // Build creates a new MachineDeployment with the variables and objects passed to the MachineDeploymentBuilder. func (m *MachineDeploymentBuilder) Build() *clusterv1.MachineDeployment { obj := &clusterv1.MachineDeployment{ - TypeMeta: metav1.TypeMeta{ - Kind: "MachineDeployment", - APIVersion: clusterv1.GroupVersion.String(), - }, ObjectMeta: metav1.ObjectMeta{ Name: m.name, Namespace: m.namespace, @@ -1938,10 +1922,6 @@ func (m *MachineSetBuilder) WithOwnerReferences(ownerRefs []metav1.OwnerReferenc // Build creates a new MachineSet with the variables and objects passed to the MachineSetBuilder. func (m *MachineSetBuilder) Build() *clusterv1.MachineSet { obj := &clusterv1.MachineSet{ - TypeMeta: metav1.TypeMeta{ - Kind: "MachineSet", - APIVersion: clusterv1.GroupVersion.String(), - }, ObjectMeta: metav1.ObjectMeta{ Name: m.name, Namespace: m.namespace, @@ -2013,10 +1993,6 @@ func (m *MachineBuilder) WithLabels(labels map[string]string) *MachineBuilder { // Build produces a Machine object from the information passed to the MachineBuilder. func (m *MachineBuilder) Build() *clusterv1.Machine { machine := &clusterv1.Machine{ - TypeMeta: metav1.TypeMeta{ - Kind: "Machine", - APIVersion: clusterv1.GroupVersion.String(), - }, ObjectMeta: metav1.ObjectMeta{ Namespace: m.namespace, Name: m.name, @@ -2148,10 +2124,6 @@ func (m *MachineHealthCheckBuilder) WithMaxUnhealthy(maxUnhealthy *intstr.IntOrS func (m *MachineHealthCheckBuilder) Build() *clusterv1.MachineHealthCheck { // create a MachineHealthCheck with the spec given in the ClusterClass mhc := &clusterv1.MachineHealthCheck{ - TypeMeta: metav1.TypeMeta{ - Kind: "MachineHealthCheck", - APIVersion: clusterv1.GroupVersion.String(), - }, ObjectMeta: metav1.ObjectMeta{ Name: m.name, Namespace: m.namespace, diff --git a/util/test/builder/crds.go b/util/test/builder/crds.go index 5e118fb10af7..5c15385e302e 100644 --- a/util/test/builder/crds.go +++ b/util/test/builder/crds.go @@ -44,10 +44,6 @@ func untypedCRD(gvk schema.GroupVersionKind) *apiextensionsv1.CustomResourceDefi func generateCRD(gvk schema.GroupVersionKind, properties map[string]apiextensionsv1.JSONSchemaProps) *apiextensionsv1.CustomResourceDefinition { return &apiextensionsv1.CustomResourceDefinition{ - TypeMeta: metav1.TypeMeta{ - APIVersion: apiextensionsv1.SchemeGroupVersion.String(), - Kind: "CustomResourceDefinition", - }, ObjectMeta: metav1.ObjectMeta{ Name: contract.CalculateCRDName(gvk.Group, gvk.Kind), Labels: map[string]string{