{{- $mysqlUrl := print "jdbc:mysql://" (include "hopsworks.consul.mysqlDnsName" .)  ":" (.Values.dependencies.mysql.port) -}}
{{- $mysqlUrlReg := regexReplaceAll ":" $mysqlUrl "\\:" -}}
{{- 
    $property := print 
        "user=" (.Values.variables.hopsworks_mysql_user)
        ":password=${ENV=HOPSWORKS_MYSQL_PASSWORD}"
        ":url=" $mysqlUrlReg
        ":useSSL=false:allowPublicKeyRetrieval=true:fail-all-connections=true"
-}}

create-jdbc-connection-pool --restype=javax.sql.DataSource --datasourceclassname=com.mysql.cj.jdbc.MysqlDataSource --isconnectvalidatereq=true --validationmethod=auto-commit --description="Hopsworks Connection Pool" --property {{ $property }} hopsworksPool

create-jdbc-connection-pool --restype javax.sql.XADataSource --datasourceclassname com.mysql.cj.jdbc.MysqlXADataSource --isconnectvalidatereq=true --validationmethod=auto-commit --description="Hopsworks EJB Connection Pool" --property {{ $property }} ejbTimerPool 

create-jdbc-resource --connectionpoolid hopsworksPool --description "Resource for Hopsworks Pool" jdbc/hopsworks

create-jdbc-resource --connectionpoolid ejbTimerPool --description "Resource for Hopsworks EJB Timers Pool" jdbc/hopsworksTimers

create-protocol --securityenabled=true https-internal

create-http --default-virtual-server server https-internal

create-network-listener --listenerport {{ .Values.hopsworksCA.containerPort }} --threadpool http-thread-pool --protocol https-internal https-int-list
