Skip to content

Feat(idp): nested spec field support via path - #241

Merged
iAlexeze merged 2 commits into
mainfrom
feat/idp-nested-fields
Aug 5, 2026
Merged

Feat(idp): nested spec field support via path#241
iAlexeze merged 2 commits into
mainfrom
feat/idp-nested-fields

Conversation

@iAlexeze

@iAlexeze iAlexeze commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

Summary

idp.fields entries now support a path field mapping a flat field name to a nested dot-notation path in the CRD spec. Callers submit flat fields; the gateway maps them to nested locations.

Previously, idp.fields only supported top-level spec paths:

fields:
  repository:
    label: "Repository"
  # → spec.repository

Now, nested paths are supported:

fields:
  cpu:
    path: app.resources.cpu
    label: "CPU Request"
  # → spec.app.resources.cpu

Callers stay flat — they submit "cpu": "500m". The gateway handles the nesting.

Implementation

  • Add IDPFieldConfig.Path field
  • Add config.SpecPath(name) — returns path if set, otherwise name
  • Add config.HasSpecPath() — returns true if path is set
  • Add utils.SetNestedPath() — sets a value at a dot-notation path, creates intermediate maps as needed
  • Add utils.IsNestedPath() — returns true if a path contains a dot
  • Update routeFields() to handle nested paths via SetNestedPath
  • Add validateIDPFieldPaths() validator:
    • Unique paths across all fields
    • No empty segments, no leading/trailing dots
    • Path segments validated with k8s.io/apimachinery/pkg/util/validation.IsQualifiedName
    • Warns on nested paths (schema existence validation TBD)

Example

Katalog

fields:
  repository:
    path: app.repository
    label: "Repository"
  cpu:
    path: app.resources.cpu
    label: "CPU Request"

Caller Request

{
  "target": "smartapp",
  "repository": "myorg/payments-api",
  "cpu": "500m"
}

Generated CR

spec:
  app:
    repository: myorg/payments-api
    resources:
      cpu: 500m

Backward Compatibility

  • Existing flat fields (without path) continue to work unchanged
  • path is optional — when omitted, the field name is used as the spec path

Testing

  • go test ./... clean
  • Flat fields work without path
  • Nested fields work with path
  • Deeply nested fields work (app.resources.cpu, networking.tls.enabled)
  • Mixed flat + nested fields work together
  • ork validate catches duplicate paths
  • ork validate catches invalid path format
  • End-to-end: target mode apply creates CR with correct nested structure

idp.fields entries now support a  field mapping a flat field name to
a nested dot-notation path in the CRD spec. Callers submit flat fields;
the gateway maps them to nested locations.

Adds:
-  field
-  helper
-  validator (unique paths, format checks)
-  helper
NestedMap's loop returned the original object unchanged when keys was
empty, trivially "succeeding" — inconsistent with its own doc comment and
with its sibling NestedSlice, which falls through to (nil, false) for the
same input by construction of its loop.
@iAlexeze
iAlexeze force-pushed the feat/idp-nested-fields branch from 46298e4 to d015fe9 Compare August 5, 2026 02:46
@iAlexeze
iAlexeze merged commit d89d160 into main Aug 5, 2026
10 checks passed
@iAlexeze
iAlexeze deleted the feat/idp-nested-fields branch August 5, 2026 02:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant