Skip to content

feat(keymanager): Barbican key-manager family (pcd_keymanager_secret, _container) — Phase 3 - #18

Merged
PF9-pushkar merged 2 commits into
mainfrom
feat/keymanager-barbican
Jul 12, 2026
Merged

feat(keymanager): Barbican key-manager family (pcd_keymanager_secret, _container) — Phase 3#18
PF9-pushkar merged 2 commits into
mainfrom
feat/keymanager-barbican

Conversation

@PF9-pushkar

Copy link
Copy Markdown
Collaborator

Third Phase 3 family — Barbican key management. New internal/services/keymanager package + a KeyManagerV1Client (catalog type key-manager).

Resources & data source

  • pcd_keymanager_secret — write-only/sensitive payload, immutable (all inputs ForceNew).
  • pcd_keymanager_container — a named grouping of secrets (secret_refs) with computed consumers.
  • pcd_keymanager_secret (data source) — lookup by name or ref; optionally fetches the payload when payload_content_type is set.

Barbican's ref-vs-UUID quirk

Barbican addresses objects by full-URL refs (secret_ref/container_ref), but Get/Delete take the bare UUID, and Create returns only the ref. Handled centrally: refToID extracts the UUID (the resource ID), the full ref is a computed attribute, and the resource derives the UUID then Gets for the rest. Write-only payload is echo-only + ImportStateVerifyIgnore'd; the wait-for-ACTIVE fires only when a payload is supplied (a payload-less secret stays PENDING forever).

Adversarial review fixes included

The review caught two real container bugs:

  1. consumers Value Conversion Error — built as []map[string]string but the attribute is a List of objects; the framework can't reflect a map into an ObjectType, so a container with any consumer failed on Create/Read (an empty list silently worked, hiding it). Now built from a struct slice.
  2. secret_refs inconsistent result — it was Optional-only but populated from the server when omitted, so a container created without secret_refs failed with "inconsistent result after apply". Now Optional+Computed.

Checks

go build/vet/gofmt/golangci-lint (0 issues), tfplugindocs generate ("Key Manager" subcategory), and terraform fmt on the new examples all clean. Acceptance test covers a secret + container + data source + import.

Live-validation status

Code-complete + adversarially reviewed. Not run against the CE lab this session (credentials unavailable). Like DNS, Barbican is live (Step 0) and needs no compute/storage backend, so this family should pass live once creds return. Tracked in DECISIONS.md.

…ner)

Phase 3. New internal/services/keymanager package + a KeyManagerV1Client (catalog
type "key-manager") on the shared config.

Resources: pcd_keymanager_secret (all fields immutable; write-only sensitive
payload; wait-for-ACTIVE only when a payload is supplied, since a payload-less
secret stays PENDING) and pcd_keymanager_container (immutable grouping of secrets
via secret_refs, computed consumers). Data source: pcd_keymanager_secret (lookup
by name or ref; optionally fetches the payload when payload_content_type is set).

Barbican identifies objects by a full URL ref (secret_ref/container_ref) but the
API's Get/Delete take the bare UUID: refToID extracts it, the resource ID is the
UUID, and the full ref is a computed attribute. Create returns only the ref, so
the resources derive the UUID and Get for the rest. Write-only payload and the
ForceNew inputs are echo-only (populated from the server only when unset), so
configured values round-trip exactly and imports don't force a replace.

Acceptance test (secret + container + data source + import), examples under the
new "Key Manager" registry subcategory, CHANGELOG, and DECISIONS row included.
build/vet/gofmt/golangci-lint (0 issues) and tfplugindocs all clean.
…fs schema

Adversarial review caught two container bugs:
- consumers was built as []map[string]string and passed to a List of ObjectType,
  which the framework cannot reflect (Value Conversion Error) once a container has
  any consumer (an empty list silently worked, hiding it). Build it from a struct
  slice like secret_refs.
- secret_refs was Optional-only but readInto populates it from the server when
  unset, so a container created without secret_refs failed with 'inconsistent
  result after apply'. Make it Optional+Computed to permit the server value.
@PF9-pushkar
PF9-pushkar merged commit 4af1b6d into main Jul 12, 2026
4 checks passed
@PF9-pushkar
PF9-pushkar deleted the feat/keymanager-barbican branch July 12, 2026 17:15
PF9-pushkar added a commit that referenced this pull request Jul 14, 2026
feat(keymanager): Barbican key-manager family (pcd_keymanager_secret, _container) — Phase 3
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