Commit Graph

69 Commits

Author SHA1 Message Date
Zaid Ajaj 677477389c
[Go] Enable l2-resource-simple conformance test ()
This PR extends sdk-gen and program-gen to understand local provider SDK
references, enabling l2-resource-simple conformance test to run
successfully
2024-08-01 08:34:31 +00:00
Fraser Waters 3560333ae6
Clean up uses of .Error() ()
Combination of a few cleanups.

1. Don't call .Error() on errors that are being passed to "%s" format
functions. Format will call `Error()` itself.
2. Don't call assert.Error then assert.Equal/Contains, just use
assert.ErrorEqual/ErrorContains instead.
3. Use "%w" if appropriate, instead of "%v"/"%s".
2023-12-20 15:54:06 +00:00
Zaid Ajaj 1a8abbf8c8
[program-gen/go] Fix required config variables of type bool and number ()
# Description

While covering more parts of go codegen, I've seen that config variables
are broken 😓 specifically when requiring config variables using
`RequireFloat` it should be `RequireFloat64` and `RequireBoolean` should
be `RequireBool`.
Moreover, it seems that `RequireObject` doesn't work at all since the
function signature doesn't match the way it was generated (see )

C# has a similar issue with optional untyped objects as config
variables. For now have skipped compilation for those.

## Checklist

- [ ] I have run `make tidy` to update any new dependencies
- [ ] I have run `make lint` to verify my code passes the lint check
  - [ ] I have formatted my code using `gofumpt`

<!--- Please provide details if the checkbox below is to be left
unchecked. -->
- [x] I have added tests that prove my fix is effective or that my
feature works
<!--- 
User-facing changes require a CHANGELOG entry.
-->
- [x] I have run `make changelog` and committed the
`changelog/pending/<file>` documenting my change
<!--
If the change(s) in this PR is a modification of an existing call to the
Pulumi Cloud,
then the service should honor older versions of the CLI where this
change would not exist.
You must then bump the API version in
/pkg/backend/httpstate/client/api.go, as well as add
it to the service.
-->
- [ ] Yes, there are changes in this PR that warrants bumping the Pulumi
Cloud API version
<!-- @Pulumi employees: If yes, you must submit corresponding changes in
the service repo. -->
2023-12-20 13:16:37 +00:00
Zaid Ajaj 3d713b2d28
[go] Unit test for LanguageResources(...) ()
One of a bunch of small PRs for go codegen to exercise pieces of code
that have no coverage

## Checklist

- [ ] I have run `make tidy` to update any new dependencies
- [x] I have run `make lint` to verify my code passes the lint check
  - [x] I have formatted my code using `gofumpt`

<!--- Please provide details if the checkbox below is to be left
unchecked. -->
- [ ] I have added tests that prove my fix is effective or that my
feature works
<!--- 
User-facing changes require a CHANGELOG entry.
-->
- [ ] I have run `make changelog` and committed the
`changelog/pending/<file>` documenting my change
<!--
If the change(s) in this PR is a modification of an existing call to the
Pulumi Cloud,
then the service should honor older versions of the CLI where this
change would not exist.
You must then bump the API version in
/pkg/backend/httpstate/client/api.go, as well as add
it to the service.
-->
- [ ] Yes, there are changes in this PR that warrants bumping the Pulumi
Cloud API version
<!-- @Pulumi employees: If yes, you must submit corresponding changes in
the service repo. -->
2023-12-12 13:26:07 +00:00
Fraser Waters 16d9f4c167
Enable perfsprint linter ()
<!--- 
Thanks so much for your contribution! If this is your first time
contributing, please ensure that you have read the
[CONTRIBUTING](https://github.com/pulumi/pulumi/blob/master/CONTRIBUTING.md)
documentation.
-->

# Description

<!--- Please include a summary of the change and which issue is fixed.
Please also include relevant motivation and context. -->

Prompted by a comment in another review:
https://github.com/pulumi/pulumi/pull/14654#discussion_r1419995945

This lints that we don't use `fmt.Errorf` when `errors.New` will
suffice, it also covers a load of other cases where `Sprintf` is
sub-optimal.

Most of these edits were made by running `perfsprint --fix`.

## Checklist

- [x] I have run `make tidy` to update any new dependencies
- [x] I have run `make lint` to verify my code passes the lint check
  - [x] I have formatted my code using `gofumpt`

<!--- Please provide details if the checkbox below is to be left
unchecked. -->
- [ ] I have added tests that prove my fix is effective or that my
feature works
<!--- 
User-facing changes require a CHANGELOG entry.
-->
- [ ] I have run `make changelog` and committed the
`changelog/pending/<file>` documenting my change
<!--
If the change(s) in this PR is a modification of an existing call to the
Pulumi Cloud,
then the service should honor older versions of the CLI where this
change would not exist.
You must then bump the API version in
/pkg/backend/httpstate/client/api.go, as well as add
it to the service.
-->
- [ ] Yes, there are changes in this PR that warrants bumping the Pulumi
Cloud API version
<!-- @Pulumi employees: If yes, you must submit corresponding changes in
the service repo. -->
2023-12-12 12:19:42 +00:00
Zaid Ajaj 70ba80b7cc
[go/sdk-gen] Fixes plain and optional properties for generated types for Go SDKs using generics ()
# Description

While working on on  I tried to add a test schema for assets and
archives that generate a `generics-only` go SDK but the the output
didn't compile. At first I thought the issue was specific to asset and
archive types but actually it was a broader issue where the
function`pkg.genPlainType(InputObjectType)` would always reduce
`Input[T]` and `Optional[T]` to just `T` on each property of
`InputObjectType`.

It is probably fine to reduce `Input[T]` because we are generating a
plain type after all. However, reducing `Optional[T]` to `T` is
incorrect because the generic variant of go sdks are more strict about
optionality of types.

> It probably works in non-generic SDKs today because it relies on a
runtime cast


Example type `TypeWithAssets` from schema that has a plain and optional
property called `plainAsset`:

  Before it was the following and it didn't compile for generic go sdks
```go

type TypeWithAssets struct {
	PlainAsset   pulumi.AssetOrArchive `pulumi:"plainAsset"`
}

type TypeWithAssetsArgs struct {
	PlainAsset   pulumix.Input[*pulumi.AssetOrArchive] `pulumi:"plainAsset"`
}

func (o TypeWithAssetsOutput) PlainAsset() pulumix.Output[*pulumi.AssetOrArchive] {
	return pulumix.Apply[TypeWithAssets](o, func(v TypeWithAssets) pulumi.AssetOrArchive { return v.PlainAsset })
}
```
 Now it generates:
```go
type TypeWithAssets struct {
	PlainAsset   *pulumi.AssetOrArchive `pulumi:"plainAsset"`
}

type TypeWithAssetsArgs struct {
	PlainAsset   *pulumi.AssetOrArchive               `pulumi:"plainAsset"`
}

func (o TypeWithAssetsOutput) PlainAsset() pulumix.Output[*pulumi.AssetOrArchive] {
	return pulumix.Apply[TypeWithAssets](o, func(v TypeWithAssets) *pulumi.AssetOrArchive { return v.PlainAsset })
}
```
Which is correct and compiles

The behavior for current non-generic SDKs remains unchanged

## Checklist

- [ ] I have run `make tidy` to update any new dependencies
- [x] I have run `make lint` to verify my code passes the lint check
  - [x] I have formatted my code using `gofumpt`

<!--- Please provide details if the checkbox below is to be left
unchecked. -->
- [ ] I have added tests that prove my fix is effective or that my
feature works
<!--- 
User-facing changes require a CHANGELOG entry.
-->
- [ ] I have run `make changelog` and committed the
`changelog/pending/<file>` documenting my change
<!--
If the change(s) in this PR is a modification of an existing call to the
Pulumi Cloud,
then the service should honor older versions of the CLI where this
change would not exist.
You must then bump the API version in
/pkg/backend/httpstate/client/api.go, as well as add
it to the service.
-->
- [ ] Yes, there are changes in this PR that warrants bumping the Pulumi
Cloud API version
<!-- @Pulumi employees: If yes, you must submit corresponding changes in
the service repo. -->
2023-11-21 16:43:51 +00:00
Anton Tayanovskyy ba039c20f8
Support returning plain values from methods ()
Support returning plain values from methods.

Implements Node, Python and Go support.

Remaining:

- [x] test receiving unknowns
- [x] acceptance tests written and passing locally for Node, Python, Go
clients against a Go server
- [x] acceptance tests passing in CI
- [x] tickets filed for remaining languages
   - [x] https://github.com/pulumi/pulumi-yaml/issues/499
   - [x] https://github.com/pulumi/pulumi-java/issues/1193
   - [x] https://github.com/pulumi/pulumi-dotnet/issues/170 

Known limitations:

- this is technically a breaking change in case there is code out there
that already uses methods that return Plain: true

- struct-wrapping limitation: the provider for the component resource
needs to still wrap the plain-returning Method response with a 1-arg
struct; by convention the field is named "res", and this is how it
travels through the plumbing

- resources cannot return plain values yet

- the provider for the component resource cannot have unknown
configuration, if it does, the methods will not be called
- Per Luke https://github.com/pulumi/pulumi/issues/11520 this might not
be supported/realizable yet

<!--- 
Thanks so much for your contribution! If this is your first time
contributing, please ensure that you have read the
[CONTRIBUTING](https://github.com/pulumi/pulumi/blob/master/CONTRIBUTING.md)
documentation.
-->

# Description

<!--- Please include a summary of the change and which issue is fixed.
Please also include relevant motivation and context. -->

Fixes https://github.com/pulumi/pulumi/issues/12709

## Checklist

- [ ] I have run `make tidy` to update any new dependencies
- [ ] I have run `make lint` to verify my code passes the lint check
  - [ ] I have formatted my code using `gofumpt`

<!--- Please provide details if the checkbox below is to be left
unchecked. -->
- [ ] I have added tests that prove my fix is effective or that my
feature works
<!--- 
User-facing changes require a CHANGELOG entry.
-->
- [ ] I have run `make changelog` and committed the
`changelog/pending/<file>` documenting my change
<!--
If the change(s) in this PR is a modification of an existing call to the
Pulumi Cloud,
then the service should honor older versions of the CLI where this
change would not exist.
You must then bump the API version in
/pkg/backend/httpstate/client/api.go, as well as add
it to the service.
-->
- [ ] Yes, there are changes in this PR that warrants bumping the Pulumi
Cloud API version
<!-- @Pulumi employees: If yes, you must submit corresponding changes in
the service repo. -->
2023-11-18 06:02:06 +00:00
bors[bot] 0d1d57f1f9
Merge
13136: Add explicit package versioning to Go codegen r=guineveresaenger a=guineveresaenger

<!--- 
Thanks so much for your contribution! If this is your first time contributing, please ensure that you have read the [CONTRIBUTING](https://github.com/pulumi/pulumi/blob/master/CONTRIBUTING.md) documentation.
-->

# Description

This PR adds logic to explicitly set a Go SDK version as well as pluginDownloadURL in the SDK itself.
This will allow us to publish tags with explicit versions, ensure the engine references the correct plugin version, and will allow for the provider to use the correct version plugin much more reliably.

This PR adds a new `pulumiVersion` file and refactors the `pulumiUtilities` file to live alongside the new version file in an `internal` folder for utilities. This allows all resources in the provider to call on `internal.PkgVersion` without generating a mod-level utilities file alongside.

I have tested this against a flat structure SDK (pulumi-docker) and a modular SDK (pulumi-okta).
I have also edited the `schema.json` files in the unit tests to reflect the new utilities path.

The changes in the PR will allow us to:

1. Read a version into `pulumiVersion.go` during codegen
2. Commit and tag that commit as `sdk/v<Version>`
3. Have the exact same SDK that was built and tested be available on github
4. Clean up the CI step that explicitly tags the Go SDK.

Fixes 

## Checklist

- [ ] I have run `make tidy` to update any new dependencies
- [x] I have run `make lint` to verify my code passes the lint check
  - [x] I have formatted my code using `gofumpt`

<!--- Please provide details if the checkbox below is to be left unchecked. -->
- [x] I have added tests that prove my fix is effective or that my feature works
<!--- 
User-facing changes require a CHANGELOG entry.
-->
- [x] I have run `make changelog` and committed the `changelog/pending/<file>` documenting my change
<!--
If the change(s) in this PR is a modification of an existing call to the Pulumi Cloud,
then the service should honor older versions of the CLI where this change would not exist.
You must then bump the API version in /pkg/backend/httpstate/client/api.go, as well as add
it to the service.
-->
- [ ] Yes, there are changes in this PR that warrants bumping the Pulumi Cloud API version
  <!-- `@Pulumi` employees: If yes, you must submit corresponding changes in the service repo. -->


Co-authored-by: Guinevere Saenger <guinevere@pulumi.com>
2023-07-07 21:33:39 +00:00
Guinevere Saenger f52d5d3baa add inline commend for isUtil bool 2023-07-06 13:20:04 -07:00
Fraser Waters 571fadae3f Use slice.Prealloc instead of make([]T, 0, ...)
Fixes https://github.com/pulumi/pulumi/issues/12738

https://github.com/pulumi/pulumi/pull/11834 turned on the prealloc
linter and changed a load of slice uses from just `var x T[]` to `x :=
make([]T, 0, preallocSize)`. This was good for performance but it turns
out there are a number of places in the codebase that treat a `nil`
slice as semnatically different to an empty slice.

Trying to test that, or even reason that through for every callsite is
untractable, so this PR replaces all expressions of the form `make([]T,
0, size)` with a call to `slice.Prealloc[T](size)`. When size is 0 that
returns a nil array, rather than an empty array.
2023-06-29 11:27:50 +01:00
Guinevere Saenger 1690f91071 don't make every package internal 2023-06-16 09:18:13 -07:00
Guinevere Saenger 1829a17150 make lint 2023-06-15 19:22:26 -07:00
Anton Tayanovskyy 3f713ab2d1 LINT 2023-03-23 18:53:34 -04:00
Anton Tayanovskyy d681223a29 Fix emission of dup types breaking Go compilation when chunking >500 helper types 2023-03-23 18:16:19 -04:00
Abhinav Gupta 7aa5b77a0c
all: Reformat with gofumpt
Per team discussion, switching to gofumpt.

[gofumpt][1] is an alternative, stricter alternative to gofmt.
It addresses other stylistic concerns that gofmt doesn't yet cover.

  [1]: https://github.com/mvdan/gofumpt

See the full list of [Added rules][2], but it includes:

- Dropping empty lines around function bodies
- Dropping unnecessary variable grouping when there's only one variable
- Ensuring an empty line between multi-line functions
- simplification (`-s` in gofmt) is always enabled
- Ensuring multi-line function signatures end with
  `) {` on a separate line.

  [2]: https://github.com/mvdan/gofumpt#Added-rules

gofumpt is stricter, but there's no lock-in.
All gofumpt output is valid gofmt output,
so if we decide we don't like it, it's easy to switch back
without any code changes.

gofumpt support is built into the tooling we use for development
so this won't change development workflows.

- golangci-lint includes a gofumpt check (enabled in this PR)
- gopls, the LSP for Go, includes a gofumpt option
  (see [installation instrutions][3])

  [3]: https://github.com/mvdan/gofumpt#installation

This change was generated by running:

```bash
gofumpt -w $(rg --files -g '*.go' | rg -v testdata | rg -v compilation_error)
```

The following files were manually tweaked afterwards:

- pkg/cmd/pulumi/stack_change_secrets_provider.go:
  one of the lines overflowed and had comments in an inconvenient place
- pkg/cmd/pulumi/destroy.go:
  `var x T = y` where `T` wasn't necessary
- pkg/cmd/pulumi/policy_new.go:
  long line because of error message
- pkg/backend/snapshot_test.go:
  long line trying to assign three variables in the same assignment

I have included mention of gofumpt in the CONTRIBUTING.md.
2023-03-03 09:00:24 -08:00
Abhinav Gupta d8c8c74c5d
golangci-lint: Enable staticcheck
Remove staticcheck from the list of disabled linters.
It's enabled by default in golangci-lint.

This also fixes minor remaining staticcheck issues
that don't merit their own pull requests,
or opts out of those that cannot be fixed yet.

Notably, we're opting out of:

- Resource.Name is deprecated ()
- github.com/golang/protobuf is deprecated ()
- strings.Title has been deprecated ()

Besides that, other issues addressed in this change are:

```
// all issues are in pkg
codegen/schema/docs_parser.go:103:4: SA4006: this value of `text` is never used (staticcheck)
codegen/schema/loader.go:253:3: SA9003: empty branch (staticcheck)
resource/deploy/step_executor.go:328:12: SA9003: empty branch (staticcheck)
resource/deploy/step_generator.go:141:10: SA9003: empty branch (staticcheck)
codegen/pcl/invoke.go:97:10: SA9003: empty branch (staticcheck)
codegen/hcl2/model/type_const.go:57:2: SA9003: empty branch (staticcheck)
codegen/hcl2/model/type_enum.go:99:9: SA4001: &*x will be simplified to x. It will not copy x. (staticcheck)
codegen/go/gen_test.go:399:19: SA4017: HasPrefix is a pure function but its return value is ignored (staticcheck)
```

Depends on , , , , , , , , 

Resolves 
2023-01-14 16:59:46 -08:00
Abhinav Gupta cc7098e4a2
codgen/go/test: Replace ineffective sort
`sort.StringSlice` is a type wrapper, not a function.

    type StringSlice []string

So `ordering = sort.StringSlice(ordering)` has no effect.

This replaces that with use of `sort.Strings`,
whic has the desired effect of sorting the slice in place.

Also drops the unnecesary index tracking to append into the slice
in favor of appends.

Issue caught by staticcheck:

```
codegen/go/gen_test.go:220:4: SA4029: sort.StringSlice is a type, not a function, and sort.StringSlice(ordering) doesn't sort your values; consider using sort.Strings instead (staticcheck)
```

Refs 
2023-01-13 10:29:23 -08:00
Abhinav Gupta e845ddf4c4
gosimple: Simplify loops
This replaces for loops and slice appends reported by gosimple
with simpler variants.

Specifically,

    for _, x := range src {
        dst = append(dst, x)
    }
    // can be replaced with
    dst = append(dst, src...)

And,

    for i, x := range src {
        dst[i] = x
    }
    // can be replaced with
    copy(dst, src)

And,

    for true { ... }
    // can be replaced with
    for { ... }

And, given a string `s`,

    for _, r := range []rune(s) { .. }
    // can be replaced with
    for _, r := range s { .. }

Lastly, this fixes in ineffective break statement
also reported by the linter.
Inside a switch block,
`break` affects the current `case` only.
The outer loop needs a label.
2023-01-12 09:55:34 -08:00
Abhinav Gupta 1158d4acee
all: Drop ioutil
Stop using io/ioutil across the entire repository.
The io/ioutil package was deprecated in Go 1.16 (2021-02)
with replacements provided in other packages.
Specifically:

    ioutil.Discard   => io.Discard
    ioutil.NopCloser => io.NopCloser
    ioutil.ReadAll   => io.ReadAll
    ioutil.ReadFile  => os.ReadFile
    ioutil.TempDir   => os.MkdirTemp
    ioutil.TempFile  => os.CreateTemp
    ioutil.WriteFile => os.WriteFile

This change switches all of these entities
across the repository.

Following this change,
the only references to ioutil are in schema files:

    % rg -l ioutil
    pkg/codegen/testing/test/testdata/aws-4.26.0.json
    pkg/codegen/testing/test/testdata/aws-4.36.0.json
    pkg/codegen/testing/test/testdata/aws-4.37.1.json
    pkg/codegen/testing/test/testdata/aws-5.4.0.json
    pkg/codegen/testing/test/testdata/aws-5.16.2.json

The bulk of this change was generated automatically
with manual touch ups afterwards.
2023-01-06 16:35:14 -08:00
Ian Wahbe 7ae9c181d0 Don't use *schema.Package in go codegen 2022-12-08 17:51:50 +01:00
Ian Wahbe cf8e8f1daf Revert "Revert "Go and Python codegen support symbols with hyphens in their names""
This reverts commit aaf547e6eb.
2022-10-17 09:37:07 -07:00
Ian Wahbe aaf547e6eb Revert "Go and Python codegen support symbols with hyphens in their names" 2022-10-14 17:07:46 -07:00
Matthew Olenik 627562a65e Fix tests 2022-10-10 12:26:21 -07:00
Matthew Olenik 5c8436656e Go and Python codegen support symbols with hyphens in their names
Previously codegen would output hyphens into the names of symbols such
as functions, variable names, etc. This fix converts hyphens to
underscores, making them valid code in Go and Python.
2022-10-10 12:25:49 -07:00
Aaron Friel bc6446815a ci: Remove -compat=1.18 flags to validate that tests pass on current and minimum supported Go versions 2022-09-27 10:41:25 -07:00
Aaron Friel 7e555cb6ab ci: Simplify test listing, update go dependencies to 1.18 compat 2022-09-21 09:51:59 -07:00
Ian Wahbe 94422f97f8
Expose external package cache + global default (Take 2) ()
* Expose external package cache

* CL

* Add a default global cache

* More cache passing

* Compare `Cache` entries by pointer equality

* Add a check for providers when doing imports

* Pass the cache

Co-authored-by: Aaron Friel <mayreply@aaronfriel.com>
2022-08-12 20:04:21 +02:00
Aaron Friel cca0a39e70
Revert "Expose external package cache ()" ()
This reverts commit 16c173963a.
2022-08-11 15:04:14 -07:00
Ian Wahbe 16c173963a
Expose external package cache ()
* Expose external package cache

* CL

* Add a default global cache

* More cache passing

Co-authored-by: Aaron Friel <mayreply@aaronfriel.com>
2022-08-11 13:28:27 -07:00
Ian Wahbe 68267e1823
Idiomatic Go: generated code message ()
* Idiomatic autogenerated message for go SDK

By convention, as outlined in
https://pkg.go.dev/cmd/go#hdr-Generate_Go_files_by_processing_source,
autogenerated go source code includes a regexp that matches
`^// Code generated .* DO NOT EDIT\.$`. I have changed our go
autogenerated message to comply and added a test on our generated
header.

* Update test results

* Mark test as parallel

* Fix nit
2022-04-19 18:39:23 +02:00
Aaron Friel ed2923653c ci: radical idea - what if slow tests & no stdout makes GH consider runner dead? 2022-03-06 14:52:13 -08:00
Ian Wahbe a1e18dae4d
export codegen tests for internal use ()
* Export Codegen test modules

* Document pkg stability guarantee

* Expose programgen

* Recommendation: Improve wording

* Move `internal` to `testing`

* Re-rout references to codegen/internal

* Fix some other "internal" references
2022-02-07 12:10:04 +01:00
Justin Van Patten 6c179e0747
[codegen/go] Honor import aliases for external types/resources ()
This change fixes the Go SDK codegen to honor package import aliases when referencing external types/resources. Local aliases are preferred, otherwise, if the external package has an import alias, it is used.

Co-authored-by: James Nugent <james@jen20.com>
Co-authored-by: Alex Suttmiller <asuttmiller@gmail.com>
2022-02-03 07:43:05 -08:00
Ian Wahbe 28528ba26b
Fix default package name ()
* Fix default pacakge name

* Update changelog

* Generalize naming functions
2021-10-11 15:28:11 -07:00
Ian Wahbe e1f0976667
Use importBasePath before name if specified ()
* Use importBasePath before name if specified

This is a go specific code change. We should clarify in the docs how
`name`, `importBasePath` and `rootPackageName` interact.

* Update CHANGELOG_PENDING.md

* Test package naming

* Explain test and remove debugging print

* Comply with linter
2021-10-07 11:56:44 -07:00
Anton Tayanovskyy 49ccd9ac97
Simplify output-funcs codegen test ()
* Consolidate output-funcs into a single normal schema.json

* Accept nodejs codegen output

* Accept dotnet output-funcs output; does not compile yet

* Accept docs output-funcs output

* Permit parallel test runs

* Accept nodejs codegen

* Fix and speed up Python codegen tests

* Dedup dash-named-schema

* Make dotnet tests pass

* Satisfy go lint
2021-09-23 13:42:20 -04:00
Anton Tayanovskyy 49298fb433
Codegen testing upgrades ()
* Multi-pass, in-place checks for SDK codegen tests; toward working Python checks

* Remove temp debug output

* Upgrade Node

* Update dotnet; need to follow up on version.txt quirks

* WIP

* Sounds like we can use non-github package names to ensure things are local

* Fix simple-enum-schema

* Fix dash-named-schema

* Fix nested-module

* Start building a test-running pass

* Infer skipping tests from skipping compiles

* Move tree schma tests to a proper place

* Address lint issues on Go code

* Build against local Go SDK

* Update pkg/codegen/internal/test/sdk_driver.go

Co-authored-by: Ian Wahbe <ian@wahbe.com>

* Make go tests work by copying them into the tree from go-extras

* Fix lint

* Fix bad merge

* Manifest-based file discovery

* Remove version-related TODO from dotnet codegen

* Add doc comment

* Do not overwrite go.mod if found from mixins

* Accept python codegen change

* Accept node codegen

* Ignore lint issue

* Accept docs changes

Co-authored-by: Ian Wahbe <ian@wahbe.com>
2021-09-22 13:55:20 -04:00
Ian Wahbe 67303e1b99
Run type checker against all languages ()
We run the best static check we can on generated code, ensuring that it is valid. 

* Run type checker against all languages (not docs)

* Fix package location, add some deps for schemas

* More tests passing

* These tests finally work

* Make linter happy

* Fix tests for merge from master

* Opt out of input-collision(nodejs) test

* Get more visibility into testing nodejs

* Fix type assumption

* Specify ts-node version

* Retrofit typescript dependencies for node14

* Give each go instance it's own module

* Attempt to diagnose remote go mod init failure

* Provide root for go mod init

* Make linter happy
2021-09-15 09:49:36 -07:00
Anton Tayanovskyy eef208633c
5758 for Go ()
* Go support for 5758 - resurrect stale PR

* Fix listStorageAccountKeys test

* Check err so linter is satisfied

* Use all the examples

* Accept codegen results

* Regenerate with PULUMI_IGNORE_AMBIENT_PLUGINS=1

* Compile and test generated code as part of the test suite

* Add a CHANGELOG entry

* Remove temp test marker

* Shorten output type name

* Simplify code

* Add issue link

* Accept more codegen changes

* Use the suggested format for linking an issue
2021-08-23 16:46:09 -04:00
Komal 0e3665f9bd
Emit To[ElementType]PtrOutput methods for go enum output types () 2021-07-13 12:54:19 -07:00
Pat Gavlin d07b325138
[codegen] Add type name generation tests. ()
The inputs and expected outputs for the tests are encoded using a
schema. Each property present in the schema forms a testcase; the
expected outputs for each language are stored in each property's
`Language` field with the language name "test". Expected outputs can be
regenerated using `PULUMI_ACCEPT`.
2021-07-09 10:23:10 -07:00
Komal 8db30bdc14
[codegen/go] - Inputty Go enums () 2021-07-07 16:25:26 -07:00
Pat Gavlin 46400d502b
[codegen] Unify SDK codegen testing ()
Rather than duplicating the list of tests and codegen driver across each
SDK, move its definition into `pkg/codegen/internal/test`. This has a
few notable benefits:

- All SDK code generators will be tested against each test. Though some
  tests may exercise a particular code generator more than others, the
  extra coverage will be generally beneficial.
- Adding a new test is simpler, as only a single file needs to be
  changed.
- All SDKs now honor the `PULUMI_ACCEPT` environment variable for
  updating baselines.
- Codegen tests now validate all generated files instead of only a
  particular subset.
2021-07-06 15:40:53 -07:00
Pat Gavlin 7b1d6ec1ac
Reify `Input` and `Optional` types in the schema type system. ()
These changes support arbitrary combinations of input + plain types
within a schema. Handling plain types at the property level was not
sufficient to support such combinations. Reifying these types
required updating quite a bit of code. This is likely to have caused
some temporary complications, but should eventually lead to
substantial simplification in the SDK and program code generators.

With the new design, input and optional types are explicit in the schema
type system. Optionals will only appear at the outermost level of a type
(i.e. Input<Optional<>>, Array<Optional<>>, etc. will not occur). In
addition to explicit input types, each object type now has a "plain"
shape and an "input" shape. The former uses only plain types; the latter
uses input shapes wherever a plain type is not specified. Plain types
are indicated in the schema by setting the "plain" property of a type spec
to true.
2021-06-24 09:17:55 -07:00
Justin Van Patten ed9124972c
[codegen/go] Fix emitted type of resources and types ()
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
James Nugent f73ec2fc71
[codegen/go] Permit production of flat Go packages ()
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
Paul Stack e955a6b06a Refactor Mock newResource and call to accept property bag rather than individual args () 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
Vivek Lakshmanan 78c48d5d31 Fix comment/example handling 2021-03-30 22:24:45 -07:00
Vivek Lakshmanan 3151d23f09 Fix to create inputs for nested collections types 2021-03-30 22:24:11 -07:00