Commit graph

141 commits

Author SHA1 Message Date
Mikhail Shilkov
1378c45849 Discriminated unions in schema and programgen 2021-05-05 10:01:22 +02: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
James Nugent
3e3e4f2deb
Permit Go program gen to work with modules at v1 (#6855)
This commit adjusts the way that Go module versions are discovered from
packages when generating Go programs, to account for those on module
version 1. Previously, this function would panic when dereferencing a
nil instance of semver.Version.
2021-04-26 19:19:43 -07:00
Pat Gavlin
1cc084dc0e
Fix inconsistent object type naming. (#6686)
See #6200 for a complete description of the issue. In short, we generate
inconsistent names for object types depending on whether or not they are
transitively reachable from resources or functions, which risks
unintentional breaking changes due to schema updates.

1. Name "input" types differently: `TArgs` for a type that is used in
   resource inputs, having `Input<T>` properties, and `T` for a type
   that is used in invoke inputs. The same schema type can produce both.

2. Always keep the name `T` for output types, avoid appending `Result` to
   the name.

3. As needed, introduce a flag in the existing providers' schemas to avoid
   breaking changes. Consider removing it on a major version bump.

Fixes #6200.
2021-04-15 19:03:28 -07:00
Paul Stack
e955a6b06a Refactor Mock newResource and call to accept property bag rather than individual args (#6672) 2021-04-14 19:32:18 +01: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
6566b9058e Fix base import path handling in go programgen 2021-01-20 16:04:33 -08: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
3aa566d286 Fix tests 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
81b6a1b83d Linting 2021-01-11 09:58:32 -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
Komal
cae129c7fa
[codegen/*] - Align makeValidIdentifier between languages (#5944) 2020-12-15 12:41:27 -08:00
Komal
791ccc58d4
[codegen/docs] - Remove primitive type links (#5911) 2020-12-14 19:56:45 -08:00
Komal
95c09d88c8
[codegen/docs] - Add enums to docs (#5912) 2020-12-14 14:40:14 -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
169fb47154 Consolidate tests 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