apiVersion: v1
data:
  initialize: "#!/bin/sh\nset -e ; # Have script exit in the event of a failed command.\nMC_CONFIG_DIR=\"/etc/minio/mc/\"\nMC=\"/usr/bin/mc
    --insecure --config-dir ${MC_CONFIG_DIR}\"\n\n# connectToMinio\n# Use a check-sleep-check
    loop to wait for Minio service to be available\nconnectToMinio() {\n  SCHEME=$1\n
    \ ATTEMPTS=0 ; LIMIT=29 ; # Allow 30 attempts\n  set -e ; # fail if we can't read
    the keys.\n  ACCESS=$(cat /config/accesskey) ; SECRET=$(cat /config/secretkey)
    ;\n  set +e ; # The connections to minio are allowed to fail.\n  echo \"Connecting
    to Minio server: $SCHEME://$MINIO_ENDPOINT:$MINIO_PORT\" ;\n  MC_COMMAND=\"${MC}
    config host add myminio $SCHEME://$MINIO_ENDPOINT:$MINIO_PORT $ACCESS $SECRET\"
    ;\n  $MC_COMMAND ;\n  STATUS=$? ;\n  until [ $STATUS = 0 ]\n  do\n    ATTEMPTS=`expr
    $ATTEMPTS + 1` ;\n    echo \\\"Failed attempts: $ATTEMPTS\\\" ;\n    if [ $ATTEMPTS
    -gt $LIMIT ]; then\n      exit 1 ;\n    fi ;\n    sleep 2 ; # 1 second intervals
    between attempts\n    $MC_COMMAND ;\n    STATUS=$? ;\n  done ;\n  set -e ; # reset
    `e` as active\n  return 0\n}\n\n# checkBucketExists ($bucket)\n# Check if the
    bucket exists, by using the exit code of `mc ls`\ncheckBucketExists() {\n  BUCKET=$1\n
    \ CMD=$(${MC} ls myminio/$BUCKET > /dev/null 2>&1)\n  return $?\n}\n\n# createBucket
    ($bucket, $policy, $purge)\n# Ensure bucket exists, purging if asked to\ncreateBucket()
    {\n  BUCKET=$1\n  POLICY=$2\n  PURGE=$3\n  VERSIONING=$4\n\n  # Purge the bucket,
    if set & exists\n  # Since PURGE is user input, check explicitly for `true`\n
    \ if [ $PURGE = true ]; then\n    if checkBucketExists $BUCKET ; then\n      echo
    \"Purging bucket '$BUCKET'.\"\n      set +e ; # don't exit if this fails\n      ${MC}
    rm -r --force myminio/$BUCKET\n      set -e ; # reset `e` as active\n    else\n
    \     echo \"Bucket '$BUCKET' does not exist, skipping purge.\"\n    fi\n  fi\n\n
    \ # Create the bucket if it does not exist\n  if ! checkBucketExists $BUCKET ;
    then\n    echo \"Creating bucket '$BUCKET'\"\n    ${MC} mb myminio/$BUCKET\n  else\n
    \   echo \"Bucket '$BUCKET' already exists.\"\n  fi\n\n\n  # set versioning for
    bucket\n  if [ ! -z $VERSIONING ] ; then\n    if [ $VERSIONING = true ] ; then\n
    \       echo \"Enabling versioning for '$BUCKET'\"\n        ${MC} version enable
    myminio/$BUCKET\n    elif [ $VERSIONING = false ] ; then\n        echo \"Suspending
    versioning for '$BUCKET'\"\n        ${MC} version suspend myminio/$BUCKET\n    fi\n
    \ else\n      echo \"Bucket '$BUCKET' versioning unchanged.\"\n  fi\n\n  # At
    this point, the bucket should exist, skip checking for existence\n  # Set policy
    on the bucket\n  echo \"Setting policy of bucket '$BUCKET' to '$POLICY'.\"\n  ${MC}
    policy set $POLICY myminio/$BUCKET\n}\n\n# Try connecting to Minio instance\nscheme=http\nconnectToMinio
    $scheme\n# Create the buckets\ncreateBucket enterprise-metrics-tsdb none false
    \ncreateBucket enterprise-metrics-admin none false \ncreateBucket enterprise-metrics-ruler
    none false"
kind: ConfigMap
metadata:
  labels:
    app: minio
    app.kubernetes.io/managed-by: Helmraiser
    chart: minio-8.0.9
    heritage: Helm
    release: enterprise-metrics
  name: enterprise-metrics-minio
  namespace: enterprise-metrics
