Skip to content

feat(documents): support document labels - #2172

Merged
d0weinberger merged 4 commits into
mainfrom
feat/support-document-labels
Aug 10, 2026
Merged

feat(documents): support document labels#2172
d0weinberger merged 4 commits into
mainfrom
feat/support-document-labels

Conversation

@d0weinberger

@d0weinberger d0weinberger commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Why this PR?

Adding document labels and description support and adapting to changes in the documents corelib client:

  • removal of ExternalID, which means that Metadata.ID is used directly.
  • introduction of Labels and Description
  • change of function signatures (i.e. everything that is not content is passed via a Metadata struct)

What has changed?

  • Users can now declare labels and description on any document config entry (dashboard, notebook, launchpad) in their config.yaml:
    type:
      document:
        kind: notebook
        description: This is my notebook
        labels:
          - team:foo
          - env:prod
  • Labels are optional; existing configs without a labels field are unaffected.
  • Description is option optional; existing configs without a description field are unaffected.
  • monaco download preserves labels and descriptions, so downloaded configs include whatever labels and description the document already has in the environment.

How does it do it?

  • The core library's new documents.Metadata struct bundles ID, Name, Type, IsPrivate, Description, and Labels into a single value; replacing the previous positional-parameter signatures with this struct was the natural place to thread labels through without touching every call-site individually.
  • DeployAPI.Deploy builds the documents.Metadata value before calling upsertDocument, which then stamps the resolved ID into metadata.ID before each Update/Create call.
  • Also, DeployAPI.Deploy now fails on an unknown document kind, instead of defaulting to an empty document type.
  • getDocumentAttributesFromConfigType was removed; its logic is now inlined into Deploy as part of the Metadata construction.

How is it tested?

Unit test:

  • config_loader_test.go: verifies labels and description are parsed from YAML into config.DocumentType
  • config_writer_test.go: verifies it is serialized back out.
  • Tests in deploy_test.go to check that labels and description reach the documents.Metadatapassed to the client.
  • download_test.go updated to assert that labels and description from the API response are captured in the downloaded config.DocumentType.

Integration test:

  • test/configtypes/documents/documents_test.go deploys a notebook with labels and description and then reads it back from the environment to verify Labels and Description match what was configured.

How does it affect users?

Users can now declare labels and description on any document config entry (dashboard, notebook, launchpad) in their config.yaml

Issue: PS-47482

@d0weinberger
d0weinberger requested a review from a team as a code owner August 5, 2026 16:02
@d0weinberger d0weinberger added the run-e2e-test Manually trigger the E2E tests for reviewed PRs label Aug 5, 2026
Comment thread pkg/config/internal/persistence/type_definition.go Outdated
Comment thread pkg/resource/document/deploy.go
@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown

E2E Test Results

    3 files   -   2    133 suites   - 113   22m 34s ⏱️ - 1h 12m 24s
2 551 tests +  2  2 549 ✅ +  2  2 💤 ±0  0 ❌ ±0 
2 551 runs   - 324  2 549 ✅  - 324  2 💤 ±0  0 ❌ ±0 

Results for commit 4dd105c. ± Comparison against base commit c6590b7.

This pull request removes 5 and adds 7 tests. Note that renamed tests count towards both.
github.com/dynatrace/dynatrace-configuration-as-code/v2/pkg/resource/document ‑ TestDeploy_WithNotExistingDocumentKind_Succeeds
github.com/dynatrace/dynatrace-configuration-as-code/v2/test/account ‑ TestDeployAndDelete_AllResources
github.com/dynatrace/dynatrace-configuration-as-code/v2/test/account ‑ TestIdempotenceOfDeployment
github.com/dynatrace/dynatrace-configuration-as-code/v2/test/configuration/pagination ‑ TestPaginationClassic
github.com/dynatrace/dynatrace-configuration-as-code/v2/test/configuration/pagination ‑ TestPaginationPlatform
github.com/dynatrace/dynatrace-configuration-as-code/v2/pkg/config/loader ‑ Test_parseConfigs/Document_dashboard_config_with_description
github.com/dynatrace/dynatrace-configuration-as-code/v2/pkg/config/loader ‑ Test_parseConfigs/Document_dashboard_config_with_labels
github.com/dynatrace/dynatrace-configuration-as-code/v2/pkg/config/writer ‑ TestWriteConfigs/Document_with_description
github.com/dynatrace/dynatrace-configuration-as-code/v2/pkg/config/writer ‑ TestWriteConfigs/Document_with_labels
github.com/dynatrace/dynatrace-configuration-as-code/v2/pkg/resource/document ‑ TestDeploy_WithDescription_PropagatesDescriptionToMetadata
github.com/dynatrace/dynatrace-configuration-as-code/v2/pkg/resource/document ‑ TestDeploy_WithLabels_PropagatesLabelsToMetadata
github.com/dynatrace/dynatrace-configuration-as-code/v2/pkg/resource/document ‑ TestDeploy_WithNotExistingDocumentKind_Fails

♻️ This comment has been updated with latest results.

@Kirdock

Kirdock commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Regarding the failing test: Haven't looked much into it, but maybe it has the same root cause as in our Terraform provider
dynatrace-oss/terraform-provider-dynatrace#1203 (comment)

@d0weinberger
d0weinberger force-pushed the feat/support-document-labels branch 2 times, most recently from 822028f to 055da65 Compare August 10, 2026 09:14
@d0weinberger d0weinberger added run-e2e-test Manually trigger the E2E tests for reviewed PRs and removed run-e2e-test Manually trigger the E2E tests for reviewed PRs labels Aug 10, 2026

@Kirdock Kirdock left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nit] Theoretically we can merge a lot of the tests, as we don't need a separate test for each and every property in the YAML/documentMeta

Comment thread pkg/config/internal/persistence/type_definition.go
Comment thread pkg/resource/document/download_test.go Outdated
Bump dynatrace-configuration-as-code-core to the version whose `DocumentClient` takes a `documents.Metadata` value instead of positional `name/isPrivate/externalId/type` arguments.

- `DocumentClient.Create/Update` now accept `(ctx, documents.Metadata, content)`
- `Deploy` builds the `Metadata` once and sets `Metadata.ID` per upsert attempt (origin object id, then custom id), preserving the update-then-create behavior and the empty-type fallback for unknown document kinds
- Regenerate/adjust the document mocks and dummy client
- Rewrite `deploy_test.go` for the 3-arg signature, matching a real expected Metadata via gomock.Eq instead of stuffing matchers into struct fields
Documents can now carry labels, threaded end-to-end the same way as the custom id.

- Add `Labels []string` to `config.DocumentType`
- Parse `labels` from and write it back in the document persistence definition
- Populate `Labels` when downloading documents
- Send `Labels` to the environment on deploy
- Tests: loader parse, writer round-trip, deploy->metadata propagation, download mapping, and an integration check that labels reach the environment
@d0weinberger
d0weinberger force-pushed the feat/support-document-labels branch from 055da65 to 6805130 Compare August 10, 2026 12:25
@d0weinberger
d0weinberger force-pushed the feat/support-document-labels branch from 6805130 to 4dd105c Compare August 10, 2026 12:33
@d0weinberger d0weinberger added run-e2e-test Manually trigger the E2E tests for reviewed PRs and removed run-e2e-test Manually trigger the E2E tests for reviewed PRs labels Aug 10, 2026
@d0weinberger

Copy link
Copy Markdown
Contributor Author

[nit] Theoretically we can merge a lot of the tests, as we don't need a separate test for each and every property in the YAML/documentMeta

Yes, but it also doesn't hurt, I think ... I'd keep the tests the way they are right now, if that's okay.

@sonarqubecloud

Copy link
Copy Markdown

@d0weinberger
d0weinberger merged commit 770b761 into main Aug 10, 2026
19 checks passed
@d0weinberger
d0weinberger deleted the feat/support-document-labels branch August 10, 2026 13:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

run-e2e-test Manually trigger the E2E tests for reviewed PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants