Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support vendoring Go projects with a committed go.work that assumes workspace mode #46

Open
jfkw opened this issue Apr 15, 2024 · 3 comments

Comments

@jfkw
Copy link
Collaborator

jfkw commented Apr 15, 2024

Add support to obs-service-go_modules for vendoring with upstream projects using workspaces. When a Go project has a workspace go.work and go.work.sum committed to git, go mod vendor will fail with error:

go mod vendor
go: 'go mod vendor' cannot be run in workspace mode.
Run 'go work vendor' to vendor the workspace or set 'GOWORK=off' to exit workspace mode.

When following the recommendation GOWORK=off, the go.sum committed to git may be incomplete otherwise out of sync if developers are routinely using only the workspace when building:

go-tpm-tools> GOWORK=off go mod vendor
go: github.com/google/go-tpm-tools/internal/util imports
        cloud.google.com/go/compute/metadata: 
        missing go.sum entry for module providing package cloud.google.com/go/compute/metadata
       (imported by github.com/google/go-tpm-tools/internal/util); to add:
        go get github.com/google/go-tpm-tools/internal/util
go: github.com/google/go-tpm-tools/internal/util imports
        github.com/golang-jwt/jwt/v4:
        no required module provides package github.com/golang-jwt/jwt/v4; to add it:
        go get github.com/golang-jwt/jwt/v4
go: github.com/google/go-tpm-tools/internal/util imports
        golang.org/x/net/http2:
        missing go.sum entry for module providing package golang.org/x/net/http2
        (imported by github.com/google/go-tpm-tools/internal/util); to add:
        go get github.com/google/go-tpm-tools/internal/util
...

Research additional upstream projects with committed workspaces and document whether a standard sequence of go mod operations that can be used to reliably vendor such projects. If no single standard sequence is possible, logic can be built into the service implementation to detect and do the right thing for known layouts as encountered.

@jfkw jfkw changed the title Support vendoring Go projects that have a committed go.work that assumes workspace mode Support vendoring Go projects with a committed go.work that assumes workspace mode Apr 15, 2024
@jfkw
Copy link
Collaborator Author

jfkw commented Apr 15, 2024

To get the upstream project github.com/google/go-tpm-tools to work with go mod vendor in non workspace mode, first run go mod tidy.

@jfkw
Copy link
Collaborator Author

jfkw commented Apr 16, 2024

Refs #47

@johanneskastl
Copy link

Any news on this one?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants