#!/bin/bash

# Generate a Helm values yaml file which overrides all the Wallaroo images in order to use a private image registry.

usage() {
    echo 'USAGE: generate-airgap-image-values --registry REGISTRY_PATH

  --registry REGISTRY_PATH     Complete host and path prefixing all images in private image registry. The path must include any discriminating
                               path components. Example: 9876543210.dkr.ecr.us-east-1.amazonaws.com/wallaroo
' >&2
    exit 1
}

set -euo pipefail
registry=''

while [ $# -gt 0 ]; do
    case $1 in
	--registry)
	    registry=$2;
	    shift 2
	    ;;
	*) usage
	   ;;
    esac
done

[[ -n "$registry" ]] || usage


cat <<EOF
# This file was automatically generated by Wallaroo generate-airgap-image-values containing
# Helm values to override third party images when installing with a private container registry.
# This should be regenerated using the new generator if upgrading.

kubectl:
  image:
    repository: $registry/kubectl

minio:
  imagePullSecrets:
    - name: regcred
  image:
    repository: $registry/minio
  mcImage:
    repository: $registry/mc

nats:
  global:
    image:
      pullSecretNames:
        - regcred
      registry: $registry

  reloader:
    enabled: true
    image:
      repository: nats-server-config-reloader
  
natsBox:
  container:
    image:
      repository: $registry/nats-box

spireAgentInit:
  image: $registry/wait-for-it:latest

fluent-bit:
  imagePullSecrets:
    - name: regcred
  image:
    repository: $registry/fluent-bit
  testFramework:
    image:
      repository: $registry/busybox
      tag: 1.36
EOF
