Skip to content

generator/gomod: support GOPROXY build arg#1141

Open
kartikjoshi21 wants to merge 1 commit into
project-dalec:mainfrom
kartikjoshi21:kartikjoshi21/gomod-proxy-build-arg
Open

generator/gomod: support GOPROXY build arg#1141
kartikjoshi21 wants to merge 1 commit into
project-dalec:mainfrom
kartikjoshi21:kartikjoshi21/gomod-proxy-build-arg

Conversation

@kartikjoshi21

Copy link
Copy Markdown
Member

Add DALEC_GOMOD_PROXY as a known frontend build arg and carry it through SourceOpts into gomod dependency generation and gomod patch preprocessing.

Fixes: #1072

Copilot AI review requested due to automatic review settings July 15, 2026 08:11

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds support for injecting a custom Go module proxy into Dalec’s gomod generator flow via a frontend build arg, allowing module downloads (including during gomod patch preprocessing) to use a user-supplied GOPROXY without requiring anything in the spec file.

Changes:

  • Introduces DALEC_GOMOD_PROXY as a known frontend build arg and threads it into SourceOpts (GomodProxy).
  • Applies the proxy override to gomod dependency download execution and gomod patch preprocessing by setting GOPROXY in the relevant BuildKit exec env.
  • Adds unit tests validating build-arg recognition and that the generated LLB exec env includes/omits GOPROXY as expected.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
source.go Adds SourceOpts.GomodProxy to carry the effective proxy override through source/generator operations.
preprocess.go Threads GomodProxy into gomod patch preprocessing and sets GOPROXY for the patch exec when provided.
load.go Marks DALEC_GOMOD_PROXY as a known/allowed build arg (so it doesn’t need to be declared in spec args).
generator_gomod.go Adds the build-arg constant and applies GOPROXY to gomod dependency generation execs when provided.
generator_gomod_test.go Adds tests confirming GOPROXY is included/omitted in gomod download + patch exec env and that the build arg is accepted.
frontend/gateway.go Reads the build arg from the gateway client and populates SourceOpts.GomodProxy.
frontend/gateway_test.go Adds coverage ensuring SourceOptFromUIClient correctly reads DALEC_GOMOD_PROXY.
determinism_test.go Updates call site for the new gomod patch generation function signature.

Comment thread preprocess.go Outdated
Comment thread source.go Outdated
Comment thread generator_gomod.go Outdated
Add DALEC_GOMOD_PROXY as a known frontend build arg and carry it through
SourceOpts into gomod dependency generation and gomod patch preprocessing.

Signed-off-by: Kartik Joshi <kartikjoshi@microsoft.com>
@kartikjoshi21
kartikjoshi21 force-pushed the kartikjoshi21/gomod-proxy-build-arg branch from bb2ec89 to 233e031 Compare July 20, 2026 11:46

@invidian invidian left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One small nit, otherwise LGTM

Comment thread frontend/gateway_test.go
client := newStubClient()
client.opts["build-arg:"+dalec.BuildArgDalecGomodProxy] = proxy

sOpt := SourceOptFromUIClient(context.Background(), client, nil, nil)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: could use t.Context().

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

Successfully merging this pull request may close these issues.

[REQ] Support injecting custom GOPROXY into gomod generator

4 participants