diff --git a/Makefile b/Makefile index 5360fd4e5..f57ee80c0 100644 --- a/Makefile +++ b/Makefile @@ -224,6 +224,7 @@ manifests: --gh-release=${GH_RELEASE} \ --image-prefix=${IMAGE_PREFIX} \ --version=${VERSION} \ + --staging-prefix=${STAGING_PREFIX} \ --dry-run=${DRY_RUN} \ --push=${PUSH} diff --git a/hack/manifests.sh b/hack/manifests.sh index e87bcaa36..42817bb88 100755 --- a/hack/manifests.sh +++ b/hack/manifests.sh @@ -22,6 +22,7 @@ BUCKET="" GH_RELEASE="" IMAGE_PREFIX="${DEFAULT_IMAGE_PREFIX}" VERSION="" +STAGING_PREFIX="" DRY_RUN=false PUSH=false KUSTOMIZES=() @@ -33,6 +34,7 @@ function usage() { echo " --gh-release is github release" echo " --image-prefix is kwok image prefix" echo " --version is version of binary" + echo " --staging-prefix is staging prefix for bucket" echo " --push will push binary to bucket" echo " --dry-run just show what would be done" } @@ -62,6 +64,10 @@ function args() { [[ "${arg#*=}" != "${arg}" ]] && VERSION="${arg#*=}" || { VERSION="${2}" && shift; } || : shift ;; + --staging-prefix | --staging-prefix=*) + [[ "${arg#*=}" != "${arg}" ]] && STAGING_PREFIX="${arg#*=}" || { STAGING_PREFIX="${2}" && shift; } || : + shift + ;; --push | --push=*) [[ "${arg#*=}" != "${arg}" ]] && PUSH="${arg#*=}" || PUSH="true" || : shift @@ -107,7 +113,11 @@ function main() { dry_run rm -r "./artifacts/kustomize" if [[ "${PUSH}" == "true" ]]; then if [[ "${BUCKET}" != "" ]]; then - dry_run gsutil cp -P "./artifacts/${kustomize}.yaml" "${BUCKET}/releases/${VERSION}/manifests/${kustomize}.yaml" + prefix="${BUCKET}/releases/" + if [[ "${STAGING_PREFIX}" != "" ]]; then + prefix="${BUCKET}/releases/${STAGING_PREFIX}-" + fi + dry_run gsutil cp -P "./artifacts/${kustomize}.yaml" "${prefix}${VERSION}/manifests/${kustomize}.yaml" fi if [[ "${GH_RELEASE}" != "" ]]; then dry_run gh -R "${GH_RELEASE}" release upload "${VERSION}" "./artifacts/${kustomize}.yaml" diff --git a/test/release/build.test.sh b/test/release/build.test.sh index d9cf51f47..c7b5601c3 100755 --- a/test/release/build.test.sh +++ b/test/release/build.test.sh @@ -448,7 +448,7 @@ function manifests_with_push_bucket() { echo "kustomize build . -o ../../kwok.yaml" echo "cd -" echo "rm -r ./artifacts/kustomize" - echo "gsutil cp -P ./artifacts/kwok.yaml bucket/releases/${VERSION}/manifests/kwok.yaml" + echo "gsutil cp -P ./artifacts/kwok.yaml bucket/releases/${PREFIX}-${VERSION}/manifests/kwok.yaml" } function main() { @@ -515,7 +515,7 @@ function main() { make --no-print-directory -C "${ROOT_DIR}" IMAGE_PREFIX=${IMAGE_PREFIX} manifests | diff -u <(want_manifests) - || failed+=("manifests") make --no-print-directory -C "${ROOT_DIR}" PUSH=true GH_RELEASE=ghrelease IMAGE_PREFIX=${IMAGE_PREFIX} manifests | diff -u <(manifests_with_push_ghrelease) - || failed+=("manifests-with-push-ghrelease") - make --no-print-directory -C "${ROOT_DIR}" PUSH=true BUCKET=bucket IMAGE_PREFIX=${IMAGE_PREFIX} manifests | diff -u <(manifests_with_push_bucket) - || failed+=("manifests-with-push-bucket") + make --no-print-directory -C "${ROOT_DIR}" PUSH=true BUCKET=bucket STAGING=true STAGING_PREFIX=${PREFIX} IMAGE_PREFIX=${IMAGE_PREFIX} manifests | diff -u <(manifests_with_push_bucket) - || failed+=("manifests-with-push-bucket") if [[ "${#failed[@]}" -ne 0 ]]; then echo "Error: Some tests failed"