|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# Copyright 2020 Cortex Labs, Inc. |
| 4 | +# |
| 5 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | +# you may not use this file except in compliance with the License. |
| 7 | +# You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, software |
| 12 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | +# See the License for the specific language governing permissions and |
| 15 | +# limitations under the License. |
| 16 | + |
| 17 | +set -euo pipefail |
| 18 | + |
| 19 | +arg1=${1:-""} |
| 20 | + |
| 21 | +provider="" |
| 22 | +if [ "$arg1" = "--aws" ]; then |
| 23 | + provider="aws" |
| 24 | +elif [ "$arg1" = "--gcp" ]; then |
| 25 | + provider="gcp" |
| 26 | +else |
| 27 | + echo "provider must be set: either pass in the --aws or the --gcp flag" |
| 28 | + exit 1 |
| 29 | +fi |
| 30 | + |
| 31 | +ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")"/.. >/dev/null && pwd)" |
| 32 | +DEBUG_CMD="dlv --listen=:2345 --headless=true --api-version=2 debug $ROOT/pkg/operator --output ${ROOT}/bin/__debug_bin" |
| 33 | + |
| 34 | +kill $(pgrep -f "${DEBUG_CMD}") >/dev/null 2>&1 || true |
| 35 | +kill $(pgrep -f __debug_bin) >/dev/null 2>&1 || true |
| 36 | + |
| 37 | +eval $(python3 $ROOT/manager/cluster_config_env.py "$ROOT/dev/config/cluster-${provider}.yaml") |
| 38 | + |
| 39 | +if [ "$provider" = "aws" ]; then |
| 40 | + export CORTEX_DEV_DEFAULT_PREDICTOR_IMAGE_REGISTRY="$CORTEX_DEV_DEFAULT_PREDICTOR_IMAGE_REGISTRY_AWS" |
| 41 | + export CLUSTER_AWS_ACCESS_KEY_ID="${CLUSTER_AWS_ACCESS_KEY_ID:-$AWS_ACCESS_KEY_ID}" |
| 42 | + export CLUSTER_AWS_SECRET_ACCESS_KEY="${CLUSTER_AWS_SECRET_ACCESS_KEY:-$AWS_SECRET_ACCESS_KEY}" |
| 43 | +else |
| 44 | + export CORTEX_DEV_DEFAULT_PREDICTOR_IMAGE_REGISTRY="$CORTEX_DEV_DEFAULT_PREDICTOR_IMAGE_REGISTRY_GCP" |
| 45 | +fi |
| 46 | + |
| 47 | +python3 $ROOT/dev/update_cli_config.py "$HOME/.cortex/cli.yaml" "${CORTEX_CLUSTER_NAME}-${provider}" "$provider" "http://localhost:8888" |
| 48 | + |
| 49 | +cp -r $ROOT/dev/config/cluster-${provider}.yaml ~/.cortex/cluster-dev.yaml |
| 50 | + |
| 51 | +if grep -qiP '^telemetry:\s*false\s*$' ~/.cortex/cli.yaml; then |
| 52 | + echo "telemetry: false" >> ~/.cortex/cluster-dev.yaml |
| 53 | +fi |
| 54 | + |
| 55 | +export CORTEX_OPERATOR_IN_CLUSTER=false |
| 56 | +export CORTEX_CLUSTER_CONFIG_PATH=~/.cortex/cluster-dev.yaml |
| 57 | + |
| 58 | +mkdir -p $ROOT/bin |
| 59 | +echo 'starting local operator in debug mode...' && eval "${DEBUG_CMD}" |
0 commit comments