---
apiVersion: v1
kind: ConfigMap
metadata:
  name: stratum-config-scripts
  labels:
    app: stratum
    chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
    release: "{{ .Release.Name }}"
    heritage: "{{ .Release.Service }}"
data:
  stratum-config: |
    #!/bin/sh
    set -e -x
    # From Helm values and then is mounted by configmap
    HELM_CHASSIS_CONFIG=/opt/chassis_config/$NODE_NAME
    # File on the switch filesystem, will be used by the stratum-config-startup script
    CHASSIS_CONFIG=$CFG_MOUNT/chassis_config.pb.txt
    if [ -f $HELM_CHASSIS_CONFIG ]; then
        if [ -f $CHASSIS_CONFIG ] && [ ! -f $CHASSIS_CONFIG.old ]; then
            mv $CHASSIS_CONFIG $CHASSIS_CONFIG.old
        fi
        cp $HELM_CHASSIS_CONFIG $CHASSIS_CONFIG
    fi
