translator

package
v0.5.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SchemaOfType

func SchemaOfType(typ any, opts Options) (schema openapi3.Schema)

SchemaOfType generates openAPI schema from original type.

func ToGoTypeValues

func ToGoTypeValues(values map[string]json.RawMessage, schema openapi3.Schema) (r map[string]any, err error)

ToGoTypeValues converts values to go types.

Types

type Options

type Options struct {
	Name          string
	DefaultValue  any
	DefaultObject any
	Description   string
	Sensitive     bool
	Order         int
	TypeExpress   any
	// IgnoreWidget used for skipping add widget for any type in sub schema.
	IgnoreWidget bool
}

type TerraformTranslator

type TerraformTranslator struct{}

TerraformTranslator translates between terraform types and go types with openapi schema.

func NewTerraformTranslator

func NewTerraformTranslator() TerraformTranslator

NewTerraformTranslator creates a new terraform translator.

func (TerraformTranslator) GetOriginalType

func (t TerraformTranslator) GetOriginalType(schema *openapi3.Schema) cty.Type

GetOriginalType returns the original type of the schema.

func (TerraformTranslator) SchemaMatched

func (t TerraformTranslator) SchemaMatched(schema openapi3.Schema) bool

func (TerraformTranslator) SchemaOfOriginalType

func (t TerraformTranslator) SchemaOfOriginalType(tp any, opts Options) *openapi3.Schema

SchemaOfOriginalType generates openAPI schema from terraform type.

func (TerraformTranslator) ToGoTypeValues

func (t TerraformTranslator) ToGoTypeValues(
	values map[string]json.RawMessage,
	schema openapi3.Schema,
) (map[string]any, error)

ToGoTypeValues converts the values to go types.

func (TerraformTranslator) ToOriginalTypeValues

func (t TerraformTranslator) ToOriginalTypeValues(values map[string]any) ([]string, map[string]cty.Value, error)

ToOriginalTypeValues Converts arbitrary go types to a cty Value.

type Translator

type Translator interface {
	// SchemaOfOriginalType generates openAPI schema from original type.
	SchemaOfOriginalType(typ any, opts Options) *openapi3.Schema
	// ToGoTypeValues converts values to go types.
	ToGoTypeValues(values map[string]json.RawMessage, schema openapi3.Schema) (map[string]any, error)
}

Translator translates between original template language and go types with openapi schema.

Jump to

Keyboard shortcuts

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