codegen

package
v3.113.0 Latest Latest
Warning

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

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

README

Pulumi CrossCode

The github.com/pulumi/pulumi/pkg/v3/codegen package defines the core components of Pulumi's CrossCode technology. CrossCode provides a set of foundational capabilities for working across a variety of programming languages supported by the Pulumi platform.

The core components of CrossCode in this package are:

  • Schema: The definition of Pulumi Schema, a language-neutral specification of cloud resource models. Pulumi Schema is the interface definition language for all Pulumi Packages, and is used as input to SDK code generation for each supported Pulumi language.
  • SDK Code Generation for Node.js, Python, Go and .NET: These libraries define how to create Pulumi SDKs from a Pulumi Schema definition of a package. The resulting SDKs expose the resource, components and functions from that package into the the Pulumi programming model defined for the given language.
  • Docs Generation: In addition to generating per-language SDKs, CrossCode supports generating language-neutral documentation for a package from it's Pulumi Schema. This documentation is currently hosted in the Pulumi Registry, but can in principle be hosted in other contexts as well.
  • Pulumi Configuration Language: An internal representation of Pulumi programs which supports all core concepts of the Pulumi programming model in a minimal form. Although not exposed directly to users today, this intermediate representation is used to support a variety of program conversion tasks, from and to various supported Pulumi languages.
  • Program Generation for Node.js, Python, Go and .NET: Support for lowering Pulumi Configuration Language into each of the supported Pulumi languages, such that examples and programs can be generated for the language.

These foundations enable a vast array of features supported in the Pulumi Platform, including:

  • Pulumi support for Node.js, Python, Go, .NET, Java and YAML: Each Pulumi language is supported by defining a representation of the Pulumi resource model in that language, and then implementing SDK Code Generation and Program Generation for the language.
  • Pulumi Packages: Pulumi packages define a set of resources using Pulumi Schema, and use the CrossCode SDK Code Generators for every Pulumi language automatically.
  • pulumi import: Cloud infrastructure resources deployed outside of Pulumi can be imported into Pulumi, including generated Pulumi code in your language of choice which defines the infrastructure. This builds on the program generation support from CrossCode.
  • tf2pulumi, arm2pulumi, crd2pulumi, kube2pulumi and cf2pulumi: These tools convert the source IaC format into an intermediate Pulumi Configuration Language model, and then use the CrossCode program generation support to convert that ultimately into the language a Pulumi user wants to use for their infrastructure.
  • pulumi convert: The pulumi convert command allows Pulumi YAML programs to be converted into programs in any other Pulumi language. Because Pulumi YAML is a proper subset of what can be expressed in Pulumi Configuration Language, this conversion from Pulumi YAML to Pulumi Configuration Language and then into each Pulumi language can be done faithfully.
  • Pulumi Registry: The Pulumi Registry provides discovery and documentation hosting for all Pulumi Packages. It is powered by the Pulumi Schema and CrossCode documentation generation features.

Learn more about Pulumi CrossCode at https://www.pulumi.com/crosscode/.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanDir

func CleanDir(dirPath string, exclusions StringSet) error

CleanDir removes all existing files from a directory except those in the exclusions list. Note: The exclusions currently don't function recursively, so you cannot exclude a single file in a subdirectory, only entire subdirectories. This function will need improvements to be able to target that use-case.

func ExpandShortEnumName

func ExpandShortEnumName(name string) string

func FilterExamples

func FilterExamples(description string, lang string) string

FilterExamples filters the code snippets in a schema docstring to include only those that target the given language.

func IsNOptionalInput added in v3.17.0

func IsNOptionalInput(t schema.Type) bool

func IsProvideDefaultsFuncRequired added in v3.19.0

func IsProvideDefaultsFuncRequired(t schema.Type) bool

If a helper function needs to be invoked to provide default values for a plain type. The provided map cannot be reused.

func MapInnerType added in v3.31.0

func MapInnerType(t schema.Type, f func(schema.Type) schema.Type) schema.Type

MapInnerType applies f to the first non-wrapper type in t. MapInnerType does not mutate it's input, and t should not either.

func MapOptionalType added in v3.31.1

func MapOptionalType(t schema.Type, f func(schema.Type) schema.Type) schema.Type

Applies f to the first non-optional type in t. If t is Optional{v} then returns Optional{f(v)}, otherwise f(t) is returned

func OptionalType added in v3.6.0

func OptionalType(p *schema.Property) schema.Type

OptionalType wraps the Property's type in an OptionalType if it is not already optional.

func PkgEquals added in v3.49.0

func PkgEquals(p1, p2 schema.PackageReference) bool

Check if two packages are the same.

func PlainType added in v3.6.0

func PlainType(t schema.Type) schema.Type

PlainType deeply removes any InputTypes from t, with the exception of argument structs. Use ResolvedType to unwrap argument structs as well.

func RequiredType added in v3.6.0

func RequiredType(p *schema.Property) schema.Type

RequiredType unwraps the OptionalType enclosing the Property's type, if any.

func ResolvedType added in v3.6.0

func ResolvedType(t schema.Type) schema.Type

ResolvedType deeply removes any InputTypes from t.

func SimplifyInputUnion added in v3.6.0

func SimplifyInputUnion(t schema.Type) schema.Type

func SortedKeys

func SortedKeys[T any](m map[string]T) []string

SortedKeys returns a sorted list of keys for the given map.

func UnwrapType added in v3.6.0

func UnwrapType(t schema.Type) schema.Type

UnwrapType removes any outer OptionalTypes and InputTypes from t.

func VisitType added in v3.50.0

func VisitType(schemaType schema.Type, visitor func(t schema.Type))

func VisitTypeClosure added in v3.1.0

func VisitTypeClosure(properties []*schema.Property, visitor func(t schema.Type))

Types

type DocLanguageHelper

type DocLanguageHelper interface {
	GetPropertyName(p *schema.Property) (string, error)
	GetEnumName(e *schema.Enum, typeName string) (string, error)
	GetDocLinkForResourceType(pkg *schema.Package, moduleName, typeName string) string
	GetDocLinkForPulumiType(pkg *schema.Package, typeName string) string
	GetDocLinkForResourceInputOrOutputType(pkg *schema.Package, moduleName, typeName string, input bool) string
	GetDocLinkForFunctionInputOrOutputType(pkg *schema.Package, moduleName, typeName string, input bool) string
	GetLanguageTypeString(pkg *schema.Package, moduleName string, t schema.Type, input bool) string

	GetFunctionName(modName string, f *schema.Function) string
	// GetResourceFunctionResultName returns the name of the result type when a static resource function is used to lookup
	// an existing resource.
	GetResourceFunctionResultName(modName string, f *schema.Function) string

	GetMethodName(m *schema.Method) string
	GetMethodResultName(pkg *schema.Package, modName string, r *schema.Resource, m *schema.Method) string

	// GetModuleDocLink returns the display name and the link for a module (including root modules) in a given package.
	GetModuleDocLink(pkg *schema.Package, modName string) (string, string)
}

DocLanguageHelper is an interface for extracting language-specific information from a Pulumi schema. See the implementation for this interface under each of the language code generators.

type Fs added in v3.47.0

type Fs map[string][]byte

A simple in memory file system.

func (Fs) Add added in v3.47.0

func (fs Fs) Add(path string, contents []byte)

Add a new file to the Fs.

Panic if the file is a duplicate.

type Set

type Set map[interface{}]struct{}

func (Set) Add

func (s Set) Add(v interface{})

func (Set) Delete added in v3.14.0

func (s Set) Delete(v interface{})

func (Set) Has

func (s Set) Has(v interface{}) bool

type StringSet

type StringSet map[string]struct{}

func NewStringSet

func NewStringSet(values ...string) StringSet

func (StringSet) Add

func (ss StringSet) Add(s string)

func (StringSet) Any

func (ss StringSet) Any() bool

func (StringSet) Contains added in v3.5.0

func (ss StringSet) Contains(subset StringSet) bool

Contains returns true if all elements of the subset are also present in the current set. It also returns true if subset is empty.

func (StringSet) Delete

func (ss StringSet) Delete(s string)

func (StringSet) Except added in v3.23.0

func (ss StringSet) Except(s string) StringSet

StringSet.Except returns the string set setminus s.

func (StringSet) Has

func (ss StringSet) Has(s string) bool

func (StringSet) SortedValues

func (ss StringSet) SortedValues() []string

func (StringSet) Subtract added in v3.5.0

func (ss StringSet) Subtract(other StringSet) StringSet

Subtract returns a new string set with all elements of the current set that are not present in the other set.

func (StringSet) Union added in v3.42.0

func (ss StringSet) Union(other StringSet) StringSet

Directories

Path Synopsis
package cgstrings has various string processing functions that are useful during code generation.
package cgstrings has various string processing functions that are useful during code generation.
Pulling out some of the repeated strings tokens into constants would harm readability, so we just ignore the goconst linter's warning.
Pulling out some of the repeated strings tokens into constants would harm readability, so we just ignore the goconst linter's warning.
Pulling out some of the repeated strings tokens into constants would harm readability, so we just ignore the goconst linter's warning.
Pulling out some of the repeated strings tokens into constants would harm readability, so we just ignore the goconst linter's warning.
Pulling out some of the repeated strings tokens into constants would harm readability, so we just ignore the goconst linter's warning.
Pulling out some of the repeated strings tokens into constants would harm readability, so we just ignore the goconst linter's warning.
hcl2
model/pretty
pretty is an extensible utility library to pretty-print nested structures.
pretty is an extensible utility library to pretty-print nested structures.
Pulling out some of the repeated strings tokens into constants would harm readability, so we just ignore the goconst linter's warning.
Pulling out some of the repeated strings tokens into constants would harm readability, so we just ignore the goconst linter's warning.
tstypes
Helper code to assist emitting correctly minimally parenthesized TypeScript type literals.
Helper code to assist emitting correctly minimally parenthesized TypeScript type literals.
Pulling out some of the repeated strings tokens into constants would harm readability, so we just ignore the goconst linter's warning.
Pulling out some of the repeated strings tokens into constants would harm readability, so we just ignore the goconst linter's warning.
testing

Jump to

Keyboard shortcuts

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