Skip to content

Commit 619ff29

Browse files
Update required controller-gen to v0.6.1 (#135)
Issue #, if available: aws-controllers-k8s/community#873 Description of changes: - Removes duplication of the `CONTROLLER_TOOLS_VERSION` variable - Deletes the defunct `k8s.sh` script (not being used anywhere in this repo) I have tested the new `controller-gen` against the `dynamodb` controller and saw no changes in output CRDs (except for the version number in an annotation). None of the breaking changes called out in the release between `0.4.0` and `0.6.1` should have any effect on our generator. By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent 5088c40 commit 619ff29

File tree

5 files changed

+22
-156
lines changed

5 files changed

+22
-156
lines changed

scripts/build-controller-release.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ BIN_DIR="$ROOT_DIR/bin"
1111
ACK_GENERATE_OLM=${ACK_GENERATE_OLM:-"false"}
1212

1313
source "$SCRIPTS_DIR/lib/common.sh"
14-
source "$SCRIPTS_DIR/lib/k8s.sh"
1514

1615
check_is_installed controller-gen "You can install controller-gen with the helper scripts/install-controller-gen.sh"
1716
check_is_installed helm "You can install Helm with the helper scripts/install-helm.sh"

scripts/build-controller.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ ROOT_DIR="$SCRIPTS_DIR/.."
99
BIN_DIR="$ROOT_DIR/bin"
1010

1111
source "$SCRIPTS_DIR/lib/common.sh"
12-
source "$SCRIPTS_DIR/lib/k8s.sh"
1312

1413
check_is_installed controller-gen "You can install controller-gen with the helper scripts/install-controller-gen.sh"
1514

scripts/install-controller-gen.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,10 @@ set -eo pipefail
1919

2020
SCRIPTS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
2121
ROOT_DIR="$SCRIPTS_DIR/.."
22-
CONTROLLER_TOOLS_VERSION="v0.4.0"
2322

2423
source "$SCRIPTS_DIR/lib/common.sh"
25-
source "$SCRIPTS_DIR/lib/k8s.sh"
2624

27-
if ! is_installed controller-gen; then
25+
if ! is_installed controller-gen || ! k8s_controller_gen_version_equals "$CONTROLLER_TOOLS_VERSION"; then
2826
# GOBIN and GOPATH are not always set, so default to GOPATH from `go env`
2927
__GOPATH=$(go env GOPATH)
3028
__install_dir=${GOBIN:-$__GOPATH/bin}

scripts/lib/common.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/usr/bin/env bash
22

3+
CONTROLLER_TOOLS_VERSION="v0.6.1"
4+
35
# setting the -x option if debugging is true
46
if [[ "${DEBUG:-"false"}" = "true" ]]; then
57
set -x
@@ -88,3 +90,22 @@ debug_msg() {
8890
fi
8991
echo "$__debug_prefix$__indent$__msg"
9092
}
93+
94+
# controller_gen_version_equals accepts a string version and returns 0 if the
95+
# installed version of controller-gen matches the supplied version, otherwise
96+
# returns 1
97+
#
98+
# Usage:
99+
#
100+
# if controller_gen_version_equals "v0.4.0"; then
101+
# echo "controller-gen is at version 0.4.0"
102+
# fi
103+
k8s_controller_gen_version_equals() {
104+
currentver="$(controller-gen --version | cut -d' ' -f2 | tr -d '\n')";
105+
requiredver="$1";
106+
if [ "$currentver" = "$requiredver" ]; then
107+
return 0
108+
else
109+
return 1
110+
fi;
111+
}

scripts/lib/k8s.sh

Lines changed: 0 additions & 151 deletions
This file was deleted.

0 commit comments

Comments
 (0)