Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 release-0.11: remove metadata.creationTimestamp when generating CRDs, RBAC, and webhooks #801

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/crd/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ func (g Generator) Generate(ctx *genall.GenerationContext) error {
} else {
fileName = fmt.Sprintf("%s_%s.%s.yaml", crdRaw.Spec.Group, crdRaw.Spec.Names.Plural, crdVersions[i])
}
if err := ctx.WriteYAML(fileName, []interface{}{crd}, genall.WithTransform(transformRemoveCRDStatus)); err != nil {
if err := ctx.WriteYAML(fileName, []interface{}{crd}, genall.WithTransform(transformRemoveCRDStatus), genall.WithTransform(genall.TransformRemoveCreationTimestamp)); err != nil {
return err
}
}
Expand Down
1 change: 0 additions & 1 deletion pkg/crd/testdata/gen/bar.example.com_foos.v1beta1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: (devel)
creationTimestamp: null
name: foos.bar.example.com
spec:
group: bar.example.com
Expand Down
1 change: 0 additions & 1 deletion pkg/crd/testdata/gen/bar.example.com_foos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: (devel)
creationTimestamp: null
name: foos.bar.example.com
spec:
group: bar.example.com
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: (devel)
creationTimestamp: null
name: zoos.bar.example.com
spec:
group: bar.example.com
Expand Down
1 change: 0 additions & 1 deletion pkg/crd/testdata/gen/zoo/bar.example.com_zooes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: (devel)
creationTimestamp: null
name: zooes.bar.example.com
spec:
group: bar.example.com
Expand Down
1 change: 0 additions & 1 deletion pkg/crd/testdata/plural/plural.example.com_testquotas.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: (devel)
creationTimestamp: null
name: testquotas.plural.example.com
spec:
group: plural.example.com
Expand Down
1 change: 0 additions & 1 deletion pkg/crd/testdata/testdata.kubebuilder.io_cronjobs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ metadata:
controller-gen.kubebuilder.io/version: (devel)
api-approved.kubernetes.io: https://github.com/kubernetes-sigs/controller-tools
cert-manager.io/inject-ca-from-secret: cert-manager/cert-manager-webhook-ca
creationTimestamp: null
name: cronjobs.testdata.kubebuilder.io
spec:
group: testdata.kubebuilder.io
Expand Down
1 change: 0 additions & 1 deletion pkg/crd/testdata/testdata.kubebuilder.io_jobs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: (devel)
creationTimestamp: null
name: jobs.testdata.kubebuilder.io
spec:
group: testdata.kubebuilder.io
Expand Down
7 changes: 7 additions & 0 deletions pkg/genall/genall.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,13 @@ func WithTransform(transform func(obj map[string]interface{}) error) *WriteYAMLO
}
}

// TransformRemoveCreationTimestamp ensures we do not write the metadata.creationTimestamp field.
func TransformRemoveCreationTimestamp(obj map[string]interface{}) error {
metadata := obj["metadata"].(map[interface{}]interface{})
delete(metadata, "creationTimestamp")
return nil
}

// WriteYAML writes the given objects out, serialized as YAML, using the
// context's OutputRule. Objects are written as separate documents, separated
// from each other by `---` (as per the YAML spec).
Expand Down
2 changes: 1 addition & 1 deletion pkg/rbac/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,5 +263,5 @@ func (g Generator) Generate(ctx *genall.GenerationContext) error {
return nil
}

return ctx.WriteYAML("role.yaml", objs)
return ctx.WriteYAML("role.yaml", objs, genall.WithTransform(genall.TransformRemoveCreationTimestamp))
}
3 changes: 0 additions & 3 deletions pkg/rbac/testdata/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
creationTimestamp: null
name: manager-role
rules:
- apiGroups:
Expand Down Expand Up @@ -58,7 +57,6 @@ rules:
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
creationTimestamp: null
name: manager-role
namespace: park
rules:
Expand All @@ -73,7 +71,6 @@ rules:
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
creationTimestamp: null
name: manager-role
namespace: zoo
rules:
Expand Down
2 changes: 1 addition & 1 deletion pkg/webhook/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ func (Generator) Generate(ctx *genall.GenerationContext) error {
} else {
fileName = fmt.Sprintf("manifests.%s.yaml", k)
}
if err := ctx.WriteYAML(fileName, v); err != nil {
if err := ctx.WriteYAML(fileName, v, genall.WithTransform(genall.TransformRemoveCreationTimestamp)); err != nil {
return err
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
apiVersion: admissionregistration.k8s.io/v1
kind: MutatingWebhookConfiguration
metadata:
creationTimestamp: null
name: mutating-webhook-configuration
webhooks:
- admissionReviewVersions:
Expand Down Expand Up @@ -31,7 +30,6 @@ webhooks:
apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingWebhookConfiguration
metadata:
creationTimestamp: null
name: validating-webhook-configuration
webhooks:
- admissionReviewVersions:
Expand Down
2 changes: 0 additions & 2 deletions pkg/webhook/testdata/invalid-sideEffects/manifests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
apiVersion: admissionregistration.k8s.io/v1
kind: MutatingWebhookConfiguration
metadata:
creationTimestamp: null
name: mutating-webhook-configuration
webhooks:
- admissionReviewVersions:
Expand Down Expand Up @@ -31,7 +30,6 @@ webhooks:
apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingWebhookConfiguration
metadata:
creationTimestamp: null
name: validating-webhook-configuration
webhooks:
- admissionReviewVersions:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
apiVersion: admissionregistration.k8s.io/v1
kind: MutatingWebhookConfiguration
metadata:
creationTimestamp: null
name: mutating-webhook-configuration
webhooks:
- admissionReviewVersions:
Expand Down Expand Up @@ -31,7 +30,6 @@ webhooks:
apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingWebhookConfiguration
metadata:
creationTimestamp: null
name: validating-webhook-configuration
webhooks:
- admissionReviewVersions:
Expand Down
2 changes: 0 additions & 2 deletions pkg/webhook/testdata/manifests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
apiVersion: admissionregistration.k8s.io/v1
kind: MutatingWebhookConfiguration
metadata:
creationTimestamp: null
name: mutating-webhook-configuration
webhooks:
- admissionReviewVersions:
Expand Down Expand Up @@ -32,7 +31,6 @@ webhooks:
apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingWebhookConfiguration
metadata:
creationTimestamp: null
name: validating-webhook-configuration
webhooks:
- admissionReviewVersions:
Expand Down
2 changes: 0 additions & 2 deletions pkg/webhook/testdata/valid/manifests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
apiVersion: admissionregistration.k8s.io/v1
kind: MutatingWebhookConfiguration
metadata:
creationTimestamp: null
name: mutating-webhook-configuration
webhooks:
- admissionReviewVersions:
Expand Down Expand Up @@ -32,7 +31,6 @@ webhooks:
apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingWebhookConfiguration
metadata:
creationTimestamp: null
name: validating-webhook-configuration
webhooks:
- admissionReviewVersions:
Expand Down