Skip to content

Commit e58f998

Browse files
authored
adding operator-sdk to the code-generator /bin folder (#305)
Issue #, if available: N/A Description of changes: Since there is a change in operator-sdk that isn't compatible with the way ACK `deployment.yaml`'s are built, it's best if we install and use a specific version in the `/bin` folder of the `code-generator`. This way no matter what version of `operator-sdk` a developer has installed, we can control what versions are used for local development and release of this project. By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license. Signed-off-by: Adam D. Cornett <[email protected]>
1 parent 3499451 commit e58f998

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

scripts/install-operator-sdk.sh

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,35 @@
88
# variable OPERATOR_SDK_VERSION and if that is not set, the value of the
99
# DEFAULT_OPERATOR_SDK_VERSION variable.
1010
#
11-
# NOTE: uses `sudo mv` to relocate a downloaded binary to /usr/local/bin/operator-sdk
11+
# NOTE: uses `sudo mv` to relocate a downloaded binary to /code-generator/bin/operator-sdk
1212

1313
set -eo pipefail
1414

1515
SCRIPTS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
1616
ROOT_DIR="$SCRIPTS_DIR/.."
17-
DEFAULT_OPERATOR_SDK_VERSION="1.7.1"
17+
DEFAULT_OPERATOR_SDK_BIN_PATH="$ROOT_DIR/../code-generator/bin"
18+
OPERATOR_SDK_BIN_PATH=${OPERATOR_SDK_BIN_PATH:-$DEFAULT_OPERATOR_SDK_BIN_PATH}
19+
DEFAULT_OPERATOR_SDK_VERSION="1.17.0"
1820

1921
source "${SCRIPTS_DIR}/lib/common.sh"
2022

2123
__operator_sdk_version="${1}"
2224
if [ "x${__operator_sdk_version}" == "x" ]; then
2325
__operator_sdk_version=${OPERATOR_SDK_VERSION:-$DEFAULT_OPERATOR_SDK_VERSION}
2426
fi
25-
if ! is_installed operator-sdk; then
27+
if ! is_installed ${OPERATOR_SDK_BIN_PATH}/operator-sdk; then
2628
__platform=$(uname | tr '[:upper:]' '[:lower:]')
2729
__tmp_install_dir=$(mktemp -d -t install-operator-sdk-XXX)
2830
__operator_sdk_url="https://github.com/operator-framework/operator-sdk/releases/download/v${__operator_sdk_version}/operator-sdk_${__platform}_amd64"
31+
32+
__install_dir=${OPERATOR_SDK_BIN_PATH}
33+
# If __install_dir does not exist, create it
34+
[[ -d $__install_dir ]] || mkdir -p "$__install_dir"
35+
__install_path="$__install_dir/operator-sdk"
36+
2937
echo -n "installing operator-sdk from ${__operator_sdk_url} ... "
3038
curl -sq -L ${__operator_sdk_url} --output ${__tmp_install_dir}/operator-sdk_${__platform}_amd64
3139
chmod +x ${__tmp_install_dir}/operator-sdk_${__platform}_amd64
32-
sudo mv ${__tmp_install_dir}/operator-sdk_${__platform}_amd64 /usr/local/bin/operator-sdk
40+
sudo mv "${__tmp_install_dir}/operator-sdk_${__platform}_amd64" "$__install_path"
3341
echo "ok."
34-
fi
42+
fi

scripts/olm-create-bundle.sh

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,16 @@ ROOT_DIR="$SCRIPTS_DIR/.."
1010
BUILD_DIR="$ROOT_DIR/build"
1111
DEFAULT_BUNDLE_CHANNEL="alpha"
1212
PRESERVE=${PRESERVE:-"false"}
13+
DEFAULT_OPERATOR_SDK_BIN_PATH="$ROOT_DIR/../code-generator/bin"
14+
OPERATOR_SDK_BIN_PATH=${OPERATOR_SDK_BIN_PATH:-$DEFAULT_OPERATOR_SDK_BIN_PATH}
1315

1416
export DOCKER_BUILDKIT=${DOCKER_BUILDKIT:-1}
1517

1618
source "$SCRIPTS_DIR/lib/common.sh"
1719

1820
check_is_installed uuidgen
1921
check_is_installed kustomize "You can install kustomize with the helper scripts/install-kustomize.sh"
20-
check_is_installed operator-sdk "You can install Operator SDK with the helmer scripts/install-operator-sdk.sh"
22+
check_is_installed ${OPERATOR_SDK_BIN_PATH}/operator-sdk "You can install Operator SDK with the helper scripts/install-operator-sdk.sh"
2123

2224
function clean_up {
2325
if [[ "$PRESERVE" == false ]]; then
@@ -64,6 +66,8 @@ Environment variables:
6466
Default: false
6567
BUNDLE_GENERATE_EXTRA_ARGS Extra arguments to pass into the command
6668
'operator-sdk generate bundle'.
69+
OPERATOR_SDK_BIN_PATH Overrides the path to the operator-sdk binary.
70+
Default: $DEFAULT_OPERATOR_SDK_BIN_PATH
6771
"
6872

6973
if [ $# -ne 2 ]; then
@@ -127,7 +131,7 @@ fi
127131
# in the controller-specific repositories.
128132
mkdir -p $BUNDLE_OUTPUT_PATH
129133
pushd $BUNDLE_OUTPUT_PATH 1> /dev/null
130-
kustomize build $tmp_kustomize_config_dir/manifests | operator-sdk generate bundle $opsdk_gen_bundle_args
134+
kustomize build $tmp_kustomize_config_dir/manifests | ${OPERATOR_SDK_BIN_PATH}/operator-sdk generate bundle $opsdk_gen_bundle_args
131135
popd 1> /dev/null
132136

133-
operator-sdk bundle validate $BUNDLE_OUTPUT_PATH/bundle
137+
${OPERATOR_SDK_BIN_PATH}/operator-sdk bundle validate $BUNDLE_OUTPUT_PATH/bundle

0 commit comments

Comments
 (0)