From 61d38912447a81716617033026646d7fa2c21656 Mon Sep 17 00:00:00 2001
From: Yusuke Kuoka <ykuoka@gmail.com>
Date: Fri, 18 Nov 2016 10:02:27 +0900
Subject: [PATCH] Bump Kubernetes version to v1.4.6+coreos.0

---
 config/config.go              |  2 +-
 config/templates/cluster.yaml |  2 +-
 contrib/bump-version          | 37 +++++++++++++++++++++++++++++++++++
 e2e/kubernetes/Dockerfile     |  2 +-
 e2e/kubernetes/Makefile       |  2 +-
 5 files changed, 41 insertions(+), 4 deletions(-)
 create mode 100755 contrib/bump-version

diff --git a/config/config.go b/config/config.go
index 1014a6190..6c71d735e 100644
--- a/config/config.go
+++ b/config/config.go
@@ -43,7 +43,7 @@ func newDefaultCluster() *Cluster {
 		PodCIDR:                  "10.2.0.0/16",
 		ServiceCIDR:              "10.3.0.0/24",
 		DNSServiceIP:             "10.3.0.10",
-		K8sVer:                   "v1.4.5_coreos.0",
+		K8sVer:                   "v1.4.6_coreos.0",
 		HyperkubeImageRepo:       "quay.io/coreos/hyperkube",
 		TLSCADurationDays:        365 * 10,
 		TLSCertDurationDays:      365,
diff --git a/config/templates/cluster.yaml b/config/templates/cluster.yaml
index 4d4aa94fe..9bc2975ef 100644
--- a/config/templates/cluster.yaml
+++ b/config/templates/cluster.yaml
@@ -143,7 +143,7 @@ kmsKeyArn: "{{.KMSKeyARN}}"
 #tlsCertDurationDays: 365
 
 # Version of hyperkube image to use. This is the tag for the hyperkube image repository.
-# kubernetesVersion: v1.4.5_coreos.0
+# kubernetesVersion: v1.4.6_coreos.0
 
 # Hyperkube image repository to use.
 # hyperkubeImageRepo: quay.io/coreos/hyperkube
diff --git a/contrib/bump-version b/contrib/bump-version
new file mode 100755
index 000000000..5e6d196f6
--- /dev/null
+++ b/contrib/bump-version
@@ -0,0 +1,37 @@
+#!/bin/bash
+#
+# This script will go through each of the tracked files in this repo and update
+# the CURRENT_VERSION to the TARGET_VERSION. This is meant as a helper - but
+# probably should still double-check the changes are correct
+
+if [ $# -ne 1 ] || [ `expr $1 : ".*_.*"` == 0 ]; then
+    echo "USAGE: $0 <target-version>"
+    echo "  example: $0 'v1.4.6_coreos.0'"
+    exit 1
+fi
+
+CURRENT_VERSION=${CURRENT_VERSION:-"v1.4.6_coreos.0"}
+TARGET_VERSION=${1}
+
+CURRENT_VERSION_BASE=${CURRENT_VERSION%%_*}
+TARGET_VERSION_BASE=${TARGET_VERSION%%_*}
+
+CURRENT_VERSION_SEMVER=${CURRENT_VERSION/_/+}
+TARGET_VERSION_SEMVER=${TARGET_VERSION/_/+}
+
+GIT_ROOT=$(git rev-parse --show-toplevel)
+
+cd $GIT_ROOT
+TRACKED=($(git grep -F "${CURRENT_VERSION_BASE}"| awk -F : '{print $1}' | sort -u))
+for i in "${TRACKED[@]}"; do
+    echo Updating $i
+    if [ "$(uname -s)" == "Darwin" ]; then
+        sed -i "" "s/${CURRENT_VERSION}/${TARGET_VERSION}/g" $i
+        sed -i "" "s/${CURRENT_VERSION_SEMVER}/${TARGET_VERSION_SEMVER}/g" $i
+        sed -i "" "s/${CURRENT_VERSION_BASE}/${TARGET_VERSION_BASE}/g" $i
+    else
+        sed -i "s/${CURRENT_VERSION}/${TARGET_VERSION}/g" $i
+        sed -i "s/${CURRENT_VERSION_SEMVER}/${TARGET_VERSION_SEMVER}/g" $i
+        sed -i "s/${CURRENT_VERSION_BASE}/${TARGET_VERSION_BASE}/g" $i
+    fi
+done
\ No newline at end of file
diff --git a/e2e/kubernetes/Dockerfile b/e2e/kubernetes/Dockerfile
index 2c93a14b2..328e6a12a 100644
--- a/e2e/kubernetes/Dockerfile
+++ b/e2e/kubernetes/Dockerfile
@@ -1,6 +1,6 @@
 FROM golang:1.7.1
 
-ARG KUBERNETES_VERSION=${KUBERNETES_VERSION:-v1.4.5+coreos.0}
+ARG KUBERNETES_VERSION=${KUBERNETES_VERSION:-v1.4.6+coreos.0}
 
 RUN apt-get update && \
     apt-get install -y rsync && \
diff --git a/e2e/kubernetes/Makefile b/e2e/kubernetes/Makefile
index a912482c5..2277c1fb0 100644
--- a/e2e/kubernetes/Makefile
+++ b/e2e/kubernetes/Makefile
@@ -1,4 +1,4 @@
-KUBERNETES_VERSION ?= v1.4.5+coreos.0
+KUBERNETES_VERSION ?= v1.4.6+coreos.0
 DOCKER_REPO ?=
 DOCKER_TAG ?= $(DOCKER_REPO)kube-e2e:$(KUBERNETES_VERSION)
 DOCKER_TAG_SANITIZED ?= $(shell echo $(DOCKER_TAG) | sed -e 's/+/_/')