Skip to content

Commit

Permalink
add hidden remote repo dir option to change clone path (#297)
Browse files Browse the repository at this point in the history
(cherry picked from commit c1f9917)
  • Loading branch information
mafredri authored and johnstcn committed Aug 5, 2024
1 parent 303ce81 commit 2a59ce0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
4 changes: 2 additions & 2 deletions envbuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func Run(ctx context.Context, opts options.Options) error {
if err != nil {
return fmt.Errorf("git clone options: %w", err)
}
cloneOpts.Path = constants.MagicRemoteRepoDir
cloneOpts.Path = opts.RemoteRepoDir

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

endStage := startStage("📦 Remote repo build mode enabled, cloning %s to %s for build context...",
newColor(color.FgCyan).Sprintf(opts.GitURL),
Expand Down
13 changes: 13 additions & 0 deletions options/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"os"
"strings"

"github.com/coder/envbuilder/constants"
"github.com/coder/envbuilder/log"
"github.com/coder/serpent"
"github.com/go-git/go-billy/v5"
Expand Down Expand Up @@ -157,6 +158,10 @@ type Options struct {
// working on the same repository.
RemoteRepoBuildMode bool

// RemoteRepoDir is the destination directory for the cloned repo when using
// remote repo build mode.
RemoteRepoDir string

// BinaryPath is the path to the local envbuilder binary when
// attempting to probe the build cache. This is only relevant when
// GetCachedImage is true.
Expand Down Expand Up @@ -450,6 +455,14 @@ func (o *Options) CLI() serpent.OptionSet {
"be used to improving cache utilization when multiple users are building " +
"working on the same repository.",
},
{
Flag: "remote-repo-dir",
Env: WithEnvPrefix("REMOTE_REPO_DIR"),
Value: serpent.StringOf(&o.RemoteRepoDir),
Default: constants.MagicRemoteRepoDir,
Hidden: true,
Description: "Specify the destination directory for the cloned repo when using remote repo build mode.",
},
{
Flag: "verbose",
Env: WithEnvPrefix("VERBOSE"),
Expand Down

0 comments on commit 2a59ce0

Please sign in to comment.