diff --git a/cluster/gce/kube-env.py b/cluster/gce/kube-env.py deleted file mode 100755 index a48c8799269..00000000000 --- a/cluster/gce/kube-env.py +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/python - -# Copyright 2015 Google Inc. All rights reserved. -# -# 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. - -import os -import sys -import yaml - -def mutate_env(path, var, value): - # Load the existing arguments - if os.path.exists(path): - args = yaml.load(open(path)) - else: - args = {} - args[var] = value - yaml.dump(args, stream=open(path, 'w'), default_flow_style=False) - -if __name__ == "__main__": - mutate_env(sys.argv[1], sys.argv[2], sys.argv[3]) diff --git a/cluster/gce/util.sh b/cluster/gce/util.sh index 77f668be465..706aca6f87f 100755 --- a/cluster/gce/util.sh +++ b/cluster/gce/util.sh @@ -418,13 +418,13 @@ function add-instance-metadata-from-file { done } -# Given a yaml file, add or mutate the given env variable +# Quote something appropriate for a yaml string. # -# TODO(zmerlynn): Yes, this is an O(n^2) build-up right now. If we end -# up with so many environment variables feeding into Salt that this -# matters, there's probably an issue... -function add-to-env { - ${KUBE_ROOT}/cluster/gce/kube-env.py "$1" "$2" "$3" +# TODO(zmerlynn): Note that this function doesn't so much "quote" as +# "strip out quotes", and we really should be using a YAML library for +# this, but PyYAML isn't shipped by default, and *rant rant rant ... SIGH* +function yaml-quote { + echo "'$(echo "${@}" | sed -e "s/'/''/g")'" } # $1: if 'true', we're building a master yaml, else a node @@ -433,29 +433,34 @@ function build-kube-env { local file=$2 rm -f ${file} - add-to-env ${file} ENV_TIMESTAMP "$(date -uIs)" # Just to track it - add-to-env ${file} KUBERNETES_MASTER "${master}" - add-to-env ${file} INSTANCE_PREFIX "${INSTANCE_PREFIX}" - add-to-env ${file} NODE_INSTANCE_PREFIX "${NODE_INSTANCE_PREFIX}" - add-to-env ${file} SERVER_BINARY_TAR_URL "${SERVER_BINARY_TAR_URL}" - add-to-env ${file} SALT_TAR_URL "${SALT_TAR_URL}" - add-to-env ${file} PORTAL_NET "${PORTAL_NET}" - add-to-env ${file} ENABLE_CLUSTER_MONITORING "${ENABLE_CLUSTER_MONITORING:-false}" - add-to-env ${file} ENABLE_NODE_MONITORING "${ENABLE_NODE_MONITORING:-false}" - add-to-env ${file} ENABLE_CLUSTER_LOGGING "${ENABLE_CLUSTER_LOGGING:-false}" - add-to-env ${file} ENABLE_NODE_LOGGING "${ENABLE_NODE_LOGGING:-false}" - add-to-env ${file} LOGGING_DESTINATION "${LOGGING_DESTINATION:-}" - add-to-env ${file} ELASTICSEARCH_LOGGING_REPLICAS "${ELASTICSEARCH_LOGGING_REPLICAS:-}" - add-to-env ${file} ENABLE_CLUSTER_DNS "${ENABLE_CLUSTER_DNS:-false}" - add-to-env ${file} DNS_REPLICAS "${DNS_REPLICAS:-}" - add-to-env ${file} DNS_SERVER_IP "${DNS_SERVER_IP:-}" - add-to-env ${file} DNS_DOMAIN "${DNS_DOMAIN:-}" - add-to-env ${file} MASTER_HTPASSWD "${MASTER_HTPASSWD}" + cat >$file <>$file <