From 7fa08b4b7588812c22db7d05bc3d2d38e81b5000 Mon Sep 17 00:00:00 2001 From: Nabarun Pal Date: Wed, 11 Mar 2020 18:08:08 +0530 Subject: [PATCH 1/2] Add a script to apply hotfixes.sh --- scripts/apply-hotfixes.sh | 73 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100755 scripts/apply-hotfixes.sh diff --git a/scripts/apply-hotfixes.sh b/scripts/apply-hotfixes.sh new file mode 100755 index 0000000000..fdd46d79d7 --- /dev/null +++ b/scripts/apply-hotfixes.sh @@ -0,0 +1,73 @@ +#!/bin/sh + +# Copyright 2020 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. + +# Script to apply hotfixes after generating the client +# More details: https://github.com/kubernetes-client/python/blob/master/devel/release.md#hot-issues + +# Check if working directory is dirty +if [ $(git status --porcelain | wc -l) -gt 0 ] +then + echo Your working directory is not clean. Please clean your working directory. + exit 1 +fi + +# Check if the current branch is a release branch (release-*) +# If it is not a release branch, don't let the patch be applied +GIT_BRANCH=$(git branch | sed -n -e 's/^\* \(.*\)/\1/p') +if ! [[ $GIT_BRANCH =~ .*release-.* ]]; then + echo Current branch: $GIT_BRANCH + echo You are not in a release branch, e.g., release-11.0, release-10.0 + echo Please switch to a release branch to run this script. + exit 1 +fi + +# Patching commit for custom client behavior +# Ref: https://github.com/kubernetes-client/python/pull/995/commits/9959273625b999ae9a8f0679c4def2ee7d699ede +git cherry-pick -n 9959273625b999ae9a8f0679c4def2ee7d699ede +if [ $? -eq 0 ] +then + echo Succesfully patched changes for custom client behavior +else + echo Failed to patch changes for custom client behavior + git restore --staged . + exit 1 +fi + +# Patching commits for enabling from kubernetes import apis +# Ref: https://github.com/kubernetes-client/python/blob/0976d59d6ff206f2f428cabc7a6b7b1144843b2a/kubernetes/client/apis/__init__.py +git cherry-pick -n dee078639b5e848db73232397087a81f1a336510 b3164930dd1789dd66915acd6772f92f512cec47 +if [ $? -eq 0 ] +then + echo Succesfully patched changes for enabling from kubernetes import apis +else + echo Failed to patch changes for enabling from kubernetes import apis + git restore --staged . + exit 1 +fi; + +# Patching commits for Client Context Manager +# Ref: https://github.com/kubernetes-client/python/pull/1073 +git cherry-pick -n 18d21df367bf9ab5554635f5c6d107f2cf2206a5 13dffb897617f87aaaee247095107d7011e002d5 +if [ $? -eq 0 ] +then + echo Succesfully patched changes for Client Context Manager +else + echo Failed to patch changes for Client Context Manager + git restore --staged . + exit 1 +fi; + +git commit -m "Apply hotfixes" From 1d2417b5d15bf14810d13381926732b7a7b24699 Mon Sep 17 00:00:00 2001 From: Nabarun Pal Date: Wed, 11 Mar 2020 18:08:26 +0530 Subject: [PATCH 2/2] Update release instructions for hot patches --- devel/release.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/devel/release.md b/devel/release.md index a6a3c51dda..fdcb0fc6ee 100644 --- a/devel/release.md +++ b/devel/release.md @@ -19,9 +19,13 @@ to add [this file](https://github.com/kubernetes-client/python/blob/0976d59d6ff2 under `kubernetes/client/apis/` to ensure the package is backwards compatible. For more details, see [#974](https://github.com/kubernetes-client/python/issues/974) +3. Add ability to the client to be used as Context Manager [kubernetes-client/python#1073](https://github.com/kubernetes-client/python/pull/1073) + Commit the manual changes like this [PR](https://github.com/kubernetes-client/python/pull/995/commits) does, then create your PR for review. +Alternatively, you can use the `scripts/apply-hotfixes.sh` script to apply changes from the above functionalities. **As mentioned above the script should be run after finishing the section `Update release tags`. Also, ensure a clean working directory before applying the script** + ## Change logs Make sure the change logs are up to date [here](https://github.com/kubernetes-client/python/blob/master/CHANGELOG.md). If they are not, follow commits added after the last release and update/commit