devspace icon indicating copy to clipboard operation
devspace copied to clipboard

Option to deep merge inside naming conflicts

Open AnatoleLucet opened this issue 7 months ago • 1 comments

Is your feature request related to a problem?

Yes. When inheriting configs using imports, it's hard to override/add specific fields inside a named object.

A very simple example:

# .devspace/shared.yml
dev:
  app:
    imageSelector: ${IMAGE}
    devImage: my-shared-dev-image
      

# apps/my-app/devspace.yml
imports:
  - path: ../../.devspace/shared.yml

vars:
  IMAGE: my-image

dev:
  app:
    ports: # this wont work. i can't add a new custom port or any other field inside `dev.app` without overriding everything
      - port: 8080

Which solution do you suggest?

Maybe adding a new option to the imports object that would allow deep merges to occur within some named objects (or every one)?

Two proposals (one or the other, not both):

imports:
  - path: ../../.devspace/shared.yml
    # 1. deep merge everything
    deepMerge: true
    # 2. deep merge by path
    merge: ["dev.app"] # additional paths of what objects should be merges
    # or `merge: ["*"]` for everything

Which alternative solutions exist?

Using profiles but this is very awkward and hard to read, especially when you need to replace 5 or 10+ fields.

imports:
  - path: ../../.devspace/shared.yml

vars:
  IMAGE: my-image

profiles:
  - name: default
    activation:
      - vars: # always activated
    patches:
      - op: add
        path: dev.app.ports
        value:
          port: 8080

AnatoleLucet avatar Jul 02 '25 09:07 AnatoleLucet

also thinking about it, it would be very useful to have an op: merge option to profiles.patches ! it would simplify patches a lot and reduce the number of operations you need to do in your profile.

E.g.:

profiles:
  - name: my-profile
    patches:
      - op: merge # would probably require two add operations, but with a merge you only need to have one
        path: dev.app
        value:
          ports:
            - port: 8080
          terminal:
            command: /entrypoint.sh

AnatoleLucet avatar Jul 03 '25 07:07 AnatoleLucet