Skip to content

Commit

Permalink
Merge pull request #1014 from alexander-demichev/tags
Browse files Browse the repository at this point in the history
Add ability to assign tags to virtual machines
  • Loading branch information
k8s-ci-robot authored Oct 18, 2021
2 parents d455fe4 + e3692e9 commit 423b6df
Show file tree
Hide file tree
Showing 19 changed files with 328 additions and 40 deletions.
24 changes: 24 additions & 0 deletions api/v1alpha3/conversion.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
Copyright 2021 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha3

import (
conversion "k8s.io/apimachinery/pkg/conversion"
v1beta1 "sigs.k8s.io/cluster-api-provider-vsphere/api/v1beta1"
)

// Convert_v1beta1_VirtualMachineCloneSpec_To_v1alpha3_VirtualMachineCloneSpec is an autogenerated conversion function.
func Convert_v1beta1_VirtualMachineCloneSpec_To_v1alpha3_VirtualMachineCloneSpec(in *v1beta1.VirtualMachineCloneSpec, out *VirtualMachineCloneSpec, s conversion.Scope) error { //nolint
return autoConvert_v1beta1_VirtualMachineCloneSpec_To_v1alpha3_VirtualMachineCloneSpec(in, out, s)
}
26 changes: 24 additions & 2 deletions api/v1alpha3/vspheremachine_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,41 @@ package v1alpha3

import (
infrav1beta1 "sigs.k8s.io/cluster-api-provider-vsphere/api/v1beta1"
utilconversion "sigs.k8s.io/cluster-api/util/conversion"
"sigs.k8s.io/controller-runtime/pkg/conversion"
)

// ConvertTo converts this VSphereMachine to the Hub version (v1beta1).
func (src *VSphereMachine) ConvertTo(dstRaw conversion.Hub) error { // nolint
dst := dstRaw.(*infrav1beta1.VSphereMachine)
return Convert_v1alpha3_VSphereMachine_To_v1beta1_VSphereMachine(src, dst, nil)
if err := Convert_v1alpha3_VSphereMachine_To_v1beta1_VSphereMachine(src, dst, nil); err != nil {
return err
}

// Manually restore data.
restored := &infrav1beta1.VSphereMachine{}
if ok, err := utilconversion.UnmarshalData(src, restored); err != nil || !ok {
return err
}

dst.Spec.TagIDs = restored.Spec.TagIDs

return nil
}

// ConvertFrom converts from the Hub version (v1beta1) to this VSphereMachine.
func (dst *VSphereMachine) ConvertFrom(srcRaw conversion.Hub) error { // nolint
src := srcRaw.(*infrav1beta1.VSphereMachine)
return Convert_v1beta1_VSphereMachine_To_v1alpha3_VSphereMachine(src, dst, nil)
if err := Convert_v1beta1_VSphereMachine_To_v1alpha3_VSphereMachine(src, dst, nil); err != nil {
return err
}

// Preserve Hub data on down-conversion.
if err := utilconversion.MarshalData(src, dst); err != nil {
return err
}

return nil
}

// ConvertTo converts this VSphereMachineList to the Hub version (v1beta1).
Expand Down
25 changes: 23 additions & 2 deletions api/v1alpha3/vspheremachinetemplate_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,39 @@ import (
infrav1beta1 "sigs.k8s.io/cluster-api-provider-vsphere/api/v1beta1"
clusterv1a3 "sigs.k8s.io/cluster-api/api/v1alpha3"
clusterv1b1 "sigs.k8s.io/cluster-api/api/v1beta1"
utilconversion "sigs.k8s.io/cluster-api/util/conversion"
"sigs.k8s.io/controller-runtime/pkg/conversion"
)

// ConvertTo
func (src *VSphereMachineTemplate) ConvertTo(dstRaw conversion.Hub) error { // nolint
dst := dstRaw.(*infrav1beta1.VSphereMachineTemplate)
return Convert_v1alpha3_VSphereMachineTemplate_To_v1beta1_VSphereMachineTemplate(src, dst, nil)
if err := Convert_v1alpha3_VSphereMachineTemplate_To_v1beta1_VSphereMachineTemplate(src, dst, nil); err != nil {
return err
}

// Manually restore data.
restored := &infrav1beta1.VSphereMachineTemplate{}
if ok, err := utilconversion.UnmarshalData(src, restored); err != nil || !ok {
return err
}
dst.Spec.Template.Spec.TagIDs = restored.Spec.Template.Spec.TagIDs

return nil
}

func (dst *VSphereMachineTemplate) ConvertFrom(srcRaw conversion.Hub) error { // nolint
src := srcRaw.(*infrav1beta1.VSphereMachineTemplate)
return Convert_v1beta1_VSphereMachineTemplate_To_v1alpha3_VSphereMachineTemplate(src, dst, nil)
if err := Convert_v1beta1_VSphereMachineTemplate_To_v1alpha3_VSphereMachineTemplate(src, dst, nil); err != nil {
return err
}

// Preserve Hub data on down-conversion.
if err := utilconversion.MarshalData(src, dst); err != nil {
return err
}

return nil
}

func (src *VSphereMachineTemplateList) ConvertTo(dstRaw conversion.Hub) error { // nolint
Expand Down
25 changes: 23 additions & 2 deletions api/v1alpha3/vspherevm_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,40 @@ package v1alpha3

import (
infrav1beta1 "sigs.k8s.io/cluster-api-provider-vsphere/api/v1beta1"
utilconversion "sigs.k8s.io/cluster-api/util/conversion"
"sigs.k8s.io/controller-runtime/pkg/conversion"
)

// ConvertTo converts this VSphereVM to the Hub version (v1beta1).
func (src *VSphereVM) ConvertTo(dstRaw conversion.Hub) error { // nolint
dst := dstRaw.(*infrav1beta1.VSphereVM)
return Convert_v1alpha3_VSphereVM_To_v1beta1_VSphereVM(src, dst, nil)
if err := Convert_v1alpha3_VSphereVM_To_v1beta1_VSphereVM(src, dst, nil); err != nil {
return err
}

// Manually restore data.
restored := &infrav1beta1.VSphereVM{}
if ok, err := utilconversion.UnmarshalData(src, restored); err != nil || !ok {
return err
}
dst.Spec.TagIDs = restored.Spec.TagIDs

return nil
}

// ConvertFrom converts from the Hub version (v1beta1) to this VSphereVM.
func (dst *VSphereVM) ConvertFrom(srcRaw conversion.Hub) error { // nolint
src := srcRaw.(*infrav1beta1.VSphereVM)
return Convert_v1beta1_VSphereVM_To_v1alpha3_VSphereVM(src, dst, nil)
if err := Convert_v1beta1_VSphereVM_To_v1alpha3_VSphereVM(src, dst, nil); err != nil {
return err
}

// Preserve Hub data on down-conversion.
if err := utilconversion.MarshalData(src, dst); err != nil {
return err
}

return nil
}

// ConvertTo converts this VSphereVMList to the Hub version (v1beta1).
Expand Down
64 changes: 50 additions & 14 deletions api/v1alpha3/zz_generated.conversion.go

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

24 changes: 24 additions & 0 deletions api/v1alpha4/conversion.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
Copyright 2021 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha4

import (
conversion "k8s.io/apimachinery/pkg/conversion"
v1beta1 "sigs.k8s.io/cluster-api-provider-vsphere/api/v1beta1"
)

// Convert_v1beta1_VirtualMachineCloneSpec_To_v1alpha4_VirtualMachineCloneSpec is an autogenerated conversion function.
func Convert_v1beta1_VirtualMachineCloneSpec_To_v1alpha4_VirtualMachineCloneSpec(in *v1beta1.VirtualMachineCloneSpec, out *VirtualMachineCloneSpec, s conversion.Scope) error { //nolint
return autoConvert_v1beta1_VirtualMachineCloneSpec_To_v1alpha4_VirtualMachineCloneSpec(in, out, s)
}
15 changes: 14 additions & 1 deletion api/v1alpha4/vspheremachine_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,26 @@ package v1alpha4

import (
infrav1beta1 "sigs.k8s.io/cluster-api-provider-vsphere/api/v1beta1"
utilconversion "sigs.k8s.io/cluster-api/util/conversion"
"sigs.k8s.io/controller-runtime/pkg/conversion"
)

// ConvertTo converts this VSphereMachine to the Hub version (v1beta1).
func (src *VSphereMachine) ConvertTo(dstRaw conversion.Hub) error { // nolint
dst := dstRaw.(*infrav1beta1.VSphereMachine)
return Convert_v1alpha4_VSphereMachine_To_v1beta1_VSphereMachine(src, dst, nil)
if err := Convert_v1alpha4_VSphereMachine_To_v1beta1_VSphereMachine(src, dst, nil); err != nil {
return err
}

// Manually restore data.
restored := &infrav1beta1.VSphereMachine{}
if ok, err := utilconversion.UnmarshalData(src, restored); err != nil || !ok {
return err
}

dst.Spec.TagIDs = restored.Spec.TagIDs

return nil
}

// ConvertFrom converts from the Hub version (v1beta1) to this VSphereMachine.
Expand Down
25 changes: 23 additions & 2 deletions api/v1alpha4/vspheremachinetemplate_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,39 @@ import (
infrav1beta1 "sigs.k8s.io/cluster-api-provider-vsphere/api/v1beta1"
clusterv1a4 "sigs.k8s.io/cluster-api/api/v1alpha4"
clusterv1b1 "sigs.k8s.io/cluster-api/api/v1beta1"
utilconversion "sigs.k8s.io/cluster-api/util/conversion"
"sigs.k8s.io/controller-runtime/pkg/conversion"
)

// ConvertTo
func (src *VSphereMachineTemplate) ConvertTo(dstRaw conversion.Hub) error { // nolint
dst := dstRaw.(*infrav1beta1.VSphereMachineTemplate)
return Convert_v1alpha4_VSphereMachineTemplate_To_v1beta1_VSphereMachineTemplate(src, dst, nil)
if err := Convert_v1alpha4_VSphereMachineTemplate_To_v1beta1_VSphereMachineTemplate(src, dst, nil); err != nil {
return err
}

// Manually restore data.
restored := &infrav1beta1.VSphereMachineTemplate{}
if ok, err := utilconversion.UnmarshalData(src, restored); err != nil || !ok {
return err
}
dst.Spec.Template.Spec.TagIDs = restored.Spec.Template.Spec.TagIDs

return nil
}

func (dst *VSphereMachineTemplate) ConvertFrom(srcRaw conversion.Hub) error { // nolint
src := srcRaw.(*infrav1beta1.VSphereMachineTemplate)
return Convert_v1beta1_VSphereMachineTemplate_To_v1alpha4_VSphereMachineTemplate(src, dst, nil)
if err := Convert_v1beta1_VSphereMachineTemplate_To_v1alpha4_VSphereMachineTemplate(src, dst, nil); err != nil {
return err
}

// Preserve Hub data on down-conversion.
if err := utilconversion.MarshalData(src, dst); err != nil {
return err
}

return nil
}

func (src *VSphereMachineTemplateList) ConvertTo(dstRaw conversion.Hub) error { // nolint
Expand Down
Loading

0 comments on commit 423b6df

Please sign in to comment.