diff --git a/Tiltfile b/Tiltfile index 51fc1cc529e..e07549bd16e 100644 --- a/Tiltfile +++ b/Tiltfile @@ -1,6 +1,5 @@ # -*- mode: Python -*- -kustomize_cmd = "./hack/tools/bin/kustomize" envsubst_cmd = "./hack/tools/bin/envsubst" update_settings(k8s_upsert_timeout_secs=60) # on first tilt up, often can take longer than 30 seconds @@ -152,7 +151,7 @@ COPY manager . # Build CAPZ and add feature gates def capz(): # Apply the kustomized yaml for this provider - yaml = str(kustomize("./config")) + yaml = str(kustomizesub("./config")) substitutions = settings.get("kustomize_substitutions", {}) for substitution in substitutions: value = substitutions[substitution] @@ -200,7 +199,6 @@ def capz(): ignore = ["templates"] ) - yaml = envsubst(yaml) k8s_yaml(blob(yaml)) @@ -333,11 +331,14 @@ def base64_decode(to_decode): decode_blob = local("echo '{}' | base64 --decode -".format(to_decode), quiet=True) return str(decode_blob) - def envsubst(yaml): yaml = yaml.replace('"', '\\"') return str(local("echo \"{}\" | {}".format(yaml, envsubst_cmd), quiet=True)) +def kustomizesub(folder): + yaml = local('hack/kustomize-sub.sh {}'.format(folder), quiet=True) + return yaml + ############################## # Actual work happens here ############################## diff --git a/hack/kustomize-sub.sh b/hack/kustomize-sub.sh new file mode 100755 index 00000000000..f8df5ded816 --- /dev/null +++ b/hack/kustomize-sub.sh @@ -0,0 +1,21 @@ +#!/bin/bash +# Copyright 2018 The Kubernetes Authors. +# +# 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. + +set -o errexit +set -o nounset +set -o pipefail + +root=$(dirname "${BASH_SOURCE[0]}") +$root/tools/bin/kustomize build $1 | $root/tools/bin/envsubst \ No newline at end of file