github.com/GoogleContainerTools/kpt@v1.0.0-beta.50.0.20240520170205-c25345ffcbee/scripts/generate-schema.sh (about) 1 #!/usr/bin/env bash 2 # Copyright 2021 The kpt Authors 3 # 4 # Licensed under the Apache License, Version 2.0 (the "License"); 5 # you may not use this file except in compliance with the License. 6 # You may obtain a copy of the License at 7 # 8 # http://www.apache.org/licenses/LICENSE-2.0 9 # 10 # Unless required by applicable law or agreed to in writing, software 11 # distributed under the License is distributed on an "AS IS" BASIS, 12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 # See the License for the specific language governing permissions and 14 # limitations under the License. 15 16 set -o errexit -o nounset -o pipefail -o posix 17 18 if ! command -v jq >/dev/null; then 19 echo "jq must be installed. Follow https://stedolan.github.io/jq/download/ to install jq." 20 exit 1 21 fi 22 23 REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)" 24 cd "${REPO_ROOT}" 25 26 make install-swagger 27 28 $GOBIN/swagger generate spec -m -w pkg/api/kptfile/v1 -o site/reference/schema/kptfile/kptfile.yaml 29 $GOBIN/swagger generate spec -m -w pkg/api/kptfile/v1 -o site/reference/schema/kptfile/kptfile.json 30 31 # We need to add schema header for schema to work in cloud-code. 32 # See https://github.com/GoogleContainerTools/kpt/pull/2520/files/aac23473c121252ec6341fdb2bcce389ae6cb122#r717867089 33 jq -s '.[0] * .[1]' scripts/schema-header.json site/reference/schema/kptfile/kptfile.json > /tmp/kptfile-schema.json 34 mv /tmp/kptfile-schema.json site/reference/schema/kptfile/kptfile.json