Skip to content

Commit 83dd2e1

Browse files
committed
add yq as external tool
On-behalf-of: @SAP [email protected]
1 parent 765e3e3 commit 83dd2e1

File tree

3 files changed

+29
-14
lines changed

3 files changed

+29
-14
lines changed

Makefile

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,23 @@ $(BOILERPLATE):
8080
boilerplate \
8181
${BOILERPLATE_VERSION}
8282

83+
YQ = _tools/yq
84+
YQ_VERSION = 4.44.6
85+
86+
.PHONY: $(YQ)
87+
$(YQ):
88+
@UNCOMPRESSED=true hack/download-tool.sh \
89+
https://github.com/mikefarah/yq/releases/download/v${YQ_VERSION}/yq_${GOOS}_${GOARCH} \
90+
yq \
91+
${YQ_VERSION} \
92+
yq_*
93+
8394
.PHONY: test
8495
test:
8596
./hack/run-tests.sh
8697

8798
.PHONY: codegen
88-
codegen:
99+
codegen: $(YQ)
89100
hack/update-codegen-crds.sh
90101
hack/update-codegen-sdk.sh
91102

hack/download-tool.sh

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,21 @@ fi
4848
curl --fail -LO "$URL"
4949
archive="$(ls)"
5050

51-
case "$archive" in
52-
*.tar.gz | *.tgz)
53-
tar xzf "$archive"
54-
;;
55-
*.zip)
56-
unzip "$archive"
57-
;;
58-
*)
59-
echo "Unknown file type: $archive" >&2
60-
exit 1
61-
esac
51+
UNCOMPRESSED=${UNCOMPRESSED:-false}
52+
53+
if ! $UNCOMPRESSED; then
54+
case "$archive" in
55+
*.tar.gz | *.tgz)
56+
tar xzf "$archive"
57+
;;
58+
*.zip)
59+
unzip "$archive"
60+
;;
61+
*)
62+
echo "Unknown file type: $archive" >&2
63+
exit 1
64+
esac
65+
fi
6266

6367
mv $BINARY_PATTERN ../$BINARY
6468
chmod +x ../$BINARY

hack/update-codegen-crds.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,13 @@ go run sigs.k8s.io/controller-tools/cmd/controller-gen \
5353
output:crd:dir=./internal/sync/crd/
5454

5555
beautify() {
56-
yq --inplace --no-doc 'del(.metadata.creationTimestamp)' "$1"
56+
_tools/yq --inplace --no-doc 'del(.metadata.creationTimestamp)' "$1"
5757

5858
# kcp 0.24 added support for conversions, but as long as our integration tests run on <0.24,
5959
# we must remove any possible conversion field or else older kcp versions will not be able to
6060
# load the generated ARS.
6161
# TODO: Remove this hack once everything in this repository is kcp 0.24+.
62-
yq --inplace --no-doc 'del(.spec.conversion)' "$1"
62+
_tools/yq --inplace --no-doc 'del(.spec.conversion)' "$1"
6363

6464
mv "$1" "$1.bak"
6565
echo -e "# This file has been generated by hack/update-codegen-crds.sh, DO NOT EDIT.\n" > "$1"

0 commit comments

Comments
 (0)