From be5e14521f428931c4ee6001e43f701719ed9a0b Mon Sep 17 00:00:00 2001 From: Katrina Verey Date: Fri, 18 Mar 2022 12:29:51 -0400 Subject: [PATCH] Script kubectl kustomize update process --- hack/update-kustomize.sh | 64 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100755 hack/update-kustomize.sh diff --git a/hack/update-kustomize.sh b/hack/update-kustomize.sh new file mode 100755 index 00000000000..b74a2364121 --- /dev/null +++ b/hack/update-kustomize.sh @@ -0,0 +1,64 @@ +#!/usr/bin/env bash + +# Copyright 2022 The Kubernetes Authors. +# +# 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. + +set -o errexit +set -o nounset +set -o pipefail + +source hack/lib/util.sh + +kube::util::require-jq +kube::util::ensure_clean_working_dir + +PUBLISHED_RELEASES=$(curl -sL 'http://api.github.com/repos/kubernetes-sigs/kustomize/releases?per_page=100' | jq '[ .[] | select(.draft == false and .prerelease == false) | { "tag_name": .tag_name, "published_at": .published_at } ]') + +LATEST_KYAML=$(echo "${PUBLISHED_RELEASES}" | jq -r '[ .[] | select(.tag_name | startswith("kyaml/v")) ] | sort_by(.published_at) | last | .tag_name | scan("\/(v[\\d.]+)") | .[0]') +LATEST_CONFIG=$(echo "${PUBLISHED_RELEASES}" | jq -r '[ .[] | select(.tag_name | startswith("cmd/config/v")) ] | sort_by(.published_at) | last | .tag_name | scan("\/(v[\\d.]+)") | .[0]') +LATEST_API=$(echo "${PUBLISHED_RELEASES}" | jq -r '[ .[] | select(.tag_name | startswith("api/v")) ] | sort_by(.published_at) | last | .tag_name | scan("\/(v[\\d.]+)") | .[0]') +LATEST_KUSTOMIZE=$(echo "${PUBLISHED_RELEASES}" | jq -r '[ .[] | select(.tag_name | startswith("kustomize/v")) ] | sort_by(.published_at) | last | .tag_name | scan("\/(v[\\d.]+)") | .[0]') + +echo "----------------------------------------" +echo "Latest kyaml: $LATEST_KYAML" +echo "Latest cmd/config: $LATEST_CONFIG" +echo "Latest api: $LATEST_API" +echo "Latest kustomize: $LATEST_KUSTOMIZE" +echo -e "----------------------------------------\n" +read -p "Update kubectl kustomize to these versions? [y/N] " -n 1 -r +echo + +if [[ $REPLY =~ ^[Yy]$ ]]; then + echo -e "\n${color_blue:?}Updating kubectl kustomize${color_norm:?}" +else + echo -e "\n${color_red:?}Update aborted${color_norm:?}" + exit 1 +fi + +./hack/pin-dependency.sh sigs.k8s.io/kustomize/kyaml "$LATEST_KYAML" +./hack/pin-dependency.sh sigs.k8s.io/kustomize/cmd/config "$LATEST_CONFIG" +./hack/pin-dependency.sh sigs.k8s.io/kustomize/api "$LATEST_API" +./hack/pin-dependency.sh sigs.k8s.io/kustomize/kustomize/v4 "$LATEST_KUSTOMIZE" + +./hack/update-vendor.sh +./hack/update-internal-modules.sh +./hack/lint-dependencies.sh + +echo -e "\n${color_blue}Committing changes${color_norm}" +git add . +git commit -a -m "Update kubectl kustomize to kyaml/$LATEST_KYAML, cmd/config/$LATEST_CONFIG, api/$LATEST_API, kustomize/$LATEST_KUSTOMIZE" + +echo -e "\n${color_green:?}Update successful${color_norm:?}" +echo "Note: If any of the integration points changed, you may need to update them manually." +echo "See https://github.com/kubernetes-sigs/kustomize/tree/master/releasing#update-kustomize-in-kubectl for more information"