file:
  /bitnami/influxdb:
    exists: true
    filetype: directory
    mode: "2775"
    owner: root
  /var/run/secrets/kubernetes.io/serviceaccount:
    exists: {{ .Vars.serviceAccount.automountServiceAccountToken }}
    filetype: directory
    mode: "3777"
command:
  check-user-info:
    exec: id
    exit-status: 0
    stdout:
    - uid={{ .Vars.influxdb.containerSecurityContext.runAsUser }}
    - /groups=.*{{ .Vars.influxdb.podSecurityContext.fsGroup }}/
  {{- $org := .Vars.auth.user.org }}
  {{- $bucket := .Vars.auth.user.bucket }}
  {{- $port := .Vars.influxdb.service.ports.http }}
  {{- $adminToken := .Vars.auth.admin.token }}
  {{- $user := .Vars.auth.user.username }}
  {{- $msg := printf "error_%s" (randAlpha 5) }}
  influx-write-read:
    exec: export INFLUX_TOKEN='{{ $adminToken }}' && influx write --host http://influxdb:{{ $port }} --org {{ $org }} --bucket {{ $bucket }} 'cpu_error,host=bitnami-server value="{{ $msg }}"' && export INFLUX_TOKEN=$(influx auth list | grep {{ $user }} | awk '{print $2}') && influx query --host http://influxdb:{{ $port }} --org {{ $org }} 'from(bucket:"{{ $bucket }}") |> range(start:-2m)'
    exit-status: 0
    stdout:
      - {{ $msg }}