-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add structural OpenAPI schema to Tekton CRDs
- Implement POSIX script to update the OpenAPI schema to Tekton CRDs using controller-gen - Add updated CRDs with OpenAPI schema Note1: the current script 'hack/update-schemas.sh' return several errors/warnings and status code 1 from execution of the controller-gen CLI due to issues when parsing the schema from the source code. Note2: the controller-gen does not preserve the field "x-kubernetes-preserve-unknown-fields: true" in the root of the schema. This field is added by the 'hack/update-schemas.sh' script Note3: Markes were addded to avoid creating the schema for recursive types that results in invalid schemata. Related issue: kubernetes-sigs/controller-tools#585 Note4: Schema for PipelineSpec was omitted from PipelineRun to reduce size. A comment was added in the description of the field for the user to refer to the schema of Pipeline. Note5: Schema of TaskSpec was omitted from TaskRun to reduce size. A comment was added in the description of the field for the user to refer to the schema of Task.
- Loading branch information
1 parent
f7097db
commit f1f45fb
Showing
18 changed files
with
102,310 additions
and
322 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/bin/sh | ||
|
||
CRD_PATH=./config/300-crds | ||
|
||
for FILENAME in `find $CRD_PATH -type f`; | ||
do | ||
echo "Processing file $FILENAME" | ||
|
||
# NOTE: APIs for the group tekton.dev are implemented under ./pkg/apis/pipeline, | ||
# while the ResolutionRequest from group resolution.tekton.dev is implemented under ./pkg/apis/resolution | ||
|
||
GROUP=$(grep -E '^ group:' $FILENAME) | ||
GROUP=${GROUP#" group: "} | ||
if [ "$GROUP" = "tekton.dev" ]; then | ||
API_SUBDIR='pipeline' | ||
else | ||
API_SUBDIR=${GROUP%".tekton.dev"} | ||
fi | ||
echo "GROUP: $GROUP" | ||
echo "API_SUBDIR: $API_SUBDIR" | ||
|
||
TEMP_DIR=$(mktemp -d) | ||
cp -p $FILENAME $TEMP_DIR/. | ||
go run sigs.k8s.io/controller-tools/cmd/[email protected] \ | ||
schemapatch:manifests=$TEMP_DIR,generateEmbeddedObjectMeta=false \ | ||
output:dir=$CRD_PATH \ | ||
paths=./pkg/apis/$API_SUBDIR/... | ||
|
||
# NOTE: the controller-gen removes the field 'x-kubernetes-preserve-unknown-fields: true' | ||
# The command below restores the field. | ||
cat >$TEMP_DIR/tmp-fix <<EOF | ||
# One can use x-kubernetes-preserve-unknown-fields: true | ||
# at the root of the schema (and inside any properties, additionalProperties) | ||
# to get the traditional CRD behaviour that nothing is pruned, despite | ||
# setting spec.preserveUnknownProperties: false. | ||
# | ||
# See https://kubernetes.io/blog/2019/06/20/crd-structural-schema/ | ||
# See issue: https://github.com/knative/serving/issues/912 | ||
x-kubernetes-preserve-unknown-fields: true | ||
EOF | ||
FIELD_IDENTATION="$(grep 'openAPIV3Schema:' $FILENAME | head -1)" | ||
FIELD_IDENTATION="${FIELD_IDENTATION%openAPIV3Schema:} " | ||
sed -i "s/^/$FIELD_IDENTATION/" $TEMP_DIR/tmp-fix | ||
|
||
if ! grep -qF "$(head -n1 $TEMP_DIR/tmp-fix)" $FILENAME; then | ||
sed -i "/ openAPIV3Schema:/r $TEMP_DIR/tmp-fix" $FILENAME | ||
fi | ||
|
||
rm -rf $TEMP_DIR | ||
done |
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
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
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