Skip to content

Commit 4df4433

Browse files
committed
fixup! extract option defaults logic
1 parent 46ee5ee commit 4df4433

File tree

1 file changed

+2
-25
lines changed

1 file changed

+2
-25
lines changed

envbuilder.go

+2-25
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import (
2626

2727
"github.com/coder/envbuilder/constants"
2828
"github.com/coder/envbuilder/git"
29-
"github.com/coder/envbuilder/internal/chmodfs"
3029
"github.com/coder/envbuilder/options"
3130

3231
"github.com/GoogleContainerTools/kaniko/pkg/config"
@@ -42,7 +41,6 @@ import (
4241
_ "github.com/distribution/distribution/v3/registry/storage/driver/filesystem"
4342
"github.com/docker/cli/cli/config/configfile"
4443
"github.com/fatih/color"
45-
"github.com/go-git/go-billy/v5/osfs"
4644
"github.com/go-git/go-git/v5/plumbing/transport"
4745
v1 "github.com/google/go-containerregistry/pkg/v1"
4846
"github.com/google/go-containerregistry/pkg/v1/remote"
@@ -61,23 +59,8 @@ type DockerConfig configfile.ConfigFile
6159
// Filesystem is the filesystem to use for all operations.
6260
// Defaults to the host filesystem.
6361
func Run(ctx context.Context, opts options.Options) error {
64-
// Temporarily removed these from the default settings to prevent conflicts
65-
// between current and legacy environment variables that add default values.
66-
// Once the legacy environment variables are phased out, this can be
67-
// reinstated to the previous default values.
68-
if len(opts.IgnorePaths) == 0 {
69-
opts.IgnorePaths = []string{
70-
"/var/run",
71-
// KinD adds these paths to pods, so ignore them by default.
72-
"/product_uuid", "/product_name",
73-
}
74-
}
75-
if opts.InitScript == "" {
76-
opts.InitScript = "sleep infinity"
77-
}
78-
if opts.InitCommand == "" {
79-
opts.InitCommand = "/bin/sh"
80-
}
62+
opts.SetDefaults()
63+
8164
if opts.CacheRepo == "" && opts.PushImage {
8265
return fmt.Errorf("--cache-repo must be set when using --push-image")
8366
}
@@ -90,12 +73,6 @@ func Run(ctx context.Context, opts options.Options) error {
9073
return fmt.Errorf("parse init args: %w", err)
9174
}
9275
}
93-
if opts.Filesystem == nil {
94-
opts.Filesystem = chmodfs.New(osfs.New("/"))
95-
}
96-
if opts.WorkspaceFolder == "" {
97-
opts.WorkspaceFolder = options.DefaultWorkspaceFolder(opts.GitURL)
98-
}
9976

10077
stageNumber := 0
10178
startStage := func(format string, args ...any) func(format string, args ...any) {

0 commit comments

Comments
 (0)