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
nolint: goconst
Index ¶
- Variables
- func Check(t *testing.T, path string, _ codegen.StringSet)
- func EnsureKeywordSafe(name string) string
- func GeneratePackage(tool string, pkg *schema.Package, extraFiles map[string][]byte) (map[string][]byte, error)
- func GenerateProgram(program *pcl.Program) (map[string][]byte, hcl.Diagnostics, error)
- func GenerateProgramBatchTest(t *testing.T, testCases []test.ProgramTest)
- func GenerateProject(directory string, project workspace.Project, program *pcl.Program) error
- func InitParamName(name string) string
- func LanguageResources(tool string, pkg *schema.Package) (map[string]LanguageResource, error)
- func PyName(name string) string
- type DocLanguageHelper
- func (d DocLanguageHelper) GetDocLinkForFunctionInputOrOutputType(pkg *schema.Package, modName, typeName string, input bool) string
- func (d DocLanguageHelper) GetDocLinkForPulumiType(pkg *schema.Package, typeName string) string
- func (d DocLanguageHelper) GetDocLinkForResourceInputOrOutputType(pkg *schema.Package, modName, typeName string, input bool) string
- func (d DocLanguageHelper) GetDocLinkForResourceType(pkg *schema.Package, modName, typeName string) string
- func (d DocLanguageHelper) GetEnumName(e *schema.Enum, typeName string) (string, error)
- func (d DocLanguageHelper) GetFunctionName(modName string, f *schema.Function) string
- func (d DocLanguageHelper) GetLanguageTypeString(pkg *schema.Package, moduleName string, t schema.Type, input bool) string
- func (d DocLanguageHelper) GetMethodName(m *schema.Method) string
- 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)
- func (d DocLanguageHelper) GetPropertyName(p *schema.Property) (string, error)
- func (d DocLanguageHelper) GetResourceFunctionResultName(modName string, f *schema.Function) string
- type LanguageResource
- type PackageInfo
- type PropertyInfo
Constants ¶
This section is empty.
Variables ¶
var Importer schema.Language = importer(0)
Importer implements schema.Language for Python.
var Keywords = codegen.NewStringSet(
"False",
"None",
"True",
"and",
"as",
"assert",
"async",
"await",
"break",
"class",
"continue",
"def",
"del",
"elif",
"else",
"except",
"exec",
"finally",
"for",
"from",
"global",
"if",
"import",
"in",
"is",
"lambda",
"nonlocal",
"not",
"or",
"pass",
"print",
"raise",
"return",
"try",
"while",
"with",
"yield")
Keywords is a map of reserved keywords used by Python 2 and 3. We use this to avoid generating unspeakable names in the resulting code. This map was sourced by merging the following reference material:
Functions ¶
func EnsureKeywordSafe ¶
EnsureKeywordSafe adds a trailing underscore if the generated name clashes with a Python 2 or 3 keyword, per PEP 8: https://www.python.org/dev/peps/pep-0008/?#function-and-method-arguments
func GeneratePackage ¶
func GenerateProgram ¶
func GenerateProgramBatchTest ¶ added in v3.44.0
func GenerateProgramBatchTest(t *testing.T, testCases []test.ProgramTest)
func GenerateProject ¶ added in v3.31.0
func InitParamName ¶
InitParamName returns a PyName-encoded name but also deduplicates the name against built-in parameters of resource __init__.
func LanguageResources ¶
LanguageResources returns a map of resources that can be used by downstream codegen. The map key is the resource schema token.
Types ¶
type DocLanguageHelper ¶
type DocLanguageHelper struct{}
DocLanguageHelper is the Python-specific implementation of the DocLanguageHelper.
func (DocLanguageHelper) GetDocLinkForFunctionInputOrOutputType ¶
func (d DocLanguageHelper) GetDocLinkForFunctionInputOrOutputType(pkg *schema.Package, modName, typeName string, input bool) string
GetDocLinkForFunctionInputOrOutputType is not implemented at this time for Python.
func (DocLanguageHelper) GetDocLinkForPulumiType ¶
func (d DocLanguageHelper) GetDocLinkForPulumiType(pkg *schema.Package, typeName string) string
GetDocLinkForPulumiType is not implemented at this time for Python.
func (DocLanguageHelper) GetDocLinkForResourceInputOrOutputType ¶
func (d DocLanguageHelper) GetDocLinkForResourceInputOrOutputType(pkg *schema.Package, modName, typeName string, input bool) string
GetDocLinkForResourceInputOrOutputType is not implemented at this time for Python.
func (DocLanguageHelper) GetDocLinkForResourceType ¶
func (d DocLanguageHelper) GetDocLinkForResourceType(pkg *schema.Package, modName, typeName string) string
GetDocLinkForResourceType returns the Python API doc for a type belonging to a resource provider.
func (DocLanguageHelper) GetEnumName ¶
GetEnumName returns the enum name specific to Python.
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 Python-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 (DocLanguageHelper) GetModuleDocLink ¶
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 Python.
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 LanguageResource ¶
type LanguageResource struct {
*schema.Resource
Name string // The resource name (e.g. Deployment)
Package string // The package name (e.g. pulumi_kubernetes.apps.v1)
}
LanguageResource is derived from the schema and can be used by downstream codegen.
type PackageInfo ¶
type PackageInfo struct {
// PackageName is an override for the name of the generated python package.
PackageName string `json:"packageName,omitempty"`
// PythonRequires determines the Python versions that the generated provider supports
PythonRequires string `json:"pythonRequires,omitempty"`
Requires map[string]string `json:"requires,omitempty"`
// Readme contains the text for the package's README.md files.
Readme string `json:"readme,omitempty"`
// Optional overrides for Pulumi module names
//
// { "flowcontrol.apiserver.k8s.io/v1alpha1": "flowcontrol/v1alpha1" }
//
ModuleNameOverrides map[string]string `json:"moduleNameOverrides,omitempty"`
// Toggle compatibility mode for a specified target.
Compatibility string `json:"compatibility,omitempty"`
// Deprecated: This bool is no longer needed since all providers now use input/output classes.
UsesIOClasses bool `json:"usesIOClasses,omitempty"`
// Determines whether to make single-return-value methods return an output object or the single value.
LiftSingleValueMethodReturns bool `json:"liftSingleValueMethodReturns,omitempty"`
// Respect the Pkg.Version field for emitted code.
RespectSchemaVersion bool `json:"respectSchemaVersion,omitempty"`
}
PackageInfo tracks Python-specific information associated with a package.
type PropertyInfo ¶
type PropertyInfo struct {
MapCase bool `json:"mapCase,omitempty"`
}
PropertyInfo tracks Python-specific information associated with properties in a package.