Skip to content

[281#1] feat(metadata): add shared metadata helpers and standardize ResourceMetadata inline#287

Closed
mpechkurov wants to merge 2 commits into
mainfrom
feat/metadata-package
Closed

[281#1] feat(metadata): add shared metadata helpers and standardize ResourceMetadata inline#287
mpechkurov wants to merge 2 commits into
mainfrom
feat/metadata-package

Conversation

@mpechkurov
Copy link
Copy Markdown
Collaborator

What

  • New internal/clients/metadata/ package with BuildMetadata, IsMetadataUpToDate, MetadataMapContains, MetadataMapEqual, DiffMetadata
  • Standardize all 8 resource types to use ResourceMetadata inline struct (replacing separate Labels/Annotations fields on Domain, Org, Space, ServiceInstance)
  • Comprehensive unit tests for the metadata package

Why

Foundation for #39 (external resource labeling). Provides shared metadata helpers to replace per-controller duplicate implementations.

Part of

Split from #281 — PR 1 of 6. No dependencies.

Merge order: [281#1] → [281#2] → [281#3] → [281#4] → [281#5] → [281#6]

Add internal/clients/metadata package with helpers for managing Cloud
Foundry resource metadata (labels and annotations) across all providers:

- BuildMetadata: merges Crossplane default labels (GetExternalTags)
  with user labels/annotations into *cfresource.Metadata; nil pointer
  values produce CF deletion markers via RemoveLabel/RemoveAnnotation

- MetadataMapEqual: exact equality check (nil == empty, nil-ptr != ptr(""))

- MetadataMapContains: subset check (desired ⊆ actual); extra keys in
  actual are ignored -- correct for merge-patch drift detection where
  CF resources may have system labels the provider doesn't manage

- IsMetadataUpToDate: convenience wrapper using MetadataMapContains
  for both labels and annotations

- DiffMetadata: computes merge-patch diff for Update calls; only
  processes keys in desired (keys in actual but not desired are left
  unchanged per CF API convention); includes nil-value deletion
  markers; accepts both label and annotation pairs

These helpers will replace per-controller duplicate implementations
(e.g. SRB controller's metadataMapEqual/isMetadataUpToDate) and
provide the foundation for issue #39 external resource labeling.
Add shared metadata client helpers (BuildMetadata, IsMetadataUpToDate,
DiffMetadata) for issue #39 external resource labeling support.

Standardize all 8 eligible resource types to use ResourceMetadata
inline struct consistently, replacing the mixed separate
Labels/Annotations fields on Space, Org, Domain, and ServiceInstance.
Update downstream consumers (client observation functions, domain
GenerateUpdate, exporter convert files) accordingly.
@SatabdiG
Copy link
Copy Markdown
Collaborator

Closing as #281 received review comments.

@SatabdiG SatabdiG closed this May 27, 2026
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.

3 participants