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

retain original manifests #131

Merged
merged 1 commit into from
Feb 4, 2024
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
# SPDX-License-Identifier: 0BSD

target/
crd-catalog/**/*.fixed
16 changes: 12 additions & 4 deletions code-generator/create-custom-resources.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ for file in ./crd-catalog/**/*.yaml; do
path="${file%.*}"
ignore_file="${path}.ignore"
args_file="${path}.args"
fixup_file="${path}.fixup"
fixed_file="${path}.fixed"
file_to_read="${file}"
crd=$(basename "${path}")
version=$(basename "$(dirname "${file}")")
group=$(basename "$(dirname "$(dirname "${file}")")")
Expand All @@ -31,13 +34,18 @@ for file in ./crd-catalog/**/*.yaml; do
else
mkdir --parents "${version_directory}"

if [ -f "${fixup_file}" ]; then
"${fixup_file}" > "${fixed_file}"
file_to_read="${fixed_file}"
fi

if [ -f "${args_file}" ]; then
if ! xargs --arg-file="${args_file}" --delimiter='\n' kopium --docs --filename="${file}" > "${version_directory}/${resource_filename}.rs"; then
echo " error in ${file}"
if ! xargs --arg-file="${args_file}" --delimiter='\n' kopium --docs --filename="${file_to_read}" > "${version_directory}/${resource_filename}.rs"; then
echo " error in ${file_to_read}"
fi
else
if ! kopium --docs --filename="${file}" --derive=Default --derive=PartialEq > "${version_directory}/${resource_filename}.rs"; then
echo " error in ${file}"
if ! kopium --docs --filename="${file_to_read}" --derive=Default --derive=PartialEq > "${version_directory}/${resource_filename}.rs"; then
echo " error in ${file_to_read}"
fi
fi
fi
Expand Down
3 changes: 0 additions & 3 deletions code-generator/generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ cargo run --package code-generator --bin crd_v1_fetcher "${FILTER}"
# generate dep5 file
cargo run --package code-generator --bin dep5_generator

# fix YAMLs
./code-generator/run-fixups.sh "${FILTER}"

# generate Rust code
./code-generator/create-custom-resources.sh "${FILTER}"

Expand Down
18 changes: 0 additions & 18 deletions code-generator/run-fixups.sh

This file was deleted.

16 changes: 16 additions & 0 deletions crd-catalog/kyverno/kyverno/kyverno.io/v1/clusterpolicies.fixup
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash

# SPDX-FileCopyrightText: The kube-custom-resources-rs Authors
# SPDX-License-Identifier: 0BSD

folder=$(dirname "${0}")
crd=$(basename "${0}" .fixup)
yaml=$(<"${folder}/${crd}.yaml")

properties='.spec.versions[0].schema.openAPIV3Schema.properties.spec.properties'

echo "${yaml}" |
yq "del(${properties}.validationFailureAction.enum[] | select(. == \"audit\"))" |
yq "del(${properties}.validationFailureAction.enum[] | select(. == \"enforce\"))" |
yq "del(${properties}.validationFailureActionOverrides.items.properties.action.enum[] | select(. == \"audit\"))" |
yq "del(${properties}.validationFailureActionOverrides.items.properties.action.enum[] | select(. == \"enforce\"))"
29 changes: 0 additions & 29 deletions crd-catalog/kyverno/kyverno/kyverno.io/v1/fixup.sh

This file was deleted.

16 changes: 16 additions & 0 deletions crd-catalog/kyverno/kyverno/kyverno.io/v1/policies.fixup
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash

# SPDX-FileCopyrightText: The kube-custom-resources-rs Authors
# SPDX-License-Identifier: 0BSD

folder=$(dirname "${0}")
crd=$(basename "${0}" .fixup)
yaml=$(<"${folder}/${crd}.yaml")

properties='.spec.versions[0].schema.openAPIV3Schema.properties.spec.properties'

echo "${yaml}" |
yq "del(${properties}.validationFailureAction.enum[] | select(. == \"audit\"))" |
yq "del(${properties}.validationFailureAction.enum[] | select(. == \"enforce\"))" |
yq "del(${properties}.validationFailureActionOverrides.items.properties.action.enum[] | select(. == \"audit\"))" |
yq "del(${properties}.validationFailureActionOverrides.items.properties.action.enum[] | select(. == \"enforce\"))"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--derive=PartialEq
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--derive=PartialEq
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash

# SPDX-FileCopyrightText: The kube-custom-resources-rs Authors
# SPDX-License-Identifier: 0BSD

folder=$(dirname "${0}")
crd=$(basename "${0}" .fixup)
yaml=$(<"${folder}/${crd}.yaml")

properties='.spec.versions[0].schema.openAPIV3Schema.properties.spec.properties'

echo "${yaml}" |
yq "del(${properties}.validationFailureAction.enum[] | select(. == \"audit\"))" |
yq "del(${properties}.validationFailureAction.enum[] | select(. == \"enforce\"))" |
yq "del(${properties}.validationFailureActionOverrides.items.properties.action.enum[] | select(. == \"audit\"))" |
yq "del(${properties}.validationFailureActionOverrides.items.properties.action.enum[] | select(. == \"enforce\"))"
29 changes: 0 additions & 29 deletions crd-catalog/kyverno/kyverno/kyverno.io/v2beta1/fixup.sh

This file was deleted.

16 changes: 16 additions & 0 deletions crd-catalog/kyverno/kyverno/kyverno.io/v2beta1/policies.fixup
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash

# SPDX-FileCopyrightText: The kube-custom-resources-rs Authors
# SPDX-License-Identifier: 0BSD

folder=$(dirname "${0}")
crd=$(basename "${0}" .fixup)
yaml=$(<"${folder}/${crd}.yaml")

properties='.spec.versions[0].schema.openAPIV3Schema.properties.spec.properties'

echo "${yaml}" |
yq "del(${properties}.validationFailureAction.enum[] | select(. == \"audit\"))" |
yq "del(${properties}.validationFailureAction.enum[] | select(. == \"enforce\"))" |
yq "del(${properties}.validationFailureActionOverrides.items.properties.action.enum[] | select(. == \"audit\"))" |
yq "del(${properties}.validationFailureActionOverrides.items.properties.action.enum[] | select(. == \"enforce\"))"
17 changes: 17 additions & 0 deletions crd-catalog/openshift/api/operator.openshift.io/v1/consoles.fixup
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash

# SPDX-FileCopyrightText: The kube-custom-resources-rs Authors
# SPDX-License-Identifier: 0BSD

folder=$(dirname "${0}")
crd=$(basename "${0}" .fixup)
yaml=$(<"${folder}/${crd}.yaml")

brand='.spec.versions[0].schema.openAPIV3Schema.properties.spec.properties.customization.properties.brand'

echo "${yaml}" |
yq "del(${brand}.enum[] | select(. == \"online\"))" |
yq "del(${brand}.enum[] | select(. == \"okd\"))" |
yq "del(${brand}.enum[] | select(. == \"ocp\"))" |
yq "del(${brand}.enum[] | select(. == \"dedicated\"))" |
yq "del(${brand}.enum[] | select(. == \"azure\"))"
Loading