aboutsummaryrefslogtreecommitdiff
path: root/prod-yolean.sh
blob: 80cb893874e489e3552bd2ed3b2ca37763be268d (plain) (blame)
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
#!/bin/bash
# Combines addons into what we 'kubectl apply -f' to production
set -ex

ANNOTATION_PREFIX='yolean.se/kubernetes-kafka-'
BUILD=$(basename $0)

function annotate {
  key=$1
  value=$2
  file=$3
  case $(uname) in
    Darwin*)
      sed -i '' 's|      annotations:|      annotations:\
        --next-annotation--|' $file
      sed -i '' "s|--next-annotation--|${ANNOTATION_PREFIX}$key: '$value'|" $file
      ;;
    *)
      sed -i "s|      annotations:|      annotations:\n        ${ANNOTATION_PREFIX}$key: '$value'|" $file
      ;;
  esac
}

git fetch
git checkout origin/master

echo "Working copy must be clean"
[ -z "$(git status --untracked-files=no -s)" ]
START_REV_GIT=$(git rev-parse --short HEAD)

git checkout -b prod-yolean-$(date +"%Y%m%dT%H%M%S")

for BRANCH in \
  addon-storage-classes \
  addon-metrics \
  addon-rest \
  addon-kube-events-topic
do
  git merge --no-ff $BRANCH -m "prod-yolean merge $BRANCH"
done

END_BRANCH_GIT=$(git rev-parse --abbrev-ref HEAD)

for F in ./50kafka.yml ./zookeeper/50pzoo.yml ./zookeeper/51zoo.yml
do
  annotate fromrev $START_REV_GIT $F
  annotate build $END_BRANCH_GIT $F
done