-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split kustomize'd CRD files for building with "up xpkg batch"
Signed-off-by: Alper Rifat Ulucinar <[email protected]>
- Loading branch information
Showing
5 changed files
with
61 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,6 @@ patches: | |
target: | ||
group: apiextensions.k8s.io | ||
kind: CustomResourceDefinition | ||
|
||
transformers: | ||
- transformer.yaml |
42 changes: 42 additions & 0 deletions
42
package/kustomize/plugin/providers.upbound.io/splittransformer/SplitTransformer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -aeuo pipefail | ||
|
||
# skip the config directory argument | ||
shift | ||
output_dir="$1" | ||
|
||
temp_file="$(mktemp)" | ||
|
||
function save_crd { | ||
group="$(sed -nr 's/^[[:space:]]*group:[[:space:]]*(.+)/\1/p' "${temp_file}")" | ||
plural="$(sed -nr 's/^[[:space:]]*plural:[[:space:]]*(.+)/\1/p' "${temp_file}")" | ||
tee < "${temp_file}" "${output_dir}/${group//apiextensions.k8s.io?/}_${plural}.yaml" | ||
|
||
# Reset the temporary file | ||
: > "${temp_file}" | ||
} | ||
|
||
while IFS= read -r line || [[ -n "${line}" ]]; do | ||
if [[ "$line" == "---" && -s "${temp_file}" ]]; then | ||
save_crd | ||
else | ||
if [[ ! -s "${temp_file}" ]]; then | ||
echo "---" >> "${temp_file}" | ||
fi | ||
|
||
echo "${line}" >> "${temp_file}" | ||
fi | ||
done | ||
|
||
# Save the last document if there is one | ||
if [[ -s "${temp_file}" ]]; then | ||
save_crd | ||
fi | ||
|
||
function cleanup { | ||
# Clean up the temporary file | ||
rm "${temp_file}" | ||
} | ||
|
||
trap cleanup EXIT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
apiVersion: providers.upbound.io | ||
kind: SplitTransformer | ||
metadata: | ||
name: splitter | ||
argsOneLiner: ../crds |