-
Notifications
You must be signed in to change notification settings - Fork 874
/
synchronize-kubeflow-manifests.sh
executable file
·183 lines (153 loc) · 6.58 KB
/
synchronize-kubeflow-manifests.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
#!/usr/bin/env bash
# This script aims at helping create a PR to update the manifests of the
# kubeflow/kubeflow repo.
# This script:
# 1. Checks out a new branch
# 2. Copies files to the correct places
# 3. Commits the changes
#
# Afterwards the developers can submit the PR to the kubeflow/manifests
# repo, based on that local branch
# strict mode http://redsymbol.net/articles/unofficial-bash-strict-mode/
set -euo pipefail
IFS=$'\n\t'
COMMIT="v1.9.1" # You can use tags as well
SRC_DIR=${SRC_DIR:=/tmp/kubeflow-kubeflow}
BRANCH=${BRANCH:=synchronize-kubeflow-kubeflow-manifests-${COMMIT?}}
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
MANIFESTS_DIR=$(dirname $SCRIPT_DIR)
echo "Creating branch: ${BRANCH}"
if [ -n "$(git status --porcelain)" ]; then
echo "WARNING: You have uncommitted changes"
fi
if [ `git branch --list $BRANCH` ]
then
echo "WARNING: Branch $BRANCH already exists."
fi
# Create the branch in the manifests repository
if ! git show-ref --verify --quiet refs/heads/$BRANCH; then
git checkout -b $BRANCH
else
echo "Branch $BRANCH already exists."
fi
echo "Checking out in $SRC_DIR to $COMMIT..."
# Checkout the upstream repository
mkdir -p $SRC_DIR
cd $SRC_DIR
if [ ! -d "kubeflow/.git" ]; then
git clone https://github.com/kubeflow/kubeflow.git
fi
cd $SRC_DIR/kubeflow
if ! git rev-parse --verify --quiet $COMMIT; then
git checkout -b $COMMIT
else
git checkout $COMMIT
fi
if [ -n "$(git status --porcelain)" ]; then
echo "WARNING: You have uncommitted changes"
fi
echo "Copying admission-webhook manifests..."
DST_DIR=$MANIFESTS_DIR/apps/admission-webhook/upstream
if [ -d "$DST_DIR" ]; then
rm -r "$DST_DIR"
fi
mkdir -p $DST_DIR
cp $SRC_DIR/kubeflow/components/admission-webhook/manifests/* $DST_DIR -r
echo "Updating README..."
SRC_TXT="\[.*\](https://github.com/kubeflow/kubeflow/tree/.*/components/admission-webhook/manifests)"
DST_TXT="\[$COMMIT\](https://github.com/kubeflow/kubeflow/tree/$COMMIT/components/admission-webhook/manifests)"
sed -i "s|$SRC_TXT|$DST_TXT|g" ${MANIFESTS_DIR}/README.md
echo "Copying centraldashboard manifests..."
DST_DIR=$MANIFESTS_DIR/apps/centraldashboard/upstream
if [ -d "$DST_DIR" ]; then
rm -r "$DST_DIR"
fi
mkdir -p $DST_DIR
cp $SRC_DIR/kubeflow/components/centraldashboard/manifests/* $DST_DIR -r
echo "Updating README..."
SRC_TXT="\[.*\](https://github.com/kubeflow/kubeflow/tree/.*/components/centraldashboard/manifests)"
DST_TXT="\[$COMMIT\](https://github.com/kubeflow/kubeflow/tree/$COMMIT/components/centraldashboard/manifests)"
sed -i "s|$SRC_TXT|$DST_TXT|g" ${MANIFESTS_DIR}/README.md
echo "Copying jupyter-web-app manifests..."
DST_DIR=$MANIFESTS_DIR/apps/jupyter/jupyter-web-app/upstream
if [ -d "$DST_DIR" ]; then
rm -r "$DST_DIR"
fi
mkdir -p $DST_DIR
cp $SRC_DIR/kubeflow/components/crud-web-apps/jupyter/manifests/* $DST_DIR -r
echo "Updating README..."
SRC_TXT="\[.*\](https://github.com/kubeflow/kubeflow/tree/.*/components/crud-web-apps/jupyter/manifests)"
DST_TXT="\[$COMMIT\](https://github.com/kubeflow/kubeflow/tree/$COMMIT/components/crud-web-apps/jupyter/manifests)"
sed -i "s|$SRC_TXT|$DST_TXT|g" ${MANIFESTS_DIR}/README.md
echo "Copying volumes-web-app manifests..."
DST_DIR=$MANIFESTS_DIR/apps/volumes-web-app/upstream
if [ -d "$DST_DIR" ]; then
rm -r "$DST_DIR"
fi
mkdir -p $DST_DIR
cp $SRC_DIR/kubeflow/components/crud-web-apps/volumes/manifests/* $DST_DIR -r
echo "Updating README..."
SRC_TXT="\[.*\](https://github.com/kubeflow/kubeflow/tree/.*/components/crud-web-apps/volumes/manifests)"
DST_TXT="\[$COMMIT\](https://github.com/kubeflow/kubeflow/tree/$COMMIT/components/crud-web-apps/volumes/manifests)"
sed -i "s|$SRC_TXT|$DST_TXT|g" ${MANIFESTS_DIR}/README.md
echo "Copying tensorboards-web-app manifests..."
DST_DIR=$MANIFESTS_DIR/apps/tensorboard/tensorboards-web-app/upstream
if [ -d "$DST_DIR" ]; then
rm -r "$DST_DIR"
fi
mkdir -p $DST_DIR
cp $SRC_DIR/kubeflow/components/crud-web-apps/tensorboards/manifests/* $DST_DIR -r
echo "Updating README..."
SRC_TXT="\[.*\](https://github.com/kubeflow/kubeflow/tree/.*/components/crud-web-apps/tensorboards/manifests)"
DST_TXT="\[$COMMIT\](https://github.com/kubeflow/kubeflow/tree/$COMMIT/components/crud-web-apps/tensorboards/manifests)"
sed -i "s|$SRC_TXT|$DST_TXT|g" ${MANIFESTS_DIR}/README.md
echo "Copying profile-controller manifests..."
DST_DIR=$MANIFESTS_DIR/apps/profiles/upstream
if [ -d "$DST_DIR" ]; then
rm -r "$DST_DIR"
fi
mkdir -p $DST_DIR
cp $SRC_DIR/kubeflow/components/profile-controller/config/* $DST_DIR -r
echo "Updating README..."
SRC_TXT="\[.*\](https://github.com/kubeflow/kubeflow/tree/.*/components/profile-controller/config)"
DST_TXT="\[$COMMIT\](https://github.com/kubeflow/kubeflow/tree/$COMMIT/components/profile-controller/config)"
sed -i "s|$SRC_TXT|$DST_TXT|g" ${MANIFESTS_DIR}/README.md
echo "Copying notebook-controller manifests..."
DST_DIR=$MANIFESTS_DIR/apps/jupyter/notebook-controller/upstream
if [ -d "$DST_DIR" ]; then
rm -r "$DST_DIR"
fi
mkdir -p $DST_DIR
cp $SRC_DIR/kubeflow/components/notebook-controller/config/* $DST_DIR -r
echo "Updating README..."
SRC_TXT="\[.*\](https://github.com/kubeflow/kubeflow/tree/.*/components/notebook-controller/config)"
DST_TXT="\[$COMMIT\](https://github.com/kubeflow/kubeflow/tree/$COMMIT/components/notebook-controller/config)"
sed -i "s|$SRC_TXT|$DST_TXT|g" ${MANIFESTS_DIR}/README.md
echo "Copying tensorboard-controller manifests..."
DST_DIR=$MANIFESTS_DIR/apps/tensorboard/tensorboard-controller/upstream
if [ -d "$DST_DIR" ]; then
rm -r "$DST_DIR"
fi
mkdir -p $DST_DIR
cp $SRC_DIR/kubeflow/components/tensorboard-controller/config/* $DST_DIR -r
echo "Updating README..."
SRC_TXT="\[.*\](https://github.com/kubeflow/kubeflow/tree/.*/components/tensorboard-controller/config)"
DST_TXT="\[$COMMIT\](https://github.com/kubeflow/kubeflow/tree/$COMMIT/components/tensorboard-controller/config)"
sed -i "s|$SRC_TXT|$DST_TXT|g" ${MANIFESTS_DIR}/README.md
echo "Copying pvcviewer-controller manifests..."
DST_DIR=$MANIFESTS_DIR/apps/pvcviewer-controller/upstream
if [ -d "$DST_DIR" ]; then
rm -r "$DST_DIR"
fi
mkdir -p $DST_DIR
cp $SRC_DIR/kubeflow/components/pvcviewer-controller/config/* $DST_DIR -r
echo "Updating README..."
SRC_TXT="\[.*\](https://github.com/kubeflow/kubeflow/tree/.*/components/pvcviewer-controller/config)"
DST_TXT="\[$COMMIT\](https://github.com/kubeflow/kubeflow/tree/$COMMIT/components/pvcviewer-controller/config)"
sed -i "s|$SRC_TXT|$DST_TXT|g" ${MANIFESTS_DIR}/README.md
echo "Successfully copied all manifests."
echo "Committing the changes..."
cd $MANIFESTS_DIR
git add apps
git add README.md
git commit -s -m "Update kubeflow/kubeflow manifests from ${COMMIT}"