apiVersion: v1
kind: ConfigMap
metadata:
  name: grafana-datasources
  namespace: federatorai
data:
  gettoken.sh: |-
    #!/usr/bin/env sh
    #while
    #do
    value=`cat /var/run/secrets/kubernetes.io/serviceaccount/token`
    value="Bearer ${value}"
    echo $value
    cp  datasources/prometheus.yaml  /etc/grafana/provisioning/datasources/prometheus.yaml
    sed -i 's/Bearer/'"$value"'/g' /etc/grafana/provisioning/datasources/prometheus.yaml
    cat /etc/grafana/provisioning/datasources/prometheus.yaml
    #done
  prometheus.yaml: |-
    {
        "apiVersion": 1,
        "datasources": [
            {
                "name": "InfluxDB",                  
                "type": "influxdb",
                "access": "proxy",
                "url": "https://alameda-influxdb.federatorai.svc:8086",
                "password": "adminpass",
                "user": "admin",
                "database": "_internal",
                "basicAuth": false,
                "isDefault": false,
                "jsonData": {
                  "tlsSkipVerify": true
                },
                "readOnly": false,
            },
            {
                "name": "Prometheus",
                "type": "prometheus",
                "access": "proxy",
                "url": "https://prometheus-k8s.openshift-monitoring.svc:9091",
                "basicAuth": false,
                "isDefault": true,
                "jsonData": {
                  "tlsSkipVerify": true,
                  "httpHeaderName1": "Authorization",
                },
                "secureJsonData": {
                  "httpHeaderValue1": "Bearer"
                },
                "readOnly": false,
            }
        ]
    }      

  
  