apiVersion: v1
kind: Secret
metadata:
  name: {{ include "karpenter.fullname" . }}-credentials
  namespace: {{ .Release.Namespace }}
  labels:
    {{- include "karpenter.labels" . | nindent 4 }}
type: Opaque
data:
  ibm_api_key: {{ required "IBM Cloud API Key is required" .Values.credentials.ibmApiKey | b64enc | quote }}
  vpc_api_key: {{ required "VPC API Key is required" .Values.credentials.vpcApiKey | b64enc | quote }}
  region: {{ required "IBM Cloud Region is required" .Values.credentials.region | b64enc | quote }}
  {{- if .Values.credentials.zone }}
  zone: {{ .Values.credentials.zone | b64enc | quote }}
  {{- end }}
  {{- if .Values.credentials.resourceGroupId }}
  resource_group_id: {{ .Values.credentials.resourceGroupId | b64enc | quote }}
  {{- end }}
  vpc_url: {{ .Values.credentials.vpcUrl | default (printf "https://%s.iaas.cloud.ibm.com/v1" .Values.credentials.region) | b64enc | quote }}
  vpc_auth_type: {{ .Values.credentials.vpcAuthType | default "iam" | b64enc | quote }}
