Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
gitpod-io
GitHub Repository: gitpod-io/gitpod
Path: blob/main/components/gitpod-protocol/go/scripts/generate-config.sh
2500 views
1
#!/bin/bash
2
# Copyright (c) 2022 Gitpod GmbH. All rights reserved.
3
# Licensed under the GNU Affero General Public License (AGPL).
4
# See License.AGPL.txt in the project root for license information.
5
6
7
COMPONENT_PATH="$(dirname "$0")/.."
8
echo "Component Path: ${COMPONENT_PATH}"
9
10
if [ "${LEEWAY_BUILD-}" == "true" ]; then
11
CONFIG_PATH="./_deps/components-gitpod-protocol--gitpod-schema/gitpod-schema.json"
12
else
13
CONFIG_PATH="$COMPONENT_PATH/../data/gitpod-schema.json"
14
fi
15
echo "Config Path: ${CONFIG_PATH}"
16
17
GITPOD_CONFIG_TYPE_PATH="$COMPONENT_PATH/gitpod-config-types.go"
18
echo "Config Types Path: ${GITPOD_CONFIG_TYPE_PATH}"
19
if [ "${LEEWAY_BUILD-}" == "true" ]; then
20
git init -q
21
git add "$GITPOD_CONFIG_TYPE_PATH"
22
fi
23
24
go install github.com/a-h/generate/...@latest
25
26
schema-generate -p protocol "$CONFIG_PATH" > "$GITPOD_CONFIG_TYPE_PATH"
27
28
# remove custom marshal logic to allow additional properties
29
sed -i '/func /,$d' "$GITPOD_CONFIG_TYPE_PATH" #functions
30
sed -i '5,10d' "$GITPOD_CONFIG_TYPE_PATH" #imports
31
# support yaml and json
32
sed -i -E 's/(json:)(".*")/yaml:\2 \1\2/g' "$GITPOD_CONFIG_TYPE_PATH"
33
gofmt -w "$GITPOD_CONFIG_TYPE_PATH"
34
35
if [ "${LEEWAY_BUILD-}" == "true" ]; then
36
./_deps/dev-addlicense--app/addlicense "$GITPOD_CONFIG_TYPE_PATH"
37
else
38
leeway run components:update-license-header
39
fi
40
41
git diff --exit-code "$GITPOD_CONFIG_TYPE_PATH"
42
43