mirror of
https://github.com/coder/terraform-provider-envbuilder.git
synced 2025-11-13 15:38:08 +00:00
address PR comments
This commit is contained in:
parent
e428e02a66
commit
af0e01e73b
2 changed files with 10 additions and 8 deletions
internal/provider
|
|
@ -468,17 +468,18 @@ func extractEnvbuilderFromImage(ctx context.Context, imgRef, destPath string) er
|
|||
return fmt.Errorf("read tar header: %w", err)
|
||||
}
|
||||
|
||||
name := filepath.Clean(th.Name)
|
||||
if th.Typeflag != tar.TypeReg {
|
||||
tflog.Debug(ctx, "skip non-regular file", map[string]any{"name": filepath.Clean(th.Name), "layer_idx": i + 1})
|
||||
tflog.Debug(ctx, "skip non-regular file", map[string]any{"name": name, "layer_idx": i + 1})
|
||||
continue
|
||||
}
|
||||
|
||||
if filepath.Clean(th.Name) != needle {
|
||||
tflog.Debug(ctx, "skip file", map[string]any{"name": filepath.Clean(th.Name), "layer_idx": i + 1})
|
||||
if name != needle {
|
||||
tflog.Debug(ctx, "skip file", map[string]any{"name": name, "layer_idx": i + 1})
|
||||
continue
|
||||
}
|
||||
|
||||
tflog.Debug(ctx, "found file", map[string]any{"name": filepath.Clean(th.Name), "layer_idx": i + 1})
|
||||
tflog.Debug(ctx, "found file", map[string]any{"name": name, "layer_idx": i + 1})
|
||||
if err := os.MkdirAll(filepath.Dir(destPath), 0o755); err != nil {
|
||||
return fmt.Errorf("create parent directories: %w", err)
|
||||
}
|
||||
|
|
@ -486,13 +487,14 @@ func extractEnvbuilderFromImage(ctx context.Context, imgRef, destPath string) er
|
|||
if err != nil {
|
||||
return fmt.Errorf("create dest file for writing: %w", err)
|
||||
}
|
||||
|
||||
defer destF.Close()
|
||||
_, err = io.Copy(destF, tr)
|
||||
if err != nil {
|
||||
return fmt.Errorf("copy dest file from image: %w", err)
|
||||
}
|
||||
_ = destF.Close()
|
||||
if err := destF.Close(); err != nil {
|
||||
return fmt.Errorf("close dest file: %w", err)
|
||||
}
|
||||
|
||||
if err := os.Chmod(destPath, 0o755); err != nil {
|
||||
return fmt.Errorf("chmod file: %w", err)
|
||||
|
|
|
|||
|
|
@ -84,7 +84,8 @@ func seedCache(ctx context.Context, t testing.TB, deps testDependencies) {
|
|||
},
|
||||
Labels: map[string]string{
|
||||
testContainerLabel: "true",
|
||||
}}, &container.HostConfig{
|
||||
},
|
||||
}, &container.HostConfig{
|
||||
NetworkMode: container.NetworkMode("host"),
|
||||
Binds: []string{deps.RepoDir + ":" + "/workspaces/empty"},
|
||||
}, nil, nil, "")
|
||||
|
|
@ -123,7 +124,6 @@ SCANLOGS:
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func getEnvOrDefault(env, defVal string) string {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue