Skip to content

Commit c1f9917

Browse files
authored
add hidden remote repo dir option to change clone path (#297)
1 parent 6afe89e commit c1f9917

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

envbuilder.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ func Run(ctx context.Context, opts options.Options) error {
138138
if err != nil {
139139
return fmt.Errorf("git clone options: %w", err)
140140
}
141-
cloneOpts.Path = constants.MagicRemoteRepoDir
141+
cloneOpts.Path = opts.RemoteRepoDir
142142

143143
endStage := startStage("📦 Remote repo build mode enabled, cloning %s to %s for build context...",
144144
newColor(color.FgCyan).Sprintf(opts.GitURL),
@@ -912,7 +912,7 @@ func RunCacheProbe(ctx context.Context, opts options.Options) (v1.Image, error)
912912
if err != nil {
913913
return nil, fmt.Errorf("git clone options: %w", err)
914914
}
915-
cloneOpts.Path = constants.MagicRemoteRepoDir
915+
cloneOpts.Path = opts.RemoteRepoDir
916916

917917
endStage := startStage("📦 Remote repo build mode enabled, cloning %s to %s for build context...",
918918
newColor(color.FgCyan).Sprintf(opts.GitURL),

options/options.go

+13
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"os"
88
"strings"
99

10+
"github.com/coder/envbuilder/constants"
1011
"github.com/coder/envbuilder/log"
1112
"github.com/coder/serpent"
1213
"github.com/go-git/go-billy/v5"
@@ -157,6 +158,10 @@ type Options struct {
157158
// working on the same repository.
158159
RemoteRepoBuildMode bool
159160

161+
// RemoteRepoDir is the destination directory for the cloned repo when using
162+
// remote repo build mode.
163+
RemoteRepoDir string
164+
160165
// BinaryPath is the path to the local envbuilder binary when
161166
// attempting to probe the build cache. This is only relevant when
162167
// GetCachedImage is true.
@@ -450,6 +455,14 @@ func (o *Options) CLI() serpent.OptionSet {
450455
"be used to improving cache utilization when multiple users are building " +
451456
"working on the same repository.",
452457
},
458+
{
459+
Flag: "remote-repo-dir",
460+
Env: WithEnvPrefix("REMOTE_REPO_DIR"),
461+
Value: serpent.StringOf(&o.RemoteRepoDir),
462+
Default: constants.MagicRemoteRepoDir,
463+
Hidden: true,
464+
Description: "Specify the destination directory for the cloned repo when using remote repo build mode.",
465+
},
453466
{
454467
Flag: "verbose",
455468
Env: WithEnvPrefix("VERBOSE"),

0 commit comments

Comments
 (0)