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

Allow tag values containing commas and equal sign

Open dominiquehunziker opened this issue 9 months ago • 10 comments

Currently, it is not possible to create tags with a value that contains , or = as this breaks the parsing logic for the tags parameter.

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: managed-premium-retain
provisioner: disk.csi.azure.com
parameters:
  skuName: Premium_ZRS
  tags: 'tag-1="aGVsbG8=",tag-2="value-2, value-3"'
reclaimPolicy: Retain
volumeBindingMode: WaitForFirstConsumer
allowVolumeExpansion: true

It would be great, if support for values with , and = can be added. For the previous (non functioning example) the desired result would be

{
  "tag-1": "aGVsbG8=",
  "tag-2": "value-2, value-3"
}

where tag-1 could be a base64 encoded value with = padding or tag-2 could be a comma separated list.

I'm uncertain what would be possible solutions as changing the parsing logic might change existing behavior. Possible options I can imagine are:

  • At least for = the logic could be relaxed to only split on the first = and treat everything afterwards as the value. Similar to how query strings are parsed in URIs.
  • Allow to escape , and =, i.e., tags: 'tag-1=aGVsbG8\=,tag-2=value-2\, value-3'
  • Quote values with , or =, i.e., tags: 'tag-1="aGVsbG8=",tag-2="value-2, value-3"'. Similar to how data with commas in CSV is handled.
  • Add another parameter which can be used to control the format of the tags parameter, such that a JSON or YAML string could be passed. For example
    parameters:
      tags: |
        tag-1: aGVsbG8=
        tag-2: value-2, value-3
      tagsFormat: Yaml
    
    or
    parameters:
      tags: |
        {
          "tag-1": "aGVsbG8=",
          "tag-2": "value-2, value-3"
        }
      tagsFormat: Json
    

dominiquehunziker avatar May 07 '24 21:05 dominiquehunziker