util

package
v0.4.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: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClearDoubleQuote

func ClearDoubleQuote(s string) string

func ConvertKeys

func ConvertKeys(input interface{}) interface{}

convertKeys recursively converts all keys in a map from camelCase to snake_case

func ConvertMapToObject

func ConvertMapToObject(ctx context.Context, data map[string]interface{}) (types.Object, error)

Convert nested map structured json into terraform object

func CreateFuncMap

func CreateFuncMap() template.FuncMap

func DiagOff

func DiagOff[V, T interface{}](input func(ctx context.Context, elementType T, elements any) (V, diag.Diagnostics), ctx context.Context, elementType T, elements any) V

func ExtractDto

func ExtractDto(jsonFilePath, refreshObjectName string) ([]byte, error)

func ExtractPath

func ExtractPath(s string) string

func ExtractResourceName

func ExtractResourceName(jsonFilePath string) (string, error)

func FirstAlphabet

func FirstAlphabet(s string) string

func FirstAlphabetToLowerCase

func FirstAlphabetToLowerCase(s string) string

func FirstAlphabetToUpperCase

func FirstAlphabetToUpperCase(s string) string

func JoinStrings

func JoinStrings(sep string, items []string) string

func MakeIdGetter

func MakeIdGetter(target string) string

func MakeRequest

func MakeRequest(method, path, endpoint, reqBody string) (map[string]interface{}, error)

func MustAbs

func MustAbs(path string) string

func PathToPascal

func PathToPascal(s string) string

func ReadAndUnmarshal

func ReadAndUnmarshal[T any](filePath string, result *T) error

func RemoveCustomType

func RemoveCustomType(filePath string) error

func RemoveDuplicates

func RemoveDuplicates(filePath string) error

func RemovingWhiteSpace

func RemovingWhiteSpace(input string) string

func SliceContains

func SliceContains(slice []string, value string) bool

func ToCamelCase

func ToCamelCase(s string) string

func ToLowerCase

func ToLowerCase(s string) string

func ToPascalCase

func ToPascalCase(s string) string

func ToSnakeCase

func ToSnakeCase(s string) string

Types

type Attribute

type Attribute struct {
	resource.Attribute
	Computed bool `json:"computed"`
	Optional bool `json:"optional"`
	Required bool `json:"required"`
}

type Components

type Components struct {
	Schemas map[string]OASchema `json:"schemas"`
}

type CrudParameters

type CrudParameters struct {
	Create *NcloudCommonRequestType   `json:"create,omitempty"`
	Read   *NcloudCommonRequestType   `json:"read"`
	Update []*NcloudCommonRequestType `json:"update"`
	Delete *NcloudCommonRequestType   `json:"delete"`
}

type DataSource

type DataSource struct {
	datasource.DataSource
	CRUDParameters      CrudParameters `json:"crud_parameters"`
	RefreshObjectName   string         `json:"refresh_object_name"`
	ImportStateOverride string         `json:"import_state_override"`
	Id                  string         `json:"id"`
}

type DetailedRequestType

type DetailedRequestType struct {
	spec.RequestType
	Parameters  *RequestParameters `json:"parameters,omitempty"`
	RequestBody *NcloudRequestBody `json:"request_body,omitempty"`
}

type Info

type Info struct {
	Name string `json:"name"`
}

type Items

type Items struct {
	Type       string              `json:"type"`
	Properties map[string]Property `json:"properties"`
}

type ListAttributeElementType

type ListAttributeElementType struct {
	String interface{} `json:"string,omitempty"`
	Bool   interface{} `json:"bool,omitempty"`
	Int64  interface{} `json:"int64,omitempty"`
}

type ListAttributeType

type ListAttributeType struct {
	ComputedOptionalRequired string                   `json:"computed_optional_required"`
	ElementType              ListAttributeElementType `json:"element_type"`
}

type ListNestedAttributeType

type ListNestedAttributeType struct {
	ComputedOptionalRequired string           `json:"computed_optional_required"`
	NestedObject             NestedObjectType `json:"nested_object"`
}

type NcloudCommonRequestType

type NcloudCommonRequestType struct {
	DetailedRequestType
	Method string `json:"method,omitempty"`
	Path   string `json:"path,omitempty"`
}

type NcloudProvider

type NcloudProvider struct {
	provider.Provider
	Endpoint string `json:"endpoint,omitempty"`
}

type NcloudRequestBody

type NcloudRequestBody struct {
	spec.RequestBody
	Required []*RequestParametersInfo `json:"required,omitempty"`
	Optional []*RequestParametersInfo `json:"optional,omitempty"`
}

type NcloudSpecification

type NcloudSpecification struct {
	spec.Specification
	Provider    *NcloudProvider `json:"provider"`
	Resources   []Resource      `json:"resources"`
	DataSources []DataSource    `json:"datasources"`
}

type NestedObjectType

type NestedObjectType struct {
	Attributes []resource.Attribute `json:"attributes"`
}

type OASchema

type OASchema struct {
	Properties map[string]Property `json:"properties"`
}

type OpenAPI

type OpenAPI struct {
	Paths      map[string]*PathItem `json:"paths"`
	Info       *Info                `json:"info"`
	Components *Components          `json:"components"`
}

type OptionalRequestBody

type OptionalRequestBody struct {
	Name     string                   `json:"name,omitempty"`
	Required []string                 `json:"required,omitempty"`
	Optional []*RequestParametersInfo `json:"optional,omitempty"`
}

type PathItem

type PathItem struct {
	Post *high.Operation `json:"post,omitempty"`
	Get  *high.Operation `json:"get,omitempty"`
}

type Paths

type Paths struct {
	AttributePath string
	ConfigPath    string
}

func InitializePaths

func InitializePaths(inputSpec, inputConfig, outputDir string) Paths

type Property

type Property struct {
	docs.SchemaProperty
	Type                     string              `json:"type"`
	Format                   string              `json:"format,omitempty"`
	ComputedOptionalRequired string              `json:"computed_optional_required,omitempty"`
	Items                    Items               `json:"items,omitempty"`
	Properties               map[string]Property `json:"properties"`
}

type RequestParameters

type RequestParameters struct {
	Required []*RequestParametersInfo `json:"required,omitempty"`
	Optional []*RequestParametersInfo `json:"optional,omitempty"`
}

type RequestParametersInfo

type RequestParametersInfo struct {
	Name   string `json:"name,omitempty"`
	Type   string `json:"type,omitempty"`
	Format string `json:"format,omitempty"`
}

type Resource

type Resource struct {
	resource.Resource
	CRUDParameters      CrudParameters `json:"crud_parameters"`
	RefreshObjectName   string         `json:"refresh_object_name"`
	ImportStateOverride string         `json:"import_state_override"`
	Id                  string         `json:"id"`
}

type Schema

type Schema struct {
	Attributes resource.Attributes `json:"attributes"`
}

type SingleNestedAttributeType

type SingleNestedAttributeType struct {
	ComputedOptionalRequired string               `json:"computed_optional_required"`
	Attributes               []resource.Attribute `json:"attributes"`
}

Jump to

Keyboard shortcuts

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