Commit Graph

15 Commits

Author SHA1 Message Date
Fraser Waters 678d916202
Remove an unused parameter from argumentTypeName ()
Noticed this while fixing https://github.com/pulumi/pulumi/pull/16753.
The first parameter to argumentTypeName was totally unused.
2024-07-23 07:03:26 +00:00
Thomas Gummerer ae8134f5ad
upgrade to latest version of golangci-lint ()
The version we currently have doesn't support Go 1.22 properly, so it
throws a bunch of warnings locally when trying to run it with the latest
Go version installed. Just running the latest version locally also
doesn't quite work, since it throws a bunch of errors from the
perfsprint linter, which seems to have gotten stricter.

Upgrade to the latest version of golangci-lint, and fix all the errors
we're getting from it. Mostly done via `perfsprint -fix`, with some
manual changes that `perfsprint -fix` wouldn't touch.
2024-04-19 06:20:33 +00:00
Zaid Ajaj 31879f4a06
[go/program-gen] Add unit tests for argumentTypeName and go optional functions ()
# Description

This PR adds unit test for `argumentTypeName` and a few missing
uncovered cases from `GenFunctionExpression` in Go program-gen. I did
have to remove a check `Title(x) == "pulumi.Any"` that would never
evaluate to `true` but I didn't think this warrants a changelog for the
CLI

## 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-12-22 15:33:56 +00:00
Abhinav Gupta 9d944a4a1f
test(codegen/go): Fix broken TestLiteralExpression
TestLiteralExpression appears to be broken on master:

```
% go test -run TestLiteralExpression
--- FAIL: TestLiteralExpression (0.00s)
    --- FAIL: TestLiteralExpression/"foo_${bar}_%baz" (0.05s)
        gen_program_expression_test.go:252:
                Error Trace:    [..]/pulumi/pkg/codegen/go/gen_program_expression_test.go:252
                Error:          Not equal:
                                expected: "fmt.Sprintf(\"foo %v %vbaz\", bar, \"%\")"
                                actual  : "fmt.Sprintf(\"foo %v%v\", bar, \" %baz\")"

                                Diff:
                                --- Expected
                                +++ Actual
                                @@ -1 +1 @@
                                -fmt.Sprintf("foo %v %vbaz", bar, "%")
                                +fmt.Sprintf("foo %v%v", bar, " %baz")
                Test:           TestLiteralExpression/"foo_${bar}_%baz"
```

Both versions are a valid way to represent that information,
so I'm fixing the test case.

I'm not sure how this broken test ended on master, though.
2023-06-20 12:25:42 -07: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
Ian Wahbe 633d586aeb
Handle long traversals in a nicer way ()
* Handle long traversals in a nicer way

* CL

* assert no error

* Update tests
2022-06-02 09:36:33 -07: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 9f6589ed8c
iwahbe/7802/compile program generator test output ()
* Move program tests into folders

* update package schema

* Enabled tests pass

* Fix lints and begin to update test cases

* Re-enable tests

* Update aws version to v4

* Refactor language specific parts

* Hook up dotnet and nodejs

* Update tests from master

* SSOT for schema/version

* Name blocking errors. Leave tests in valid state

* Give each language its own folder

* Remove SkipCompile for azure-sa (bug was fixed)

* Fix nits + changes asserts to require

* Remove unused import

* One last assert => require
2021-09-29 11:33:57 -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
pulumi-bot 73a66f48ea [breaking] Changing the version of go.mod in sdk / pkg to be v3 2021-04-14 19:32:18 +01:00
Mikhail Shilkov 98f04cd2fc
Ensure top-level precedence to avoid flaky tests () 2020-10-05 19:50:51 +02:00
Evan Boyle fa3000801e
skip transient test () 2020-06-24 13:53:18 -07:00
Evan Boyle 94cd67b564
[Go Program Gen] Improved type handling and invokes () 2020-06-05 18:52:00 -07:00
Evan Boyle 9b2c6d726d
[Go Program Gen] binary, unary, and conditional expression support () 2020-05-28 13:47:49 -07:00
Evan Boyle c8142677cc
expression tests for basic go program literals () 2020-05-27 07:32:13 -07:00