apiVersion: v1
data:
  gitInitRepo.sh: |-
    until $(curl --output /dev/null --silent --head --fail http://gogs);
    do 
      echo 'waiting for gogs'
      sleep 11;
    done

    sleep 42

    echo 'create user'
    curl -d "user_name={{.Values.gogs.git.user}}&email=yuuvis%40yuuvis.org&password={{.Values.gogs.git.password}}&retype={{.Values.gogs.git.password}}" -c cookies.txt http://gogs/user/sign_up 

    echo 'login git'
    CSRF=$(cat ./cookies.txt | grep _csrf | cut -f 7)
    curl -d "_csrf=$CSRF&user_name={{.Values.gogs.git.user}}&password={{.Values.gogs.git.password}}" -c cookies2.txt -L http://gogs/user/login

    echo 'create git repository'
    CSRF2=$(cat ./cookies2.txt | grep _csrf | cut -f 7)
    curl -d "_csrf=$CSRF2&user_id=1&repo_name=yuuvis-config&private=on&description=&gitignores=&license=&readme=Default&auto_init=on" -b cookies2.txt -L http://gogs/repo/create
kind: ConfigMap
metadata:
  name: gitinitrepo
