Skip to content

Commit

Permalink
Support oci layout format
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel J Walsh <[email protected]>

Closes: #1319
Approved by: rhatdan
  • Loading branch information
rhatdan authored and rh-atomic-bot committed Feb 20, 2019
1 parent f9e645a commit fa71977
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 0 deletions.
3 changes: 3 additions & 0 deletions docs/buildah-from.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ Multiple transports are supported:
**docker-daemon:**_docker-reference_
An image _docker-reference_ stored in the docker daemon's internal storage. _docker-reference_ must include either a tag or a digest. Alternatively, when reading images, the format can also be docker-daemon:algo:digest (an image ID).

**oci:**_path_**:**_tag_**
An image tag in a directory compliant with "Open Container Image Layout Specification" at _path_.

**oci-archive:**_path_**:**_tag_
An image _tag_ in a directory compliant with "Open Container Image Layout Specification" at _path_.

Expand Down
3 changes: 3 additions & 0 deletions docs/buildah-pull.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ Multiple transports are supported:
**docker-daemon:**_docker-reference_
An image _docker-reference_ stored in the docker daemon's internal storage. _docker-reference_ must include either a tag or a digest. Alternatively, when reading images, the format can also be docker-daemon:algo:digest (an image ID).

**oci:**_path_**:**_tag_**
An image tag in a directory compliant with "Open Container Image Layout Specification" at _path_.

**oci-archive:**_path_**:**_tag_
An image _tag_ in a directory compliant with "Open Container Image Layout Specification" at _path_.

Expand Down
8 changes: 8 additions & 0 deletions pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/containers/image/docker/reference"
tarfile "github.com/containers/image/docker/tarfile"
ociarchive "github.com/containers/image/oci/archive"
oci "github.com/containers/image/oci/layout"
"github.com/containers/image/signature"
is "github.com/containers/image/storage"
"github.com/containers/image/transports"
Expand Down Expand Up @@ -112,6 +113,13 @@ func localImageNameForReference(ctx context.Context, store storage.Store, srcRef
if name[:1] == "/" {
name = name[1:]
}
case oci.Transport.Name():
// supports pull from a directory
name = split[1]
// remove leading "/"
if name[:1] == "/" {
name = name[1:]
}
default:
ref := srcRef.DockerReference()
if ref == nil {
Expand Down
19 changes: 19 additions & 0 deletions tests/pull.bats
Original file line number Diff line number Diff line change
Expand Up @@ -197,3 +197,22 @@ load helpers
[ "$status" -eq 0 ]
[ $(wc -l <<< "$output") -ge 3 ]
}

@test "pull-from-oci-directory" {
run buildah pull --signature-policy ${TESTSDIR}/policy.json alpine
echo "$output"
[ "$status" -eq 0 ]
run buildah push --signature-policy ${TESTSDIR}/policy.json docker.io/library/alpine:latest oci:${TESTDIR}/alpine
echo "$output"
[ "$status" -eq 0 ]
run buildah rmi alpine
echo "$output"
[ "$status" -eq 0 ]
run buildah pull --signature-policy ${TESTSDIR}/policy.json oci:${TESTDIR}/alpine
echo "$output"
[ "$status" -eq 0 ]
run buildah images --format "{{.Name}}:{{.Tag}}"
echo "$output"
[ "$status" -eq 0 ]
[[ "$output" =~ "alpine" ]]
}

0 comments on commit fa71977

Please sign in to comment.