{{- if .Values.sqlGateway.enabled }}
---
# Hadoop Configuration ConfigMap for SQL Gateway
apiVersion: v1
kind: ConfigMap
metadata:
  name: hadoop-config-{{ .Values.sessionCluster.name }}
  namespace: {{ include "flink-sql-gateway.namespace" . }}
  labels:
    {{- include "flink-sql-gateway.sqlGateway.labels" . | nindent 4 }}
data:
  core-site.xml: |
    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
      <property>
        <name>fs.defaultFS</name>
        <value>hdfs://localhost:9000</value>
      </property>
      <property>
        <name>hadoop.tmp.dir</name>
        <value>/tmp/hadoop</value>
      </property>
      
      <!-- S3A Configuration -->
      <property>
        <name>fs.s3a.impl</name>
        <value>org.apache.hadoop.fs.s3a.S3AFileSystem</value>
      </property>
      <property>
        <name>fs.s3a.aws.credentials.provider</name>
        <value>org.apache.hadoop.fs.s3a.SimpleAWSCredentialsProvider</value>
      </property>
      <property>
        <name>fs.s3a.access.key</name>
        <value>${AWS_ACCESS_KEY_ID}</value>
      </property>
      <property>
        <name>fs.s3a.secret.key</name>
        <value>${AWS_SECRET_ACCESS_KEY}</value>
      </property>
      <property>
        <name>fs.s3a.endpoint</name>
        <value>${S3_ENDPOINT}</value>
      </property>
      <property>
        <name>fs.s3a.path.style.access</name>
        <value>true</value>
      </property>
      <property>
        <name>fs.s3a.connection.ssl.enabled</name>
        <value>false</value>
      </property>
      <property>
        <name>fs.s3a.fast.upload</name>
        <value>true</value>
      </property>
      <property>
        <name>fs.s3a.multipart.size</name>
        <value>67108864</value>
      </property>
      <property>
        <name>fs.s3a.multipart.threshold</name>
        <value>134217728</value>
      </property>
    </configuration>
  
  hdfs-site.xml: |
    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
      <property>
        <name>dfs.replication</name>
        <value>1</value>
      </property>
      <property>
        <name>dfs.namenode.name.dir</name>
        <value>/tmp/hadoop/namenode</value>
      </property>
      <property>
        <name>dfs.datanode.data.dir</name>
        <value>/tmp/hadoop/datanode</value>
      </property>
    </configuration>
  
  yarn-site.xml: |
    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
      <property>
        <name>yarn.nodemanager.aux-services</name>
        <value>mapreduce_shuffle</value>
      </property>
      <property>
        <name>yarn.resourcemanager.hostname</name>
        <value>localhost</value>
      </property>
    </configuration>
{{- end }}