Please consider making the codebase compatible with vendoring
I am currently packaging `google-guest-agent` for SLE/openSUSE and the current build system doesn't allow vendoring on the vanilla source tree. Instead, one has to perform the build first by running `make`, after which `go mod vendor` succeeds.
Demonstration:
```
glaubitz@suse-laptop:~/upstream/google-guest-agent> go mod vendor
go: github.com/GoogleCloudPlatform/google-guest-agent/cmd/acs_cli imports
github.com/GoogleCloudPlatform/google-guest-agent/internal/acp/proto/google_guest_agent/acp: no required module provides package github.com/GoogleCloudPlatform/google-guest-agent/internal/acp/proto/google_guest_agent/acp; to add it:
go get github.com/GoogleCloudPlatform/google-guest-agent/internal/acp/proto/google_guest_agent/acp
go: github.com/GoogleCloudPlatform/google-guest-agent/cmd/core_plugin/agentcrypto imports
github.com/GoogleCloudPlatform/google-guest-agent/cmd/core_plugin/agentcrypto/proto/credentials: no required module provides package github.com/GoogleCloudPlatform/google-guest-agent/cmd/core_plugin/agentcrypto/proto/credentials; to add it:
go get github.com/GoogleCloudPlatform/google-guest-agent/cmd/core_plugin/agentcrypto/proto/credentials
go: github.com/GoogleCloudPlatform/google-guest-agent/cmd/core_plugin/snapshot imports
github.com/GoogleCloudPlatform/google-guest-agent/cmd/core_plugin/snapshot/proto/cloud_vmm: no required module provides package github.com/GoogleCloudPlatform/google-guest-agent/cmd/core_plugin/snapshot/proto/cloud_vmm; to add it:
go get github.com/GoogleCloudPlatform/google-guest-agent/cmd/core_plugin/snapshot/proto/cloud_vmm
go: github.com/GoogleCloudPlatform/google-guest-agent/cmd/core_plugin/workloadcertrefresh imports
github.com/GoogleCloudPlatform/google-guest-agent/cmd/core_plugin/workloadcertrefresh/proto/mwlid: no required module provides package github.com/GoogleCloudPlatform/google-guest-agent/cmd/core_plugin/workloadcertrefresh/proto/mwlid; to add it:
go get github.com/GoogleCloudPlatform/google-guest-agent/cmd/core_plugin/workloadcertrefresh/proto/mwlid
glaubitz@suse-laptop:~/upstream/google-guest-agent> make
golang build environment:
#########################
GOOS=linux
VERSION=dev
#########################
Making proto dependencies dir...
Cloning/updating go-tpm-tools...
Already up to date.
Making proto dependencies dir...
Cloning/updating mwlid-proto...
Already up to date.
[GEN] cmd/core_plugin/agentcrypto/proto/guest_credentials.proto
[GEN] cmd/core_plugin/snapshot/proto/snapshot_service.proto
[GEN] internal/acp/proto/agent_controlplane.proto
[GEN] cmd/core_plugin/workloadcertrefresh/proto/workload_identity.proto
[BIN] cmd/core_plugin/core_plugin
[BIN] cmd/ggactl/ggactl_plugin
[BIN] cmd/google_authorized_keys/google_authorized_keys
[BIN] cmd/google_guest_agent/google_guest_agent
[BIN] cmd/google_guest_compat_manager/google_guest_compat_manager
[BIN] cmd/gce_metadata_script_runner/gce_metadata_script_runner
[BIN] cmd/metadata_script_runner_compat/gce_compat_metadata_script_runner
[BIN] cmd/google_authorized_keys_compat/google_authorized_keys_compat
glaubitz@suse-laptop:~/upstream/google-guest-agent> go mod vendor
glaubitz@suse-laptop:~/upstream/google-guest-agent> ls -l vendor
total 68
drwxr-xr-x 3 glaubitz users 4096 Jan 22 09:09 cel.dev
drwxr-xr-x 3 glaubitz users 4096 Jan 22 09:09 cloud.google.com
drwxr-xr-x 19 glaubitz users 4096 Jan 22 09:09 github.com
drwxr-xr-x 3 glaubitz users 4096 Jan 22 09:09 go.bug.st
drwxr-xr-x 3 glaubitz users 4096 Jan 22 09:09 golang.org
drwxr-xr-x 6 glaubitz users 4096 Jan 22 09:09 google.golang.org
drwxr-xr-x 5 glaubitz users 4096 Jan 22 09:09 go.opentelemetry.io
drwxr-xr-x 3 glaubitz users 4096 Jan 22 09:09 gopkg.in
drwxr-xr-x 3 glaubitz users 4096 Jan 22 09:09 go.uber.org
-rw-r--r-- 1 glaubitz users 27534 Jan 22 09:09 modules.txt
drwxr-xr-x 3 glaubitz users 4096 Jan 22 09:09 software.sslmate.com
glaubitz@suse-laptop:~/upstream/google-guest-agent>
```
Since Linux distributions disable network access during build, running `git clone` during a package build will fail. Additionally, we vendor all the dependencies using `go mod vendor` that the whole build process can take place offline.
Thus, it would be very useful if the build system of `google-guest-agent` could be changed to import Go modules the standard way without using `git clone` which would make vendoring the dependencies and building the package much easier and more streamlined for downstream distributions.
Thanks for consideration!
4 条评论