Commit graph

86 commits

Author SHA1 Message Date
Mike Metral
672feff428
Fix Go init.go codegen to be govet compliant (#7195)
Co-authored-by: Mike Metral <mmetral@apple.com>
2021-06-04 13:57:04 +03:00
Justin Van Patten
ed9124972c
[codegen/go] Fix emitted type of resources and types (#7158)
In Go, resource types are modeled as pointers, but there were cases where the type was not being emitted as a pointer, leading to panics and marshaling errors in programs. Additionally, array and map values that are external references were being emitted as pointers, but only resources should be pointers (not types), regardless of whether the resource type is external or local.
2021-05-27 16:02:19 -07:00
Levi Blackstone
aeb6857f7f
[codegen] Encrypt input args for secret properties (#7128)
The output side was already handled using the
addionalSecretOutputs property. This change
ensures both inputs and outputs are encrypted
in the state.
2021-05-26 16:00:51 -06:00
James Nugent
93d7057f80
[codegen/go] Respect baseImportPath in Go SDKs (#6866)
If `rootPackageName` is set, we can look for the version in the
baseImportPath rather than at a location based on the package name -
which currently fails if every component is not named `pulumi-*`. To err
on the side of caution, this method is only used for packages where
`rootPackageName` is set, meaning existing SDKs retain their current
behavior.

The new behavior is confirmed via the test added in #6862.
2021-04-29 17:09:05 -06:00
James Nugent
f73ec2fc71
[codegen/go] Permit production of flat Go packages (#6862)
When working in a monorepo environment, it can be desirable to generate
Go SDKs into a structure less like the upstream SDKs, and more like
this:

github.com/x/mymonorepo/sdk/go/package-name

Where `package-name` is also the root of a Go module. Since
`package-name` is not a valid package name in Go, it's also desirable to
be able to choose a replacement name and reduce the amount of nesting.

This commit adds a new Go option to the schema, `rootPackageName`, which
can be used to modify the generated root package name (e.g. to
`mypackage` instead of `package-name`, and remove the additional layer
of nesting.

Test coverage is added to ensure that the correct file structure and
package names are generated.
2021-04-29 13:30:01 -06:00
pulumi-bot
73a66f48ea [breaking] Changing the version of go.mod in sdk / pkg to be v3 2021-04-14 19:32:18 +01:00
Justin Van Patten
a9f0aead13
[codegen/go] Fix Go resource registrations (#6641)
We've been emitting calls to `New<Resource>` for resource registrations
in Go, passing `nil` for args. However, some of those `New<Resource>`
functions actually check for `nil` args and return an error if the
resource has required arguments.

At first, I was looking for a way to check inside `New<Resource>` if
the `URN` option was specified and in that case not error on
`nil` args (like we do in other languages), but we don't provide a way
to access the resource option values outside the Go SDK), so I don't
think there is a way to do it this way for Go.

So instead, this change updates the registration code to call
`ctx.RegisterResource` directly instead of `New<Resource>`, where we can
pass a `nil` args.
2021-03-31 16:50:30 -06:00
Vivek Lakshmanan
78c48d5d31 Fix comment/example handling 2021-03-30 22:24:45 -07:00
Vivek Lakshmanan
fec7209d6b PR comments and some additional cleanup 2021-03-30 22:24:11 -07:00
Vivek Lakshmanan
3151d23f09 Fix to create inputs for nested collections types 2021-03-30 22:24:11 -07:00
Vivek Lakshmanan
05b196dc59 Avoid processing collections of primitives 2021-03-30 22:24:11 -07:00
Vivek Lakshmanan
8b5e196209 Cleanup 2021-03-30 22:24:11 -07:00
Vivek Lakshmanan
700a576b70 Support nested collection types 2021-03-30 22:24:11 -07:00
Justin Van Patten
572c74826c
Add schema & codegen support for plain properties (#6481)
This change adds schema and codegen support for plain properties which
are emitted typed as the plain type rather than wrapped as an `Input`.
Plain properties require a prompt value and do not accept a value that
is `Output`.
2021-03-10 07:08:08 -08:00
Vivek Lakshmanan
8d022e39e8 Fix tests 2021-02-25 22:26:54 -08:00
Vivek Lakshmanan
92571f8f12 Adding enum container types support for go codegen 2021-02-25 22:26:37 -08:00
Vivek Lakshmanan
7cba9df480 Handle arrays/maps of external refs as pointers 2021-01-29 10:12:17 -08:00
Vivek Lakshmanan
82020af298 Various fixes go codegen to fix SDK compilation problems 2021-01-26 23:16:42 -08:00
Vivek Lakshmanan
54582e7c68
Merge pull request #6179 from pulumi/vl/FixEnum
[codegen/go] Fix default value handling for enums
2021-01-22 19:28:01 -08:00
Vivek Lakshmanan
fd3bbca5aa Fix default value handling for enums 2021-01-22 17:30:44 -08:00
Levi Blackstone
f5dab03846
[codegen/go] Handle hyphenated package names 2021-01-22 15:42:11 -07:00
Vivek Lakshmanan
4da8a45eb2 Option to generate container types resources now specified in GoPackageInfo 2021-01-20 11:29:01 -08:00
Vivek Lakshmanan
38ac84038c Make resource container-type generation optional 2021-01-20 11:29:01 -08:00
Vivek Lakshmanan
3d6701732a PR comments 2021-01-20 11:29:01 -08:00
Vivek Lakshmanan
22896074f3 Expand testing to cover all generated files 2021-01-20 11:29:01 -08:00
Vivek Lakshmanan
842e4aa052 Support for external resource references and imports/aliases 2021-01-20 11:29:01 -08:00
Levi Blackstone
2dfec71a5c
[codegen/go] Register resource modules/packages (#6121) 2021-01-19 16:59:51 -07:00
Levi Blackstone
aec642e8c9
[codegen/go] Add utility function to get current package version (#6117)
This function uses reflection to determine the current package
path and then extracts the version from that path string.
2021-01-15 10:03:57 -07:00
Vivek Lakshmanan
6259bc0e8d Remove unnecessary local copy of stringSet 2021-01-12 14:28:50 -08:00
Vivek Lakshmanan
15f9fb395f Address review comments 2021-01-11 10:00:13 -08:00
Vivek Lakshmanan
b70c89eeec Allow optional strict enum types to be omitted
Fixes https://github.com/pulumi/pulumi/issues/6068
2021-01-11 09:58:32 -08:00
Komal
9b33dd84d5
[codegen/*] - Fix enum names that start with an underscore. (#5950) 2020-12-16 09:22:44 -08:00
Levi Blackstone
d3c75afce1
[codegen/go] Fix Input/Output methods for Go resources (#5916) 2020-12-11 11:49:08 -07:00
Vivek Lakshmanan
1cfbe5bdd5 Linting fixes 2020-11-18 10:57:01 -08:00
Vivek Lakshmanan
d1caee26d3 Update makeSafeEnum semantics to match other languages 2020-11-18 09:44:30 -08:00
Vivek Lakshmanan
da5c01f9ca Fix build/tests 2020-11-18 00:13:41 -08:00
Vivek Lakshmanan
6e466e4ec0 Apply suggestions from code review
Co-authored-by: Komal <komal@pulumi.com>

Address PR comments
2020-11-18 00:08:09 -08:00
Vivek Lakshmanan
c818098733 Address PR comment 2020-11-18 00:07:42 -08:00
Vivek Lakshmanan
65e027062d Add an underscore if enum values have underscores 2020-11-18 00:07:42 -08:00
Vivek Lakshmanan
41fff5dc08 Add type as prefix for enum values 2020-11-18 00:07:42 -08:00
Vivek Lakshmanan
3c2b7a8945 Add additional test to demonstrate strict/relaxed enum semantics 2020-11-18 00:07:42 -08:00
Vivek Lakshmanan
43e48950df Adding support for go enum generation 2020-11-18 00:07:42 -08:00
Mikhail Shilkov
66c5cdb7a1
Parse string arrays from env in Go first-class provider (#5744) 2020-11-13 10:59:41 +01:00
Levi Blackstone
64e5de1edc
[codegen/go] Add support for ResourceType and isComponent (#5497) 2020-11-09 11:55:53 -07:00
Mikhail Shilkov
da1f25928d
[codegen] Adjust Go/Python package naming for Azure NextGen (#5373) 2020-09-15 13:56:58 +02:00
Mikhail Shilkov
07a923e494 Revert Go input/output generation 2020-09-15 12:36:04 +02:00
Mikhail Shilkov
bbf403ba85
Do not generate unused input/output types in Go (#5345)
Do not generate unused input/output types in Go
2020-09-15 09:33:13 +02:00
Evan Boyle
0f98bac105
fix unchecked type assertion (#5194) 2020-08-19 13:58:13 -07:00
Pat Gavlin
a19843f433
[codegen/{go,nodejs,python}] Normalize modules. (#5006)
In general, a package/module name in these targets is derived from the
module portion of a type token. If the type token is not already in an
expected form--namely, all lowercase--the generated package/module names
will also be in unexpected forms. These changes normalize the module
names to lowercase s.t. the generated package/module names conform to
expectations.
2020-07-14 10:58:29 -07:00
Pat Gavlin
54c5a75e34 [codegen/{go,nodejs}] Minor fixes in SDK gen.
- NodeJS: fix get + constructor generation for types with required args
  and no state type.
- Go: fix type + import generation for properties in the root module.
2020-07-10 11:23:31 -07:00