update

package
v1.28.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 25, 2025 License: MPL-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsZeroValues added in v1.23.0

func IsZeroValues[T any](last *T) bool

func PatchPayload

func PatchPayload[T any, U any](state *T, plan *U, options ...PatchOptions) (*U, error)

PatchPayload uses the state and plan to changes to find the patch request, including changes only when: - The plan has replaced, added, or removed list values from the state Note that we intentionally do NOT include removed state values: - The state value is probably computed and not needed in the request However, for nested attributes, we MUST include some of the removed state values (e.g., `replication_spec[*].(id|zone_id)`) Assumptions: - Only Optional|Required attributes are set in the state|plan. `connection_strings` are not needed - --> Except specific computed attributes in nested_attributes (e.g., `replication_spec[*].(id|zone_id`) - The state and plan can be dumped to json How it works: 1. Use `jsondiff` to find the patch, aka. operations to go from state to plan 2. Groups the operations by attribute name 3. Filters the operations to only include replaced, added or removed list values 4. Adds nested "removed" values from the state to the request 5. Use `jsonpatch` to apply each attribute plan & state patch to an empty JSON object 6. Create a `patchReq` pointer with the final JSON object marshaled to `T` or return nil if there are no changes (`{}`)

func PatchPayloadTpf

func PatchPayloadTpf[TFModel any, SDKRequest any](ctx context.Context, diags *diag.Diagnostics, state, plan *TFModel, converter func(ctx context.Context, input *TFModel, diags *diag.Diagnostics) *SDKRequest) *SDKRequest

Types

type PatchOptions added in v1.23.0

type PatchOptions struct {
	IgnoreInStateSuffix  []string
	IgnoreInStatePrefix  []string
	IncludeInStateSuffix []string
	ForceUpdateAttr      []string
}

Current limitation if the field is set as part of a nested attribute in a map

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL