forked from openshift-knative/serverless-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update-deps.sh
executable file
·83 lines (70 loc) · 2.56 KB
/
update-deps.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/usr/bin/env bash
ROOT_DIR=$(dirname "$0")/..
readonly ROOT_DIR
# shellcheck disable=SC1091,SC1090
source "${ROOT_DIR}/vendor/knative.dev/hack/library.sh"
# shellcheck disable=SC1091,SC1090
source "${ROOT_DIR}/hack/lib/metadata.bash"
set -o errexit
set -o nounset
set -o pipefail
cd "${ROOT_DIR}"
# This controls the knative release version we track.
KN_VERSION="release-1.11"
EVENTING_VERSION="release-v1.11"
EVENTING_KAFKA_BROKER_VERSION="release-v1.11"
SERVING_VERSION="release-v1.11"
GO_VERSION="$(metadata.get requirements.golang)"
OCP_VERSION="$(metadata.get requirements.ocpVersion.min)"
# The list of dependencies that we track at HEAD and periodically
# float forward in this repository.
FLOATING_DEPS=(
"knative.dev/operator@${KN_VERSION}"
)
REPLACE_DEPS=(
"knative.dev/eventing-kafka-broker=github.com/openshift-knative/eventing-kafka-broker@${EVENTING_KAFKA_BROKER_VERSION}"
"knative.dev/eventing=github.com/openshift-knative/eventing@${EVENTING_VERSION}"
"knative.dev/serving=github.com/openshift-knative/serving@${SERVING_VERSION}"
"knative.dev/pkg=knative.dev/pkg@${KN_VERSION}"
"knative.dev/hack=knative.dev/hack@${KN_VERSION}"
"knative.dev/networking=knative.dev/networking@${KN_VERSION}"
"knative.dev/reconciler-test=knative.dev/reconciler-test@${KN_VERSION}"
"github.com/openshift/api=github.com/openshift/api@release-${OCP_VERSION}"
"github.com/openshift/client-go=github.com/openshift/client-go@release-${OCP_VERSION}"
"github.com/openshift/machine-config-operator=github.com/openshift/machine-config-operator@release-${OCP_VERSION}"
)
# Parse flags to determine if we need to update our floating deps.
GO_GET=0
while [[ $# -ne 0 ]]; do
parameter=$1
case ${parameter} in
--upgrade) GO_GET=1 ;;
*) abort "unknown option ${parameter}" ;;
esac
shift
done
readonly GO_GET
if (( GO_GET )); then
export GOPROXY="https://proxy.golang.org,direct"
# Treat forks specifically due to https://github.com/golang/go/issues/32721
for dep in "${REPLACE_DEPS[@]}"; do
go mod edit -replace "${dep}"
# Let the dependency update the magic SHA otherwise the
# following "go mod edit" will fail.
go mod tidy -compat="${GO_VERSION}"
go mod vendor
done
go get -d "${FLOATING_DEPS[@]}"
fi
# Prune modules.
go mod tidy -compat="${GO_VERSION}"
go mod vendor
# Remove unnecessary files.
find vendor/ \( -name "OWNERS" \
-o -name "OWNERS_ALIASES" \
-o -name "BUILD" \
-o -name "BUILD.bazel" \
-o -name "*_test.go" \) -exec rm -fv {} +
find vendor -type f -name '*.sh' -exec chmod +x {} +
# Apply patches
git apply "${ROOT_DIR}"/hack/patches/*