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

    sleep 42

    echo 'create user'
    curl -X 'POST' \
    'http://gitea_admin:{{.Values.gitea.gitea.admin.password}}@gitea-http:3000/api/v1/admin/users' \
    -H 'accept: application/json' \
    -H 'Content-Type: application/json' \
    -d '{
       "email": "{{.Values.yuuvis.git.user}}@yuuvis.com",
       "must_change_password": false,
       "password": "{{.Values.yuuvis.git.password}}",
       "username": "{{.Values.yuuvis.git.user}}"
    }'
    
    echo 'create git repository'
    curl -X 'POST'   'http://{{.Values.yuuvis.git.user}}:{{.Values.yuuvis.git.password}}@gitea-http:3000/api/v1/user/repos'   -H 'accept: application/json'   -H 'Content-Type: application/json'   -d '{
      "auto_init": true,
      "default_branch": "main",
      "description": "yuuvis config files",
      "name": "yuuvis-config",
      "private": true,
      "template": true,
      "trust_model": "default"
    }'
kind: ConfigMap
metadata:
  name: gitinitrepo
