apiVersion: v1
kind: ConfigMap
metadata:
  namespace: cabotage
  name: consul-scripts
data:
  write-secrets.sh: |
    if [ "$CONSUL_ACL_AGENT_TOKEN" != "null" ]; then
      cat > /etc/consul/secrets/acl_agent_token.json <<EOF
    {"acl_agent_token": "$CONSUL_ACL_AGENT_TOKEN"}
    EOF
      echo "Wrote /etc/consul/secrets/acl_agent_token.json"
    fi
    cat > /etc/consul/secrets/encrypt.json <<EOF
    {"encrypt": "$GOSSIP_ENCRYPTION_KEY"}
    EOF
    echo "Wrote /etc/consul/secrets/encrypt.json"
