csi-driver icon indicating copy to clipboard operation
csi-driver copied to clipboard

Trim dns-names after spliting

Open melck opened this issue 3 years ago • 1 comments

Hello,

I want to use yaml to have a better readbility of the field csi.cert-manager.io/dns-names. For example :

csi:
  readOnly: true
  driver: csi.cert-manager.io
  volumeAttributes:
    csi.cert-manager.io/issuer-name: log-ca-issuer
    csi.cert-manager.io/key-usages: server auth,client auth
    csi.cert-manager.io/key-encoding: PKCS8
    csi.cert-manager.io/common-name: log-opensearch-node
    csi.cert-manager.io/dns-names: >-
      ${POD_NAME},
      opensearch-cluster-master-headless,
      ${POD_NAME}.opensearch-cluster-master-headless,
      ${POD_NAME}.opensearch-cluster-master-headless.${POD_NAMESPACE}.svc.cluster.local,
      opensearch-cluster-master-headless.${POD_NAMESPACE}.svc.cluster.local

This yaml feature will regroup data like this : ${POD_NAME}, opensearch-cluster-master-headless, ${POD_NAME}.opensearch-cluster-master-headless, ${POD_NAME}.opensearch-cluster-master-headless.${POD_NAMESPACE}.svc.cluster.local, opensearch-cluster-master-headless.${POD_NAMESPACE}.svc.cluster.local

Is it possible to trim DNS names after splitting to avoid extra space produce by yaml ?

melck avatar Aug 17 '22 09:08 melck

Yes, this is a clear improvement to me. DNS doesn't contain space characters so we can safely omit them when they appear:

  1. before the start of the first entry
  2. after a comma separator
  3. trailing

We can achieve this by splitting the csv, and then using string.TrimSpace on every item.


We should extend this to all list typed attributes.

/assign

JoshVanL avatar Aug 17 '22 10:08 JoshVanL