Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion context.go
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ func (c *context) contain(p string) (string, error) {

// ZOMBIES(stevvooe): In certain cases, we may want to remap these to a
// "containment error", so the caller can decide what to do.
return filepath.Join("/", filepath.Clean(sanitized)), nil
return filepath.Clean(sanitized), nil
}

// digest returns the digest of the file at path p, relative to the root.
Expand Down
2 changes: 1 addition & 1 deletion manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func BuildManifest(ctx Context) (*Manifest, error) {
return fmt.Errorf("error walking %s: %v", p, err)
}

if p == "/" {
if p == "." {
// skip root
return nil
}
Expand Down
46 changes: 22 additions & 24 deletions manifest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func TestWalkFS(t *testing.T) {

{
kind: rdirectory,
path: "/dev",
path: "dev",
mode: 0755,
},

Expand Down Expand Up @@ -311,41 +311,39 @@ func expectedResourceList(root string, resources []dresource) ([]Resource, error
resourceMap := map[string]Resource{}
paths := []string{}
for _, r := range resources {
absPath := r.path
if !filepath.IsAbs(absPath) {
absPath = "/" + absPath
if filepath.IsAbs(r.path) {
return nil, fmt.Errorf("path must be relative: %q", r.path)
}
switch r.kind {
case rfile:
f := &regularFile{
resource: resource{
paths: []string{absPath},
paths: []string{r.path},
mode: r.mode,
uid: r.uid,
gid: r.gid,
},
size: int64(r.size),
digests: []digest.Digest{r.digest},
}
resourceMap[absPath] = f
paths = append(paths, absPath)
resourceMap[r.path] = f
paths = append(paths, r.path)
case rdirectory:
d := &directory{
resource: resource{
paths: []string{absPath},
paths: []string{r.path},
mode: r.mode,
uid: r.uid,
gid: r.gid,
},
}
resourceMap[absPath] = d
paths = append(paths, absPath)
resourceMap[r.path] = d
paths = append(paths, r.path)
case rhardlink:
targetPath := r.target
if !filepath.IsAbs(targetPath) {
targetPath = "/" + targetPath
if filepath.IsAbs(r.target) {
return nil, fmt.Errorf("target must be relative: %q", r.target)
}
target, ok := resourceMap[targetPath]
target, ok := resourceMap[r.target]
if !ok {
return nil, errors.New("must specify target before hardlink for test resources")
}
Expand All @@ -354,7 +352,7 @@ func expectedResourceList(root string, resources []dresource) ([]Resource, error
return nil, errors.New("hardlink target must be regular file")
}
// TODO(dmcgowan): full merge
rf.paths = append(rf.paths, absPath)
rf.paths = append(rf.paths, r.path)
// TODO(dmcgowan): check if first path is now different, changes source order and should update
// resource map key, to avoid canonically ordered first should be regular file
sort.Stable(sort.StringSlice(rf.paths))
Expand All @@ -366,39 +364,39 @@ func expectedResourceList(root string, resources []dresource) ([]Resource, error
}
s := &symLink{
resource: resource{
paths: []string{absPath},
paths: []string{r.path},
mode: r.mode,
uid: r.uid,
gid: r.gid,
},
target: targetPath,
}
resourceMap[absPath] = s
paths = append(paths, absPath)
resourceMap[r.path] = s
paths = append(paths, r.path)
case rchardev:
d := &device{
resource: resource{
paths: []string{absPath},
paths: []string{r.path},
mode: r.mode,
uid: r.uid,
gid: r.gid,
},
major: uint64(r.major),
minor: uint64(r.minor),
}
resourceMap[absPath] = d
paths = append(paths, absPath)
resourceMap[r.path] = d
paths = append(paths, r.path)
case rnamedpipe:
p := &namedPipe{
resource: resource{
paths: []string{absPath},
paths: []string{r.path},
mode: r.mode,
uid: r.uid,
gid: r.gid,
},
}
resourceMap[absPath] = p
paths = append(paths, absPath)
resourceMap[r.path] = p
paths = append(paths, r.path)
default:
return nil, fmt.Errorf("unknown resource type: %v", r.kind)
}
Expand Down
4 changes: 2 additions & 2 deletions manifest_test_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ import "os"
var (
devNullResource = resource{
kind: chardev,
path: "/dev/null",
path: "dev/null",
major: 3,
minor: 2,
mode: 0666 | os.ModeDevice | os.ModeCharDevice,
}

devZeroResource = resource{
kind: chardev,
path: "/dev/zero",
path: "dev/zero",
major: 3,
minor: 3,
mode: 0666 | os.ModeDevice | os.ModeCharDevice,
Expand Down
4 changes: 3 additions & 1 deletion proto/manifest.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion proto/manifest.proto
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ message Manifest {
message Resource {
// Path specifies the path from the bundle root. If more than one
// path is present, the entry may represent a hardlink, rather than using
// a link target. The path format is operating system specific.
// a link target.
// A path must be relative to the bundle root.
// TODO(AkihiroSuda): use '/' seperator regardless of the operating system used for building the manifest?
repeated string path = 1;

// NOTE(stevvooe): Need to define clear precedence for user/group/uid/gid precedence.
Expand Down