Documentation
¶
Index ¶
- func DispatchOutputUnion(ctx context.Context, union *kbapi.OutputUnion, handlers OutputUnionHandlers) (diags diag.Diagnostics)
- func GetOperationalSpaceFromState(ctx context.Context, state tfsdk.State) (string, diag.Diagnostics)
- func IDValidator(attributeName string) validator.String
- func ProxyIDForUpdate(plan, prior types.String) *string
- func SpaceIDFromSet(spaceIDs types.Set) string
- func SpaceIDFromSetOrDefault(spaceIDs types.Set, fallback string) types.String
- type OutputUnionHandlers
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DispatchOutputUnion ¶
func DispatchOutputUnion(ctx context.Context, union *kbapi.OutputUnion, handlers OutputUnionHandlers) (diags diag.Diagnostics)
DispatchOutputUnion resolves the discriminated variant held by union and invokes the matching handler in handlers. It appends an error diagnostic if union is unset, the discriminator can't be resolved, or the resolved variant has no matching handler.
func GetOperationalSpaceFromState ¶ added in v0.12.2
func GetOperationalSpaceFromState(ctx context.Context, state tfsdk.State) (string, diag.Diagnostics)
GetOperationalSpaceFromState extracts the operational space ID from Terraform state. This helper reads space_ids from state (not plan) to determine which space to use for API operations, preventing errors when space_ids changes (e.g., prepending a new space).
**Why read from STATE not PLAN:** When updating space_ids = ["space-a"] → ["space-b", "space-a"], we need to query the policy in a space where it currently EXISTS (space-a from STATE), not where it WILL exist (space-b from PLAN). Otherwise, the API call fails with 404.
Selection Strategy:
- Extract space_ids from state
- If empty/null → return "" (uses default space without /s/{spaceId} prefix)
- Otherwise → return first space from state (where resource currently exists)
Note: With Sets, there's no inherent ordering, but we can rely on deterministic iteration to get a consistent space for API operations.
func IDValidator ¶ added in v0.16.3
IDValidator returns a reusable Fleet ID validator for the given Terraform attribute name.
func ProxyIDForUpdate ¶
ProxyIDForUpdate returns a pointer suitable for a generated update body's proxy_id field. A known non-empty plan value is sent as-is. When the plan unsets a previously set proxy_id, an empty string is sent rather than nil: the generated `json:"proxy_id,omitempty"` tag drops nil, and Fleet treats an omitted field as "leave unchanged", which would leave the prior proxy_id in place and produce an "inconsistent result after apply". When proxy_id was already unset, nil is returned so the field stays omitted.
func SpaceIDFromSet ¶ added in v0.15.0
SpaceIDFromSet extracts the first known, non-empty space ID from a space_ids set attribute. Returns an empty string if the set is null, unknown, empty, or contains only empty/unknown elements (directing API calls to the default space).
func SpaceIDFromSetOrDefault ¶ added in v0.16.4
SpaceIDFromSetOrDefault returns the first known, non-empty space ID from a space_ids set, or fallback wrapped in types.StringValue when none is set. This is the GetSpaceID helper shared by Fleet resource models, which differ only in their fallback value.
Types ¶
type OutputUnionHandlers ¶
type OutputUnionHandlers struct {
Elasticsearch func(ctx context.Context, data *kbapi.KibanaHTTPAPIsOutputResponseElasticsearch) diag.Diagnostics
Logstash func(ctx context.Context, data *kbapi.KibanaHTTPAPIsOutputResponseLogstash) diag.Diagnostics
Kafka func(ctx context.Context, data *kbapi.KibanaHTTPAPIsOutputResponseKafka) diag.Diagnostics
RemoteElasticsearch func(ctx context.Context, data *kbapi.KibanaHTTPAPIsOutputResponseRemoteElasticsearch) diag.Diagnostics
}
OutputUnionHandlers holds one callback per kbapi.OutputUnion discriminated variant. Callers with different receiver types (e.g. the output resource and the outputs data source) supply their own per-type fromAPI* methods as handlers to DispatchOutputUnion, so the discriminator dispatch logic is defined once and both call sites are guaranteed to handle the same set of variants.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package fleetschema holds attribute builders shared between Fleet integration package installation resources (integration, customintegration) to keep their descriptions and semantics from drifting apart.
|
Package fleetschema holds attribute builders shared between Fleet integration package installation resources (integration, customintegration) to keep their descriptions and semantics from drifting apart. |
|
Package globaldatatags provides the shared Terraform model, schema, and map<->API conversion helpers for the `global_data_tags` map attribute used by both internal/fleet/agentpolicy and internal/fleet/managedintegration.
|
Package globaldatatags provides the shared Terraform model, schema, and map<->API conversion helpers for the `global_data_tags` map attribute used by both internal/fleet/agentpolicy and internal/fleet/managedintegration. |
|
Package managedintegration: model ↔ Kibana managed_integrations API conversion — POST/PUT request bodies (toCreateBody) and state population from KibanaHTTPAPIsManagedIntegration (populateFromManagedIntegration).
|
Package managedintegration: model ↔ Kibana managed_integrations API conversion — POST/PUT request bodies (toCreateBody) and state population from KibanaHTTPAPIsManagedIntegration (populateFromManagedIntegration). |
|
Package policyshape provides the shared Plugin Framework modeling for Fleet package policy inputs, streams, and vars: the "shape" of a package policy body that is common to every resource that creates or updates one (elasticstack_fleet_integration_policy today; elasticstack_fleet_managed_integration).
|
Package policyshape provides the shared Plugin Framework modeling for Fleet package policy inputs, streams, and vars: the "shape" of a package policy body that is common to every resource that creates or updates one (elasticstack_fleet_integration_policy today; elasticstack_fleet_managed_integration). |