Search code examples
kuberneteskubernetes-helm

Escape dots in YAML keys in Helm unittest


Would someone know how to escape dots . in Helm and precisely the unittest plugin? The template

[...]
spec:
  config:
    my.config: "foo"

The test

[...]
asserts:      
  - equal:
    path: "spec.config.my\.config"
    value: "foo"

Throws

yaml: line 23: found unknown escape character

Solution

  • The helm-unittest documentation states:

    Map keys in path containing periods (.) are supported with the use of a jsonPath syntax: For more detail on the jsonPath syntax.

    The example syntax looks like root.ancestor.parent["dotted.field.name"]. Adapting it to your example,

    asserts:      
      - equal:
        path: spec.config["my.config"]
        value: "foo"