gen

package
v3.38.0 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2022 License: Apache-2.0 Imports: 39 Imported by: 82

Documentation

Overview

Pulling out some of the repeated strings tokens into constants would harm readability, so we just ignore the goconst linter's warning.

nolint: lll, goconst

Pulling out some of the repeated strings tokens into constants would harm readability, so we just ignore the goconst linter's warning.

nolint: lll, goconst

Index

Constants

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 CRDTypes

func CRDTypes(tool string, pkg *schema.Package) (map[string]*bytes.Buffer, error)

CRDTypes returns a map from each module name to a buffer containing the code for its generated types.

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 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) 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"`

	// 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"`

	// 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"`
}

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.

Jump to

Keyboard shortcuts

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