{"modulePath":"github.com/GoCodeAlone/workflow","version":"v0.87.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package sensitive\n\nPackage sensitive routes ResourceOutput fields flagged as Sensitive through a secrets.Provider, returning sanitized placeholders for state persistence and a hydrated map for in-process consumers.\n\nPer the engine-sensitive-output-routing design (workflow v0.27.0):\n\n  - Route is invoked on Create/Update only. Read/Adoption/Refresh paths use Sanitize-only logic (not in this package — see cmd/wfctl/infra\\_apply.go) to prevent cache pollution.\n  - The placeholder format \"secret\\_ref://\\\u003cSecretKey(resource,key)\u003e\" is distinct from the user-supplied \"secret://\\\u003ckey\u003e\" config-reference convention.\n  - Routing trigger is exclusively out.Sensitive\\[k]==true (per-call dynamic). ResourceDriver.SensitiveKeys() is NOT consulted here; it remains a display-masking signal.\n\nLimitation (v0.27.0): only string-typed sensitive output values are supported. Non-string sensitive outputs (e.g., \\[]byte, int) yield an error from Route. Future expansion via a MarshalSensitive interface is out of scope.\n\n## Constants\n\n```go\nconst (\n\t// PlaceholderPrefix is the URI scheme used in state.Outputs values to\n\t// reference a routed secret stored in the configured secrets.Provider.\n\t// Distinct from secrets.SecretPrefix (\"secret://\") which is for\n\t// user-supplied config references.\n\tPlaceholderPrefix = \"secret_ref://\"\n)\n```\n\n## Functions\n\n```go\nfunc IsPlaceholder(v any) bool\n```\nIsPlaceholder reports whether v is a string with the PlaceholderPrefix. Non-string values return false.\n\n```go\nfunc MaskSensitiveForDiff(driverKeys []string, desired, current map[string]any) (map[string]any, map[string]any)\n```\nMaskSensitiveForDiff returns copies of desired and current with sensitive keys elided from BOTH sides. A key is considered sensitive when:\n\n  - it is named in driverKeys (i.e., ResourceDriver.SensitiveKeys()), OR\n  - its value in current matches the PlaceholderPrefix.\n\nEliding from both sides ensures driver.Diff or other field-by-field comparators don't report drift when state has a placeholder and live has a different (or absent) value. Non-sensitive keys are passed through unchanged.\n\nEither input may be nil; the corresponding output is also nil.\n\n```go\nfunc Placeholder(resourceName, outputKey string) string\n```\nPlaceholder returns PlaceholderPrefix + SecretKey(resourceName, outputKey), replacing a routed value in state.Outputs.\n\n```go\nfunc Revoke(\n\tctx context.Context,\n\tprovider secrets.Provider,\n\tresourceName string,\n\tmergedKeys []string,\n) error\n```\nRevoke deletes routed secrets for resourceName. mergedKeys is the union of placeholder-derived keys (caller extracts from pre-delete state.Outputs) and any legacy heuristic keys. Errors from provider.Delete are aggregated via errors.Join — Revoke does NOT stop on the first error so partial cleanup proceeds. Keys that were never stored (provider returns secrets.ErrNotFound) are silently treated as success.\n\n```go\nfunc RevokeKeys(ctx context.Context, provider secrets.Provider, keys []string) error\n```\nRevokeKeys deletes exact persisted identifiers and verifies absence. Unlike legacy Revoke, a missing provider is an error when cleanup debt exists.\n\n```go\nfunc Route(\n\tctx context.Context,\n\tprovider secrets.Provider,\n\tresourceName string,\n\tout *interfaces.ResourceOutput,\n) (sanitized map[string]any, hydrated map[string]string, err error)\n```\nRoute routes sensitive fields from out through provider, keying each secret via SecretKey(resourceName, outputKey). Returns:\n\n  - sanitized: a copy of out.Outputs with sensitive values replaced by PlaceholderPrefix + SecretKey(resourceName, k). Suitable for persistence to interfaces.IaCStateStore.\n  - hydrated: a flat map keyed by SecretKey of values that were routed. Suitable for in-process hand-off to post-apply consumers in the same wfctl invocation. Empty when no fields were routed.\n\nRouting trigger is out.Sensitive\\[k] == true with out.Outputs\\[k] present (any value, including empty string). When the sensitive key's value is absent from out.Outputs the key is silently SKIPPED — neither provider.Set is called nor a placeholder inserted (the engine has no value to route; existing routed-secret in provider stays as-is).\n\nErrors:\n\n  - resourceName == \"\" with non-empty Sensitive map → error (defensive; out.Name is intentionally NOT consulted, since Read/Adoption paths may have empty out.Name).\n  - provider == nil with non-empty Sensitive map AND any sensitive key present in out.Outputs → error naming the resource and keys.\n  - provider.Set returns an error → error wrapping the failed key. Set is invoked in sorted order by key for determinism; on first error the loop stops and hydrated contains values already routed so the caller can compensate partial writes.\n\nOut is not mutated.\n\n```go\nfunc SecretKey(resourceName, outputKey string) string\n```\nSecretKey returns the canonical secrets.Provider key for a resource's output. The key is provider-safe and collision-resistant for distinct (resourceName, outputKey) pairs. Exported so audit-state-secrets and other consumers can recompute routed-secret names from known resource/output pairs.\n\n```go\nfunc VerifyAbsent(ctx context.Context, provider secrets.Provider, key string) error\n```\nVerifyAbsent checks readable stores directly and write-only stores through their key listing. Values and provider error payloads never enter diagnostics.\n\n","path":"github.com/GoCodeAlone/workflow/iac/sensitive","name":"sensitive","synopsis":"Package sensitive routes ResourceOutput fields flagged as Sensitive through a secrets.Provider, returning sanitized placeholders for state persistence and a hydrated map for in-process consumers.","isRedistributable":true}
