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

@@ -20,13 +20,13 @@ set -o errexit
set -o nounset
set -o pipefail
hackdir=$(CDPATH="" cd $(dirname $0); pwd)
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
# 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.
cd "${KUBE_REPO_ROOT}"
cd "${KUBE_ROOT}"
# Check for `go` binary and set ${GOPATH}.
kube::setup_go_environment

View File

@@ -36,7 +36,7 @@
# the final GOPATH.
# --- 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_GO_PACKAGE - Full name of the Kubernetes Go package.
@@ -61,7 +61,7 @@ kube::version_ldflags() {
unset CDPATH
cd "${KUBE_REPO_ROOT}"
cd "${KUBE_ROOT}"
declare -a ldflags=()
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
# is defined.
if [[ -z ${KUBE_NO_GODEPS:-} ]]; then
GOPATH="${GOPATH}:${KUBE_REPO_ROOT}/Godeps/_workspace"
GOPATH="${GOPATH}:${KUBE_ROOT}/Godeps/_workspace"
fi
export GOPATH
@@ -172,18 +172,19 @@ kube::binaries_from_targets() {
}
# --- Environment Variables ---
# Make ${KUBE_REPO_ROOT} an absolute path.
KUBE_REPO_ROOT=$(
set -eu
# Make ${KUBE_ROOT} an absolute path.
KUBE_ROOT=$(
set -o errexit
set -o nounset
set -o pipefail
unset CDPATH
scripts_dir=$(dirname "${BASH_SOURCE[0]}")
cd "${scripts_dir}"
cd ..
kube_root=$(dirname "${BASH_SOURCE}")/..
cd "${kube_root}"
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}"
export KUBE_TARGET
@@ -195,12 +196,14 @@ export KUBE_GO_PACKAGE
# So that Go knows how to import Kubernetes sources by full path.
# 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_basedir=$(dirname "${go_pkg_dir}")
mkdir -p "${go_pkg_basedir}"
rm -f "${go_pkg_dir}"
# 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.
# Then build a release
$(dirname $0)/../build/release.sh
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
# Build a release
"${KUBE_ROOT}/build/release.sh"
if [ "$?" != "0" ]; then
echo "Building a release failed!"
exit 1
fi
# 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
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
# Then build a release
$(dirname $0)/../build/release.sh
"${KUBE_ROOT}/build/release.sh"
if [ "$?" != "0" ]; then
echo "Building the release failed!"
exit 1
fi
# 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
set -e
source "${KUBE_REPO_ROOT}/cluster/kube-env.sh"
source "${KUBE_REPO_ROOT}/cluster/$KUBERNETES_PROVIDER/util.sh"
source "${KUBE_ROOT}/cluster/kube-env.sh"
source "${KUBE_ROOT}/cluster/$KUBERNETES_PROVIDER/util.sh"
# Launch a container
$KUBECFG -p 8080:80 run dockerfile/nginx 2 myNginx

View File

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

View File

@@ -20,8 +20,8 @@ set -o errexit
set -o nounset
set -o pipefail
source "${KUBE_REPO_ROOT}/cluster/kube-env.sh"
source "${KUBE_REPO_ROOT}/cluster/$KUBERNETES_PROVIDER/util.sh"
source "${KUBE_ROOT}/cluster/kube-env.sh"
source "${KUBE_ROOT}/cluster/$KUBERNETES_PROVIDER/util.sh"
CONTROLLER_NAME=update-demo
@@ -79,26 +79,26 @@ function validate() {
export DOCKER_HUB_USER=jbeda
# 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() {
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
validate 2 nautilus
${KUBE_REPO_ROOT}/examples/update-demo/3-scale.sh 1
${KUBE_ROOT}/examples/update-demo/3-scale.sh 1
sleep 2
validate 1 nautilus
${KUBE_REPO_ROOT}/examples/update-demo/3-scale.sh 2
${KUBE_ROOT}/examples/update-demo/3-scale.sh 2
sleep 2
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
validate 2 kitten

View File

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

View File

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

View File

@@ -17,15 +17,15 @@
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.
cd "${KUBE_REPO_ROOT}"
cd "${KUBE_ROOT}"
# Check for `go` binary and set ${GOPATH}.
kube::setup_go_environment
find_test_dirs() {
cd src/${KUBE_GO_PACKAGE}
find . -not \( \

View File

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

View File

@@ -14,13 +14,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.
REPO_ROOT="$(cd "$(dirname "$0")/../" && pwd -P)"
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
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
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}"
result=1
fi
@@ -29,8 +29,8 @@ done
dirs=("cluster" "hack" "hooks")
for dir in ${dirs[@]}; do
for file in $(grep -r -l "" "${REPO_ROOT}/${dir}/" | grep "[.]sh"); do
if [[ "$(${REPO_ROOT}/hooks/boilerplate.sh "${file}")" -eq "0" ]]; then
for file in $(grep -r -l "" "${KUBE_ROOT}/${dir}/" | grep "[.]sh"); do
if [[ "$("${KUBE_ROOT}/hooks/boilerplate.sh" "${file}")" -eq "0" ]]; then
echo "Boilerplate header is wrong for: ${file}"
result=1
fi

View File

@@ -23,9 +23,9 @@ if [[ -z $(echo "${GO_VERSION[2]}" | grep -E 'go1.2|go1.3') ]]; then
exit 0
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})
if [[ -n "${bad}" ]]; then
echo "$bad"