gen

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: 44 Imported by: 61

Documentation

Overview

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.

Index

Constants

View Source
const (
	GenericsSettingNone         = "none"
	GenericsSettingSideBySide   = "side-by-side"
	GenericsSettingGenericsOnly = "generics-only"
)
View Source
const ExternalModuleSig = ":always-external:"

A signifier that the module is external, and will never match.

This token is always an invalid module since ':' is not allowed within modules.

View Source
const (
	IndexToken = "index"
)
View Source
const ProvideDefaultsMethodName = "Defaults"

The name of the method used to instantiate defaults.

Variables

View Source
var Importer schema.Language = importer(0)

Importer implements schema.Language for Go.

Functions

func AnnotateComponentInputs added in v3.67.1

func AnnotateComponentInputs(component *pcl.Component)

func Check added in v3.27.0

func Check(t *testing.T, path string, deps codegen.StringSet, pulumiSDKPath string)

func GeneratePackage

func GeneratePackage(tool string, pkg *schema.Package) (map[string][]byte, error)

func GenerateProgram

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

func GenerateProgramBatchTest added in v3.44.0

func GenerateProgramBatchTest(t *testing.T, testCases []test.ProgramTest)

func GenerateProgramWithOptions added in v3.25.0

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

func GenerateProject added in v3.31.0

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

func GenerateProjectFiles added in v3.76.0

func GenerateProjectFiles(project workspace.Project, program *pcl.Program) (map[string][]byte, hcl.Diagnostics, error)

func LanguageResources

func LanguageResources(tool string, pkg *schema.Package) (map[string]LanguageResource, error)

LanguageResources returns a map of resources that can be used by downstream codegen. The map key is the resource schema token.

func NeedsGoOutputVersion added in v3.17.1

func NeedsGoOutputVersion(f *schema.Function) bool

func Title

func Title(s string) string

Title converts the input string to a title case where only the initial letter is upper-cased. It also removes $-prefix if any.

func TypeCheck added in v3.33.2

func TypeCheck(t *testing.T, path string, deps codegen.StringSet, pulumiSDKPath string)

Types

type Cache added in v3.38.0

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

A threadsafe cache for sharing between invocations of GenerateProgram.

func NewCache added in v3.38.0

func NewCache() *Cache

type DocLanguageHelper

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

DocLanguageHelper is the Go-specific implementation of the DocLanguageHelper.

func (*DocLanguageHelper) GeneratePackagesMap

func (d *DocLanguageHelper) GeneratePackagesMap(pkg *schema.Package, tool string, goInfo GoPackageInfo)

GeneratePackagesMap generates a map of Go packages for resources, functions and types.

func (DocLanguageHelper) GetDocLinkForFunctionInputOrOutputType

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

GetDocLinkForFunctionInputOrOutputType returns the doc link for an input or output type of a Function.

func (DocLanguageHelper) GetDocLinkForPulumiType

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

GetDocLinkForPulumiType returns the doc link for a Pulumi type.

func (DocLanguageHelper) GetDocLinkForResourceInputOrOutputType

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

GetDocLinkForResourceInputOrOutputType returns the godoc URL for an input or output type.

func (DocLanguageHelper) GetDocLinkForResourceType

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

GetDocLinkForResourceType returns the godoc URL for a type belonging to a resource provider.

func (DocLanguageHelper) GetEnumName

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

GetEnumName returns the enum name specific to Go.

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

GetLanguageTypeString returns the Go-specific type given a Pulumi schema type.

func (DocLanguageHelper) GetMethodName added in v3.10.2

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

func (DocLanguageHelper) GetMethodResultName added in v3.10.2

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

GetModuleDocLink returns the display name and the link for a module.

func (DocLanguageHelper) GetPropertyName

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

GetPropertyName returns the property name specific to Go.

func (DocLanguageHelper) GetResourceFunctionResultName

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

GetResourceFunctionResultName returns the name of the result type when a function is used to lookup an existing resource.

type GenerateProgramOptions added in v3.25.0

type GenerateProgramOptions struct {
	AssignResourcesToVariables bool // Assign resource to a new variable instead of _.
	ExternalCache              *Cache
}

GenerateProgramOptions are used to configure optional generator behavior.

type GoPackageInfo

type GoPackageInfo struct {
	// Base path for package imports
	//
	//    github.com/pulumi/pulumi-kubernetes/sdk/go/kubernetes
	ImportBasePath string `json:"importBasePath,omitempty"`

	// Module path for go.mod
	//
	//   go get github.com/pulumi/pulumi-aws-native/sdk/go/aws@v0.16.0
	//          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ module path
	//                                                  ~~~~~~ package path - can be any number of path parts
	//                                                         ~~~~~~~ version
	ModulePath string `json:"modulePath,omitempty"`

	// Explicit package name, which may be different to the import path.
	RootPackageName string `json:"rootPackageName,omitempty"`

	// Map from module -> package name
	//
	//    { "flowcontrol.apiserver.k8s.io/v1alpha1": "flowcontrol/v1alpha1" }
	//
	ModuleToPackage map[string]string `json:"moduleToPackage,omitempty"`

	// Map from package name -> package alias
	//
	//    { "github.com/pulumi/pulumi-kubernetes/sdk/go/kubernetes/flowcontrol/v1alpha1": "flowcontrolv1alpha1" }
	//
	PackageImportAliases map[string]string `json:"packageImportAliases,omitempty"`

	// Generate container types (arrays, maps, pointer output types etc.) for each resource.
	// These are typically used to support external references.
	GenerateResourceContainerTypes bool `json:"generateResourceContainerTypes,omitempty"`

	// The version of the Pulumi SDK used with this provider, e.g. 3.
	// Used to generate doc links for pulumi builtin types. If omitted, the latest SDK version is used.
	PulumiSDKVersion int `json:"pulumiSDKVersion,omitempty"`

	// Feature flag to disable generating `$fnOutput` invoke
	// function versions to save space.
	DisableFunctionOutputVersions bool `json:"disableFunctionOutputVersions,omitempty"`

	// Determines whether to make single-return-value methods return an output struct or the value.
	LiftSingleValueMethodReturns bool `json:"liftSingleValueMethodReturns,omitempty"`

	// Feature flag to disable generating input type registration. This is a
	// space saving measure.
	DisableInputTypeRegistrations bool `json:"disableInputTypeRegistrations,omitempty"`

	// When set, the code generator will use this name for the generated internal module
	// instead of "internal" so that functionality within the module can be used by end users.
	InternalModuleName string `json:"internalModuleName,omitempty"`

	// Feature flag to disable generating Pulumi object default functions. This is a
	// space saving measure.
	DisableObjectDefaults bool `json:"disableObjectDefaults,omitempty"`

	// GenerateExtraInputTypes determines whether or not the code generator generates input (and output) types for
	// all plain types, instead of for only types that are used as input/output types.
	GenerateExtraInputTypes bool `json:"generateExtraInputTypes,omitempty"`

	// omitExtraInputTypes determines whether the code generator generates input (and output) types
	// for all plain types, instead of for only types that are used as input/output types.
	OmitExtraInputTypes bool `json:"omitExtraInputTypes,omitempty"`

	// Respect the Pkg.Version field for emitted code.
	RespectSchemaVersion bool `json:"respectSchemaVersion,omitempty"`

	// InternalDependencies are blank imports that are emitted in the SDK so that `go mod tidy` does not remove the
	// associated module dependencies from the SDK's go.mod.
	InternalDependencies []string `json:"internalDependencies,omitempty"`

	// Specifies how to handle generating a variant of the SDK that uses generics.
	// Allowed values are the following:
	// - "none" (default): do not generate a generics variant of the SDK
	// - "side-by-side": generate a side-by-side generics variant of the SDK under the x subdirectory
	// - "only-generics": generate a generics variant of the SDK only
	Generics string `json:"generics,omitempty"`
}

GoPackageInfo holds information required to generate the Go SDK from a schema.

type LanguageResource

type LanguageResource struct {
	*schema.Resource

	Alias   string // The package alias (e.g. appsv1)
	Name    string // The resource name (e.g. Deployment)
	Package string // The package name (e.g. github.com/pulumi/pulumi-kubernetes/sdk/v2/go/kubernetes/apps/v1)
}

LanguageResource is derived from the schema and can be used by downstream codegen.

type ObjectTypeFromConfigMetadata added in v3.67.1

type ObjectTypeFromConfigMetadata = struct {
	TypeName      string
	ComponentName string
}

Jump to

Keyboard shortcuts

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