-
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.
feat(dev): allow .env to be sourced when bringing up/down a cluster
Previously, cluster-up.sh and cluster-down.sh both had similar code to clone the local-dev-cluster repo. This is now moved to a single script. The scripts also `cd` in local-dev-cluster dir which meant that a .env file at the root of kepler project will not be honored by the local-dev-cluster/main.sh. This has been fixed by invoking the main.sh from the root of kepler project itself This commit modifies the cluster-up and down targets to * clone local-dev-cluster to tmp dir (which is ignored by git) * sources .env in project root where settings that needs to passed down to local-dev-cluster can be kept. E.g. ```sh PROMETHEUS_ENABLE=true GRAFANA_ENABLE=true ``` Signed-off-by: Sunil Thaha <[email protected]>
- 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 "$@" |