# helm_charts_configmap--peer.yaml
apiVersion: v1
kind: ConfigMap
metadata:
  name: {{ include "hlf-peer.fullname" . }}--peer
  labels:
{{ include "labels.standard" . | indent 4 }}
data:
  CORE_PEER_ADDRESSAUTODETECT: "true"
  CORE_PEER_ID: {{ .Release.Name }}
  CORE_PEER_NETWORKID: nid1
  # If we have an ingress, we set hostname to it
  {{- if .Values.ingress.enabled }}
  CORE_PEER_ADDRESS: {{ index .Values.ingress.hosts 0 }}:443
  {{- else }}
  # Otherwise we use CORE_PEER_ADDRESSAUTODETECT to auto-detect its address
  {{- end }}
  CORE_PEER_LISTENADDRESS: 0.0.0.0:7051
  CORE_PEER_EVENTS_ADDRESS: 0.0.0.0:7053
  CORE_PEER_COMMITTER_ENABLED: "true"
  CORE_PEER_PROFILE_ENABLED: "true"
  CORE_PEER_DISCOVERY_PERIOD: 60s
  CORE_PEER_DISCOVERY_TOUCHPERIOD: 60s
  CORE_PEER_LOCALMSPID: {{ .Values.peer.mspID | quote }}
  CORE_PEER_MSPCONFIGPATH: /var/hyperledger/msp
  ###########
  # Logging #
  ###########
  CORE_LOGGING_LEVEL: {{ .Values.logging.level | quote }}
  CORE_LOGGING_PEER: {{ .Values.logging.peer | quote }}
  CORE_LOGGING_CAUTHDSL: {{ .Values.logging.cauthdsl | quote }}
  CORE_LOGGING_GOSSIP: {{ .Values.logging.gossip | quote }}
  CORE_LOGGING_LEDGER: {{ .Values.logging.ledger | quote }}
  CORE_LOGGING_MSP: {{ .Values.logging.msp | quote }}
  CORE_LOGGING_POLICIES: {{ .Values.logging.policies | quote }}
  CORE_LOGGING_GRPC: {{ .Values.logging.grpc | quote }}
  ##########
  # Gossip #
  ##########
  CORE_PEER_GOSSIP_BOOTSTRAP: {{ .Values.peer.gossip.bootstrap | quote }}
  CORE_PEER_GOSSIP_ENDPOINT: {{ .Values.peer.gossip.endpoint | quote }}
  CORE_PEER_GOSSIP_EXTERNALENDPOINT: {{ .Values.peer.gossip.externalEndpoint | quote }}
  CORE_PEER_GOSSIP_ORGLEADER: {{ .Values.peer.gossip.orgLeader | quote }}
  CORE_PEER_GOSSIP_USELEADERELECTION: {{ .Values.peer.gossip.useLeaderElection | quote }}
  #############
  # CHAINCODE #
  #############
  {{- if .Values.peer.chaincode.builder }}
  CORE_CHAINCODE_BUILDER: {{ .Values.peer.chaincode.builder | quote }}
  {{- end}}
  {{- if .Values.peer.chaincode.runtime.golang }}
  CORE_CHAINCODE_GOLANG_RUNTIME: {{ .Values.peer.chaincode.runtime.golang | quote }}
  {{- end}}
  {{- if .Values.peer.chaincode.runtime.java }}
  CORE_CHAINCODE_JAVA_RUNTIME: {{ .Values.peer.chaincode.runtime.java | quote }}
  {{- end}}
  {{- if .Values.peer.chaincode.runtime.node }}
  CORE_CHAINCODE_NODE_RUNTIME: {{ .Values.peer.chaincode.runtime.node | quote }}
  {{- end}}
  ##########
  # TLS    #
  ##########
  CORE_PEER_TLS_ENABLED: {{ .Values.peer.tls.server.enabled | quote }}
  CORE_PEER_TLS_CERT_FILE: "/var/hyperledger/tls/server/pair/tls.crt"
  CORE_PEER_TLS_KEY_FILE: "/var/hyperledger/tls/server/pair/tls.key"
  CORE_PEER_TLS_ROOTCERT_FILE: "/var/hyperledger/tls/server/cert/cacert.pem"
  CORE_PEER_TLS_CLIENTAUTHREQUIRED: {{ .Values.peer.tls.client.enabled | quote }}
  # This is fixed prior to starting the peer
  CORE_PEER_TLS_CLIENTROOTCAS_FILES: "/var/hyperledger/tls/client/cert/*"
  CORE_PEER_TLS_CLIENTCERT_FILE: "/var/hyperledger/tls/client/pair/tls.crt"
  CORE_PEER_TLS_CLIENTKEY_FILE: "/var/hyperledger/tls/client/pair/tls.key"
  CORE_VM_ENDPOINT: unix:///host/var/run/docker.sock
  CORE_LEDGER_STATE_STATEDATABASE: {{ .Values.peer.databaseType | quote }}
  # Containers in the same pod share the host
  {{- if eq .Values.peer.databaseType "CouchDB" }}
  CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS: {{ .Values.peer.couchdbInstance }}-hlf-couchdb:5984
  {{- end }}
  PEER_CFG_PATH: /var/hyperledger/config
  FABRIC_CFG_PATH: /var/hyperledger/fabric_cfg
  GODEBUG: "netdns=go"
  ADMIN_MSP_PATH: /var/hyperledger/admin_msp
  ORD_TLS_PATH: /var/hyperledger/tls/ord/cert
##############
# Operations #
##############
  {{- if eq .Values.peer.metrics.provider "prometheus" }}
  CORE_OPERATIONS_LISTENADDRESS: 0.0.0.0:9443
  {{- end }}
  {{- if eq .Values.peer.metrics.provider "statsd" }}
  CORE_OPERATIONS_LISTENADDRESS: 127.0.0.1:8125
  {{- end }}
###########
# Metrics #
###########
  CORE_METRICS_PROVIDER: {{ .Values.peer.metrics.provider | quote }}
  {{- if eq .Values.peer.metrics.provider "statsd" }}
  CORE_METRICS_STATSD_NETWORK: {{ .Values.peer.metrics.statsd.network | quote }}
  CORE_METRICS_STATSD_ADDRESS: {{ .Values.peer.metrics.statsd.address | quote }}
  CORE_METRICS_STATSD_WRITEINTERVAL: {{ .Values.peer.metrics.statsd.writeInterval | quote }}
  CORE_METRICS_STATSD_PREFIX: {{ .Values.peer.metrics.statsd.prefix | quote }}
  {{- end }}