Path: blob/main/components/gitpod-protocol/go/scripts/generate-config.sh
2500 views
#!/bin/bash1# Copyright (c) 2022 Gitpod GmbH. All rights reserved.2# Licensed under the GNU Affero General Public License (AGPL).3# See License.AGPL.txt in the project root for license information.456COMPONENT_PATH="$(dirname "$0")/.."7echo "Component Path: ${COMPONENT_PATH}"89if [ "${LEEWAY_BUILD-}" == "true" ]; then10CONFIG_PATH="./_deps/components-gitpod-protocol--gitpod-schema/gitpod-schema.json"11else12CONFIG_PATH="$COMPONENT_PATH/../data/gitpod-schema.json"13fi14echo "Config Path: ${CONFIG_PATH}"1516GITPOD_CONFIG_TYPE_PATH="$COMPONENT_PATH/gitpod-config-types.go"17echo "Config Types Path: ${GITPOD_CONFIG_TYPE_PATH}"18if [ "${LEEWAY_BUILD-}" == "true" ]; then19git init -q20git add "$GITPOD_CONFIG_TYPE_PATH"21fi2223go install github.com/a-h/generate/...@latest2425schema-generate -p protocol "$CONFIG_PATH" > "$GITPOD_CONFIG_TYPE_PATH"2627# remove custom marshal logic to allow additional properties28sed -i '/func /,$d' "$GITPOD_CONFIG_TYPE_PATH" #functions29sed -i '5,10d' "$GITPOD_CONFIG_TYPE_PATH" #imports30# support yaml and json31sed -i -E 's/(json:)(".*")/yaml:\2 \1\2/g' "$GITPOD_CONFIG_TYPE_PATH"32gofmt -w "$GITPOD_CONFIG_TYPE_PATH"3334if [ "${LEEWAY_BUILD-}" == "true" ]; then35./_deps/dev-addlicense--app/addlicense "$GITPOD_CONFIG_TYPE_PATH"36else37leeway run components:update-license-header38fi3940git diff --exit-code "$GITPOD_CONFIG_TYPE_PATH"414243