feat(documents): support document labels - #2172
Conversation
E2E Test Results 3 files - 2 133 suites - 113 22m 34s ⏱️ - 1h 12m 24s 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.♻️ This comment has been updated with latest results. |
|
Regarding the failing test: Haven't looked much into it, but maybe it has the same root cause as in our Terraform provider |
822028f to
055da65
Compare
Kirdock
left a comment
There was a problem hiding this comment.
[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
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
055da65 to
6805130
Compare
…k to empty type Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
6805130 to
4dd105c
Compare
Yes, but it also doesn't hurt, I think ... I'd keep the tests the way they are right now, if that's okay. |
|



Why this PR?
Adding document labels and description support and adapting to changes in the documents corelib client:
ExternalID, which means thatMetadata.IDis used directly.LabelsandDescriptionMetadatastruct)What has changed?
labelsanddescriptionon any document config entry (dashboard, notebook, launchpad) in theirconfig.yaml:labelsfield are unaffected.descriptionfield are unaffected.monaco downloadpreserves labels and descriptions, so downloaded configs include whatever labels and description the document already has in the environment.How does it do it?
documents.Metadatastruct bundlesID,Name,Type,IsPrivate,Description, andLabelsinto 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.Deploybuilds thedocuments.Metadatavalue before callingupsertDocument, which then stamps the resolved ID intometadata.IDbefore eachUpdate/Createcall.DeployAPI.Deploynow fails on an unknown document kind, instead of defaulting to an empty document type.getDocumentAttributesFromConfigTypewas removed; its logic is now inlined intoDeployas part of theMetadataconstruction.How is it tested?
Unit test:
config_loader_test.go: verifieslabelsanddescriptionare parsed from YAML intoconfig.DocumentTypeconfig_writer_test.go: verifies it is serialized back out.deploy_test.goto check thatlabelsanddescriptionreach thedocuments.Metadatapassed to the client.download_test.goupdated to assert that labels and description from the API response are captured in the downloadedconfig.DocumentType.Integration test:
test/configtypes/documents/documents_test.godeploys a notebook with labels and description and then reads it back from the environment to verifyLabelsandDescriptionmatch what was configured.How does it affect users?
Users can now declare
labelsanddescriptionon any document config entry (dashboard, notebook, launchpad) in theirconfig.yamlIssue: PS-47482