From 11ffe7324c865ff4c27b7a6dbc4de130d041d036 Mon Sep 17 00:00:00 2001 From: Robert-André Mauchin Date: Jun 27 2019 14:49:32 +0000 Subject: Initial import Signed-off-by: Robert-André Mauchin --- diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9b63ea2 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/distribution-2.7.1.tar.gz diff --git a/0001-Add-reference-ParseDockerRef-utility-function.patch b/0001-Add-reference-ParseDockerRef-utility-function.patch new file mode 100644 index 0000000..5407ed4 --- /dev/null +++ b/0001-Add-reference-ParseDockerRef-utility-function.patch @@ -0,0 +1,150 @@ +From 0ac367fd6bee057d404c405a298b4b7aedf301ec Mon Sep 17 00:00:00 2001 +From: Sebastiaan van Stijn +Date: Mon, 10 Dec 2018 23:51:58 +0100 +Subject: [PATCH] Add reference.ParseDockerRef utility function + +ParseDockerRef normalizes the image reference following the docker +convention. This is added mainly for backward compatibility. The reference +returned can only be either tagged or digested. For reference contains both tag +and digest, the function returns digested reference, e.g. + + docker.io/library/busybox:latest@sha256:7cc4b5aefd1d0cadf8d97d4350462ba51c694ebca145b08d7d41b41acc8db5aa + +will be returned as + + docker.io/library/busybox@sha256:7cc4b5aefd1d0cadf8d97d4350462ba51c694ebca145b08d7d41b41acc8db5aa. + +Signed-off-by: Sebastiaan van Stijn +--- + reference/normalize.go | 29 ++++++++++++++ + reference/normalize_test.go | 80 +++++++++++++++++++++++++++++++++++++ + 2 files changed, 109 insertions(+) + +diff --git a/reference/normalize.go b/reference/normalize.go +index 2d71fc5e9..b3dfb7a6d 100644 +--- a/reference/normalize.go ++++ b/reference/normalize.go +@@ -56,6 +56,35 @@ func ParseNormalizedNamed(s string) (Named, error) { + return named, nil + } + ++// ParseDockerRef normalizes the image reference following the docker convention. This is added ++// mainly for backward compatibility. ++// The reference returned can only be either tagged or digested. For reference contains both tag ++// and digest, the function returns digested reference, e.g. docker.io/library/busybox:latest@ ++// sha256:7cc4b5aefd1d0cadf8d97d4350462ba51c694ebca145b08d7d41b41acc8db5aa will be returned as ++// docker.io/library/busybox@sha256:7cc4b5aefd1d0cadf8d97d4350462ba51c694ebca145b08d7d41b41acc8db5aa. ++func ParseDockerRef(ref string) (Named, error) { ++ named, err := ParseNormalizedNamed(ref) ++ if err != nil { ++ return nil, err ++ } ++ if _, ok := named.(NamedTagged); ok { ++ if canonical, ok := named.(Canonical); ok { ++ // The reference is both tagged and digested, only ++ // return digested. ++ newNamed, err := WithName(canonical.Name()) ++ if err != nil { ++ return nil, err ++ } ++ newCanonical, err := WithDigest(newNamed, canonical.Digest()) ++ if err != nil { ++ return nil, err ++ } ++ return newCanonical, nil ++ } ++ } ++ return TagNameOnly(named), nil ++} ++ + // splitDockerDomain splits a repository name to domain and remotename string. + // If no valid domain is found, the default domain is used. Repository name + // needs to be already validated before. +diff --git a/reference/normalize_test.go b/reference/normalize_test.go +index a881972ac..a636236ee 100644 +--- a/reference/normalize_test.go ++++ b/reference/normalize_test.go +@@ -623,3 +623,83 @@ func TestMatch(t *testing.T) { + } + } + } ++ ++func TestParseDockerRef(t *testing.T) { ++ testcases := []struct { ++ name string ++ input string ++ expected string ++ }{ ++ { ++ name: "nothing", ++ input: "busybox", ++ expected: "docker.io/library/busybox:latest", ++ }, ++ { ++ name: "tag only", ++ input: "busybox:latest", ++ expected: "docker.io/library/busybox:latest", ++ }, ++ { ++ name: "digest only", ++ input: "busybox@sha256:e6693c20186f837fc393390135d8a598a96a833917917789d63766cab6c59582", ++ expected: "docker.io/library/busybox@sha256:e6693c20186f837fc393390135d8a598a96a833917917789d63766cab6c59582", ++ }, ++ { ++ name: "path only", ++ input: "library/busybox", ++ expected: "docker.io/library/busybox:latest", ++ }, ++ { ++ name: "hostname only", ++ input: "docker.io/busybox", ++ expected: "docker.io/library/busybox:latest", ++ }, ++ { ++ name: "no tag", ++ input: "docker.io/library/busybox", ++ expected: "docker.io/library/busybox:latest", ++ }, ++ { ++ name: "no path", ++ input: "docker.io/busybox:latest", ++ expected: "docker.io/library/busybox:latest", ++ }, ++ { ++ name: "no hostname", ++ input: "library/busybox:latest", ++ expected: "docker.io/library/busybox:latest", ++ }, ++ { ++ name: "full reference with tag", ++ input: "docker.io/library/busybox:latest", ++ expected: "docker.io/library/busybox:latest", ++ }, ++ { ++ name: "gcr reference without tag", ++ input: "gcr.io/library/busybox", ++ expected: "gcr.io/library/busybox:latest", ++ }, ++ { ++ name: "both tag and digest", ++ input: "gcr.io/library/busybox:latest@sha256:e6693c20186f837fc393390135d8a598a96a833917917789d63766cab6c59582", ++ expected: "gcr.io/library/busybox@sha256:e6693c20186f837fc393390135d8a598a96a833917917789d63766cab6c59582", ++ }, ++ } ++ for _, test := range testcases { ++ t.Run(test.name, func(t *testing.T) { ++ normalized, err := ParseDockerRef(test.input) ++ if err != nil { ++ t.Fatal(err) ++ } ++ output := normalized.String() ++ if output != test.expected { ++ t.Fatalf("expected %q to be parsed as %v, got %v", test.input, test.expected, output) ++ } ++ _, err = Parse(output) ++ if err != nil { ++ t.Fatalf("%q should be a valid reference, but got an error: %v", output, err) ++ } ++ }) ++ } ++} diff --git a/golang-github-docker-distribution.spec b/golang-github-docker-distribution.spec new file mode 100644 index 0000000..63d5dc0 --- /dev/null +++ b/golang-github-docker-distribution.spec @@ -0,0 +1,104 @@ +# Generated by go2rpm +%bcond_without check + +# https://github.com/docker/distribution +%global goipath github.com/docker/distribution +Version: 2.7.1 + +%gometa + +%global common_description %{expand: +The Docker toolset to pack, ship, store, and deliver content. + +This repository's main product is the Docker Registry 2.0 implementation for +storing and distributing Docker images. It supersedes the docker/docker-registry +project with a new API design, focused around security and performance.} + +%global golicenses LICENSE +%global godocs docs BUILDING.md CONTRIBUTING.md README.md ROADMAP.md + +Name: %{goname} +Release: 1%{?dist} +Summary: Docker toolset to pack, ship, store, and deliver content + +# Upstream license specification: Apache-2.0 +License: ASL 2.0 +URL: %{gourl} +Source0: %{gosource} +# Needed by containerd +Patch0: https://github.com/docker/distribution/commit/0ac367fd6bee057d404c405a298b4b7aedf301ec.patch#/0001-Add-reference-ParseDockerRef-utility-function.patch + + +BuildRequires: golang(github.com/aws/aws-sdk-go/aws) +BuildRequires: golang(github.com/aws/aws-sdk-go/aws/awserr) +BuildRequires: golang(github.com/aws/aws-sdk-go/aws/corehandlers) +BuildRequires: golang(github.com/aws/aws-sdk-go/aws/credentials) +BuildRequires: golang(github.com/aws/aws-sdk-go/aws/credentials/ec2rolecreds) +BuildRequires: golang(github.com/aws/aws-sdk-go/aws/ec2metadata) +BuildRequires: golang(github.com/aws/aws-sdk-go/aws/endpoints) +BuildRequires: golang(github.com/aws/aws-sdk-go/aws/request) +BuildRequires: golang(github.com/aws/aws-sdk-go/aws/session) +BuildRequires: golang(github.com/aws/aws-sdk-go/service/cloudfront/sign) +BuildRequires: golang(github.com/aws/aws-sdk-go/service/s3) +BuildRequires: golang(github.com/Azure/azure-sdk-for-go/storage) +BuildRequires: golang(github.com/bshuster-repo/logrus-logstash-hook) +BuildRequires: golang(github.com/bugsnag/bugsnag-go) +BuildRequires: golang(github.com/docker/go-metrics) +BuildRequires: golang(github.com/docker/libtrust) +BuildRequires: golang(github.com/garyburd/redigo/redis) +BuildRequires: golang(github.com/gorilla/handlers) +BuildRequires: golang(github.com/gorilla/mux) +BuildRequires: golang(github.com/mitchellh/mapstructure) +BuildRequires: golang(github.com/ncw/swift) +BuildRequires: golang(github.com/opencontainers/go-digest) +BuildRequires: golang(github.com/opencontainers/image-spec/specs-go/v1) +BuildRequires: golang(github.com/Shopify/logrus-bugsnag) +BuildRequires: golang(github.com/sirupsen/logrus) +BuildRequires: golang(github.com/spf13/cobra) +BuildRequires: golang(github.com/yvasiyarov/gorelic) +BuildRequires: golang(golang.org/x/crypto/bcrypt) +BuildRequires: golang(gopkg.in/check.v1) +BuildRequires: golang(gopkg.in/yaml.v2) +BuildRequires: golang(rsc.io/letsencrypt) + +%if %{with check} +# Tests +BuildRequires: golang(github.com/ncw/swift/swifttest) +%endif + +%description +%{common_description} + +%gopkg + +%prep +%goprep +%patch0 -p1 + +%build +for cmd in cmd/* ; do + %gobuild -o %{gobuilddir}/bin/$(basename $cmd) %{goipath}/$cmd +done + +%install +%gopkginstall +install -m 0755 -vd %{buildroot}%{_bindir} +install -m 0755 -vp %{gobuilddir}/bin/* %{buildroot}%{_bindir}/ + +%if %{with check} +%check +%gocheck -d health/checks \ + -d registry/handlers \ + -t registry/storage/driver +%endif + +%files +%license LICENSE +%doc docs BUILDING.md CONTRIBUTING.md README.md ROADMAP.md +%{_bindir}/* + +%gopkgfiles + +%changelog +* Wed May 01 17:39:11 CEST 2019 Robert-André Mauchin - 2.7.1-1 +- Initial package diff --git a/sources b/sources new file mode 100644 index 0000000..7d7a74b --- /dev/null +++ b/sources @@ -0,0 +1 @@ +SHA512 (distribution-2.7.1.tar.gz) = f6baf0e7aa96ebe828c628f7dfd84ee899331c3c1bdab86662aef595b092702b6d9b2c9be766a6de6d153ff4ca55d85c5fd8785a0968f285f56a32a50092c754