From a10be993abfe5239ded8a87d7eb7aeff0a6214f9 Mon Sep 17 00:00:00 2001 From: Mathias Fredriksson Date: Mon, 5 Aug 2024 09:33:39 +0000 Subject: [PATCH 1/2] add hidden remote repo clone path option --- envbuilder.go | 4 ++-- options/options.go | 13 +++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/envbuilder.go b/envbuilder.go index 215ccc48..729632ae 100644 --- a/envbuilder.go +++ b/envbuilder.go @@ -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.RemoteRepoClonePath endStage := startStage("📦 Remote repo build mode enabled, cloning %s to %s for build context...", newColor(color.FgCyan).Sprintf(opts.GitURL), @@ -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.RemoteRepoClonePath endStage := startStage("📦 Remote repo build mode enabled, cloning %s to %s for build context...", newColor(color.FgCyan).Sprintf(opts.GitURL), diff --git a/options/options.go b/options/options.go index ff6a8be3..91dca2ab 100644 --- a/options/options.go +++ b/options/options.go @@ -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" @@ -157,6 +158,10 @@ type Options struct { // working on the same repository. RemoteRepoBuildMode bool + // RemoteRepoClonePath is the destination path for the cloned repo when + // using remote repo build mode. + RemoteRepoClonePath 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. @@ -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-clone-path", + Env: WithEnvPrefix("REMOTE_REPO_CLONE_PATH"), + Value: serpent.StringOf(&o.RemoteRepoClonePath), + Default: constants.MagicRemoteRepoDir, + Hidden: true, + Description: "Specify the destination path for the cloned repo when using remote repo build mode.", + }, { Flag: "verbose", Env: WithEnvPrefix("VERBOSE"), From b054c768ee88d6def537a311e0ba85c82ea80081 Mon Sep 17 00:00:00 2001 From: Mathias Fredriksson Date: Mon, 5 Aug 2024 09:40:44 +0000 Subject: [PATCH 2/2] rename --- envbuilder.go | 4 ++-- options/options.go | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/envbuilder.go b/envbuilder.go index 729632ae..a16f2fb4 100644 --- a/envbuilder.go +++ b/envbuilder.go @@ -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 = opts.RemoteRepoClonePath + cloneOpts.Path = opts.RemoteRepoDir endStage := startStage("📦 Remote repo build mode enabled, cloning %s to %s for build context...", newColor(color.FgCyan).Sprintf(opts.GitURL), @@ -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 = opts.RemoteRepoClonePath + cloneOpts.Path = opts.RemoteRepoDir endStage := startStage("📦 Remote repo build mode enabled, cloning %s to %s for build context...", newColor(color.FgCyan).Sprintf(opts.GitURL), diff --git a/options/options.go b/options/options.go index 91dca2ab..d7bd66b3 100644 --- a/options/options.go +++ b/options/options.go @@ -158,9 +158,9 @@ type Options struct { // working on the same repository. RemoteRepoBuildMode bool - // RemoteRepoClonePath is the destination path for the cloned repo when - // using remote repo build mode. - RemoteRepoClonePath string + // 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 @@ -456,12 +456,12 @@ func (o *Options) CLI() serpent.OptionSet { "working on the same repository.", }, { - Flag: "remote-repo-clone-path", - Env: WithEnvPrefix("REMOTE_REPO_CLONE_PATH"), - Value: serpent.StringOf(&o.RemoteRepoClonePath), + Flag: "remote-repo-dir", + Env: WithEnvPrefix("REMOTE_REPO_DIR"), + Value: serpent.StringOf(&o.RemoteRepoDir), Default: constants.MagicRemoteRepoDir, Hidden: true, - Description: "Specify the destination path for the cloned repo when using remote repo build mode.", + Description: "Specify the destination directory for the cloned repo when using remote repo build mode.", }, { Flag: "verbose",