Skip to content

v4.40.1: select with += causes node to be emptied instead of appending #1869

Closed
@mkowalski

Description

Describe the bug
After upgrading from 4.35.2 to 4.40.1 there seems to be regression when using select combined with += causing the whole node to be emptied instead of appending the requested content.

Version of yq: 4.40.1
Operating system: Linux
Installed via: go install

Input Yaml
data1.yml:

spec:
  install:
    spec:
      clusterPermissions:
        - rules:
            - chocobomb:
                - "chocobomb"
          serviceAccountName: nmstate-operator

Command
The command you ran:

yq --inplace eval '.spec.install.spec.clusterPermissions[] |= select(.rules[]) |= select(.serviceAccountName == "nmstate-operator").rules += {"apiGroups":["security.openshift.io"],"resources":["securitycontextconstraints"],"verbs":["use"],"resourceNames":["privileged"]}' data1.yaml

Actual behavior

spec:
  install:
    spec:
      clusterPermissions:
        - {}

Expected behavior

spec:
  install:
    spec:
      clusterPermissions:
        - rules:
            - chocobomb:
                - "chocobomb"
            - apiGroups:
                - security.openshift.io
              resources:
                - securitycontextconstraints
              verbs:
                - use
              resourceNames:
                - privileged
          serviceAccountName: nmstate-operator

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions