translator

package
v0.4.0-rc2 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SchemaOfType

func SchemaOfType(
	typ any,
	name string,
	def any,
	description string,
	sensitive bool,
	order int,
) (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 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,
	name string,
	def any,
	description string,
	sensitive bool,
	order int,
) *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,
		name string,
		def any,
		description string,
		sensitive bool,
		order int) *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