{{- $arcExtensionSettings := include "arc-extension-settings" . | fromYaml }}

{{- if $arcExtensionSettings.isArcExtension }}

{{- if $arcExtensionSettings.isProxyEnabled }}
apiVersion: v1
kind: Secret
metadata:
  name: ama-metrics-proxy-config
  namespace: kube-system
type: Opaque
data:
  {{- if .Values.Azure.proxySettings.httpProxy }}
    HTTP_PROXY: {{.Values.Azure.proxySettings.httpProxy | b64enc | quote}}
    http_proxy: {{.Values.Azure.proxySettings.httpProxy | b64enc | quote}}
  {{end}}
  {{- if .Values.Azure.proxySettings.httpsProxy }}
    HTTPS_PROXY: {{.Values.Azure.proxySettings.httpsProxy | b64enc | quote}}
    https_proxy: {{.Values.Azure.proxySettings.httpsProxy | b64enc | quote}}
  {{end}}
  {{- if .Values.Azure.proxySettings.noProxy }}
    NO_PROXY: {{.Values.Azure.proxySettings.noProxy| b64enc | quote}}
    no_proxy: {{.Values.Azure.proxySettings.noProxy| b64enc | quote}}
  {{end}}
{{- end }}

---

{{- if and (or .Values.Azure.proxySettings.isCustomCert $arcExtensionSettings.isProxyEnabled ) (.Values.Azure.proxySettings.proxyCert) }}
apiVersion: v1
kind: Secret
metadata:
  name: ama-metrics-proxy-cert
  namespace: kube-system
type: Opaque
data: 
  proxy-cert.crt: {{.Values.Azure.proxySettings.proxyCert | b64enc | quote}}
{{- end }}

{{- end }}