atmos icon indicating copy to clipboard operation
atmos copied to clipboard

Support `metadata.component` in abstract components

Open mss opened this issue 5 months ago • 1 comments

Describe the Feature

In an abstract component you can define a value for metadata.component. That one is completely ignored though and the real component will fall back to the default value instead.

There might be a reason why that value isn't inherited but if it was just an oversight it would be useful if that could be changed.

Expected Behavior

A real component foo inheriting an abstract component with metadata.component: foo/v1 should look for the root module in components/terraform/foo/v1 and not components/terraform/foo.

Use Case

I thought that there was a design pattern for this but couldn't find it: We make heavy use of something I'd call the Multi-Version Abstract Components pattern.

Our stack definitions all look like this:

import:
  - catalog/components/example/v1_2
components:
  terraform:
    example/eu-central-1:
      metadata:
        inherits:
          - example/_component
        component: '{{ .settings.metadata.component }}'

With the catalog entries like these (vars left out to keep the sample short):

components:
  terraform:
    example/_component:
      metadata:
        type: abstract
      settings:
        metadata:
          component: example/v1.2

All tied together with vendor configs like these:

---
apiVersion: atmos/v1
kind: AtmosVendorConfig
metadata:
  name: example
spec:
  bases:
    - &component
      source: 'git::https://gitlab.example.com/project/atmos/{{ .Component | path.Dir }}.git?depth=1&ref={{ .Version }}'
      targets:
        - 'components/terraform/{{ .Component }}'
      excluded_paths:
        - '.git/**'
      tags:
        - example
  sources:
    - <<: *component
      component: example/v1.2
      version: v1.2.3
    - <<: *component
      component: example/v2.0
      version: v2.0.0

Describe Ideal Solution

The settings solution should not be necessary and this should work:

Real:

import:
  - catalog/components/example/v1_2
components:
  terraform:
    example/eu-central-1:
      metadata:
        inherits:
          - example/_component

Abstract:

components:
  terraform:
    example/_component:
      metadata:
        type: abstract
      metadata:
        component: example/v1.2

Alternatives Considered

  • Keep doing what we do
  • Maybe use templates instead of inheritance? But we try to stay away from tmpl files since we already use a lot of templating and inheritance which tends to confuse people and that would add another layer (and lifecycle) of templating.

Additional Context

No response

mss avatar Oct 07 '25 11:10 mss

Note to myself: Check if this was implemented in v1.201.0 via #1812.

mss avatar Dec 12 '25 09:12 mss