Skip to content

Commit e49120f

Browse files
committed
adding operator-sdk to the code-generator /bin folder and using that to generate the bundle this allows for the user to have one version locally but pin this project to a known working version
Signed-off-by: Adam D. Cornett <adc@redhat.com>
1 parent 7052f68 commit e49120f

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

scripts/install-operator-sdk.sh

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,29 @@ 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/../../aws-controllers-k8s/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}; 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: 5 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/../../aws-controllers-k8s/code-generator/bin/operator-sdk"
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} "You can install Operator SDK with the helper scripts/install-operator-sdk.sh"
2123

2224
function clean_up {
2325
if [[ "$PRESERVE" == false ]]; then
@@ -127,7 +129,7 @@ fi
127129
# in the controller-specific repositories.
128130
mkdir -p $BUNDLE_OUTPUT_PATH
129131
pushd $BUNDLE_OUTPUT_PATH 1> /dev/null
130-
kustomize build $tmp_kustomize_config_dir/manifests | operator-sdk generate bundle $opsdk_gen_bundle_args
132+
kustomize build $tmp_kustomize_config_dir/manifests | ${OPERATOR_SDK_BIN_PATH} generate bundle $opsdk_gen_bundle_args
131133
popd 1> /dev/null
132134

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

0 commit comments

Comments
 (0)