Skip to content

Commit

Permalink
Temp: Add metadata to machine object
Browse files Browse the repository at this point in the history
  • Loading branch information
jsturtevant committed Oct 16, 2021
1 parent 531fd66 commit d36d3ff
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 12 deletions.
5 changes: 5 additions & 0 deletions api/v1alpha3/azuremachinetemplate_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package v1alpha3

import (
apimachineryconversion "k8s.io/apimachinery/pkg/conversion"
"sigs.k8s.io/cluster-api-provider-azure/api/v1beta1"
infrav1beta1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1"
utilconversion "sigs.k8s.io/cluster-api/util/conversion"
"sigs.k8s.io/controller-runtime/pkg/conversion"
Expand Down Expand Up @@ -90,3 +91,7 @@ func Convert_v1beta1_AzureSharedGalleryImage_To_v1alpha3_AzureSharedGalleryImage

return nil
}

func Convert_v1beta1_AzureMachineTemplateResource_To_v1alpha3_AzureMachineTemplateResource(in *v1beta1.AzureMachineTemplateResource, out *AzureMachineTemplateResource, s apimachineryconversion.Scope) error {
return nil
}
6 changes: 1 addition & 5 deletions api/v1alpha3/zz_generated.conversion.go

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

5 changes: 5 additions & 0 deletions api/v1alpha4/azuremachinetemplate_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package v1alpha4

import (
apimachineryconversion "k8s.io/apimachinery/pkg/conversion"
infrav1beta1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1"
"sigs.k8s.io/controller-runtime/pkg/conversion"
)
Expand Down Expand Up @@ -45,3 +46,7 @@ func (dst *AzureMachineTemplateList) ConvertFrom(srcRaw conversion.Hub) error {
src := srcRaw.(*infrav1beta1.AzureMachineTemplateList)
return Convert_v1beta1_AzureMachineTemplateList_To_v1alpha4_AzureMachineTemplateList(src, dst, nil)
}

func Convert_v1beta1_AzureMachineTemplateResource_To_v1alpha4_AzureMachineTemplateResource(in *infrav1beta1.AzureMachineTemplateResource, out *AzureMachineTemplateResource, s apimachineryconversion.Scope) error {
return nil
}
30 changes: 23 additions & 7 deletions api/v1alpha4/zz_generated.conversion.go

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

3 changes: 3 additions & 0 deletions api/v1beta1/azuremachinetemplate_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package v1beta1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
)

// AzureMachineTemplateSpec defines the desired state of AzureMachineTemplate.
Expand Down Expand Up @@ -52,6 +53,8 @@ func init() {

// AzureMachineTemplateResource describes the data needed to create an AzureMachine from a template.
type AzureMachineTemplateResource struct {
// +optional
ObjectMeta clusterv1.ObjectMeta `json:"metadata,omitempty"`
// Spec is the specification of the desired behavior of the machine.
Spec AzureMachineSpec `json:"spec"`
}
1 change: 1 addition & 0 deletions api/v1beta1/zz_generated.deepcopy.go

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

Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,48 @@ spec:
description: AzureMachineTemplateResource describes the data needed
to create an AzureMachine from a template.
properties:
metadata:
description: "ObjectMeta is metadata that all persisted resources
must have, which includes all objects users must create. This
is a copy of customizable fields from metav1.ObjectMeta. \n
ObjectMeta is embedded in `Machine.Spec`, `MachineDeployment.Template`
and `MachineSet.Template`, which are not top-level Kubernetes
objects. Given that metav1.ObjectMeta has lots of special cases
and read-only fields which end up in the generated CRD validation,
having it as a subset simplifies the API and some issues that
can impact user experience. \n During the [upgrade to controller-tools@v2](https://github.com/kubernetes-sigs/cluster-api/pull/1054)
for v1alpha2, we noticed a failure would occur running Cluster
API test suite against the new CRDs, specifically `spec.metadata.creationTimestamp
in body must be of type string: \"null\"`. The investigation
showed that `controller-tools@v2` behaves differently than its
previous version when handling types from [metav1](k8s.io/apimachinery/pkg/apis/meta/v1)
package. \n In more details, we found that embedded (non-top
level) types that embedded `metav1.ObjectMeta` had validation
properties, including for `creationTimestamp` (metav1.Time).
The `metav1.Time` type specifies a custom json marshaller that,
when IsZero() is true, returns `null` which breaks validation
because the field isn't marked as nullable. \n In future versions,
controller-tools@v2 might allow overriding the type and validation
for embedded types. When that happens, this hack should be revisited."
properties:
annotations:
additionalProperties:
type: string
description: 'Annotations is an unstructured key value map
stored with a resource that may be set by external tools
to store and retrieve arbitrary metadata. They are not queryable
and should be preserved when modifying objects. More info:
http://kubernetes.io/docs/user-guide/annotations'
type: object
labels:
additionalProperties:
type: string
description: 'Map of string keys and values that can be used
to organize and categorize (scope and select) objects. May
match selectors of replication controllers and services.
More info: http://kubernetes.io/docs/user-guide/labels'
type: object
type: object
spec:
description: Spec is the specification of the desired behavior
of the machine.
Expand Down

0 comments on commit d36d3ff

Please sign in to comment.