Skip to content

Commit 256b0dc

Browse files
committed
root path for win or linux
Signed-off-by: Juan Bustamante <jbustamante@vmware.com>
1 parent 87cc8d3 commit 256b0dc

4 files changed

Lines changed: 24 additions & 6 deletions

File tree

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ require (
77
github.com/apex/log v1.9.0
88
github.com/buildpacks/imgutil v0.0.0-20230203224758-32072eab009a
99
github.com/buildpacks/lifecycle v0.15.3
10-
github.com/docker/cli v23.0.0+incompatible
10+
github.com/docker/cli v23.0.1+incompatible
1111
github.com/docker/docker v20.10.23+incompatible
1212
github.com/docker/go-connections v0.4.0
1313
github.com/dustin/go-humanize v1.0.1

internal/paths/defaults_unix.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
//go:build linux || darwin
2+
// +build linux darwin
3+
4+
package paths
5+
6+
const (
7+
RootDir = `/`
8+
)

internal/paths/defaults_windows.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package paths
2+
3+
const (
4+
RootDir = `c:\`
5+
)

pkg/client/build.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ import (
1818
"github.com/buildpacks/imgutil/remote"
1919
"github.com/buildpacks/lifecycle/platform"
2020

21+
"github.com/buildpacks/pack/internal/paths"
22+
2123
"github.com/docker/docker/api/types"
2224
"github.com/docker/docker/volume/mounts"
2325
"github.com/google/go-containerregistry/pkg/name"
@@ -320,6 +322,7 @@ func (c *Client) Build(ctx context.Context, opts BuildOptions) error {
320322
return err
321323
}
322324
hostRunImagePath := filepath.Join(opts.LayoutConfig.LayoutRepoDir, targetRunImagePath)
325+
targetRunImagePath = filepath.Join(paths.RootDir, "layout-repo", targetRunImagePath)
323326
fetchOptions.LayoutOption = image.LayoutOption{
324327
Path: hostRunImagePath,
325328
Sparse: opts.LayoutConfig.Sparse,
@@ -766,6 +769,7 @@ func (c *Client) processLayoutPath(inputImageRef, previousImageRef InputImageRef
766769
if err != nil {
767770
return layoutPathConfig{}, err
768771
}
772+
targetImagePath = filepath.Join(paths.RootDir, "layout-repo", targetImagePath)
769773
c.logger.Debugf("local image path %s will be mounted into the container at path %s", hostImagePath, targetImagePath)
770774

771775
if previousImageRef.Name() != "" {
@@ -777,6 +781,7 @@ func (c *Client) processLayoutPath(inputImageRef, previousImageRef InputImageRef
777781
if err != nil {
778782
return layoutPathConfig{}, err
779783
}
784+
targetPreviousImagePath = filepath.Join(paths.RootDir, "layout-repo", targetPreviousImagePath)
780785
c.logger.Debugf("local previous image path %s will be mounted into the container at path %s", hostPreviousImagePath, targetPreviousImagePath)
781786
}
782787
return layoutPathConfig{
@@ -1228,12 +1233,12 @@ func fullImagePath(inputImageRef InputImageReference, create bool) (string, erro
12281233
// - The run-image path
12291234
func appendLayoutVolumes(volumes []string, config layoutPathConfig) []string {
12301235
if config.hostPreviousImagePath != "" {
1231-
volumes = append(volumes, writableVolume(config.hostImagePath, config.targetImagePath),
1232-
readOnlyVolume(config.hostPreviousImagePath, config.targetPreviousImagePath),
1233-
readOnlyVolume(config.hostRunImagePath, config.targetRunImagePath))
1236+
volumes = append(volumes, readOnlyVolume(config.hostPreviousImagePath, config.targetPreviousImagePath),
1237+
readOnlyVolume(config.hostRunImagePath, config.targetRunImagePath),
1238+
writableVolume(config.hostImagePath, config.targetImagePath))
12341239
} else {
1235-
volumes = append(volumes, writableVolume(config.hostImagePath, config.targetImagePath),
1236-
readOnlyVolume(config.hostRunImagePath, config.targetRunImagePath))
1240+
volumes = append(volumes, readOnlyVolume(config.hostRunImagePath, config.targetRunImagePath),
1241+
writableVolume(config.hostImagePath, config.targetImagePath))
12371242
}
12381243
return volumes
12391244
}

0 commit comments

Comments
 (0)