codegen

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: Apache-2.0 Imports: 31 Imported by: 7

Documentation

Overview

The codegen package provides utilities for converting Pulumi YAML templates to other forms (e.g. programs in higher-level languages supported by Pulumi).

Index

Constants

This section is empty.

Variables

View Source
var ProjectKeysToOmit = []string{"configuration", "resources", "outputs", "variables"}

Functions

func ConvertTemplate

func ConvertTemplate(template *ast.TemplateDecl, generate GenerateFunc, loader schema.ReferenceLoader) (map[string][]byte, hcl.Diagnostics, error)

ConvertTemplate converts a Pulumi YAML template to a target language using PCL as an intermediate representation.

loader is the schema.Loader used when binding the the PCL program. If `nil`, a `schema.Loader` will be created from `newPluginHost()`.

func ConvertTemplateIL

func ConvertTemplateIL(template *ast.TemplateDecl, loader schema.ReferenceLoader) (string, hcl.Diagnostics, error)

func Eject

func Eject(dir string, loader schema.ReferenceLoader) (*workspace.Project, *pcl.Program, error)

Eject on a YAML program directory returns a Pulumi Project and a YAML program which has been parsed and converted to the intermediate PCL language

func EjectProgram

func EjectProgram(template *ast.TemplateDecl, loader schema.ReferenceLoader) (*pcl.Program, hcl.Diagnostics, error)

func GenerateProgram

func GenerateProgram(program *pcl.Program) (map[string][]byte, hcl.Diagnostics, error)

Generate a serializable YAML template.

func GenerateProject

func GenerateProject(directory string, project workspace.Project, program *pcl.Program) error

func ImportTemplate

func ImportTemplate(file *ast.TemplateDecl, loader pulumiyaml.PackageLoader) (*model.Body, syntax.Diagnostics)

ImportTemplate converts a YAML template to a PCL definition.

func LoadTemplate

func LoadTemplate(dir string) (*workspace.Project, *ast.TemplateDecl, hcl.Diagnostics, error)

Types

type BlockSyntax added in v0.5.3

type BlockSyntax struct {
	Leading  syntax.TriviaList
	Trailing syntax.TriviaList
}

func (BlockSyntax) FootComment added in v0.5.3

func (b BlockSyntax) FootComment() string

func (BlockSyntax) HeadComment added in v0.5.3

func (b BlockSyntax) HeadComment() string

func (BlockSyntax) LineComment added in v0.5.3

func (b BlockSyntax) LineComment() string

func (BlockSyntax) Range added in v0.5.3

func (b BlockSyntax) Range() *hcl.Range

type DocLanguageHelper

type DocLanguageHelper struct{}

DocLanguageHelper is the YAML-specific implementation of the DocLanguageHelper.

func (DocLanguageHelper) GetDocLinkForFunctionInputOrOutputType

func (d DocLanguageHelper) GetDocLinkForFunctionInputOrOutputType(pkg *schema.Package, moduleName, typeName string, input bool) string

func (DocLanguageHelper) GetDocLinkForPulumiType

func (d DocLanguageHelper) GetDocLinkForPulumiType(pkg *schema.Package, typeName string) string

func (DocLanguageHelper) GetDocLinkForResourceInputOrOutputType

func (d DocLanguageHelper) GetDocLinkForResourceInputOrOutputType(pkg *schema.Package, moduleName, typeName string, input bool) string

func (DocLanguageHelper) GetDocLinkForResourceType

func (d DocLanguageHelper) GetDocLinkForResourceType(pkg *schema.Package, moduleName, typeName string) string

func (DocLanguageHelper) GetEnumName

func (d DocLanguageHelper) GetEnumName(e *schema.Enum, typeName string) (string, error)

Pulumi YAML doesn't have enums, so you should just use the value itself.

func (DocLanguageHelper) GetFunctionName

func (d DocLanguageHelper) GetFunctionName(modName string, f *schema.Function) string

func (DocLanguageHelper) GetLanguageTypeString

func (d DocLanguageHelper) GetLanguageTypeString(pkg *schema.Package, moduleName string, t schema.Type, input bool) string

func (DocLanguageHelper) GetMethodName

func (d DocLanguageHelper) GetMethodName(m *schema.Method) string

func (DocLanguageHelper) GetMethodResultName

func (d DocLanguageHelper) GetMethodResultName(pkg *schema.Package, modName string, r *schema.Resource, m *schema.Method) string

There is no way to name types besides resources and invokes in Pulumi YAML.

func (d DocLanguageHelper) GetModuleDocLink(pkg *schema.Package, modName string) (string, string)

func (DocLanguageHelper) GetPropertyName

func (d DocLanguageHelper) GetPropertyName(p *schema.Property) (string, error)

func (DocLanguageHelper) GetResourceFunctionResultName

func (d DocLanguageHelper) GetResourceFunctionResultName(modName string, f *schema.Function) string

type GenerateFunc

type GenerateFunc func(program *pcl.Program) (map[string][]byte, hcl.Diagnostics, error)

A GenerateFunc generates a set of output files from a PCL program. This is used to convert YAML templates to higher-level languages using PCL as an intermediate representation.

type HasTrivia added in v0.5.3

type HasTrivia interface {
	GetLeadingTrivia() syntax.TriviaList
	GetTrailingTrivia() syntax.TriviaList
}

type Invoke

type Invoke struct {
	Function  string      `yaml:"function" json:"function"`
	Arguments interface{} `yaml:"arguments,omitempty" json:"arguments,omitempty"`
	Return    string      `yaml:"return,omitempty" json:"return,omitempty"`
}

type Traversal

type Traversal struct {
	// contains filtered or unexported fields
}

A `ScopedTraversalExpression` ready to display.

func (Traversal) Equal

func (t Traversal) Equal(o Traversal) bool

func (Traversal) OmitFirst

func (t Traversal) OmitFirst() Traversal

func (Traversal) String

func (t Traversal) String() string

func (Traversal) WithRoot

func (t Traversal) WithRoot(s string, hclRange *hcl.Range) Traversal

type TraversalList

type TraversalList = []Traversal

func AppendTraversal

func AppendTraversal(tl TraversalList, t Traversal) TraversalList

func NewTraversalList

func NewTraversalList() TraversalList

type TraversalSegment

type TraversalSegment struct {
	// contains filtered or unexported fields
}

A segment of `Traversal`

type YAMLError

type YAMLError struct {
	// contains filtered or unexported fields
}

A user-facing yaml error

func (YAMLError) AppendTo

func (l YAMLError) AppendTo(g *generator)

Jump to

Keyboard shortcuts

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