Commit Graph

14 Commits

Author SHA1 Message Date
Luke Hoban d75251c49f
Add an `organization` intrinsic to PCL ()
We have added `getOrganization` fucntions to all SDKs. So we can now
lift this into PCL. This is needed to support `pulumi.organization` in
YAML, so that convert from YAML can target PCL and other downstream
languages.

Part of https://github.com/pulumi/pulumi-yaml/issues/461.

---------

Co-authored-by: Fraser Waters <fraser@pulumi.com>
2024-08-19 03:58:19 +00:00
Fraser Waters c35306d798
Use publisher and repository fields to default the Go import path ()
Currently we generate an "internal" package in our Go sdks that the
other packages in the sdk need to import. This requires them to know the
base import path (because Go doesn't have relative imports).

We also want to start writing out go.mod files as part of codegen rather
than provider authors manually adding them in the sdk directory above.
This _also_ requires the import path for the module.

Rather than requiring every user to specify the base import path in the
schema "go language" section we improve the default behaviour to use the
provider and repository fields from the schema that users are probably
filling in anyway.
2024-08-07 21:02:07 +00:00
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
Zaid Ajaj 4297d38ace
[Go] Re-enable l1-stack-reference conformance test ()
By fixing the emitted function for `getOutput` in Go program-gen which
is specific to stack references.

Locally the generated program compiles but I get a runtime error:
```
Error:      	Not equal: 
expected: resource.PropertyValue{V:"plain"}
actual  : resource.PropertyValue{V:(*resource.Secret)(0x14000aa6050)}

Diff:
--- Expected
+++ Actual
@@ -1,3 +1,7 @@
 (resource.PropertyValue) {
- V: (string) (len=5) "plain"
+ V: (*resource.Secret)({
+  Element: (resource.PropertyValue) {
+   V: (string) (len=5) "plain"
+  }
+ })
 }
Messages:   	expected property "plain" to be {plain}
```
However I _think_ this is a local problem with some cached Go SDK
artifacts because when go the implementation of `GetOutput` (from the
generated program) it brings me to a different implementation than the
one I find on latest SDK so testing in CI to make sure

EDIT: fixed by removing hardcoded `/` in the used path when replacing
Pulumi SDK reference

Fixes 
2024-07-30 08:12:38 +00:00
Zaid Ajaj 549904cece
[Go] Re-enable l1-output-array conformance test ()
On top of  

fixes output array expressions where their values need to be
(recursively) lifted as output so they can be exported from the stack.
2024-07-29 20:09:34 +00:00
Zaid Ajaj 7c14d59c2b
[Go] Re-enable l1-output-string conformance test ()
The issue was that `NUL` characters weren't being escaped and ended up
in the literal string in the generated Go program which the Go compiler
isn't a big fan of. This PR fixes the problem.

Resolves 
2024-07-29 16:35:31 +00:00
Fraser Waters 3460c9963f
Enable l1-output-number conformance test for Go ()
This required fixing `__convert` in Go programgen to handle expressions
that needed to result in input-y values. This also fixed the
"single-or-none" codegen test.
2024-07-22 17:12:28 +00:00
Fraser Waters 0362ff3bf9
Enable l1-main for Go conformance tests ()
Enables the l1-main conformance test for Go. This required fixing up Go
programgen to respect the "main" attribute in the projects Pulumi.yaml
if present.
2024-07-22 09:50:25 +00:00
Fraser Waters 9e75b0a0a4
Enable l1-output-bool test in Go conformance () 2024-07-21 23:30:14 +00:00
Fraser Waters 977ea57247
Enable the l1-empty test for Go ()
Enable the l1-empty test for Go.

This required some changes in reporting versions from the Go language
host (replaced dependencies don't really have a version anymore, because
they've been replaced by a local artefact and that doesn't contain any
version info itself). This then cascaded that the conformance test had
to be less strict about checking versions from GetDependencies because
Go now returns empty versions for these local deps.
2024-07-17 13:15:07 +00:00
Fraser Waters 40227d99ab
Change Go dependency tests to use real dependencies ()
For conformance testing we want "replace" directives to be respected
since they change the version of the dependency. These tests were all
written using replace directives instead of just normal real
dependencies and so fixing the Go host to respect "replace" broke these
tests.
This rewrites the tests to use real dependencies pulled from a separate
repo at https://github.com/pulumi/go-dependency-testdata.
2024-07-17 10:48:53 +00:00
Fraser Waters 3c9424ccc0
Fix lookup module deps with go.work files ()
<!--- 
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/15741.

`go list -m` returns all modules in a workspace if inside a Go
workspace. We only need the one module found in the Pulumi program
directory (or above it). So we set `GOWORK=off` before calling `go list
-m`.

## 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-21 09:48:04 +00:00
Abhinav Gupta dfefb0a613
fix(host/go): Allow Pulumi program in a subdir of the module
Fixes a regression in the Go language host where we started misbehaving
if the Pulumi.yaml was in a subdirectory of the Go module.

    myproject/
      |- go.mod
      |- foo.go
      '- infra/
          |- Pulumi.yaml
          '- main.go

This regression was introduced in ,
where we started parsing go.mod files to extract version information
and incorrectly assumed that the go.mod file was in the request
directory.

To fix this, we'll use the following command to get the absolute path
to the go.mod file.

    go list -m -f '{{.GoMod}}'

This command works in the root or subdirectory of a module
in both vendor and module mode.

Testing:
Includes a regression test in both module and vendor mode.

Resolves 
2023-05-17 13:20:38 -07:00
Abhinav Gupta dbcb6e8f17
test(go/host): GetRequiredPlugins and GetProgramDependencies
Adds a test that sets up a Go module with a few dependencies
and queries its plugins and dependencies with the Go language host.
This test passes today because we're running in module mode.

A sibling test will be added for vendor mode
to verify the fix for , where this same check would fail
if we vendor the dependencies into the Pulumi program.

NOTE:
The test does not run in parallel because we need to change the
working directory. This is resolved in a follow-up.
2023-04-21 10:28:23 -07:00