|
| 1 | +#!/bin/sh |
| 2 | + |
| 3 | +# Copyright 2020 The Kubernetes Authors. |
| 4 | +# |
| 5 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | +# you may not use this file except in compliance with the License. |
| 7 | +# You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, software |
| 12 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | +# See the License for the specific language governing permissions and |
| 15 | +# limitations under the License. |
| 16 | + |
| 17 | +# Script to apply hotfixes after generating the client |
| 18 | +# More details: https://github.com/kubernetes-client/python/blob/master/devel/release.md#hot-issues |
| 19 | + |
| 20 | +# Check if working directory is dirty |
| 21 | +if [ $(git status --porcelain | wc -l) -gt 0 ] |
| 22 | +then |
| 23 | + echo Your working directory is not clean. Please clean your working directory. |
| 24 | + exit 1 |
| 25 | +fi |
| 26 | + |
| 27 | +# Check if the current branch is a release branch (release-*) |
| 28 | +# If it is not a release branch, don't let the patch be applied |
| 29 | +GIT_BRANCH=$(git branch | sed -n -e 's/^\* \(.*\)/\1/p') |
| 30 | +if ! [[ $GIT_BRANCH =~ .*release-.* ]]; then |
| 31 | + echo Current branch: $GIT_BRANCH |
| 32 | + echo You are not in a release branch, e.g., release-11.0, release-10.0 |
| 33 | + echo Please switch to a release branch to run this script. |
| 34 | + exit 1 |
| 35 | +fi |
| 36 | + |
| 37 | +# Patching commit for custom client behavior |
| 38 | +# Ref: https://github.com/kubernetes-client/python/pull/995/commits/9959273625b999ae9a8f0679c4def2ee7d699ede |
| 39 | +git cherry-pick -n 9959273625b999ae9a8f0679c4def2ee7d699ede |
| 40 | +if [ $? -eq 0 ] |
| 41 | +then |
| 42 | + echo Succesfully patched changes for custom client behavior |
| 43 | +else |
| 44 | + echo Failed to patch changes for custom client behavior |
| 45 | + git restore --staged . |
| 46 | + exit 1 |
| 47 | +fi |
| 48 | + |
| 49 | +# Patching commits for enabling from kubernetes import apis |
| 50 | +# Ref: https://github.com/kubernetes-client/python/blob/0976d59d6ff206f2f428cabc7a6b7b1144843b2a/kubernetes/client/apis/__init__.py |
| 51 | +git cherry-pick -n dee078639b5e848db73232397087a81f1a336510 b3164930dd1789dd66915acd6772f92f512cec47 |
| 52 | +if [ $? -eq 0 ] |
| 53 | +then |
| 54 | + echo Succesfully patched changes for enabling from kubernetes import apis |
| 55 | +else |
| 56 | + echo Failed to patch changes for enabling from kubernetes import apis |
| 57 | + git restore --staged . |
| 58 | + exit 1 |
| 59 | +fi; |
| 60 | + |
| 61 | +# Patching commits for Client Context Manager |
| 62 | +# Ref: https://github.com/kubernetes-client/python/pull/1073 |
| 63 | +git cherry-pick -n 18d21df367bf9ab5554635f5c6d107f2cf2206a5 13dffb897617f87aaaee247095107d7011e002d5 |
| 64 | +if [ $? -eq 0 ] |
| 65 | +then |
| 66 | + echo Succesfully patched changes for Client Context Manager |
| 67 | +else |
| 68 | + echo Failed to patch changes for Client Context Manager |
| 69 | + git restore --staged . |
| 70 | + exit 1 |
| 71 | +fi; |
| 72 | + |
| 73 | +git commit -m "Apply hotfixes" |
0 commit comments