utils

package
v0.6.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Extract

func Extract(input []byte) any

Extracts the error message from the generic HTTP response

func IsMapSubset added in v0.6.0

func IsMapSubset[K, V comparable](m, sub map[K]V) bool

func JSONToTerraformDynamicValue added in v0.5.0

func JSONToTerraformDynamicValue(b []byte) (types.Dynamic, error)

Converts a json marshaled byte array into a Terraform Data with Dynamic Type

Adapted from https://github.com/magodo/terraform-provider-restful/blob/ eb875adeb0967a0a3cd7393d8eb2016a2642ac0f/internal/dynamic/dynamic.go#L284

func ProcessString

func ProcessString(input string) (output string)

Process string according to RFC6902 standard 1. "~0" will be converted back to "~" 2. "~1" will be converted back to "/"

func TFTypesToBytes added in v0.6.0

func TFTypesToBytes(d types.Dynamic) ([]byte, error)

func TFTypesToJSON added in v0.6.0

func TFTypesToJSON(d types.Dynamic) (map[string]interface{}, error)

Types

type DefaultResponse

type DefaultResponse struct {
	Message []string    `json:"msg"`
	Error   interface{} `binding:"required" form:"err" json:"err"`
}

type MustBeMapOfString added in v0.3.0

type MustBeMapOfString struct{}

func (MustBeMapOfString) Description added in v0.3.0

func (v MustBeMapOfString) Description(_ context.Context) string

func (MustBeMapOfString) MarkdownDescription added in v0.3.0

func (v MustBeMapOfString) MarkdownDescription(ctx context.Context) string

func (MustBeMapOfString) ValidateString added in v0.3.0

type UpdateOperations

type UpdateOperations struct {
	Create map[string]jsonpatch.Operation
	Update map[string]jsonpatch.Operation
	Delete map[string]jsonpatch.Operation
}

func JSONDiffToTerraformOperations

func JSONDiffToTerraformOperations(state, plan []byte) (UpdateOperations, error)

Calculates the diff between state and plan objects. The output of this function is arrays of jsondiff.Ops that has been modified to suit the needs of Terraform CRUD operation. The following modifications are: Updating a JSON object can be classified into three distinct operations.

  1. Creating a new key value pair at the root.
  2. Updating a root value. Creating a new key value pair in a nested path will be considered as updating a root value.
  3. Deleting an existing key value pair from the root.
  4. Values inside the jsondiff.Operation are discarded and disregarded.
  5. Only the paths are important.
  6. It is considered a root key if the path contains only one slash "/xxx"

Jump to

Keyboard shortcuts

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