Skip to content

replacements in structured data ignore options (delimiter/index) #6028

Description

@seankhliao

What happened?

Try the new replacements in structured data feature #5679 added in 5.8.0

Use a replacement where the target uses options for a partial string replacement

What did you expect to happen?

The whole string was replaced inside the structured data (wrong).
A substring was replaced in annotations (correct).

How can we reproduce it (as minimally and precisely as possible)?

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
configMapGenerator:
  - name: my-config
    options:
      disableNameSuffixHash: true
      annotations:
        example.com/foo: a/b/c
    literals:
      - |
        config.yaml=
        foo: a/b/c
replacements:
  - sourceValue: zzz
    targets:
      - select:
          kind: ConfigMap
          name: my-config
        fieldPaths:
          - data.config\.yaml.foo
          - metadata.annotations.example\.com/foo
        options:
          delimiter: /
          index: 1

Expected output

apiVersion: v1
data:
  config.yaml: 'foo: a/zzz/c'
kind: ConfigMap
metadata:
  annotations:
    example.com/foo: a/zzz/c
  name: my-config

Actual output

apiVersion: v1
data:
  config.yaml: 'foo: zzz'
kind: ConfigMap
metadata:
  annotations:
    example.com/foo: a/zzz/c
  name: my-config

Kustomize version

5.8.0

Operating system

Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugCategorizes issue or PR as related to a bug.lifecycle/staleDenotes an issue or PR has remained open with no activity and has become stale.triage/acceptedIndicates an issue or PR is ready to be actively worked on.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions