Commit Graph

106 Commits

Author SHA1 Message Date
Fraser Waters e554b2623b
Finish supporting dotnet conformance ()
Last few changes needed to get the dotnet repo passing conformance
tests.
2024-04-22 06:37:50 +00:00
Fraser Waters 892aec25b6
Fixes to pass dotnet conformance ()
<!--- 
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. -->

This isn't quite enough for dotnet conformance to pass on everything
yet, but it's a start and gets the L1 programs passing.


## 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
  - [ ] 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. -->
2024-04-19 10:21:09 +00:00
Zaid Ajaj 4a012def4b
[sdk-gen, dotnet/go] Fixes SDK-generation when referencing shared types in config variables ()
# Description


Fixes  
- In .NET, non-primitive types such as objects used in config variables
will be generated anyways under the `Types` namespace as plain-shaped
objects inside of the `Config` class. This is because the types from
`Outputs` or `Inputs` cannot be used directly from config. Also no
longer marking objects used from config variables as "outputs" (doesn't
make any sense)

- In Go, disable adding imports into the `config.go` based on used
shared types because these are not used/referenced in the config module
anywhere anyways.

## 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. -->
- [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. -->
2024-03-28 17:14:47 +00:00
Eron Wright 8c7a9e5d3f
Support for non-overlay components in codegen for pulumi-kubernetes provider ()
<!--- 
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 enhances the codegen for dotnet to allow the pulumi-kubernetes
provider to have non-overlay components. Previously all components were
overlays and didn't require codegen.

The specific change is to not apply the `KubernetesResource` base class
when the resource is a component. It is inappropriate to use
`KubernetesResource` in this case because it extends `CustomResource`
not `ComponentResource`.

The sdkgen test suite for `kubernetes20` mode was updated with a new
example resource:
- a non-overlay component resource
([code](https://github.com/pulumi/pulumi/pull/15490/files#diff-31beec99a7baef687bd1024481d8c6e1d13b1c7f4494b417cc044fe71ad0f8cd))

The fix is manifested
[here](https://github.com/pulumi/pulumi/pull/15490/files#diff-79ca901e45591fc7db0c022cf914e99eccc0e35b2d3b1e8ee2ce45ad82faaf29R16).
## 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. -->
- [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. -->
2024-03-04 19:37:54 +00:00
Eron Wright 1c4393b30f
[dotnet] codegen fix for resources without constant input properties ()
<!--- 
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. -->

This PR fixes a bug in the dotnet codegen where the wrong "args" class
name would be used, in the case that the resource has no constant
inputs. This is an edge case because most resources do have at least one
such input.

For example, a new resource definition in p/k produced this output:
```csharp
namespace Pulumi.Kubernetes.Yaml.V2
{
        public ConfigGroup(string name, Pulumi.Kubernetes.Types.Inputs.Yaml.V2.ConfigGroupArgs? args = null, CustomResourceOptions? options = null)
            : base("kubernetes:yaml/v2:ConfigGroup", name, args ?? new ConfigGroupArgs(), MakeResourceOptions(options, ""), remote: true)
        {
        }
}
```
Which doesn't compile because `ConfigGroupArgs` is in a separate
namespace.

Should be:
```csharp
        public ConfigGroup(string name, Pulumi.Kubernetes.Types.Inputs.Yaml.V2.ConfigGroupArgs? args = null, CustomResourceOptions? options = null)
            : base("kubernetes:yaml/v2:ConfigGroup", name, args ?? new Pulumi.Kubernetes.Types.Inputs.Yaml.V2.ConfigGroupArgs(), MakeResourceOptions(options, ""), remote: true)
        {
        }
```

[Here's
](https://github.com/pulumi/pulumi/pull/15488/files#diff-18b12fabab20d68398aced2890b1ca3073cc32081bb62a022b77a5090c209e3bR45)where
the fix manifests itself in the new test case.

## Testing

A new SDK test case was added to cover the whole `kubernetes20`
compatibility mode, based on a simplified schema from the
pulumi-kubernetes provider.

The schema contains a representative set of resources:
1. `kubernetes:core/v1:ConfigMap` - a non-overlay resource representing
a Kubernetes kind.
2. `kubernetes:core/v1:ConfigMapList` - a Kubernetes list kind
3. `kubernetes:helm.sh/v3:Release` - a non-overlay, non-Kubernetes
resource
4. `kubernetes:yaml:ConfigGroup` - an overlay component resource

An important detail is whether a resource has any input properties that
have a constant value, such as we see with `kind` and `apiVersion`. The
`Release` resource intentionally has no such constant inputs.

## 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. -->
- [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. -->
2024-03-02 06:01:31 +00:00
Thomas Gummerer baecc85eaf
turn on the golangci-lint exhaustive linter ()
Turn on the golangci-lint exhaustive linter.  This is the first step
towards catching more missing cases during development rather than
in tests, or in production.

This might be best reviewed commit-by-commit, as the first commit turns
on the linter with the `default-signifies-exhaustive: true` option set,
which requires a lot less changes in the current codebase.

I think it's probably worth doing the second commit as well, as that
will get us the real benefits, even though we end up with a little bit
more churn. However it means all the `switch` statements are covered,
which isn't the case after the first commit, since we do have a lot of
`default` statements that just call `assert.Fail`.
 
Fixes  

## 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. -->
2024-01-17 16:50:41 +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
Thomas Meckel f83ee4a5fc
feat: Add support for language specific settings for resources ()
<!--- 
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 contains changes to support language specific settings for
resources. This PR is a prerequisite to resolve a corresponding
[bug](https://github.com/pulumi/pulumi-terraform-bridge/issues/1460) in
the Terraform Bridge.

<!--- 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-terraform-bridge/issues/1460

## 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. -->
- [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: Thomas Meckel <tmeckel@users.noreply.github.com>
2023-11-29 16:35:08 +00:00
Zaid Ajaj 78ccc7437d
[sdk-gen] No longer writing out name and project from alias definitions into generated SDKs ()
# Description

After adding a test schema for aliases in  @Frassle noticed it was
incorrect to write out the name and project of aliases into the SDKs.
This PR fixes this such that we now only write out the `type` of the
alias into generated code.

Supersedes 

## 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. -->
- [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-11-21 22:40:14 +00:00
Fraser Waters a227c57ea2
Fix nested modules in dotnet codegen ()
<!--- 
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/14296.

## 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. -->
- [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: Thomas Gummerer <t.gummerer@gmail.com>
2023-10-20 22:21:58 +00:00
Zaid Ajaj a1112c878e
[dotnet/sdk-gen] Fixes potential conflicts when generating resources called System ()
# Description

When generating a C# package that has a resource called `System`, it
fails to compile when we fully qualify
`System.Diagnostics.CodeAnalysis.SuppressMessage` in the generated
`Config.cs` file since it thinks that `System.Diagnostics` is referring
to a static class on the `System` resource definition.

The fix is to prefix the attribute with `global::` so that type
resolution works as expected.

## 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.
-->
- [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-09-22 13:41:15 +00:00
Zaid Ajaj 46277d5567 Generate output-versioned invokes for functions without inputs 2023-08-08 14:00:30 +02: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
Fraser Waters 1154d8c072 Write <Version> to .csproj when respectSchemaVersion is set
This is more in alignment with the other languages where when
respectSchemaVersion is set we write the version to the project file
(pacakge.json for NodeJS, setup.py for Python) so that no version
information has to be set on the build command itself.
2023-03-27 15:54:16 +01:00
Abhinav Gupta e395deef6b
all: Assert => Assertf
Migrates all remaining usages of
`contract.Assert*` and `contract.Require*` to the f variants,
which require adding meaningful error messages.

There were a couple cases where a `testing.T` or `testing.B`
was already available.
For those, this uses t.FailNow or require.NoError.

Refs 
2023-03-03 14:37:43 -08: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
bors[bot] 857e398e47
Merge
12333: Update dotnet codegen to net6.0 r=dixler a=Frassle

<!--- 
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. -->

netcore3.1 is out of support, we've just been waiting on ecosystem and providers to update build scripts to support this.

## Checklist

<!--- 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.
-->
- [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 Service,
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 Service API version
  <!-- `@Pulumi` employees: If yes, you must submit corresponding changes in the service repo. -->


Co-authored-by: Fraser Waters <fraser@pulumi.com>
2023-03-03 14:35:10 +00:00
Fraser Waters 677b1d5e60 Update dotnet codegen to net6.0 2023-03-02 16:35:38 +00:00
Abhinav Gupta cc32691bc1
chore(all): strings.Replace(..., -1) => strings.Replace(...)
Replaces all instances of `strings.Replace(s, old, new, -1)`
with the equivalent `strings.ReplaceAll(s, old, new)`.
This function has been available since Go 1.12.
2023-03-01 13:22:33 -08:00
Abhinav Gupta 8280296699
gosimple: printf, time.Since, TrimPrefix, etc.
Fix a bunch of other gosimple issues:

- `Printf` used for static string
- `Skip(Printf(..))` => `Skipf(..)`
- `time.Now().Sub(t)` => `time.Since(t)`
- `HasPrefix; TrimPrefix` => `TrimPrefix`
- Unnecessary type casts
- `IndexRune(..) != 1` => `ContainsRune`
- `if cond { return true } else { return false }` => `return cond`
2023-01-12 09:55:34 -08:00
Zaid Ajaj 330676a0d0 Initial implementation of simplified invokes for dotnet and nodejs 2023-01-11 14:17:14 -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
Abhinav Gupta 0bff0b8716 sdk/go: Remove 'nolint' directives from package docs
Go treats comments that match the following regex as directives.

    //[a-z0-9]+:[a-z0-9]

Comments that are directives don't show in an entity's documentation.
5a550b6951 (diff-f56160fd9fcea272966a8a1d692ad9f49206fdd8dbcbfe384865a98cd9bc2749R165)

Our code has `//nolint` directives that now show in the API Reference.
This is because these directives are in one of the following forms,
which don't get this special treatment.

    // nolint:foo
    //nolint: foo

This change fixes all such directives found by the regex:
`// nolint|//nolint: `.
See bottom of commit for command used for the fix.

Verification:
Here's the output of `go doc` on some entities
before and after this change.

Before
```
% go doc github.com/pulumi/pulumi/sdk/v3/go/pulumi | head -n8
package pulumi // import "github.com/pulumi/pulumi/sdk/v3/go/pulumi"

nolint: lll, interfacer

nolint: lll, interfacer

const EnvOrganization = "PULUMI_ORGANIZATION" ...
var ErrPlugins = errors.New("pulumi: plugins requested")
```

After
```
% go doc github.com/pulumi/pulumi/sdk/v3/go/pulumi | head -n8
package pulumi // import "github.com/pulumi/pulumi/sdk/v3/go/pulumi"

const EnvOrganization = "PULUMI_ORGANIZATION" ...
var ErrPlugins = errors.New("pulumi: plugins requested")
func BoolRef(v bool) *bool
func Float64Ref(v float64) *float64
func IntRef(v int) *int
func IsSecret(o Output) bool
```

Before
```
% go doc github.com/pulumi/pulumi/sdk/v3/go/pulumi URN_
package pulumi // import "github.com/pulumi/pulumi/sdk/v3/go/pulumi"

func URN_(o string) ResourceOption
    URN_ is an optional URN of a previously-registered resource of this type to
    read from the engine. nolint: revive
```

After:
```
% go doc github.com/pulumi/pulumi/sdk/v3/go/pulumi URN_
package pulumi // import "github.com/pulumi/pulumi/sdk/v3/go/pulumi"

func URN_(o string) ResourceOption
    URN_ is an optional URN of a previously-registered resource of this type to
    read from the engine.
```

Note that golangci-lint offers a 'nolintlint'  linter
that finds such miuses of nolint,
but it also finds other issues so I've deferred that to a follow up PR.

Resolves 

Related: https://github.com/golangci/golangci-lint/issues/892

[git-generate]
FILES=$(mktemp)
rg -l '// nolint|//nolint: ' |
  tee "$FILES" |
  xargs perl -p -i -e '
    s|// nolint|//nolint|g;
    s|//nolint: |//nolint:|g;
  '
rg '.go$' < "$FILES" | xargs gofmt -w -s
2023-01-06 09:06:47 -08:00
Aaron Friel a682a1ab06
Revert "Simplified invokes: SDK-gen and program-gen implementation for dotnet and nodejs" 2022-12-20 17:47:29 -08:00
Zaid Ajaj a6f26d2355 Initial implementation of simplified invokes for dotnet and nodejs 2022-12-16 13:39:03 +01:00
bors[bot] a5e7c3a5d6
Merge
11606: Remove .NET type imports and add a test for  r=iwahbe a=iwahbe

This is follow up for . It adjusts a SDK generation test to include the new feature. I also remove the resource import code for .NET, since it broke the test and we use absolute paths at this point.

Co-authored-by: Ian Wahbe <ian@wahbe.com>
2022-12-09 16:46:33 +00:00
bors[bot] c11a8ebb30
Merge
11596: [sdk/gen] Avoid generating Result types for functions with empty outputs r=Zaid-Ajaj a=Zaid-Ajaj

<!--- 
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. -->

Part of  where we shouldn't generate result types for function invokes that have no properties. 

This is a separate PR to showcase the exact changes required to improve the situation and reduce the diff from 

## Checklist

<!--- 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.
-->
- [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 Service,
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 Service API version
  <!-- `@Pulumi` employees: If yes, you must submit corresponding changes in the service repo. -->


Co-authored-by: Zaid Ajaj <zaid.naom@gmail.com>
2022-12-09 16:18:00 +00:00
Zaid Ajaj b0b4add2a6 Do not generate Result types for functions with empty outputs 2022-12-09 14:36:44 +01:00
Ian Wahbe 7467b16287 Remove .NET type imports and add a test for
Adjust CL for multiple languages.
2022-12-09 14:03:20 +01:00
Ian Wahbe 6ff61ae1ae Don't use `*schema.Package` in .NET codegen 2022-12-08 17:50:45 +01:00
Zaid Ajaj 9fde68ed13 [dotnet/sdk-gen] Do not reference Pulumi nuget if a project reference already exists 2022-11-14 15:10:00 +01:00
Ian Wahbe a43eaf35df Set minimum .NET build version to 3.23.0 2022-11-10 09:49:12 -08:00
bors[bot] e6e027edcc
Merge
11315: Add default dependencies for {.NET,nodejs} r=iwahbe a=iwahbe

Fixes 
Fixes 

Co-authored-by: Ian Wahbe <ian@wahbe.com>
2022-11-10 02:04:37 +00:00
Ian Wahbe 0ab75557b6 Add Pulumi as a default dependency for .NET 2022-11-09 14:05:50 -08:00
Ian Wahbe 7d5a38c9b1 Standardize the FS abstraction for codegen 2022-11-09 13:12:51 -08:00
Justin Van Patten 74906cb005 [codegen/dotnet] Fix array/map types for secret inputs
Fix the type emitted for `ImmutableArray.Create` and `ImmutableDictionary.Create` for secret properties.
2022-09-26 10:01:32 -07:00
Justin Van Patten 94fef806d2 [codegen/dotnet] Fix codegen for functions with secret parameters
The non-`Output<T>` returning functions take parameters as plain values, which cannot be made secrets. Before this change, .NET codegen was trying to convert the inputs into secrets, but this would error during compilation because the plain types are not `Input<T>`.
2022-09-23 13:47:15 -07:00
Zaid Ajaj fe94ca322d Make sure all references to Pulumi types now are suffixed with the global modifier 2022-09-15 01:19:32 +02:00
Zaid Ajaj 8a34e80267 Ensure that Pulumi.Config reference is coming from the main Pulumi namespace 2022-09-15 01:06:26 +02:00
Zaid Ajaj 9ab26c7703
[dotnet/codegen] Prefix referenced Pulumi types with global modifier ()
* Prefix referenced Pulumi types with global modifier

* Changelog entry
2022-07-27 11:24:21 +02:00
Zaid Ajaj b98194a33f
[dotnet/codegen] Override inherited Empty property from arg types ()
* Override inherited Empty property from arg types

* change log entry

* Merge branch 'master' into zaid/static-empty-resource-args
2022-07-27 11:23:34 +02:00
Ian Wahbe 183fa89163
Add an EnumType to the PCL model ()
* Add an EnumType to the PCL model

Languages implementation:
- [X] C#
- [X] Python
- [X] TypeScript
- [X] Go

* Fix assert

* Take namespace settings into account

* Implement enums for Go

* Update tests and add documentation.

* Add a test + handle output&unsafe

* Get outputs compiling for Go

* Line up types for Go

* Add nodejs

* Add Python

* Change expression form

* Fix nil check (`==` -> `!=`)

* Standardize nodejs & python checks

This should fix the Node OOM error.

* Rename enum-py to typed-enum-pp

* Don't reference schema types in `hcl2/model`

* Fix nits
2022-04-18 11:03:42 +02:00
Ian Wahbe f2d8858444
Respect schema versions (toggled via flag) ()
* Add version (when env var is set)

* Correct python pypi implementation

* Add a test

* Update CHANGELOG_PENDING.md

* Set as language option

* Remove version.txt from .gitignore

* Add go support

* Correctly handle nodejs.pluginVersion
2022-02-03 17:07:13 +01:00
Ian Wahbe 90913de3fb
[codegen/dotnet] Allow generated SDKs to have a global namespace other then `Pulumi` ()
* Allow .NET packages alternate owners

Specifically, this allows a generated package with a enclosing namespace
different then "Pulumi."

* New test case files

* Remove unused import

* Update CHANGELOG_PENDING.md

* Update codegen from master merge

* Use rootNamespace instead of namespace

* publisher overrides Author and "Company" in .NET

* Add publisher propagation to CHANGELOG_PENDING.md

* Fix nits

* Use fmt.Sprintf over +

* Restore sdk_driver.go (mostly)

* Add docs to allLanguages add documentation.

* Update tests from master

* Add rootNamespace to docs
2022-01-21 12:58:11 -08:00
Ian Wahbe 2f04a6931f
[sdk/dotnet] add plugin download url ()
* [sdk/dotnet] Add PluginDownloadURL

* Update CHANGELOG_PENDING.md

* Add dotnet test

* Set Random resource.remote = false

* Add codegen

* Codegen changes to Utilizes.cs

* Fix ResourceOptions.merge

* Remove WithVersion

* Fix local test environment

* Add WithVersion back (marked as obsolete)

* Fix ResourceOptions.Copy

* Use null coalescence operator

* Set csharp to use projectReferences

* Add PluginDownloadURL to CallOptions

* Populate CallOptions in codegen

* Revert "Populate CallOptions in codegen"

This reverts commit e3397e0733.

* Make backwards compatible with previous sdks

* Run integration tests on MacOS

* Attempt to fix macos build error

* Disable full testing suite (MacOS)
2022-01-13 16:10:17 -08:00
Anton Tayanovskyy a72cccee73
Revert "[sdk/dotnet] Add PluginDownloadURL ()" ()
This reverts commit bf93ed714d.
2022-01-12 17:25:25 -05:00
Ian Wahbe bf93ed714d
[sdk/dotnet] Add PluginDownloadURL ()
* [sdk/dotnet] Add PluginDownloadURL

* Update CHANGELOG_PENDING.md

* Add dotnet test

* Set Random resource.remote = false

* Add codegen

* Codegen changes to Utilizes.cs

* Fix ResourceOptions.merge

* Remove WithVersion

* Fix local test environment

* Add WithVersion back (marked as obsolete)

* Fix ResourceOptions.Copy

* Use null coalescence operator

* Set csharp to use projectReferences

* Add PluginDownloadURL to CallOptions

* Populate CallOptions in codegen

* Revert "Populate CallOptions in codegen"

This reverts commit e3397e0733.

* Make backwards compatible with previous sdks
2022-01-11 17:36:48 -08:00
Justin Van Patten 043c42b336
Use `pulumi-plugin.json` rather than `pulumiplugin.json` ()
Current/older versions of the Python language host cannot read `pulumiplugin.json` without returning an error. This hasn't been a problem because none of our packages have included the file. However, we're going to start including this file by default in packages. To avoid this error on older CLIs, we'll use a different file name. And since we're introducing the use of this file in the .NET and Go language hosts, we'll use the new name for these languages as well for consistency.
2021-12-15 10:41:44 -08:00
Ian Wahbe 05e26e384a
[codegen/dotnet] Emit `pulumiplugin json` during codegen ()
* Emit `pulumiplugin.json` during codegen

* Update codgen tests

* Update CHANGELOG_PENDING.md
2021-12-02 12:47:33 -08:00
Ian Wahbe af2a4ed278
[codegen/dotnet] Qualify function input type paths ()
* Give function input types fully qualified names

* Update tests

* Address linter

* Reduce scope of change

* Restore output-funcs-edgeorder schema.json
2021-12-01 17:53:18 -08:00