Standardize how we refer to the kubernetes root.

Now use $KUBE_ROOT as the variable pretty much everywhere.
This commit is contained in:
Joe Beda 2014-10-03 14:58:49 -07:00
parent 38d5906044
commit d43a6ec5a3
42 changed files with 172 additions and 156 deletions

View File

@ -17,9 +17,10 @@
# This script sets up a go workspace locally and builds all go components. # This script sets up a go workspace locally and builds all go components.
# You can 'source' this file if you want to set up GOPATH in your local shell. # You can 'source' this file if you want to set up GOPATH in your local shell.
cd $(dirname "${BASH_SOURCE}")/../.. >/dev/null KUBE_ROOT=$(dirname "${BASH_SOURCE}")/../..
readonly KUBE_REPO_ROOT="${PWD}" cd "${KUBE_ROOT}"
readonly KUBE_TARGET="${KUBE_REPO_ROOT}/_output/build"
readonly KUBE_TARGET="${KUBE_ROOT}/_output/build"
readonly KUBE_GO_PACKAGE=github.com/GoogleCloudPlatform/kubernetes readonly KUBE_GO_PACKAGE=github.com/GoogleCloudPlatform/kubernetes
mkdir -p "${KUBE_TARGET}" mkdir -p "${KUBE_TARGET}"
@ -39,7 +40,7 @@ function kube::build::make_binary() {
local -r bin=${gopkg##*/} local -r bin=${gopkg##*/}
echo "+++ Building ${bin} for ${GOOS}/${GOARCH}" echo "+++ Building ${bin} for ${GOOS}/${GOARCH}"
pushd "${KUBE_REPO_ROOT}" >/dev/null pushd "${KUBE_ROOT}" >/dev/null
godep go build -ldflags "${KUBE_LD_FLAGS-}" -o "${ARCH_TARGET}/${bin}" "${gopkg}" godep go build -ldflags "${KUBE_LD_FLAGS-}" -o "${ARCH_TARGET}/${bin}" "${gopkg}"
popd >/dev/null popd >/dev/null
} }

View File

@ -16,6 +16,7 @@
set -e set -e
source $(dirname $0)/common.sh KUBE_ROOT=$(dirname "${BASH_SOURCE}")/../..
source "${KUBE_ROOT}/build/build-image/common.sh"
kube::build::make_binaries "$@" kube::build::make_binaries "$@"

View File

@ -16,7 +16,8 @@
set -e set -e
source $(dirname $0)/common.sh KUBE_ROOT=$(dirname "${BASH_SOURCE}")/../..
source "${KUBE_ROOT}/build/build-image/common.sh"
readonly CROSS_BINARIES=( readonly CROSS_BINARIES=(
./cmd/kubecfg ./cmd/kubecfg

View File

@ -16,20 +16,21 @@
set -e set -e
source $(dirname $0)/common.sh KUBE_ROOT=$(dirname "${BASH_SOURCE}")/../..
source "${KUBE_ROOT}/build/build-image/common.sh"
kube::build::make_binaries "./cmd/integration" kube::build::make_binaries "./cmd/integration"
readonly ETCD_DIR="${KUBE_REPO_ROOT}/_output/etcd" readonly ETCD_DIR="${KUBE_ROOT}/_output/etcd"
mkdir -p "${ETCD_DIR}" mkdir -p "${ETCD_DIR}"
echo "+++ Running integration test" echo "+++ Running integration test"
etcd -name test -data-dir ${ETCD_DIR} > "${KUBE_REPO_ROOT}/_output/etcd.log" & etcd -name test -data-dir ${ETCD_DIR} > "${KUBE_ROOT}/_output/etcd.log" &
readonly ETCD_PID=$! readonly ETCD_PID=$!
sleep 5 sleep 5
${KUBE_TARGET}/linux/amd64/integration "${KUBE_TARGET}/linux/amd64/integration"
kill $ETCD_PID kill $ETCD_PID

View File

@ -16,7 +16,8 @@
set -e set -e
source $(dirname $0)/common.sh KUBE_ROOT=$(dirname "${BASH_SOURCE}")/../..
source "${KUBE_ROOT}/build/build-image/common.sh"
echo "+++ Running unit tests" echo "+++ Running unit tests"

View File

@ -19,7 +19,8 @@ set -o errexit
set -o nounset set -o nounset
set -o pipefail set -o pipefail
cd $(dirname "${BASH_SOURCE}")/.. KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
cd "${KUBE_ROOT}"
source hack/config-go.sh source hack/config-go.sh
@ -36,8 +37,6 @@ readonly KUBE_GCS_MAKE_PUBLIC="${KUBE_GCS_MAKE_PUBLIC:-y}"
# Constants # Constants
readonly KUBE_REPO_ROOT="${PWD}"
readonly KUBE_BUILD_IMAGE_REPO=kube-build readonly KUBE_BUILD_IMAGE_REPO=kube-build
readonly KUBE_BUILD_IMAGE_TAG=build readonly KUBE_BUILD_IMAGE_TAG=build
readonly KUBE_BUILD_IMAGE="${KUBE_BUILD_IMAGE_REPO}:${KUBE_BUILD_IMAGE_TAG}" readonly KUBE_BUILD_IMAGE="${KUBE_BUILD_IMAGE_REPO}:${KUBE_BUILD_IMAGE_TAG}"
@ -49,7 +48,7 @@ readonly KUBE_GO_PACKAGE="github.com/GoogleCloudPlatform/kubernetes"
# #
# Note that here "LOCAL" is local to the docker daemon. In the boot2docker case # Note that here "LOCAL" is local to the docker daemon. In the boot2docker case
# this is still inside the VM. We use the same directory in both cases though. # this is still inside the VM. We use the same directory in both cases though.
readonly LOCAL_OUTPUT_ROOT="${KUBE_REPO_ROOT}/_output" readonly LOCAL_OUTPUT_ROOT="${KUBE_ROOT}/_output"
readonly LOCAL_OUTPUT_BUILD="${LOCAL_OUTPUT_ROOT}/build" readonly LOCAL_OUTPUT_BUILD="${LOCAL_OUTPUT_ROOT}/build"
readonly REMOTE_OUTPUT_ROOT="/go/src/${KUBE_GO_PACKAGE}/_output" readonly REMOTE_OUTPUT_ROOT="/go/src/${KUBE_GO_PACKAGE}/_output"
readonly REMOTE_OUTPUT_DIR="${REMOTE_OUTPUT_ROOT}/build" readonly REMOTE_OUTPUT_DIR="${REMOTE_OUTPUT_ROOT}/build"
@ -374,7 +373,7 @@ function kube::release::package_salt_tarball() {
rm -rf "${release_stage}" rm -rf "${release_stage}"
mkdir -p "${release_stage}" mkdir -p "${release_stage}"
cp -R "${KUBE_REPO_ROOT}/cluster/saltbase" "${release_stage}/" cp -R "${KUBE_ROOT}/cluster/saltbase" "${release_stage}/"
local package_name="${RELEASE_DIR}/kubernetes-salt.tar.gz" local package_name="${RELEASE_DIR}/kubernetes-salt.tar.gz"
tar czf "${package_name}" -C "${release_stage}/.." . tar czf "${package_name}" -C "${release_stage}/.." .
@ -396,7 +395,7 @@ function kube::release::package_full_tarball() {
# We want everything in /cluster except saltbase. That is only needed on the # We want everything in /cluster except saltbase. That is only needed on the
# server. # server.
cp -R "${KUBE_REPO_ROOT}/cluster" "${release_stage}/" cp -R "${KUBE_ROOT}/cluster" "${release_stage}/"
rm -rf "${release_stage}/cluster/saltbase" rm -rf "${release_stage}/cluster/saltbase"
mkdir -p "${release_stage}/server" mkdir -p "${release_stage}/server"
@ -404,12 +403,12 @@ function kube::release::package_full_tarball() {
cp "${RELEASE_DIR}"/kubernetes-server-*.tar.gz "${release_stage}/server/" cp "${RELEASE_DIR}"/kubernetes-server-*.tar.gz "${release_stage}/server/"
mkdir -p "${release_stage}/third_party" mkdir -p "${release_stage}/third_party"
cp -R "${KUBE_REPO_ROOT}/third_party/htpasswd" "${release_stage}/third_party/htpasswd" cp -R "${KUBE_ROOT}/third_party/htpasswd" "${release_stage}/third_party/htpasswd"
cp -R "${KUBE_REPO_ROOT}/examples" "${release_stage}/" cp -R "${KUBE_ROOT}/examples" "${release_stage}/"
cp "${KUBE_REPO_ROOT}/README.md" "${release_stage}/" cp "${KUBE_ROOT}/README.md" "${release_stage}/"
cp "${KUBE_REPO_ROOT}/LICENSE" "${release_stage}/" cp "${KUBE_ROOT}/LICENSE" "${release_stage}/"
cp "${KUBE_REPO_ROOT}/Vagrantfile" "${release_stage}/" cp "${KUBE_ROOT}/Vagrantfile" "${release_stage}/"
local package_name="${RELEASE_DIR}/kubernetes.tar.gz" local package_name="${RELEASE_DIR}/kubernetes.tar.gz"
tar czf "${package_name}" -C "${release_stage}/.." . tar czf "${package_name}" -C "${release_stage}/.." .

View File

@ -19,7 +19,8 @@
# This is a no-op on Linux when the Docker daemon is local. This is only # This is a no-op on Linux when the Docker daemon is local. This is only
# necessary on Mac OS X with boot2docker. # necessary on Mac OS X with boot2docker.
source $(dirname "${BASH_SOURCE}")/common.sh KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
source "$KUBE_ROOT/build/common.sh"
kube::build::verify_prereqs kube::build::verify_prereqs
kube::build::copy_output kube::build::copy_output

View File

@ -19,7 +19,8 @@
# This makes the docker build image, builds the binaries and copies them out # This makes the docker build image, builds the binaries and copies them out
# of the docker container. # of the docker container.
source $(dirname "${BASH_SOURCE}")/common.sh KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
source "$KUBE_ROOT/build/common.sh"
kube::build::verify_prereqs kube::build::verify_prereqs
kube::build::build_image kube::build::build_image

View File

@ -21,7 +21,8 @@
# directory. It will then copy over the Dockerfile and build the kube-build # directory. It will then copy over the Dockerfile and build the kube-build
# image. # image.
source $(dirname "${BASH_SOURCE}")/common.sh KUBE_ROOT="$(dirname "${BASH_SOURCE}")/.."
source "$KUBE_ROOT/build/common.sh"
kube::build::verify_prereqs kube::build::verify_prereqs
kube::build::build_image kube::build::build_image

View File

@ -16,7 +16,8 @@
# Clean out the output directory on the docker host. # Clean out the output directory on the docker host.
source $(dirname "${BASH_SOURCE}")/common.sh KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
source "$KUBE_ROOT/build/common.sh"
kube::build::verify_prereqs kube::build::verify_prereqs
kube::build::clean_output kube::build::clean_output

View File

@ -19,7 +19,8 @@
# This makes the docker build image, builds the cross binaries and copies them # This makes the docker build image, builds the cross binaries and copies them
# out of the docker container. # out of the docker container.
source $(dirname "${BASH_SOURCE}")/common.sh KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
source "$KUBE_ROOT/build/common.sh"
kube::build::verify_prereqs kube::build::verify_prereqs
kube::build::build_image kube::build::build_image

View File

@ -19,7 +19,8 @@
# This script will make the 'run image' after building all of the necessary # This script will make the 'run image' after building all of the necessary
# binaries. # binaries.
source $(dirname "${BASH_SOURCE}")/common.sh KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
source "$KUBE_ROOT/build/common.sh"
kube::build::verify_prereqs kube::build::verify_prereqs
kube::build::build_image kube::build::build_image

View File

@ -18,7 +18,8 @@
# images and other build artifacts. All intermediate artifacts will be hosted # images and other build artifacts. All intermediate artifacts will be hosted
# publicly on Google Cloud Storage currently. # publicly on Google Cloud Storage currently.
source $(dirname "${BASH_SOURCE}")/common.sh KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
source "$KUBE_ROOT/build/common.sh"
kube::build::verify_prereqs kube::build::verify_prereqs
kube::build::build_image kube::build::build_image

View File

@ -16,7 +16,8 @@
# Run the integration test. # Run the integration test.
source $(dirname "${BASH_SOURCE}")/common.sh KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
source "$KUBE_ROOT/build/common.sh"
kube::build::verify_prereqs kube::build::verify_prereqs
kube::build::build_image kube::build::build_image

View File

@ -16,7 +16,8 @@
# Run all of the golang unit tests. # Run all of the golang unit tests.
source $(dirname "${BASH_SOURCE}")/common.sh KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
source "$KUBE_ROOT/build/common.sh"
kube::build::verify_prereqs kube::build::verify_prereqs
kube::build::build_image kube::build::build_image

View File

@ -18,7 +18,8 @@
# #
# This container will have a snapshot of the current sources. # This container will have a snapshot of the current sources.
source $(dirname "${BASH_SOURCE}")/common.sh KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
source "$KUBE_ROOT/build/common.sh"
kube::build::verify_prereqs kube::build::verify_prereqs
kube::build::build_image kube::build::build_image

View File

@ -18,15 +18,11 @@
# Use the config file specified in $KUBE_CONFIG_FILE, or default to # Use the config file specified in $KUBE_CONFIG_FILE, or default to
# config-default.sh. # config-default.sh.
source $(dirname ${BASH_SOURCE})/${KUBE_CONFIG_FILE-"config-default.sh"} KUBE_ROOT=$(dirname "${BASH_SOURCE}")/../..
source "${KUBE_ROOT}/cluster/gce/${KUBE_CONFIG_FILE-"config-default.sh"}"
# Verify prereqs # Verify prereqs
#
# Vars set:
# KUBE_REPO_ROOT
function verify-prereqs { function verify-prereqs {
KUBE_REPO_ROOT="$(dirname ${BASH_SOURCE})/../.."
for x in gcloud gcutil gsutil; do for x in gcloud gcutil gsutil; do
if [ "$(which $x)" == "" ]; then if [ "$(which $x)" == "" ]; then
echo "Can't find $x in PATH, please fix and retry." echo "Can't find $x in PATH, please fix and retry."
@ -41,18 +37,18 @@ function verify-prereqs {
# SERVER_BINARY_TAR # SERVER_BINARY_TAR
# SALT_TAR # SALT_TAR
function find-release-tars { function find-release-tars {
SERVER_BINARY_TAR="${KUBE_REPO_ROOT}/server/kubernetes-server-linux-amd64.tar.gz" SERVER_BINARY_TAR="${KUBE_ROOT}/server/kubernetes-server-linux-amd64.tar.gz"
if [[ ! -f "$SERVER_BINARY_TAR" ]]; then if [[ ! -f "$SERVER_BINARY_TAR" ]]; then
SERVER_BINARY_TAR="${KUBE_REPO_ROOT}/_output/release-tars/kubernetes-server-linux-amd64.tar.gz" SERVER_BINARY_TAR="${KUBE_ROOT}/_output/release-tars/kubernetes-server-linux-amd64.tar.gz"
fi fi
if [[ ! -f "$SERVER_BINARY_TAR" ]]; then if [[ ! -f "$SERVER_BINARY_TAR" ]]; then
echo "!!! Cannot find kubernetes-server-linux-amd64.tar.gz" echo "!!! Cannot find kubernetes-server-linux-amd64.tar.gz"
exit 1 exit 1
fi fi
SALT_TAR="${KUBE_REPO_ROOT}/server/kubernetes-salt.tar.gz" SALT_TAR="${KUBE_ROOT}/server/kubernetes-salt.tar.gz"
if [[ ! -f "$SALT_TAR" ]]; then if [[ ! -f "$SALT_TAR" ]]; then
SALT_TAR="${KUBE_REPO_ROOT}/_output/release-tars/kubernetes-salt.tar.gz" SALT_TAR="${KUBE_ROOT}/_output/release-tars/kubernetes-salt.tar.gz"
fi fi
if [[ ! -f "$SALT_TAR" ]]; then if [[ ! -f "$SALT_TAR" ]]; then
echo "!!! Cannot find kubernetes-salt.tar.gz" echo "!!! Cannot find kubernetes-salt.tar.gz"
@ -195,7 +191,7 @@ EOF
# Instantiate a kubernetes cluster # Instantiate a kubernetes cluster
# #
# Assumed vars # Assumed vars
# KUBE_REPO_ROOT # KUBE_ROOT
# <Various vars set in config file> # <Various vars set in config file>
function kube-up { function kube-up {
# Detect the project into $PROJECT if it isn't set # Detect the project into $PROJECT if it isn't set
@ -210,7 +206,7 @@ function kube-up {
trap 'rm -rf "${kube_temp}"' EXIT trap 'rm -rf "${kube_temp}"' EXIT
get-password get-password
python "${KUBE_REPO_ROOT}/third_party/htpasswd/htpasswd.py" \ python "${KUBE_ROOT}/third_party/htpasswd/htpasswd.py" \
-b -c "${kube_temp}/htpasswd" "$KUBE_USER" "$KUBE_PASSWORD" -b -c "${kube_temp}/htpasswd" "$KUBE_USER" "$KUBE_PASSWORD"
local htpasswd=$(cat "${kube_temp}/htpasswd") local htpasswd=$(cat "${kube_temp}/htpasswd")
@ -253,8 +249,8 @@ function kube-up {
echo "readonly SERVER_BINARY_TAR_URL='${SERVER_BINARY_TAR_URL}'" echo "readonly SERVER_BINARY_TAR_URL='${SERVER_BINARY_TAR_URL}'"
echo "readonly SALT_TAR_URL='${SALT_TAR_URL}'" echo "readonly SALT_TAR_URL='${SALT_TAR_URL}'"
echo "readonly MASTER_HTPASSWD='${htpasswd}'" echo "readonly MASTER_HTPASSWD='${htpasswd}'"
grep -v "^#" "${KUBE_REPO_ROOT}/cluster/gce/templates/download-release.sh" grep -v "^#" "${KUBE_ROOT}/cluster/gce/templates/download-release.sh"
grep -v "^#" "${KUBE_REPO_ROOT}/cluster/gce/templates/salt-master.sh" grep -v "^#" "${KUBE_ROOT}/cluster/gce/templates/salt-master.sh"
) > "${kube_temp}/master-start.sh" ) > "${kube_temp}/master-start.sh"
gcutil addinstance ${MASTER_NAME}\ gcutil addinstance ${MASTER_NAME}\
@ -275,7 +271,7 @@ function kube-up {
echo "#! /bin/bash" echo "#! /bin/bash"
echo "MASTER_NAME='${MASTER_NAME}'" echo "MASTER_NAME='${MASTER_NAME}'"
echo "MINION_IP_RANGE=${MINION_IP_RANGES[$i]}" echo "MINION_IP_RANGE=${MINION_IP_RANGES[$i]}"
grep -v "^#" "${KUBE_REPO_ROOT}/cluster/gce/templates/salt-minion.sh" grep -v "^#" "${KUBE_ROOT}/cluster/gce/templates/salt-minion.sh"
) > "${kube_temp}/minion-start-${i}.sh" ) > "${kube_temp}/minion-start-${i}.sh"
gcutil addfirewall ${MINION_NAMES[$i]}-all \ gcutil addfirewall ${MINION_NAMES[$i]}-all \
@ -448,7 +444,7 @@ function kube-push {
echo "cd /var/cache/kubernetes-install" echo "cd /var/cache/kubernetes-install"
echo "readonly SERVER_BINARY_TAR_URL=${SERVER_BINARY_TAR_URL}" echo "readonly SERVER_BINARY_TAR_URL=${SERVER_BINARY_TAR_URL}"
echo "readonly SALT_TAR_URL=${SALT_TAR_URL}" echo "readonly SALT_TAR_URL=${SALT_TAR_URL}"
grep -v "^#" "${KUBE_REPO_ROOT}/cluster/gce/templates/download-release.sh" grep -v "^#" "${KUBE_ROOT}/cluster/gce/templates/download-release.sh"
echo "echo Executing configuration" echo "echo Executing configuration"
echo "sudo salt '*' mine.update" echo "sudo salt '*' mine.update"
echo "sudo salt --force-color '*' state.highstate" echo "sudo salt --force-color '*' state.highstate"
@ -472,12 +468,12 @@ function kube-push {
# Execute prior to running tests to build a release if required for env. # Execute prior to running tests to build a release if required for env.
# #
# Assumed Vars: # Assumed Vars:
# KUBE_REPO_ROOT # KUBE_ROOT
function test-build-release { function test-build-release {
# Build source # Build source
"${KUBE_REPO_ROOT}/hack/build-go.sh" "${KUBE_ROOT}/hack/build-go.sh"
# Make a release # Make a release
"${KUBE_REPO_ROOT}/release/release.sh" "${KUBE_ROOT}/release/release.sh"
} }
# Execute prior to running tests to initialize required structure. This is # Execute prior to running tests to initialize required structure. This is
@ -520,5 +516,5 @@ function test-teardown {
--sleep_between_polls "${POLL_SLEEP_INTERVAL}" \ --sleep_between_polls "${POLL_SLEEP_INTERVAL}" \
--force \ --force \
${MINION_TAG}-${INSTANCE_PREFIX}-http-alt || true > /dev/null ${MINION_TAG}-${INSTANCE_PREFIX}-http-alt || true > /dev/null
$(dirname $0)/../cluster/kube-down.sh > /dev/null "${KUBE_ROOT}/cluster/kube-down.sh" > /dev/null
} }

View File

@ -19,8 +19,9 @@
# exit on any error # exit on any error
set -e set -e
source $(dirname $0)/kube-env.sh KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
source $(dirname $0)/$KUBERNETES_PROVIDER/util.sh source "${KUBE_ROOT}/cluster/kube-env.sh"
source "${KUBE_ROOT}/cluster/${KUBERNETES_PROVIDER}/util.sh"
echo "Bringing down cluster using provider: $KUBERNETES_PROVIDER" echo "Bringing down cluster using provider: $KUBERNETES_PROVIDER"

View File

@ -22,14 +22,15 @@
# exit on any error # exit on any error
set -e set -e
source $(dirname $0)/kube-env.sh KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
source $(dirname $0)/$KUBERNETES_PROVIDER/util.sh source "${KUBE_ROOT}/cluster/kube-env.sh"
source "${KUBE_ROOT}/cluster/${KUBERNETES_PROVIDER}/util.sh"
echo "Updating cluster using provider: $KUBERNETES_PROVIDER" echo "Updating cluster using provider: $KUBERNETES_PROVIDER"
verify-prereqs verify-prereqs
kube-push kube-push
source $(dirname $0)/validate-cluster.sh "${KUBE_ROOT}/cluster/validate-cluster.sh"
echo "Done" echo "Done"

View File

@ -23,14 +23,15 @@
# exit on any error # exit on any error
set -e set -e
source $(dirname $0)/kube-env.sh KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
source $(dirname $0)/$KUBERNETES_PROVIDER/util.sh source "${KUBE_ROOT}/cluster/kube-env.sh"
source "${KUBE_ROOT}/cluster/${KUBERNETES_PROVIDER}/util.sh"
echo "Starting cluster using provider: $KUBERNETES_PROVIDER" echo "Starting cluster using provider: $KUBERNETES_PROVIDER"
verify-prereqs verify-prereqs
kube-up kube-up
source $(dirname $0)/validate-cluster.sh "${KUBE_ROOT}/cluster/validate-cluster.sh"
echo "Done" echo "Done"

View File

@ -14,9 +14,9 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
ROOT_DIR="$(dirname ${BASH_SOURCE})/.." KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
source "${ROOT_DIR}/cluster/kube-env.sh" source "${KUBE_ROOT}/cluster/kube-env.sh"
source "${ROOT_DIR}/cluster/${KUBERNETES_PROVIDER}/util.sh" source "${KUBE_ROOT}/cluster/${KUBERNETES_PROVIDER}/util.sh"
# Detect the OS name/arch so that we can find our binary # Detect the OS name/arch so that we can find our binary
case "$(uname -s)" in case "$(uname -s)" in
@ -52,9 +52,9 @@ case "$(uname -m)" in
exit 1 exit 1
esac esac
kubecfg="${ROOT_DIR}/_output/build/${host_os}/${host_arch}/kubecfg" kubecfg="${KUBE_ROOT}/_output/build/${host_os}/${host_arch}/kubecfg"
if [[ ! -x "$kubecfg" ]]; then if [[ ! -x "$kubecfg" ]]; then
kubecfg="${ROOT_DIR}/platforms/${host_os}/${host_arch}/kubecfg" kubecfg="${KUBE_ROOT}/platforms/${host_os}/${host_arch}/kubecfg"
fi fi
if [[ ! -x "$kubecfg" ]]; then if [[ ! -x "$kubecfg" ]]; then
echo "It looks as if you don't have a compiled version of Kubernetes. If you" >&2 echo "It looks as if you don't have a compiled version of Kubernetes. If you" >&2

View File

@ -21,7 +21,7 @@ set -o errexit
set -o nounset set -o nounset
set -o pipefail set -o pipefail
readonly SALTBASE="$(dirname $0)" readonly SALT_ROOT=$(dirname "${BASH_SOURCE}")
readonly SERVER_BIN_TAR=${1-} readonly SERVER_BIN_TAR=${1-}
if [[ -z "$SERVER_BIN_TAR" ]]; then if [[ -z "$SERVER_BIN_TAR" ]]; then
@ -38,10 +38,10 @@ trap "rm -rf ${KUBE_TEMP}" EXIT
echo "+++ Installing salt files" echo "+++ Installing salt files"
mkdir -p /srv mkdir -p /srv
# This bash voodoo will prepend $SALTBASE to the start of each item in the # This bash voodoo will prepend $SALT_ROOT to the start of each item in the
# $SALTDIRS array # $SALTDIRS array
readonly SALTDIRS=(salt pillar reactor) readonly SALTDIRS=(salt pillar reactor)
cp -R --preserve=mode "${SALTDIRS[@]/#/${SALTBASE}/}" /srv/ cp -R --preserve=mode "${SALTDIRS[@]/#/${SALT_ROOT}/}" /srv/
echo "+++ Install binaries from tar: $1" echo "+++ Install binaries from tar: $1"

View File

@ -15,4 +15,5 @@
# limitations under the License. # limitations under the License.
## Contains configuration values for interacting with the Vagrant cluster in test mode ## Contains configuration values for interacting with the Vagrant cluster in test mode
source $(dirname ${BASH_SOURCE})/config-default.sh KUBE_ROOT=$(dirname "${BASH_SOURCE}")/../..
source "${KUBE_ROOT}/cluster/vagrant/config-default.sh"

View File

@ -53,7 +53,8 @@ while [[ $# > 0 ]]; do
esac esac
done done
cd $(dirname ${BASH_SOURCE})/../../ KUBE_ROOT=$(dirname "${BASH_SOURCE}")/../..
cd "${KUBE_ROOT}"
echo All verbose output will be redirected to $logfile, use --logfile option to change. echo All verbose output will be redirected to $logfile, use --logfile option to change.

View File

@ -16,19 +16,9 @@
# exit on any error # exit on any error
set -e set -e
source $(dirname $0)/provision-config.sh
# # Install Docker on master to run the build. This is a necessary chunk of KUBE_ROOT=$(dirname "${BASH_SOURCE}")/../..
# # bootstrapping. source "${KUBE_ROOT}/cluster/vagrant/provision-config.sh"
# yum install -y docker-io
# SYSTEMD_LOG_LEVEL=notice systemctl enable docker
# systemctl start docker
# # Build release
# echo "Building release"
# pushd /vagrant
# bash -x ./build/release.sh
# popd
function release_not_found() { function release_not_found() {
echo "It looks as if you don't have a compiled version of Kubernetes. If you" >&2 echo "It looks as if you don't have a compiled version of Kubernetes. If you" >&2
@ -117,10 +107,10 @@ state_output: mixed
EOF EOF
# Configure nginx authorization # Configure nginx authorization
mkdir -p $KUBE_TEMP mkdir -p "$KUBE_TEMP"
mkdir -p /srv/salt/nginx mkdir -p /srv/salt/nginx
python $(dirname $0)/../../third_party/htpasswd/htpasswd.py -b -c ${KUBE_TEMP}/htpasswd $MASTER_USER $MASTER_PASSWD python "${KUBE_ROOT}/third_party/htpasswd/htpasswd.py" -b -c "${KUBE_TEMP}/htpasswd" "$MASTER_USER" "$MASTER_PASSWD"
MASTER_HTPASSWD=$(cat ${KUBE_TEMP}/htpasswd) MASTER_HTPASSWD=$(cat "${KUBE_TEMP}/htpasswd")
echo $MASTER_HTPASSWD > /srv/salt/nginx/htpasswd echo $MASTER_HTPASSWD > /srv/salt/nginx/htpasswd
# we will run provision to update code each time we test, so we do not want to do salt install each time # we will run provision to update code each time we test, so we do not want to do salt install each time

View File

@ -16,7 +16,8 @@
# exit on any error # exit on any error
set -e set -e
source $(dirname $0)/provision-config.sh KUBE_ROOT=$(dirname "${BASH_SOURCE}")/../..
source "${KUBE_ROOT}/cluster/vagrant/provision-config.sh"
MINION_IP=$4 MINION_IP=$4
@ -30,11 +31,11 @@ fi
minion_ip_array=(${MINION_IPS//,/ }) minion_ip_array=(${MINION_IPS//,/ })
for (( i=0; i<${#MINION_NAMES[@]}; i++)); do for (( i=0; i<${#MINION_NAMES[@]}; i++)); do
minion=${MINION_NAMES[$i]} minion=${MINION_NAMES[$i]}
ip=${minion_ip_array[$i]} ip=${minion_ip_array[$i]}
if [ ! "$(cat /etc/hosts | grep $minion)" ]; then if [ ! "$(cat /etc/hosts | grep $minion)" ]; then
echo "Adding $minion to hosts file" echo "Adding $minion to hosts file"
echo "$ip $minion" >> /etc/hosts echo "$ip $minion" >> /etc/hosts
fi fi
done done
# Let the minion know who its master is # Let the minion know who its master is
@ -61,4 +62,4 @@ if ! which salt-minion >/dev/null 2>&1; then
fi fi
# run the networking setup # run the networking setup
$(dirname $0)/provision-network.sh $@ "${KUBE_ROOT}/cluster/vagrant/provision-network.sh" $@

View File

@ -16,7 +16,8 @@
# exit on any error # exit on any error
set -e set -e
source $(dirname $0)/provision-config.sh KUBE_ROOT=$(dirname "${BASH_SOURCE}")/../..
source "${KUBE_ROOT}/cluster/vagrant/provision-config.sh"
MINION_IP=$4 MINION_IP=$4
MINION_ID=$5 MINION_ID=$5

View File

@ -16,7 +16,8 @@
# A library of helper functions that each provider hosting Kubernetes must implement to use cluster/kube-*.sh scripts. # A library of helper functions that each provider hosting Kubernetes must implement to use cluster/kube-*.sh scripts.
source $(dirname ${BASH_SOURCE})/${KUBE_CONFIG_FILE-"config-default.sh"} KUBE_ROOT=$(dirname "${BASH_SOURCE}")/../..
source "${KUBE_ROOT}/cluster/vagrant/${KUBE_CONFIG_FILE-"config-default.sh"}"
function detect-master () { function detect-master () {
echo "KUBE_MASTER_IP: ${KUBE_MASTER_IP}" echo "KUBE_MASTER_IP: ${KUBE_MASTER_IP}"
@ -91,7 +92,7 @@ function kube-up {
local count="0" local count="0"
until [[ "$count" == "1" ]]; do until [[ "$count" == "1" ]]; do
local minions local minions
minions=$("$(dirname $0)/cluster/kubecfg.sh" -template '{{range.Items}}{{.ID}}:{{end}}' list minions) minions=$("${KUBE_ROOT}/cluster/kubecfg.sh" -template '{{range.Items}}{{.ID}}:{{end}}' list minions)
count=$(echo $minions | grep -c "${MINION_NAMES[i]}") || { count=$(echo $minions | grep -c "${MINION_NAMES[i]}") || {
printf "." printf "."
sleep 2 sleep 2

View File

@ -23,15 +23,16 @@
# exit on any error # exit on any error
set -e set -e
source $(dirname $0)/kube-env.sh KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
source $(dirname $0)/$KUBERNETES_PROVIDER/util.sh source "${KUBE_ROOT}/cluster/kube-env.sh"
source "${KUBE_ROOT}/cluster/${KUBERNETES_PROVIDER}/util.sh"
get-password get-password
detect-master > /dev/null detect-master > /dev/null
detect-minions > /dev/null detect-minions > /dev/null
MINIONS_FILE=/tmp/minions MINIONS_FILE=/tmp/minions
$(dirname $0)/kubecfg.sh -template '{{range.Items}}{{.ID}}:{{end}}' list minions > ${MINIONS_FILE} "${KUBE_ROOT}/cluster/kubecfg.sh" -template '{{range.Items}}{{.ID}}:{{end}}' list minions > ${MINIONS_FILE}
# On vSphere, use minion IPs as their names # On vSphere, use minion IPs as their names
if [ "$KUBERNETES_PROVIDER" == "vsphere" ]; then if [ "$KUBERNETES_PROVIDER" == "vsphere" ]; then

View File

@ -20,13 +20,13 @@ set -o errexit
set -o nounset set -o nounset
set -o pipefail set -o pipefail
hackdir=$(CDPATH="" cd $(dirname $0); pwd) KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
# Set the environment variables required by the build. # Set the environment variables required by the build.
. "${hackdir}/config-go.sh" source "${KUBE_ROOT}/hack/config-go.sh"
# Go to the top of the tree. # Go to the top of the tree.
cd "${KUBE_REPO_ROOT}" cd "${KUBE_ROOT}"
# Check for `go` binary and set ${GOPATH}. # Check for `go` binary and set ${GOPATH}.
kube::setup_go_environment kube::setup_go_environment

View File

@ -36,7 +36,7 @@
# the final GOPATH. # the final GOPATH.
# --- Environment Variables set by sourcing config-go.sh --- # --- Environment Variables set by sourcing config-go.sh ---
# KUBE_REPO_ROOT - Path to the top of the build tree. # KUBE_ROOT - Path to the top of the build tree.
# KUBE_TARGET - Path where output Go files are saved. # KUBE_TARGET - Path where output Go files are saved.
# KUBE_GO_PACKAGE - Full name of the Kubernetes Go package. # KUBE_GO_PACKAGE - Full name of the Kubernetes Go package.
@ -61,7 +61,7 @@ kube::version_ldflags() {
unset CDPATH unset CDPATH
cd "${KUBE_REPO_ROOT}" cd "${KUBE_ROOT}"
declare -a ldflags=() declare -a ldflags=()
if [[ -n ${KUBE_GIT_COMMIT-} ]] || KUBE_GIT_COMMIT=$(git rev-parse "HEAD^{commit}" 2>/dev/null); then if [[ -n ${KUBE_GIT_COMMIT-} ]] || KUBE_GIT_COMMIT=$(git rev-parse "HEAD^{commit}" 2>/dev/null); then
@ -143,7 +143,7 @@ kube::setup_go_environment() {
# Append the tree maintained by `godep` to the GOPATH unless KUBE_NO_GODEPS # Append the tree maintained by `godep` to the GOPATH unless KUBE_NO_GODEPS
# is defined. # is defined.
if [[ -z ${KUBE_NO_GODEPS:-} ]]; then if [[ -z ${KUBE_NO_GODEPS:-} ]]; then
GOPATH="${GOPATH}:${KUBE_REPO_ROOT}/Godeps/_workspace" GOPATH="${GOPATH}:${KUBE_ROOT}/Godeps/_workspace"
fi fi
export GOPATH export GOPATH
@ -172,18 +172,19 @@ kube::binaries_from_targets() {
} }
# --- Environment Variables --- # --- Environment Variables ---
# Make ${KUBE_REPO_ROOT} an absolute path. # Make ${KUBE_ROOT} an absolute path.
KUBE_REPO_ROOT=$( KUBE_ROOT=$(
set -eu set -o errexit
set -o nounset
set -o pipefail
unset CDPATH unset CDPATH
scripts_dir=$(dirname "${BASH_SOURCE[0]}") kube_root=$(dirname "${BASH_SOURCE}")/..
cd "${scripts_dir}" cd "${kube_root}"
cd ..
pwd pwd
) )
export KUBE_REPO_ROOT export KUBE_ROOT
KUBE_TARGET="${KUBE_REPO_ROOT}/_output/go" KUBE_TARGET="${KUBE_ROOT}/_output/go"
mkdir -p "${KUBE_TARGET}" mkdir -p "${KUBE_TARGET}"
export KUBE_TARGET export KUBE_TARGET
@ -195,12 +196,14 @@ export KUBE_GO_PACKAGE
# So that Go knows how to import Kubernetes sources by full path. # So that Go knows how to import Kubernetes sources by full path.
# Use a subshell to avoid leaking these variables. # Use a subshell to avoid leaking these variables.
set -eu set -o errexit
set -o nounset
set -o pipefail
go_pkg_dir="${KUBE_TARGET}/src/${KUBE_GO_PACKAGE}" go_pkg_dir="${KUBE_TARGET}/src/${KUBE_GO_PACKAGE}"
go_pkg_basedir=$(dirname "${go_pkg_dir}") go_pkg_basedir=$(dirname "${go_pkg_dir}")
mkdir -p "${go_pkg_basedir}" mkdir -p "${go_pkg_basedir}"
rm -f "${go_pkg_dir}" rm -f "${go_pkg_dir}"
# TODO: This symlink should be relative. # TODO: This symlink should be relative.
ln -s "${KUBE_REPO_ROOT}" "${go_pkg_dir}" ln -s "${KUBE_ROOT}" "${go_pkg_dir}"
) )

View File

@ -16,12 +16,14 @@
# This script will build a dev release and push it to an existing cluster. # This script will build a dev release and push it to an existing cluster.
# Then build a release KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
$(dirname $0)/../build/release.sh
# Build a release
"${KUBE_ROOT}/build/release.sh"
if [ "$?" != "0" ]; then if [ "$?" != "0" ]; then
echo "Building a release failed!" echo "Building a release failed!"
exit 1 exit 1
fi fi
# Now push this out to the cluster # Now push this out to the cluster
$(dirname $0)/../cluster/kube-push.sh "${KUBE_ROOT}/cluster/kube-push.sh"

View File

@ -19,12 +19,14 @@
set -e set -e
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
# Then build a release # Then build a release
$(dirname $0)/../build/release.sh "${KUBE_ROOT}/build/release.sh"
if [ "$?" != "0" ]; then if [ "$?" != "0" ]; then
echo "Building the release failed!" echo "Building the release failed!"
exit 1 exit 1
fi fi
# Now bring a new cluster up with that release. # Now bring a new cluster up with that release.
$(dirname $0)/../cluster/kube-up.sh "${KUBE_ROOT}/cluster/kube-up.sh"

View File

@ -20,8 +20,8 @@
# Exit on error # Exit on error
set -e set -e
source "${KUBE_REPO_ROOT}/cluster/kube-env.sh" source "${KUBE_ROOT}/cluster/kube-env.sh"
source "${KUBE_REPO_ROOT}/cluster/$KUBERNETES_PROVIDER/util.sh" source "${KUBE_ROOT}/cluster/$KUBERNETES_PROVIDER/util.sh"
# Launch a container # Launch a container
$KUBECFG -p 8080:80 run dockerfile/nginx 2 myNginx $KUBECFG -p 8080:80 run dockerfile/nginx 2 myNginx

View File

@ -20,10 +20,10 @@
set -e set -e
source "${KUBE_REPO_ROOT}/cluster/kube-env.sh" source "${KUBE_ROOT}/cluster/kube-env.sh"
source "${KUBE_REPO_ROOT}/cluster/$KUBERNETES_PROVIDER/util.sh" source "${KUBE_ROOT}/cluster/$KUBERNETES_PROVIDER/util.sh"
GUESTBOOK="${KUBE_REPO_ROOT}/examples/guestbook" GUESTBOOK="${KUBE_ROOT}/examples/guestbook"
# Launch the guestbook example # Launch the guestbook example
$KUBECFG -c "${GUESTBOOK}/redis-master.json" create /pods $KUBECFG -c "${GUESTBOOK}/redis-master.json" create /pods

View File

@ -20,8 +20,8 @@ set -o errexit
set -o nounset set -o nounset
set -o pipefail set -o pipefail
source "${KUBE_REPO_ROOT}/cluster/kube-env.sh" source "${KUBE_ROOT}/cluster/kube-env.sh"
source "${KUBE_REPO_ROOT}/cluster/$KUBERNETES_PROVIDER/util.sh" source "${KUBE_ROOT}/cluster/$KUBERNETES_PROVIDER/util.sh"
CONTROLLER_NAME=update-demo CONTROLLER_NAME=update-demo
@ -79,26 +79,26 @@ function validate() {
export DOCKER_HUB_USER=jbeda export DOCKER_HUB_USER=jbeda
# Launch a container # Launch a container
${KUBE_REPO_ROOT}/examples/update-demo/2-create-replication-controller.sh ${KUBE_ROOT}/examples/update-demo/2-create-replication-controller.sh
function teardown() { function teardown() {
echo "Cleaning up test artifacts" echo "Cleaning up test artifacts"
${KUBE_REPO_ROOT}/examples/update-demo/5-down.sh ${KUBE_ROOT}/examples/update-demo/5-down.sh
} }
trap "teardown" EXIT trap "teardown" EXIT
validate 2 nautilus validate 2 nautilus
${KUBE_REPO_ROOT}/examples/update-demo/3-scale.sh 1 ${KUBE_ROOT}/examples/update-demo/3-scale.sh 1
sleep 2 sleep 2
validate 1 nautilus validate 1 nautilus
${KUBE_REPO_ROOT}/examples/update-demo/3-scale.sh 2 ${KUBE_ROOT}/examples/update-demo/3-scale.sh 2
sleep 2 sleep 2
validate 2 nautilus validate 2 nautilus
${KUBE_REPO_ROOT}/examples/update-demo/4-rolling-update.sh kitten 1s ${KUBE_ROOT}/examples/update-demo/4-rolling-update.sh kitten 1s
sleep 2 sleep 2
validate 2 kitten validate 2 kitten

View File

@ -19,14 +19,14 @@
# Use testing config # Use testing config
export KUBE_CONFIG_FILE="config-test.sh" export KUBE_CONFIG_FILE="config-test.sh"
export KUBE_REPO_ROOT="$(dirname $0)/.." KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
# TODO(jbeda): This will break on usage if there is a space in # TODO(jbeda): This will break on usage if there is a space in
# ${KUBE_REPO_ROOT}. Covert to an array? Or an exported function? # ${KUBE_ROOT}. Covert to an array? Or an exported function?
export KUBECFG="${KUBE_REPO_ROOT}/cluster/kubecfg.sh -expect_version_match" export KUBECFG="${KUBE_ROOT}/cluster/kubecfg.sh -expect_version_match"
source $(dirname $0)/../cluster/kube-env.sh source "${KUBE_ROOT}/cluster/kube-env.sh"
source $(dirname $0)/../cluster/$KUBERNETES_PROVIDER/util.sh source "${KUBE_ROOT}/cluster/$KUBERNETES_PROVIDER/util.sh"
# For debugging of this test's components, it's helpful to leave the test # For debugging of this test's components, it's helpful to leave the test
# cluster running. # cluster running.
@ -48,10 +48,10 @@ test-build-release
if [[ ${ALREADY_UP} -ne 1 ]]; then if [[ ${ALREADY_UP} -ne 1 ]]; then
# Now bring a test cluster up with that release. # Now bring a test cluster up with that release.
$(dirname $0)/../cluster/kube-up.sh "${KUBE_ROOT}/cluster/kube-up.sh"
else else
# Just push instead # Just push instead
$(dirname $0)/../cluster/kube-push.sh "${KUBE_ROOT}/cluster/kube-push.sh"
fi fi
# Perform any required setup of the cluster # Perform any required setup of the cluster
@ -64,8 +64,8 @@ if [[ ${LEAVE_UP} -ne 1 ]]; then
fi fi
any_failed=0 any_failed=0
for test_file in $(ls $(dirname $0)/e2e-suite/); do for test_file in $(ls "${KUBE_ROOT}/hack/e2e-suite/"); do
"$(dirname $0)/e2e-suite/${test_file}" "${KUBE_ROOT}/hack/e2e-suite/${test_file}"
result="$?" result="$?"
if [[ "${result}" -eq "0" ]]; then if [[ "${result}" -eq "0" ]]; then
echo "${test_file} returned ${result}; passed!" echo "${test_file} returned ${result}; passed!"

View File

@ -17,8 +17,9 @@
# This command checks that the built commands can function together for # This command checks that the built commands can function together for
# simple scenarios. It does not require Docker so it can run in travis. # simple scenarios. It does not require Docker so it can run in travis.
source $(dirname $0)/util.sh KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
source $(dirname $0)/config-go.sh source "${KUBE_ROOT}/hack/util.sh"
source "${KUBE_ROOT}/hack/config-go.sh"
function cleanup() function cleanup()
{ {
@ -48,7 +49,7 @@ KUBELET_PORT=${KUBELET_PORT:-10250}
GO_OUT=${KUBE_TARGET}/bin GO_OUT=${KUBE_TARGET}/bin
# Check kubecfg # Check kubecfg
out=$(${GO_OUT}/kubecfg -version) out=$("${GO_OUT}/kubecfg" -version)
echo kubecfg: $out echo kubecfg: $out
# Start kubelet # Start kubelet

View File

@ -17,15 +17,15 @@
set -e set -e
source $(dirname $0)/config-go.sh KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
source "${KUBE_ROOT}/hack/config-go.sh"
# Go to the top of the tree. # Go to the top of the tree.
cd "${KUBE_REPO_ROOT}" cd "${KUBE_ROOT}"
# Check for `go` binary and set ${GOPATH}. # Check for `go` binary and set ${GOPATH}.
kube::setup_go_environment kube::setup_go_environment
find_test_dirs() { find_test_dirs() {
cd src/${KUBE_GO_PACKAGE} cd src/${KUBE_GO_PACKAGE}
find . -not \( \ find . -not \( \

View File

@ -18,10 +18,9 @@ set -o errexit
set -o nounset set -o nounset
set -o pipefail set -o pipefail
basedir=$(dirname "$0") KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
source "${basedir}/config-go.sh" source "${KUBE_ROOT}/hack/config-go.sh"
source "${KUBE_ROOT}/hack/util.sh"
source "${KUBE_REPO_ROOT}/hack/util.sh"
cleanup() { cleanup() {
kill "${ETCD_PID-}" >/dev/null 2>&1 || : kill "${ETCD_PID-}" >/dev/null 2>&1 || :
@ -31,7 +30,7 @@ cleanup() {
} }
if [[ "${KUBE_NO_BUILD_INTEGRATION+set}" != "set" ]]; then if [[ "${KUBE_NO_BUILD_INTEGRATION+set}" != "set" ]]; then
"${KUBE_REPO_ROOT}/hack/build-go.sh" cmd/integration "${KUBE_ROOT}/hack/build-go.sh" cmd/integration
fi fi
# Run cleanup to stop etcd on interrupt or other kill signal. # Run cleanup to stop etcd on interrupt or other kill signal.
@ -43,7 +42,7 @@ echo ""
echo "Integration test cases..." echo "Integration test cases..."
echo "" echo ""
GOFLAGS="-tags 'integration no-docker'" \ GOFLAGS="-tags 'integration no-docker'" \
"${KUBE_REPO_ROOT}/hack/test-go.sh" test/integration "${KUBE_ROOT}/hack/test-go.sh" test/integration
echo "" echo ""
echo "Integration scenario ..." echo "Integration scenario ..."

View File

@ -14,13 +14,13 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
REPO_ROOT="$(cd "$(dirname "$0")/../" && pwd -P)" KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
result=0 result=0
gofiles="$(find ${REPO_ROOT} -type f | grep "[.]go$" | grep -v "Godeps/\|third_party/\|release/\|_?output/|target/")" gofiles="$(find "${KUBE_ROOT}" -type f | grep "[.]go$" | grep -v "Godeps/\|third_party/\|release/\|_?output/|target/")"
for file in ${gofiles}; do for file in ${gofiles}; do
if [[ "$(${REPO_ROOT}/hooks/boilerplate.sh "${file}")" -eq "0" ]]; then if [[ "$("${KUBE_ROOT}/hooks/boilerplate.sh" "${file}")" -eq "0" ]]; then
echo "Boilerplate header is wrong for: ${file}" echo "Boilerplate header is wrong for: ${file}"
result=1 result=1
fi fi
@ -29,8 +29,8 @@ done
dirs=("cluster" "hack" "hooks") dirs=("cluster" "hack" "hooks")
for dir in ${dirs[@]}; do for dir in ${dirs[@]}; do
for file in $(grep -r -l "" "${REPO_ROOT}/${dir}/" | grep "[.]sh"); do for file in $(grep -r -l "" "${KUBE_ROOT}/${dir}/" | grep "[.]sh"); do
if [[ "$(${REPO_ROOT}/hooks/boilerplate.sh "${file}")" -eq "0" ]]; then if [[ "$("${KUBE_ROOT}/hooks/boilerplate.sh" "${file}")" -eq "0" ]]; then
echo "Boilerplate header is wrong for: ${file}" echo "Boilerplate header is wrong for: ${file}"
result=1 result=1
fi fi

View File

@ -23,9 +23,9 @@ if [[ -z $(echo "${GO_VERSION[2]}" | grep -E 'go1.2|go1.3') ]]; then
exit 0 exit 0
fi fi
REPO_ROOT="$(cd "$(dirname "$0")/../" && pwd -P)" KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
files="$(find ${REPO_ROOT} -type f | grep "[.]go$" | grep -v "third_party/\|release/\|_?output/\|target/\|Godeps/")" files="$(find "${KUBE_ROOT}" -type f | grep "[.]go$" | grep -v "third_party/\|release/\|_?output/\|target/\|Godeps/")"
bad=$(gofmt -s -l ${files}) bad=$(gofmt -s -l ${files})
if [[ -n "${bad}" ]]; then if [[ -n "${bad}" ]]; then
echo "$bad" echo "$bad"