Skip to content

Commit 14477c0

Browse files
authored
Merge pull request #1210 from yastij/add-meta-0.7
Add metadata field to the VSphereMachineTemplate
2 parents 7e1a78f + 7ad944e commit 14477c0

File tree

5 files changed

+141
-15
lines changed

5 files changed

+141
-15
lines changed

api/v1alpha2/vspheremachinetemplate_conversion.go

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ package v1alpha2
1919
import (
2020
apiconversion "k8s.io/apimachinery/pkg/conversion"
2121
infrav1alpha3 "sigs.k8s.io/cluster-api-provider-vsphere/api/v1alpha3"
22+
clusterv1 "sigs.k8s.io/cluster-api/api/v1alpha2"
23+
2224
utilconversion "sigs.k8s.io/cluster-api/util/conversion"
2325
"sigs.k8s.io/controller-runtime/pkg/conversion"
2426
)
@@ -38,7 +40,6 @@ func (src *VSphereMachineTemplate) ConvertTo(dstRaw conversion.Hub) error { // n
3840

3941
dst.Spec.Template.Spec.VirtualMachineCloneSpec = restored.Spec.Template.Spec.VirtualMachineCloneSpec
4042
dst.Spec.Template.Spec.FailureDomain = restored.Spec.Template.Spec.FailureDomain
41-
4243
return nil
4344
}
4445

@@ -69,8 +70,24 @@ func (dst *VSphereMachineTemplateList) ConvertFrom(srcRaw conversion.Hub) error
6970
return Convert_v1alpha3_VSphereMachineTemplateList_To_v1alpha2_VSphereMachineTemplateList(src, dst, nil)
7071
}
7172

72-
// Convert_v1alpha2_VSphereMachineTemplateResource_To_v1alpha3_VSphereMachineTemplateResource converts VSphereMachineTemplateResource from v1alpha2 to v1alpha3.
73-
func Convert_v1alpha2_VSphereMachineTemplateResource_To_v1alpha3_VSphereMachineTemplateResource(in *VSphereMachineTemplateResource, out *infrav1alpha3.VSphereMachineTemplateResource, s apiconversion.Scope) error { // nolint
74-
return autoConvert_v1alpha2_VSphereMachineTemplateResource_To_v1alpha3_VSphereMachineTemplateResource(in, out, s)
73+
//nolint
74+
func Convert_v1alpha2_VSphereMachineTemplateResource_To_v1alpha3_VSphereMachineTemplateResource(in *VSphereMachineTemplateResource, out *infrav1alpha3.VSphereMachineTemplateResource, s apiconversion.Scope) error {
75+
if err := clusterv1.Convert_v1alpha2_ObjectMeta_To_v1alpha3_ObjectMeta(&in.ObjectMeta, &out.ObjectMeta, s); err != nil {
76+
return err
77+
}
78+
if err := Convert_v1alpha2_VSphereMachineSpec_To_v1alpha3_VSphereMachineSpec(&in.Spec, &out.Spec, s); err != nil {
79+
return err
80+
}
81+
return nil
82+
}
7583

84+
//nolint
85+
func Convert_v1alpha3_VSphereMachineTemplateResource_To_v1alpha2_VSphereMachineTemplateResource(in *infrav1alpha3.VSphereMachineTemplateResource, out *VSphereMachineTemplateResource, s apiconversion.Scope) error {
86+
if err := clusterv1.Convert_v1alpha3_ObjectMeta_To_v1alpha2_ObjectMeta(&in.ObjectMeta, &out.ObjectMeta, s); err != nil {
87+
return err
88+
}
89+
if err := Convert_v1alpha3_VSphereMachineSpec_To_v1alpha2_VSphereMachineSpec(&in.Spec, &out.Spec, s); err != nil {
90+
return err
91+
}
92+
return nil
7693
}

api/v1alpha2/zz_generated.conversion.go

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

api/v1alpha3/types.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ package v1alpha3
1818

1919
import (
2020
"fmt"
21+
22+
clusterv1 "sigs.k8s.io/cluster-api/api/v1alpha3"
2123
)
2224

2325
const (
@@ -142,6 +144,11 @@ type VirtualMachineCloneSpec struct {
142144

143145
// VSphereMachineTemplateResource describes the data needed to create a VSphereMachine from a template
144146
type VSphereMachineTemplateResource struct {
147+
// Standard object's metadata.
148+
// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
149+
// +optional
150+
ObjectMeta clusterv1.ObjectMeta `json:"metadata,omitempty"`
151+
145152
// Spec is the specification of the desired behavior of the machine.
146153
Spec VSphereMachineSpec `json:"spec"`
147154
}

api/v1alpha3/zz_generated.deepcopy.go

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

config/crd/bases/infrastructure.cluster.x-k8s.io_vspheremachinetemplates.yaml

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,105 @@ spec:
367367
description: VSphereMachineTemplateResource describes the data needed
368368
to create a VSphereMachine from a template
369369
properties:
370+
metadata:
371+
description: 'Standard object''s metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata'
372+
properties:
373+
annotations:
374+
additionalProperties:
375+
type: string
376+
description: 'Annotations is an unstructured key value map
377+
stored with a resource that may be set by external tools
378+
to store and retrieve arbitrary metadata. They are not queryable
379+
and should be preserved when modifying objects. More info:
380+
http://kubernetes.io/docs/user-guide/annotations'
381+
type: object
382+
generateName:
383+
description: "GenerateName is an optional prefix, used by
384+
the server, to generate a unique name ONLY IF the Name field
385+
has not been provided. If this field is used, the name returned
386+
to the client will be different than the name passed. This
387+
value will also be combined with a unique suffix. The provided
388+
value has the same validation rules as the Name field, and
389+
may be truncated by the length of the suffix required to
390+
make the value unique on the server. \n If this field is
391+
specified and the generated name exists, the server will
392+
NOT return a 409 - instead, it will either return 201 Created
393+
or 500 with Reason ServerTimeout indicating a unique name
394+
could not be found in the time allotted, and the client
395+
should retry (optionally after the time indicated in the
396+
Retry-After header). \n Applied only if Name is not specified.
397+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#idempotency"
398+
type: string
399+
labels:
400+
additionalProperties:
401+
type: string
402+
description: 'Map of string keys and values that can be used
403+
to organize and categorize (scope and select) objects. May
404+
match selectors of replication controllers and services.
405+
More info: http://kubernetes.io/docs/user-guide/labels'
406+
type: object
407+
name:
408+
description: 'Name must be unique within a namespace. Is required
409+
when creating resources, although some resources may allow
410+
a client to request the generation of an appropriate name
411+
automatically. Name is primarily intended for creation idempotence
412+
and configuration definition. Cannot be updated. More info:
413+
http://kubernetes.io/docs/user-guide/identifiers#names'
414+
type: string
415+
namespace:
416+
description: "Namespace defines the space within each name
417+
must be unique. An empty namespace is equivalent to the
418+
\"default\" namespace, but \"default\" is the canonical
419+
representation. Not all objects are required to be scoped
420+
to a namespace - the value of this field for those objects
421+
will be empty. \n Must be a DNS_LABEL. Cannot be updated.
422+
More info: http://kubernetes.io/docs/user-guide/namespaces"
423+
type: string
424+
ownerReferences:
425+
description: List of objects depended by this object. If ALL
426+
objects in the list have been deleted, this object will
427+
be garbage collected. If this object is managed by a controller,
428+
then an entry in this list will point to this controller,
429+
with the controller field set to true. There cannot be more
430+
than one managing controller.
431+
items:
432+
description: OwnerReference contains enough information
433+
to let you identify an owning object. An owning object
434+
must be in the same namespace as the dependent, or be
435+
cluster-scoped, so there is no namespace field.
436+
properties:
437+
apiVersion:
438+
description: API version of the referent.
439+
type: string
440+
blockOwnerDeletion:
441+
description: If true, AND if the owner has the "foregroundDeletion"
442+
finalizer, then the owner cannot be deleted from the
443+
key-value store until this reference is removed. Defaults
444+
to false. To set this field, a user needs "delete"
445+
permission of the owner, otherwise 422 (Unprocessable
446+
Entity) will be returned.
447+
type: boolean
448+
controller:
449+
description: If true, this reference points to the managing
450+
controller.
451+
type: boolean
452+
kind:
453+
description: 'Kind of the referent. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
454+
type: string
455+
name:
456+
description: 'Name of the referent. More info: http://kubernetes.io/docs/user-guide/identifiers#names'
457+
type: string
458+
uid:
459+
description: 'UID of the referent. More info: http://kubernetes.io/docs/user-guide/identifiers#uids'
460+
type: string
461+
required:
462+
- apiVersion
463+
- kind
464+
- name
465+
- uid
466+
type: object
467+
type: array
468+
type: object
370469
spec:
371470
description: Spec is the specification of the desired behavior
372471
of the machine.

0 commit comments

Comments
 (0)