Skip to content

insert at beginning of section #820

@DrissiReda

Description

@DrissiReda

Hello,

I'm trying to modify some files that are later used by templates. I want to know if there is a possibility to insert values at the beginning instead of the end of the section:

Original file

spec:
  containers:
  - name: c

Command:

yq e ' .spec.volumeMounts.name = "data"' file.yml 

Output

spec:
  containers:
  - name: c
  volumeMounts:
    name: data

Desired output

spec:
  volumeMounts:
    name: data
  containers:
  - name: c

I need it to be inserted at the beginning, so that if the template modifies it, I want it to ignore my entry.

Is there any way to achieve this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions