Skip to content

Commit

Permalink
VPA: add k8s deps update script
Browse files Browse the repository at this point in the history
  • Loading branch information
wozniakjan committed Nov 15, 2019
1 parent 4a36794 commit 50511dd
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 110 deletions.
3 changes: 3 additions & 0 deletions vertical-pod-autoscaler/e2e/go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// for updating kubernetes dependencies, use `autoscaler/vertical-pod-autoscaler/hack/update-kubernetes-deps-in-e2e.sh`
// for any other update, use standard `go mod` commands

module k8s.io/autoscaler/vertical-pod-autoscaler/e2e

go 1.12
Expand Down
64 changes: 64 additions & 0 deletions vertical-pod-autoscaler/hack/update-kubernetes-deps-in-e2e.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#!/usr/bin/env bash

# Copyright 2019 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.

# Usage:
# $ K8S_TAG=<k8s_tag> ./hack/update-kubernetes-deps-in-e2e.sh
# K8S_TAG - k8s version to use for the dependencies update.
# Suggested format is K8S_TAG=v1.10.3

set -eou errexit pipefail nounset

K8S_TAG=${K8S_TAG:-v1.16.2}
K8S_TAG=${K8S_TAG#v}

export GO111MODULE=on

function update_deps() {
# list staged k8s.io repos
MODS=($(
curl -sS https://raw.githubusercontent.com/kubernetes/kubernetes/v${K8S_TAG}/go.mod |
sed -n 's|.*k8s.io/\(.*\) => ./staging/src/k8s.io/.*|k8s.io/\1|p'
))

# get matching tag for each staged k8s.io repo
for MOD in "${MODS[@]}"; do
V=$(
go mod download -json "${MOD}@kubernetes-${K8S_TAG}" |
sed -n 's|.*"Version": "\(.*\)".*|\1|p'
)
go mod edit "-replace=${MOD}=${MOD}@${V}"
done

# update k8s.io/kubernetes to desired tag
go get "k8s.io/kubernetes@v${K8S_TAG}"
}


# execute in subshell to keep CWD even in case of failures
(
# find script directory invariantly of CWD
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

# cd to e2e tests
cd $DIR/../e2e

# update k8s deps in e2e
update_deps

# tidy and vendor modules
go mod tidy
go mod vendor
)
110 changes: 0 additions & 110 deletions vertical-pod-autoscaler/update_deps.sh

This file was deleted.

0 comments on commit 50511dd

Please sign in to comment.