-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1009 from sthaha/fix-cluster-env-source
feat(dev): allow .env to be sourced when bringing up/down a cluster
- Loading branch information
Showing
5 changed files
with
63 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,3 +39,4 @@ local-dev-cluster | |
*.test | ||
*.cache | ||
/tmp | ||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# This file is part of the Kepler project | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
|
||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
# Copyright 2022 The Kepler Contributors | ||
# | ||
set -eu -o pipefail | ||
|
||
# NOTE: assumes that the project root is one level up | ||
PROJECT_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." >/dev/null 2>&1 && pwd) | ||
declare -r PROJECT_ROOT | ||
|
||
# NOTE: this allows common settings to be stored as `.env` file | ||
# shellcheck disable=SC1091 | ||
[[ -f "$PROJECT_ROOT/.env" ]] && source "$PROJECT_ROOT/.env" | ||
|
||
# NOTE: these settings can be overridden in the .env file | ||
declare -r LOCAL_DEV_CLUSTER_DIR="${LOCAL_DEV_CLUSTER_DIR:-"$PROJECT_ROOT/local-dev-cluster"}" | ||
declare -r LOCAL_DEV_CLUSTER_VERSION="${LOCAL_DEV_CLUSTER_VERSION:-v0.0.3}" | ||
|
||
# Supported CLUSTER_PROVIDER are kind,microshift | ||
export CLUSTER_PROVIDER=${CLUSTER_PROVIDER:-kind} | ||
|
||
clone_local_dev_cluster() { | ||
if [ -d "$LOCAL_DEV_CLUSTER_DIR" ]; then | ||
echo "using local local-dev-cluster" | ||
return 0 | ||
fi | ||
|
||
echo "downloading local-dev-cluster" | ||
git clone -b "$LOCAL_DEV_CLUSTER_VERSION" \ | ||
https://github.com/sustainable-computing-io/local-dev-cluster.git \ | ||
--depth=1 \ | ||
"$LOCAL_DEV_CLUSTER_DIR" | ||
} | ||
|
||
main() { | ||
local op="$1" | ||
shift | ||
|
||
cd "$PROJECT_ROOT" | ||
|
||
clone_local_dev_cluster | ||
echo "Bringing cluster - $op" | ||
"$LOCAL_DEV_CLUSTER_DIR/main.sh" "$op" | ||
} | ||
|
||
main "$@" |