Documentation ¶
Overview ¶
Copyright 2022, Pulumi Corporation. All rights reserved.
Default value and config value code-generation facilities for SDK generation are kept in this separate file as they are a bit intricate.
Index ¶
- Constants
- Variables
- 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 GenerateProject(directory string, project workspace.Project, program *pcl.Program) error
- func LanguageResources(tool string, pkg *schema.Package) (map[string]LanguageResource, error)
- func Template(name string, text string) *tmplt.Template
- 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 MethodCall
- type PackageInfo
- func (i PackageInfo) BasePackageOrDefault() string
- func (i PackageInfo) With(overrides PackageInfo) PackageInfo
- func (i PackageInfo) WithDefaultDependencies() PackageInfo
- func (i PackageInfo) WithDependencyDefault(key string, ver semver.Version) PackageInfo
- func (i PackageInfo) WithJavaSdkDependencyDefault(ver semver.Version) PackageInfo
- type PropertyInfo
- type TypeShape
- func (ts TypeShape) Equal(other TypeShape) bool
- func (ts TypeShape) ListType(ctx *classFileContext) string
- func (ts TypeShape) Optional() TypeShape
- func (ts TypeShape) Output() TypeShape
- func (ts TypeShape) ParameterTypes(imports *names.Imports) []string
- func (ts TypeShape) ParameterTypesTransformed(f func(TypeShape) string) []string
- func (ts TypeShape) StringJavaTypeShape(imports *names.Imports) string
- func (ts TypeShape) ToCode(imports *names.Imports) string
- func (ts TypeShape) ToCodeClassLiteral(imports *names.Imports) string
- func (ts TypeShape) ToCodeCommentedAnnotations(imports *names.Imports) string
- func (ts TypeShape) ToCodeErased(imports *names.Imports) string
- func (ts TypeShape) ToCodeWithOptions(imports *names.Imports, opts TypeShapeStringOptions) string
- func (ts TypeShape) ToTree(imports *names.Imports) (string, string)
- func (ts TypeShape) UnEither() (bool, TypeShape, TypeShape)
- func (ts TypeShape) UnList() (bool, TypeShape)
- func (ts TypeShape) UnNullable() (bool, TypeShape)
- func (ts TypeShape) UnOptional() (bool, TypeShape)
- func (ts TypeShape) UnOutput() (bool, TypeShape)
- func (ts TypeShape) WithoutAnnotations() TypeShape
- type TypeShapeStringOptions
Constants ¶
const (
// MissingKeyErrorOption is the renderer option to stop execution immediately with an error on missing key
MissingKeyErrorOption = "missingkey=error"
)
Variables ¶
var Importer schema.Language = importer(0)
Importer implements schema.Language for Java
Functions ¶
func GeneratePackage ¶
func GenerateProgram ¶
func GenerateProject ¶
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 Java-specific implementation of the similarly named codegen interface.
func (DocLanguageHelper) GetDocLinkForFunctionInputOrOutputType ¶
func (DocLanguageHelper) GetDocLinkForPulumiType ¶
func (d DocLanguageHelper) GetDocLinkForPulumiType(pkg *schema.Package, typeName string) string
TODO revisit once javadocs are published.
Not every language currently supports this. For Python docsgen the implementation returns "" also.
For an example of a language that supports this, check out Go.
When visiting https://www.pulumi.com/registry/packages/aws/api-docs/s3/bucket/ search for `func NewBucket`.
Context, BucketArgs and ResourceOption get linked to Go API docs.
For Java we could link to JavaDoc when appropriate.
func (DocLanguageHelper) GetDocLinkForResourceInputOrOutputType ¶
func (DocLanguageHelper) GetDocLinkForResourceType ¶
func (d DocLanguageHelper) GetDocLinkForResourceType(pkg *schema.Package, modName, typeName string) string
func (DocLanguageHelper) GetEnumName ¶
func (DocLanguageHelper) GetFunctionName ¶
func (d DocLanguageHelper) GetFunctionName(modName string, f *schema.Function) string
func (DocLanguageHelper) GetLanguageTypeString ¶
func (DocLanguageHelper) GetMethodName ¶
func (d DocLanguageHelper) GetMethodName(m *schema.Method) string
func (DocLanguageHelper) GetMethodResultName ¶
func (DocLanguageHelper) GetModuleDocLink ¶
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 LanguageResource ¶
type LanguageResource struct { *schema.Resource Name string // The resource name (e.g. Deployment) Package string // The package name (e.g. apps.v1) }
LanguageResource is derived from the schema and can be used by downstream codegen.
type MethodCall ¶
func (MethodCall) String ¶
func (m MethodCall) String() string
type PackageInfo ¶
type PackageInfo struct { // Overrides how Schema packages names translate to Java // package names. // // Absent an entry in Packages, Java code generator tries to // do something reasonable and produce a Java looking name for // a given Schema package. If this undesirable, adding an // entry in Packages will specify the desired Java name // manually. // // For example, pulumi-kubernetes specifies Packages names for // versioned API packages like this: // // packages: // "admissionregistration.k8s.io/v1: "admissionregistration.v1" // Packages map[string]string `json:"packages,omitempty"` // The prefix of the Java package to generate. // // Defaults to "com.pulumi". // // The generated Java code will start with: // // package ${BasePackage}.${pkg.Name}; // // Note that pkg.Name is coming from the Schema. // // For example, if the package is named "azuread" then the // generated code will be placed under: // // package com.pulumi.azuread // // And if BasePackage is set to "com.myorg" then the generated // code will instead be placed under: // // package com.myorg.azuread // BasePackage string `json:"basePackage"` // If set to "gradle" enables a generation of a basic set of // Gradle build files. BuildFiles string `json:"buildFiles"` // Specifies Maven-style dependencies for the generated code. // // The dependency on Java SDK (com.pulumi:pulumi) is special // and will be auto-popualted if not specified here. // // Other dependencies need to be specified if: // // - the package references types from other packages // // - the code generator is asked to emit build files, as in // BuildFiles="gradle", and produce a compiling project // // For example, pulumi-eks referenes pulumi-aws types, and can // specify the desired version: // // dependencies: // "com.pulumi:aws": "5.4.0" Dependencies map[string]string `json:"dependencies,omitempty"` // If non-empty and BuildFiles="gradle", enables the use of a // given version of io.github.gradle-nexus.publish-plugin in // the generated Gradle build files. GradleNexusPublishPluginVersion string `json:"gradleNexusPublishPluginVersion"` // If non-empty and BuildFiles="gradle", generates a test // section to enable `gradle test` command to run unit tests // over the generated code. Supported values: "JUnitPlatform". GradleTest string `json:"gradleTest"` }
PackageInfo defines Java-specific extensions to Pulumi Packages Schema.
These options affect how GeneratePackage generates and lays out Java SDKs for Pulumi Packages.
The options are typically set in the .language.java section of the Schema, but can also be overridden during code generation:
pulumi-java-gen generate --override overrides.json
See https://www.pulumi.com/docs/guides/pulumi-packages/schema/#language-specific-extensions
func (PackageInfo) BasePackageOrDefault ¶
func (i PackageInfo) BasePackageOrDefault() string
func (PackageInfo) With ¶ added in v0.2.1
func (i PackageInfo) With(overrides PackageInfo) PackageInfo
func (PackageInfo) WithDefaultDependencies ¶ added in v0.5.2
func (i PackageInfo) WithDefaultDependencies() PackageInfo
Makes sure dependencies are added for libraries that the generated code may link against.
func (PackageInfo) WithDependencyDefault ¶ added in v0.5.2
func (i PackageInfo) WithDependencyDefault(key string, ver semver.Version) PackageInfo
Makes sure Depdendencies contains the key if it does not already. If the key is missing, uses ver as the new version to depend on.
func (PackageInfo) WithJavaSdkDependencyDefault ¶ added in v0.5.2
func (i PackageInfo) WithJavaSdkDependencyDefault(ver semver.Version) PackageInfo
Makes sure Depdendencies contains the "com.pulumi:pulumi" key if it does not already. If the key is missing, uses ver as the new version to depend on.
type PropertyInfo ¶
type PropertyInfo struct {
Name string `json:"name,omitempty"`
}
PropertyInfo represents a Java language-specific info for a property.
type TypeShape ¶
func (TypeShape) ParameterTypes ¶
func (TypeShape) ParameterTypesTransformed ¶
func (TypeShape) StringJavaTypeShape ¶
StringJavaTypeShape returns a Java code representation.
func (TypeShape) ToCodeClassLiteral ¶
ToCodeClassLiteral converts to Java class literal, may add imports to use short names.
func (TypeShape) ToCodeCommentedAnnotations ¶
func (TypeShape) ToCodeErased ¶
ToCodeErased converts to Java code with erased generics, may add imports to use short names.
func (TypeShape) ToCodeWithOptions ¶
func (ts TypeShape) ToCodeWithOptions(imports *names.Imports, opts TypeShapeStringOptions) string
func (TypeShape) UnNullable ¶
func (TypeShape) UnOptional ¶
func (TypeShape) WithoutAnnotations ¶
type TypeShapeStringOptions ¶
type TypeShapeStringOptions struct { // useful for type parameters because (most) annotations are not allowed on a generic parameter type CommentOutAnnotations bool // useful for annotation parameters and other contexts where comments or annotations are not allowed SkipAnnotations bool // useful for .class or [].class to skip the generic part of the type GenericErasure bool // useful to append .class AppendClassLiteral bool // useful to append [].class AppendClassArrayLiteral bool }