Skip to content

Instantly share code, notes, and snippets.

@brandtkeller
Last active December 12, 2025 20:19
Show Gist options
  • Select an option

  • Save brandtkeller/2471352069a675e7b93a65386abf405c to your computer and use it in GitHub Desktop.

Select an option

Save brandtkeller/2471352069a675e7b93a65386abf405c to your computer and use it in GitHub Desktop.
namespacing for values and schema merging

Given a child zarf definition

# child/zarf.yaml
kind: ZarfPackageConfig
metadata:
  name: child-package

values:
  files:
    - child-values.yaml
components:
  - name: database
    charts:
      - name: example-chart
        version: 0.1.0
        localPath: "charts/example-chart"
        namespace: "database"
        values:
          - sourcePath: ".app.name"
            targetPath: ".appName"
          - sourcePath: ".app.replicas"
            targetPath: ".replicaCount"
          - sourcePath: ".app.image.tag"
            targetPath: ".image.tag"
          - sourcePath: ".database.host"
            targetPath: ".config.database.host"

With a child values file:

# child-values.yaml
app:
  name:
  replicas: 2
  image:
    tag: 1.1.1
database:
  host: localhost

Then a parent zarf definition:

# parent/zarf.yaml
kind: ZarfPackageConfig
metadata:
  name: parent-package

values:
  files:
    - parent-values.yaml

components:
  - name: database
    import:
      path: ../child

  - name: frontend
    charts:
      - name: frontend-chart
        version: 0.1.0
        localPath: "charts/frontend-chart"
        namespace: "web"
        values:
          - sourcePath: ".app.name"
            targetPath: ".appName"
          - sourcePath: ".app.replicas"
            targetPath: ".replicaCount"
          - sourcePath: ".app.image.tag"
            targetPath: ".image.tag"
          - sourcePath: ".database.host"
            targetPath: ".config.database.host"
    

with a parent values file with:

# parent-values.yaml
app:
  name:
  replicas: 2
  image:
    tag: 1.1.1

Then on import - it would namespace the children values by some key (import name?) - resulting in a package with:

# parent/zarf.yaml
kind: ZarfPackageConfig
metadata:
  name: parent-package

values:
  files:
    - parent-values.yaml

components:
  - name: database
    charts:
      - name: example-chart
        version: 0.1.0
        localPath: <some path here>
        namespace: "database"
        values:
          - sourcePath: ".database.app.name"
            targetPath: ".appName"
          - sourcePath: ".database.app.replicas"
            targetPath: ".replicaCount"
          - sourcePath: ".database.app.image.tag"
            targetPath: ".image.tag"
          - sourcePath: ".database.database.host"
            targetPath: ".config.database.host"

  - name: frontend
    charts:
      - name: frontend-chart
        version: 0.1.0
        localPath: "charts/frontend-chart"
        namespace: "web"
        values:
          - sourcePath: ".app.name"
            targetPath: ".appName"
          - sourcePath: ".app.replicas"
            targetPath: ".replicaCount"
          - sourcePath: ".app.image.tag"
            targetPath: ".image.tag"
    

and the merged values would be:

# values.yaml in the package
app:
  name:
  replicas: 2
  image:
    tag: 1.1.1
database:
    app:
    name:
    replicas: 2
    image:
        tag: 1.1.1
    database:
    host: localhost

Given a child schema file:

{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "properties": {
    "replicas": {
      "type": "integer",
      "minimum": 1,
      "maximum": 10
    },
    "storage": {
      "type": "string",
      "pattern": "^[0-9]+Gi$"
    }
  },
  "required": ["replicas", "storage"]
}

We could then wrap the child schema in the parent schema

{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "properties": {
    "database": {
      "type": "object",
      "properties": {
        "replicas": {
          "type": "integer",
          "minimum": 1,
          "maximum": 10
        },
        "storage": {
          "type": "string",
          "pattern": "^[0-9]+Gi$"
        }
      },
      "required": ["replicas", "storage"]
    }
  },
  "required": ["database"]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment