Skip to content

Commit

Permalink
Migrate to oras-go library
Browse files Browse the repository at this point in the history
Signed-off-by: Josh Dolitsky <[email protected]>
  • Loading branch information
jdolitsky committed May 4, 2021
1 parent 1ec0c36 commit c4371a2
Show file tree
Hide file tree
Showing 77 changed files with 33 additions and 6,290 deletions.
18 changes: 5 additions & 13 deletions .github/workflows/build-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,8 @@ jobs:
- name: setup go environment
uses: actions/setup-go@v1
with:
go-version: '1.16.2'
- name: run unit tests
run: make test
- name: run acceptance tests
run: |
export LOCAL_REGISTRY_HOSTNAME="$(hostname -I | awk '{print $1}')"
make acceptance
- name: upload coverage report
uses: actions/upload-artifact@master
with:
name: oras-coverage-report-${{ github.sha }}
path: .cover/
if: always()
go-version: '1.16.3'
- name: Build CLI
run: make build-linux
- name: Check version
run: bin/linux/amd64/oras version
18 changes: 5 additions & 13 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,8 @@ jobs:
- name: setup go environment
uses: actions/setup-go@v1
with:
go-version: '1.16.2'
- name: run unit tests
run: make test
- name: run acceptance tests
run: |
export LOCAL_REGISTRY_HOSTNAME="$(hostname -I | awk '{print $1}')"
make acceptance
- name: upload coverage report
uses: actions/upload-artifact@master
with:
name: oras-coverage-report-${{ github.sha }}
path: .cover/
if: always()
go-version: '1.16.3'
- name: Build CLI
run: make build-linux
- name: Check version
run: bin/linux/amd64/oras version
2 changes: 1 addition & 1 deletion .github/workflows/release-github.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: setup go environment
uses: actions/setup-go@v1
with:
go-version: '1.16.2'
go-version: '1.16.3'
- name: run goreleaser
uses: goreleaser/goreleaser-action@v2
with:
Expand Down
70 changes: 0 additions & 70 deletions BUILDING.md

This file was deleted.

4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
FROM docker.io/library/golang:1.15.7-alpine as builder
FROM docker.io/library/golang:1.16.3-alpine as builder
RUN apk add git make
ENV ORASPKG /oras
ADD . ${ORASPKG}
WORKDIR ${ORASPKG}
RUN make build-linux
RUN mv ${ORASPKG}/bin/linux/amd64/oras /go/bin/oras

FROM docker.io/library/alpine:3.13.0
FROM docker.io/library/alpine:3.13.5
LABEL maintainer="[email protected]"
RUN apk --update add ca-certificates
COPY --from=builder /go/bin/oras /bin/oras
Expand Down
6 changes: 1 addition & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@ LDFLAGS += -X $(PROJECT_PKG)/internal/version.GitTreeState=${GIT_DIRTY}

.PHONY: test
test: vendor check-encoding
./scripts/test.sh

.PHONY: acceptance
acceptance:
./scripts/acceptance.sh
echo "TODO: add unit tests"

.PHONY: covhtml
covhtml:
Expand Down
61 changes: 2 additions & 59 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[![Go Report Card](https://goreportcard.com/badge/github.com/deislabs/oras)](https://goreportcard.com/report/github.com/deislabs/oras)
[![GoDoc](https://godoc.org/github.com/deislabs/oras?status.svg)](https://godoc.org/github.com/deislabs/oras)

![ORAS](./oras.png)
![ORAS](https://github.com/oras-project/oras-www/raw/main/docs/assets/images/oras.png)

[Registries are evolving as Cloud Native Artifact Stores](https://stevelasker.blog/2019/01/25/cloud-native-artifact-stores-evolve-from-container-registries/). To enable this goal, Microsoft has donated ORAS as a means to enable various client libraries with a way to push [OCI Artifacts][artifacts] to [OCI Conformant](https://github.com/opencontainers/oci-conformance) registries.

Expand Down Expand Up @@ -240,64 +240,7 @@ oras pull localhost:5000/hello-artifact:v2 -a
## ORAS Go Module
While the ORAS CLI provides a great way to get started, and test registry support for [OCI Artifacts][artifacts], the primary experience enables a native experience for your artifact of choice. Using the ORAS Go Module, you can develop your own push/pull experience: `myclient push artifacts.azurecr.io/myartifact:1.0 ./mything.thang`
The package `github.com/deislabs/oras/pkg/oras` can quickly be imported in other Go-based tools that
wish to benefit from the ability to store arbitrary content in container registries.
### ORAS Go Module Example
[Source](examples/simple_push_pull.go)
```go
package main
import (
"context"
"fmt"
"github.com/deislabs/oras/pkg/content"
"github.com/deislabs/oras/pkg/oras"
"github.com/containerd/containerd/remotes/docker"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
)
func check(e error) {
if e != nil {
panic(e)
}
}
func main() {
ref := "localhost:5000/oras:test"
fileName := "hello.txt"
fileContent := []byte("Hello World!\n")
customMediaType := "my.custom.media.type"
ctx := context.Background()
resolver := docker.NewResolver(docker.ResolverOptions{})
// Push file(s) w custom mediatype to registry
memoryStore := content.NewMemoryStore()
desc := memoryStore.Add(fileName, customMediaType, fileContent)
pushContents := []ocispec.Descriptor{desc}
fmt.Printf("Pushing %s to %s...\n", fileName, ref)
desc, err := oras.Push(ctx, resolver, ref, memoryStore, pushContents)
check(err)
fmt.Printf("Pushed to %s with digest %s\n", ref, desc.Digest)
// Pull file(s) from registry and save to disk
fmt.Printf("Pulling from %s and saving to %s...\n", ref, fileName)
fileStore := content.NewFileStore("")
defer fileStore.Close()
allowedMediaTypes := []string{customMediaType}
desc, _, err = oras.Pull(ctx, resolver, ref, fileStore, oras.WithAllowedMediaTypes(allowedMediaTypes))
check(err)
fmt.Printf("Pulled from %s with digest %s\n", ref, desc.Digest)
fmt.Printf("Try running 'cat %s'\n", fileName)
}
```
See https://github.com/oras-project/oras-go
## Contributing
Expand Down
2 changes: 1 addition & 1 deletion cmd/oras/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package main
import (
"context"

orascontent "github.com/deislabs/oras/pkg/content"
orascontent "github.com/oras-project/oras-go/pkg/content"

"github.com/containerd/containerd/content"
"github.com/containerd/containerd/content/local"
Expand Down
2 changes: 1 addition & 1 deletion cmd/oras/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"os"
"strings"

auth "github.com/deislabs/oras/pkg/auth/docker"
auth "github.com/oras-project/oras-go/pkg/auth/docker"

"github.com/docker/docker/pkg/term"
"github.com/sirupsen/logrus"
Expand Down
2 changes: 1 addition & 1 deletion cmd/oras/logout.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package main
import (
"context"

auth "github.com/deislabs/oras/pkg/auth/docker"
auth "github.com/oras-project/oras-go/pkg/auth/docker"

"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
Expand Down
6 changes: 3 additions & 3 deletions cmd/oras/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import (
"fmt"
"os"

"github.com/deislabs/oras/pkg/content"
ctxo "github.com/deislabs/oras/pkg/context"
"github.com/deislabs/oras/pkg/oras"
"github.com/oras-project/oras-go/pkg/content"
ctxo "github.com/oras-project/oras-go/pkg/context"
"github.com/oras-project/oras-go/pkg/oras"

"github.com/containerd/containerd/reference"
"github.com/sirupsen/logrus"
Expand Down
6 changes: 3 additions & 3 deletions cmd/oras/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (
"os"
"path/filepath"

"github.com/deislabs/oras/pkg/content"
ctxo "github.com/deislabs/oras/pkg/context"
"github.com/deislabs/oras/pkg/oras"
"github.com/oras-project/oras-go/pkg/content"
ctxo "github.com/oras-project/oras-go/pkg/context"
"github.com/oras-project/oras-go/pkg/oras"

ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/sirupsen/logrus"
Expand Down
2 changes: 1 addition & 1 deletion cmd/oras/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"net/http"
"os"

auth "github.com/deislabs/oras/pkg/auth/docker"
auth "github.com/oras-project/oras-go/pkg/auth/docker"

"github.com/containerd/containerd/remotes"
"github.com/containerd/containerd/remotes/docker"
Expand Down
9 changes: 0 additions & 9 deletions docs/README.md

This file was deleted.

Loading

0 comments on commit c4371a2

Please sign in to comment.