...
1#!/bin/bash
2
3# Copyright 2017 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
18# overall flow
19# 1. make a clean gopath
20# 2. godep restore based on k8s.io/kuberentes provided manifest
21# 3. go get anything unlisted. This handles deps from k8s.io/*
22# 4. remove old vendoring data
23# 5. vendor packages we need
24# 6. remove anything vendored from k8s.io/* from vendor, but not manifest.
25# This allows go get to work and still be able to flatten dependencies.
26# 6. copy new vendored packages and save them
27
28set -o errexit
29set -o nounset
30set -o pipefail
31
32goPath=$(mktemp -d "${TMPDIR:-/tmp/}$(basename 0).XXXXXXXXXXXX")
33echo ${goPath}
34
35export GOPATH=${goPath}
36
37mkdir -p ${goPath}/src/k8s.io/kube-aggregator
38cp -R . ${goPath}/src/k8s.io/kube-aggregator
39
40pushd ${goPath}/src/k8s.io/kube-aggregator
41rm -rf vendor || true
42
43# restore what we have in our new manifest that we've sync
44godep restore
45
46# we have to some crazy schenanigans for client-go until it can keep its syncs up to date
47# we have to restore its old/bad deps
48go get -d k8s.io/client-go/... || true
49pushd ${goPath}/src/k8s.io/client-go
50godep restore
51rm -rf ${goPath}/src/k8s.io/apimachinery
52rm -rf ${goPath}/src/k8s.io/apiserver
53popd
54
55# the manifest doesn't include any levels of k8s.io dependencies so load them using the go get
56# assume you sync all the repos at the same time, the leves you get will be correct
57go get -d ./... || true
58
59
60# save the new levels of dependencies
61rm -rf vendor || true
62rm -rf Godeps || true
63godep save ./...
64
65# remove the vendored k8s.io/* go files
66rm -rf vendor/k8s.io
67popd
68
69# remove the vendor dir we have and move the one we just made
70rm -rf vendor || true
71rm -rf Godeps || true
72git rm -rf vendor || true
73git rm -rf Godeps || true
74mv ${goPath}/src/k8s.io/kube-aggregator/vendor .
75mv ${goPath}/src/k8s.io/kube-aggregator/Godeps .
76git add vendor
77git add Godeps
78git commit -m "sync: resync vendor folder"
79
View as plain text