Skip to content

Commit b422c0d

Browse files
committed
Update comments to make the code more readable
1 parent d54611c commit b422c0d

1 file changed

Lines changed: 17 additions & 12 deletions

File tree

scripts/release.sh

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -67,35 +67,36 @@ set -o errexit
6767
set -o nounset
6868
set -o pipefail
6969

70-
# used by the client generator: https://github.com/kubernetes-client/gen/blob/729332ad08f0f4d98983b7beb027e2f657236ef9/openapi/openapi-generator/client-generator.sh#L52
70+
# Set constants used by the client generator.
7171
export USERNAME=kubernetes
7272

73+
# Set up utilities.
7374
repo_root="$(git rev-parse --show-toplevel)"
7475
declare -r repo_root
7576
cd "${repo_root}"
7677

7778
source scripts/util/changelog.sh
7879
source scripts/util/kube_changelog.sh
7980

80-
old_client_version=$(python3 "scripts/constants.py" CLIENT_VERSION)
81-
old_k8s_api_version=$(util::changelog::get_k8s_api_version "v$old_client_version")
81+
# Read user inputs or values locally.
8282
KUBERNETES_BRANCH=${KUBERNETES_BRANCH:-$(python3 "scripts/constants.py" KUBERNETES_BRANCH)}
8383
CLIENT_VERSION=${CLIENT_VERSION:-$(python3 "scripts/constants.py" CLIENT_VERSION)}
8484
DEVELOPMENT_STATUS=${DEVELOPMENT_STATUS:-$(python3 "scripts/constants.py" DEVELOPMENT_STATUS)}
8585

86-
# get Kubernetes API Version
86+
# Get Kubernetes API versions
87+
old_client_version=$(python3 "scripts/constants.py" CLIENT_VERSION)
88+
old_k8s_api_version=$(util::changelog::get_k8s_api_version "v$old_client_version")
8789
new_k8s_api_version=$(util::kube_changelog::find_latest_patch_version $KUBERNETES_BRANCH)
8890
echo "Old Kubernetes API Version: $old_k8s_api_version"
8991
echo "New Kubernetes API Version: $new_k8s_api_version"
9092

93+
# Update version constants
9194
sed -i "s/^KUBERNETES_BRANCH =.*$/KUBERNETES_BRANCH = \"$KUBERNETES_BRANCH\"/g" scripts/constants.py
9295
sed -i "s/^CLIENT_VERSION =.*$/CLIENT_VERSION = \"$CLIENT_VERSION\"/g" scripts/constants.py
9396
sed -i "s/^DEVELOPMENT_STATUS =.*$/DEVELOPMENT_STATUS = \"$DEVELOPMENT_STATUS\"/g" scripts/constants.py
9497
git commit -am "update version constants for $CLIENT_VERSION release"
9598

96-
util::changelog::update_release_api_version $CLIENT_VERSION $old_client_version $new_k8s_api_version
97-
98-
# get API change release notes since $old_k8s_api_version.
99+
# Update CHANGELOG with API change release notes since $old_k8s_api_version.
99100
# NOTE: $old_k8s_api_version may be one-minor-version behind $KUBERNETES_BRANCH, e.g.
100101
# KUBERNETES_BRANCH=release-1.19
101102
# old_k8s_api_version=1.18.17
@@ -106,30 +107,34 @@ util::changelog::update_release_api_version $CLIENT_VERSION $old_client_version
106107
# TODO(roycaihw): not all Kubernetes API changes modify the OpenAPI spec.
107108
# Download the patch and skip if the spec is not modified. Also we want to
108109
# look at other k/k sections like "deprecation"
110+
util::changelog::update_release_api_version $CLIENT_VERSION $old_client_version $new_k8s_api_version
109111
release_notes=$(util::kube_changelog::get_api_changelog "$KUBERNETES_BRANCH" "$old_k8s_api_version")
110112
if [[ -n "$release_notes" ]]; then
111113
util::changelog::write_changelog v$CLIENT_VERSION "### API Change" "$release_notes"
112114
fi
113-
114115
git commit -am "update changelog"
115116

116-
# run client generator
117+
# Re-generate the client
117118
scripts/update-client.sh
118119

120+
# Apply hotfixes
119121
rm -r kubernetes/test/
120122
git add .
121123
git commit -m "temporary generated commit"
122124
scripts/apply-hotfixes.sh
123125
git reset HEAD~2
124-
# custom object API is hosted in gen repo. Commit API change separately for
125-
# easier review
126+
127+
# Custom object API is hosted in gen repo. Commit custom object API change
128+
# separately for easier review
126129
if [[ -n "$(git diff kubernetes/client/api/custom_objects_api.py)" ]]; then
127130
git add kubernetes/client/api/custom_objects_api.py
128131
git commit -m "generated client change for custom_objects"
129132
fi
133+
# Check if there is any API change, then commit
130134
git add kubernetes/docs kubernetes/client/api/ kubernetes/client/models/ kubernetes/swagger.json.unprocessed scripts/swagger.json
131-
# verify if there are staged changes, then commit
132135
git diff-index --quiet --cached HEAD || git commit -m "generated API change"
136+
# Commit everything else
133137
git add .
134138
git commit -m "generated client change"
139+
135140
echo "Release finished successfully."

0 commit comments

Comments
 (0)