Commit Graph

2 Commits

Author SHA1 Message Date
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