Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(envbuilder): RunCacheProbe: remove references to constants.MagicDir #315

Merged
merged 3 commits into from
Aug 14, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions envbuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -948,7 +948,7 @@ func RunCacheProbe(ctx context.Context, opts options.Options) (v1.Image, error)
}

defaultBuildParams := func() (*devcontainer.Compiled, error) {
dockerfile := filepath.Join(constants.MagicDir, "Dockerfile")
dockerfile := filepath.Join(buildTimeWorkspaceFolder, "Dockerfile")
file, err := opts.Filesystem.OpenFile(dockerfile, os.O_CREATE|os.O_WRONLY, 0o644)
if err != nil {
return nil, err
Expand All @@ -970,7 +970,7 @@ func RunCacheProbe(ctx context.Context, opts options.Options) (v1.Image, error)
return &devcontainer.Compiled{
DockerfilePath: dockerfile,
DockerfileContent: content,
BuildContext: constants.MagicDir,
BuildContext: buildTimeWorkspaceFolder,
}, nil
}

Expand Down Expand Up @@ -1010,7 +1010,7 @@ func RunCacheProbe(ctx context.Context, opts options.Options) (v1.Image, error)
opts.Logger(log.LevelInfo, "No Dockerfile or image specified; falling back to the default image...")
fallbackDockerfile = defaultParams.DockerfilePath
}
buildParams, err = devContainer.Compile(opts.Filesystem, devcontainerDir, constants.MagicDir, fallbackDockerfile, opts.WorkspaceFolder, false, os.LookupEnv)
buildParams, err = devContainer.Compile(opts.Filesystem, devcontainerDir, buildTimeWorkspaceFolder, fallbackDockerfile, opts.WorkspaceFolder, false, os.LookupEnv)
Copy link
Member

Choose a reason for hiding this comment

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

Will this potentially change any of the Docker instructions/"directives"? That could lead to a cache miss if that's the case. Otherwise LGTM.

Copy link
Member Author

Choose a reason for hiding this comment

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

I see a comment in devcontainer.go that mentions featureDir must be reproducible based on the feature name, but I think that's relative to the build context.

In any case, I think it makes sense to beef up the testing around RunCacheProbe outside of a container as a non-root user.

Copy link
Member Author

Choose a reason for hiding this comment

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

I looked into adding some more non-rootful cache probe tests and I then remembered that you actually need the envbuilder binary for this. The infrastructure for all that is already there in the terraform provider tests, so that's probably a better place to do it.

if err != nil {
return nil, fmt.Errorf("compile devcontainer.json: %w", err)
}
Expand Down