
(@ def vsphere_conf(values): -@)
[Global]
(@ if values.vsphereCSI.insecureFlag: -@)
insecure-flag = true
(@ else: -@)
thumbprint = "(@=values.vsphereCSI.tlsThumbprint @)"
(@ end -@)
(@ if hasattr(values.vsphereCSI, "queryLimit") and str(values.vsphereCSI.queryLimit) != "None" and int(values.vsphereCSI.queryLimit) > 0: -@)
query-limit = (@=str(values.vsphereCSI.queryLimit) @)
(@ end -@)
(@ if hasattr(values.vsphereCSI, "listVolumeThreshold") and str(values.vsphereCSI.listVolumeThreshold) != "None" and int(values.vsphereCSI.listVolumeThreshold) > 0:  -@)
list-volume-threshold = (@=str(values.vsphereCSI.listVolumeThreshold) @)
(@ end -@)
cluster-id = vmware-system-csi/(@=values.vsphereCSI.clusterName @)
cluster-distribution = "TKGMulticloud"

(@ if hasattr(values.vsphereCSI, "netpermissions"): -@)
(@ if values.vsphereCSI.netpermissions: -@)
(@ for np in values.vsphereCSI.netpermissions: -@)
[NetPermissions "(@=np @)"]
(@ if hasattr(values.vsphereCSI.netpermissions[np], "ips"): -@)
Ips = "(@=values.vsphereCSI.netpermissions[np]["ips"] @)"
(@ end -@)
(@ if hasattr(values.vsphereCSI.netpermissions[np], "permissions"): -@)
Permissions = "(@=values.vsphereCSI.netpermissions[np]["permissions"] @)"
(@ end -@)

(@ if hasattr(values.vsphereCSI.netpermissions[np], "rootsquash"): -@)
(@ if values.vsphereCSI.netpermissions[np]["rootsquash"]: -@)
RootSquash = true

(@ else: -@)
RootSquash = false

(@ end -@)
(@ else: -@)
RootSquash = false

(@ end -@)

(@ end -@)
(@ end -@)
(@ end -@)

[VirtualCenter "(@=values.vsphereCSI.server @)"]
user = "(@=values.vsphereCSI.username.replace("\\", "\\\\").replace("\"", "\\\"").replace("\t","\\t") @)"
password = "(@=values.vsphereCSI.password.replace("\\", "\\\\").replace("\"", "\\\"").replace("\t","\\t") @)"
datacenters = "(@=values.vsphereCSI.datacenter @)"
(@ if values.vsphereCSI.insecureFlag: -@)
insecure-flag = true
(@ else: -@)
thumbprint = "(@=values.vsphereCSI.tlsThumbprint @)"
(@ end -@)

[Network]
public-network = "(@=values.vsphereCSI.publicNetwork @)"
(@ if values.vsphereCSI.region or values.vsphereCSI.zone: -@)

[Labels]
(@ # if useTopologyCategories is set as True, csi config uses topology-categories. Otherwise still use region,zone -@)
(@ if hasattr(values.vsphereCSI, "useTopologyCategories") and values.vsphereCSI.useTopologyCategories: -@)

(@ if values.vsphereCSI.region and values.vsphereCSI.zone: -@)
topology-categories = "(@=values.vsphereCSI.region @), (@=values.vsphereCSI.zone @)"
(@ else: -@)
(@ if values.vsphereCSI.region: -@)
topology-categories = "(@=values.vsphereCSI.region @)"
(@ end -@)
(@ if values.vsphereCSI.zone: -@)
topology-categories = "(@=values.vsphereCSI.zone @)"
(@ end -@)
(@ end -@)

(@ else: -@)

(@ if values.vsphereCSI.region: -@)
region = "(@=values.vsphereCSI.region @)"
(@ end -@)
(@ if values.vsphereCSI.zone: -@)
zone = "(@=values.vsphereCSI.zone @)"
(@ end -@)
(@ end -@)
(@- end @)

(@- end @)
