Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proper account checking and respect TMPDIR in release process #24940

Merged
merged 2 commits into from
May 6, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions build/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1516,9 +1516,9 @@ function kube::release::docker::release() {
fi
}

function kube::release::has_gcloud_account() {
function kube::release::gcloud_account_is_active() {
local -r account="${1-}"
if [[ -n $(gcloud auth list --filter-account $account 2>/dev/null) ]]; then
if [[ -n $(gcloud auth list --filter-account $account 2>/dev/null | grep "active") ]]; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alternately (possibly less fragile):

if [[ $(gcloud auth list --format='value(active_account)') -eq "${account}" ]]; then

return 0
else
return 1
Expand Down
5 changes: 3 additions & 2 deletions build/push-official-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ KUBE_GCS_PUBLISH_VERSION="${KUBE_RELEASE_VERSION}"

KUBE_DOCKER_REGISTRY="gcr.io/google_containers"
KUBE_DOCKER_IMAGE_TAG="${KUBE_RELEASE_VERSION}"
KUBE_GCLOUD_PRODUCTION_ACCOUNT="k8s.production.user@gmail.com"

KUBE_ROOT="$(dirname "${BASH_SOURCE}")/.."
source "${KUBE_ROOT}/build/common.sh"
Expand All @@ -47,8 +48,8 @@ if "${KUBE_ROOT}/cluster/kubectl.sh" 'version' | grep 'Client' | grep 'dirty'; t
exit 1
fi

if ! kube::release::has_gcloud_account k8s.production.user@gmail.com; then
kube::log::error "Pushing images to gcr.io/google_containers requires credentials for account k8s.production.user@gmail.com"
if ! kube::release::gcloud_account_is_active "${KUBE_GCLOUD_PRODUCTION_ACCOUNT}"; then
kube::log::error "Pushing images to gcr.io/google_containers requires being logged in as ${KUBE_GCLOUD_PRODUCTION_ACCOUNT}"
return 1
fi

Expand Down
3 changes: 2 additions & 1 deletion release/build-official-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ function sha1() {

declare -r KUBE_GITHUB="https://github.com/kubernetes/kubernetes.git"
declare -r KUBE_RELEASE_VERSION=${1-}
declare -r TMPDIR=${TMPDIR:-"/tmp"}
declare -r KUBE_RELEASE_UMASK=${KUBE_RELEASE_UMASK:-022}

VERSION_REGEX="^v(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)(-(beta|alpha)\\.(0|[1-9][0-9]*))?$"
Expand All @@ -65,7 +66,7 @@ else
KUBE_RELEASE_TYPE="stable"
fi

declare -r KUBE_BUILD_DIR=$(mktemp -d "/tmp/kubernetes-build-release-${KUBE_RELEASE_VERSION}-XXXXXXX")
declare -r KUBE_BUILD_DIR=$(mktemp -d "${TMPDIR}/kubernetes-build-release-${KUBE_RELEASE_VERSION}-XXXXXXX")

# Set the default umask for the release. This ensures consistency
# across our release builds.
Expand Down
5 changes: 3 additions & 2 deletions release/cut-official-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,12 @@ function main() {
local -r release_umask=${release_umask:-022}
umask "${release_umask}"

declare -r TMPDIR=${TMPDIR:-"/tmp"}
local -r github="https://github.com/kubernetes/kubernetes.git"
declare -r DIR=$(mktemp -d "/tmp/kubernetes-${release_type}-release-${new_version}-XXXXXXX")
declare -r DIR=$(mktemp -d "${TMPDIR}/kubernetes-${release_type}-release-${new_version}-XXXXXXX")

# Start a tmp file that will hold instructions for the user.
declare -r INSTRUCTIONS=$(mktemp "/tmp/kubernetes-${release_type}-release-${new_version}-instructions-XXXXXXX")
declare -r INSTRUCTIONS=$(mktemp "${TMPDIR}/kubernetes-${release_type}-release-${new_version}-instructions-XXXXXXX")
if $DRY_RUN; then
cat > "${INSTRUCTIONS}" <<- EOM
Success on dry run! Do
Expand Down