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

operator: patch back in the checksum field into the flux crds #14265

Merged
merged 1 commit into from
Oct 19, 2023
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 23 additions & 5 deletions src/go/k8s/config/crd/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,29 +1,47 @@
# This kustomization.yaml is not intended to be run by itself,
# since it depends on service name and namespace that are out of this kustomize package.
# It should be run by config/default
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

#+kubebuilder:scaffold:crdkustomizeresource
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: The same comment as with patches. Kubebuilder can be confused if we would like to add new resource later via kubebuilder cli.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I know what happened. I did a kustomize edit fix and it reorganized. I'll open a PR to move these back where they belong.

resources:
- bases/redpanda.vectorized.io_clusters.yaml
- bases/redpanda.vectorized.io_consoles.yaml
- bases/cluster.redpanda.com_redpandas.yaml
- bases/cluster.redpanda.com_topics.yaml
#+kubebuilder:scaffold:crdkustomizeresource
- bases/toolkit.fluxcd.io/helm-controller.yaml
- bases/toolkit.fluxcd.io/source-controller.yaml

patches:
# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix.
# patches here are for enabling the conversion webhook for each CRD
- path: patches/webhook_in_clusters.yaml
- path: patches/webhook_in_redpanda_consoles.yaml
- path: patches/webhook_in_cluster.redpanda.com_topics.yaml
Comment on lines -16 to -18
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: This movement break the kubebuilder (I think). If in the future you would like to add new webhook configuraiton it will end up here (before +kubebuilder:scaffold:crdkustomizewebhookpatch line).

For anyone that would look at this file it would be hard to understand if patches where added manually or by kubebuilder.

#+kubebuilder:scaffold:crdkustomizewebhookpatch

# [CERTMANAGER] To enable webhook, uncomment all the sections with [CERTMANAGER] prefix.
# patches here are for enabling the CA injection for each CRD
patches:
- path: patches/webhook_in_clusters.yaml
- path: patches/webhook_in_redpanda_consoles.yaml
- path: patches/webhook_in_cluster.redpanda.com_topics.yaml
- path: patches/cainjection_in_clusters.yaml
- path: patches/cainjection_in_redpanda_consoles.yaml
- path: patches/cainjection_in_cluster.redpanda.com_topics.yaml
#+kubebuilder:scaffold:crdkustomizecainjectionpatch
- path: patches/re-add-checksum-field_in_source.toolkit.fluxcd.io.yaml
target:
kind: CustomResourceDefinition
name: "^(buckets|helmcharts|helmrepositories).source.toolkit.fluxcd.io$"
- path: patches/re-add-checksum-field_in_gitrepositories.source.toolkit.fluxcd.io.yaml
target:
kind: CustomResourceDefinition
name: gitrepositories.source.toolkit.fluxcd.io
- path: patches/re-add-checksum-field_in_ocirepositories.source.toolkit.fluxcd.io.yaml
target:
kind: CustomResourceDefinition
name: ocirepositories.source.toolkit.fluxcd.io


# patches CRD to re-add removed fields from beta CRDs

# the following config is for teaching kustomize how to do kustomization for CRDs.
configurations:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
# The following patch adds the spec.versions.v1beta2.schema.openAPIV3Schema.properties.status.properties.artifact.properties.checksum property
# and the spec.versions.v1beta2.schema.openAPIV3Schema.properties.status.properties.includedArtifacts.items.properties.checksum property
# that was removed
- op: add
path: /spec/versions/1/schema/openAPIV3Schema/properties/status/properties/artifact/properties/checksum
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm afraid of the numbers like 0 or 1. If we change the order we will end up in the same situation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, that's the choice the jsonpatch project made. We have no choice. Luckily, kubebuilder does build the crd with the versions in the same order. If upstream removes a version, however, that will break this.

value:
type: string
description: Checksum is the SHA256 checksum of the Artifact file (obsolete)
- op: add
path: /spec/versions/1/schema/openAPIV3Schema/properties/status/properties/includedArtifacts/items/properties/checksum
value:
type: string
description: Checksum is the SHA256 checksum of the Artifact file (obsolete)
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
# The following patch adds the spec.versions.v1beta2.schema.openAPIV3Schema.properties.status.properties.artifact.properties.checksum property that was removed
# apiVersion: apiextensions.k8s.io/v1
- op: replace
path: /spec/versions/0/schema/openAPIV3Schema/properties/status/properties/artifact/properties/checksum
value:
type: string
description: Checksum is the SHA256 checksum of the Artifact file (obsolete)
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
# The following patch adds the spec.versions.v1beta2.schema.openAPIV3Schema.properties.status.properties.artifact.properties.checksum property that was removed
# apiVersion: apiextensions.k8s.io/v1
- op: replace
path: /spec/versions/1/schema/openAPIV3Schema/properties/status/properties/artifact/properties/checksum
value:
type: string
description: Checksum is the SHA256 checksum of the Artifact file (obsolete)
- op: replace
path: /spec/versions/0/schema/openAPIV3Schema/properties/status/properties/artifact/properties/checksum
value:
type: string
description: Checksum is the SHA256 checksum of the Artifact file (obsolete)
Loading