* [codegen/go] Fix accessors on struct ptr outputs
The accesor methods on nestred struct Ptr outputs were previously not accepting pointer typed inputs as they should, and would thus always panic if used.
The "simple" fix would be to just accept the pointer type and blindly dereference it. But this doesn't seem like the right experience - it would make these accessors very unsafe to use in practice.
Instead, this PR implements the accessors on pointer-typed outputs as nil-coaslescing, always lifting the output type into a pointer type and flowing a nil value into the result type. This ensures the accessor will not nil-deref, and that user code can handle the `nil` value itself (or use `.Apply` directly to implement more specialized behaviour).
Before:
```go
// Name of your S3 bucket.
func (o BuildStorageLocationPtrOutput) Bucket() pulumi.StringOutput {
return o.ApplyT(func(v BuildStorageLocation) string { return v.Bucket }).(pulumi.StringOutput)
}
```
After:
```go
// Name of your S3 bucket.
func (o BuildStorageLocationPtrOutput) Bucket() pulumi.StringPtrOutput {
return o.ApplyT(func(v *BuildStorageLocation) *string {
if v == nil {
return nil
}
return &v.Bucket
}).(pulumi.StringPtrOutput)
}
```
However, due to the decision to have this more usable behaviour, this is a breaking change, as some/many accessors now return a pointer type when they previously did not.
Fixespulumi/pulumi-azure#530.
* Mark nested property types as requiring ptr types
* Add CHANGELOG
* More fixes
Some property names are mapped from their `camelCase` Pulumi name to a
`snake_case` Python name. This mapping is irregular, and only occurs for
resources properties and function calls.
Note that there's still more work to do here: this only fixes names on
the output side; the input side is still broken for nested resource
proprerties and function calls.
The underlying design--annotated types in `hcl2/model`--may need some
additional work in the future, but I _believe_ it's good enough for now.
* Optimize titles and descriptions
* Move regexp to file level variable
* wip
* Add title tags and description to module and pkg index pages
* Remove block_external_search_index from index.tmpl
* Improve resource descriptions
* Add more providers to look up map
* Improve module level descriptions
Clean up
cleanup
* Update the function.tmpl with the auto-generated disclaimer. Pass title tag and meta description for the function template as well.
* Fix whitespace in the package_details template..
* Account for empty module names for package-level resources. Move logic for generating title tag and description into separate methods for Resources and Functions.
* Add a test for the generated resource and function title tag.
Co-authored-by: Praneet Loke <1466314+praneetloke@users.noreply.github.com>
* Add ids to headers so they can be linked to
* Make header ids more general
Rather than including the identifier in the name of the id, use a simpler more generic id.
* H3=>H2 for Modules/Resources/Functions/Package Details headings
This way, on individual resource/function pages, it doesn't make it look like "Package Details" is a sub heading under "Supporting Types" in the right-hand "ON THIS PAGE".
* Add auto-generated disclaimer for the resource.tmpl as well.
* Allow specifying the languages to show in the lang chooser. Hide the go language for k8s overlay resources.
* Add another exclusion for generating the C# constructor param for k8s overlay resources.
* Replace hard-coded exclusions for skipping input properties with checking for ConstValue attribute of input properties.
- Define `null` in Pulumi HCL2
- Bind Pulumi HCL2 in topological order s.t. variable types can be
properly computed
- Fix resources that range over bools and numbers
- Add element, length, lookup, readFile, and split functions
- Do not rewrite function signatures with input types during binding
- Fix splat expression binding for non-lists
- Add support for evaluating expressions
- Add support for operator precedence to code generators
- Add support for constants to the HCL2 IR
- Add support for generating ranged resources in Python
- Add support for generating conditional resource in Node and Python
- Fix various naming issues in Python
After importing some resources, and running a second update with the
import still applied, an unexpected replace would occur. This wouldn't
happen for the vast majority of resources, but for some it would.
It turns out that the resources that trigger this are ones that use a
different format of identifier for the import input than they do for the
ID property.
Before this change, we would trigger an import-replacement when an
existing resource's ID property didn't match the import property, which
would be the case for the small set of resources where the input
identifier is different than the ID property.
To avoid this, we now store the `importID` in the statefile, and
compare that to the import property instead of comparing the ID.
* Add a method to the DocLanguageHelper interface to get the API doc link for Pulumi types.
* Add a test for Go API doc link methods.
* Use GetDocLinkForPulumiType in gen_function as well.
* Make `async:true` the default for `invoke` calls (#3750)
* Switch away from native grpc impl. (#3728)
* Remove usage of the 'deasync' library from @pulumi/pulumi. (#3752)
* Only retry as long as we get unavailable back. Anything else continues. (#3769)
* Handle all errors for now. (#3781)
* Do not assume --yes was present when using pulumi in non-interactive mode (#3793)
* Upgrade all paths for sdk and pkg to v2
* Backport C# invoke classes and other recent gen changes (#4288)
Adjust C# generation
* Replace IDeployment with a sealed class (#4318)
Replace IDeployment with a sealed class
* .NET: default to args subtype rather than Args.Empty (#4320)
* Adding system namespace for Dotnet code gen
This is required for using Obsolute attributes for deprecations
```
Iam/InstanceProfile.cs(142,10): error CS0246: The type or namespace name 'ObsoleteAttribute' could not be found (are you missing a using directive or an assembly reference?) [/Users/stack72/code/go/src/github.com/pulumi/pulumi-aws/sdk/dotnet/Pulumi.Aws.csproj]
Iam/InstanceProfile.cs(142,10): error CS0246: The type or namespace name 'Obsolete' could not be found (are you missing a using directive or an assembly reference?) [/Users/stack72/code/go/src/github.com/pulumi/pulumi-aws/sdk/dotnet/Pulumi.Aws.csproj]
```
* Fix the nullability of config type properties in C# codegen (#4379)
- Parentheses were not handled properly
- Literals inside of template control sequences were not handled
properly
These changes also improve test coverage for the printers.
* Fix k8s input type links for constructor args.
* Skip using property case maps for k8s Python.
* Fix the namespace of C# constructor args type and resource type.
This is required for using Obsolute attributes for deprecations
```
Iam/InstanceProfile.cs(142,10): error CS0246: The type or namespace name 'ObsoleteAttribute' could not be found (are you missing a using directive or an assembly reference?) [/Users/stack72/code/go/src/github.com/pulumi/pulumi-aws/sdk/dotnet/Pulumi.Aws.csproj]
Iam/InstanceProfile.cs(142,10): error CS0246: The type or namespace name 'Obsolete' could not be found (are you missing a using directive or an assembly reference?) [/Users/stack72/code/go/src/github.com/pulumi/pulumi-aws/sdk/dotnet/Pulumi.Aws.csproj]
```
* Use the correct module names for languages.
* Add Kubernetes to the title lookup map.
* Add output properties to the map only if filtered output properties is non-zero length.
* Add a check for the Python code gen to prevent infinte recursion. Remove the custom logic for k8s for generating Python property case maps.
* Fix bug with C# links for k8s constructor resources.
* Apply a style on the deprecation message.
* Use the display name when rendering a property type that does not have a link.
* Fix the python type string generator for docs to inspect union types.
* Update cleanTypeString to account for nodejs package names.
* Add missing lookup names for packages.
Pulumi HCL2 IR:
- Add support for invokes
- Add support for resource options, incl. ranged resources
- Allow the apply rewriter to ignore promise-typed values
- Add tests for the binder
- Add support functions for TF: entries and range
NodeJS codegen:
- Simplify for expression codegen
- Add support for invoke codegen
- Add support for entries and range functions
- Add tests
Python codegen:
- Implement codegen for most expression types
- Add support for invoke codegen
- Add tests
* Add new templates for generating index files. Remove the now irrelevant code.
* Add comment for generating index files by deduping module names. Use the path format of a module name as the link.
* Add a trailing slash for module links in the index page.
* Move the categories rendered in the index file into their own template file. Handle kubernetes provider specific module name conversion while generating parent modules.
* Fix issue with the k8s provider resource being generated as a module rather than a resource on the package-level index page.
* Show the deprecation message of a resource at the top of the document.
* Move k8s specific things to its own file.
* Add title attribute to the list items. Show the last part of a module name, in case it contains path separators
* Lookup the package name from the Go language info object for k8s then use that to lookup the C# namespace.
* Move the logic for cleaning a property type string for display names to a separate function.
* Export the title function from go and dotnet code generators for use in the resource doc generator. Use the title function from the respective lang code gens to match the correct title case used there. Fix issue with the Kubernetes namespace not being stripped for C# property type strings.
* Skip including apiVersion and kind as input properties for Kubernetes until pulumi-kubernetes#1062 is merged.
* Fix an issue with stripping the module name from type doc links in nodejs.
* Remove unused code that visited object types. Update the nested types code to account for types that may reference themselves. Added glog logging statements. Save the package-level language info objects, so we can use them later.
* Check if a type token has already been added as an input or an output type when collecting nested types.
* Rename appearsIn to typeUsage.
* Scan provider resource also using the special-case function if package is k8s.
* Simplify the display names for Pulumi types by removing the Pulumi prefix.
- config variables are now specified as `config <name> <type>`
- output variables are now specified as `output <name> <type>`
- apply arguments are assigned better names by the apply rewriters
These changes add preliminary (read: incomplete) support for
representing Pulumi programs using HCL2. Language-specific code
generators can use this representation as a basis for understanding the
semantics of a Pulumi program.
Some properties have constant values, such as the
apiVersion and kind for the Kubernetes provider. Add
a Const field to the Property schema to support this.
Instead of always running `npm install`, if the Policy Pack is Python, emit instructions on how to install dependencies. Also minor cleanup/refactoring.
This was still in pkg and wasn't accessible from the scripts location.
This code should be in the go/common location of sdk so that it can be
accessed from within our build scripts
Without this change, we were not able to get access to the Version number
for Python and none of our Python builds have been publishing binaries
* Decode the C# language info from the schema package and set it in the dotnet lang helper for docs. Pass the qualifier for C# property type strings based on whether it is an input or an output property.
* Don't pass a module name for Pulumi core types used in TS constructor and Function params.
* Add tests for generating doc links for nodejs types.
* Add test for confirming input doc link for C# type.
* Fix the C# type name for InvokeOptions.
The initial config represents any config that was specified programmatically to the Policy Pack, for Policy Packs that support programmatic configuration like AWSGuard.
* Add tests for the examples processing.
* Update the schema-based code generators to strip out non-relevant code examples wrapped in short-codes.
* Extract language relevant examples for Functions too.
* Simpler way of extracting the surrounding text from the description.
* Add some more new-line characters to clean-up the examples sections.
* Update the C# invoke signature in the Functions template used by resource docs generator.
* Add a new function to the DocLanguageHelper interface for resource docs generator to generate language-specific property names.
* Add a new DisplayName property to the propertyType struct for simpler display names without module names.
* Update templates to use the DisplayName property of propertyType. Strip the namespace/module name from type names for use as display names.
* Generate Go package maps at the beginning, so that the resource docs can use the appropriate package context for generating a property type string name.
* Temporarily block the resource docs from search indexing.
* Use PascalCase for nested type names in Python.
* Fix bug with Python property name casing for nested types by checking the property case maps.
* Fix rename stack message when attempting to move organizations
* Include the URL to change stack ownership
Co-authored-by: Lee-Ming Zen <lee@pulumi.com>
Rather than shelling out to the `rm` and `cp` commands,
use Go's os utils to perform these operations. This will
work on any platform rather than just Linux.
This package contains a driver for generating source code from HCL2
expressions. The driver is based on the fmt package's support for custom
formatters.
These changes implement `GetRequiredPlugins` for Go using a registry
mechanism and an alternate entry point for `pulumi.Run`. Packages that
require plugins are expected to register themselves with the Pulumi SDK.
When `pulumi.Run` is used and the `PULUMI_PLUGINS` envvar is truthy, the
program will dump a JSON-encoded description of its required plugins to
stdout. The language host then uses this description to respond to
These changes add a package for type checking and modeling HCL2
configurations. It is made up of three primary components:
1. A static type system
2. A semantic representation of HCL2 expressions and a binder from HCL2
native syntax to this representation
3. A semantic representation of HCL2 structural elements and binders
from HCL2 native syntax to this representation.
The type system is described in the "Extended Types" section of the
specification. The semantic representations of expressions and
structural elements are documented in their implementations.