file:
  {{ .Vars.persistence.mountPath }}:
    exists: true
    filetype: directory
    mode: "2775"
    owner: root
  /opt/bitnami/cassandra/conf/cassandra.yaml:
    exists: true
    filetype: file
    mode: "0644"
    group: root
    contains:
      - /num_tokens.*{{ .Vars.cluster.numTokens }}/
  /var/run/secrets/kubernetes.io/serviceaccount:
    exists: {{ .Vars.serviceAccount.automountServiceAccountToken }}
    filetype: directory
    mode: "3777"
command:
  {{- $dbUser := .Vars.dbUser.user }}
  {{- $dbPassword := .Vars.dbUser.password }}
  {{- $port := .Vars.containerPorts.cql }}
  {{- $nodes := .Vars.replicaCount }}
  {{- $keyspace := printf "test_%s" (randAlpha 5) }}
  manage-keyspace:
    exec: "cqlsh -u {{ $dbUser }} -p {{ $dbPassword }} -e 'CREATE KEYSPACE {{ $keyspace }} WITH REPLICATION = { $$class$$: $$SimpleStrategy$$, $$replication_factor$$ : {{ $nodes }} };' cassandra-0.cassandra-headless {{ $port }}{{ range $e, $i := until $nodes }} && cqlsh -u {{ $dbUser }} -p {{ $dbPassword }} -e 'USE {{ $keyspace }};' cassandra-{{ $i }}.cassandra-headless {{ $port }}{{ end }}"
    exit-status: 0
    timeout: 20000
  cluster-size:
    exec: if [ "$(nodetool status | grep {{ .Vars.cluster.numTokens }} | wc -l)" -ne {{ $nodes }} ]; then exit 1; fi
    exit-status: 0
    timeout: 20000
  check-user-info:
    exec: id
    exit-status: 0
    stdout:
    - uid={{ .Vars.containerSecurityContext.runAsUser }}
    - /groups=.*{{ .Vars.podSecurityContext.fsGroup }}/
