From dfd491ba8e2682c733db7a3aa13f3573068a23dc Mon Sep 17 00:00:00 2001 From: Atlas Kerr Date: Wed, 30 Jan 2019 18:07:17 -0600 Subject: [PATCH 1/5] specs-go: Add go structs. Signed-off-by: Atlas Kerr --- specs-go/v1/error.go | 37 +++++++++++++++++++++++++++++++++++++ specs-go/v1/repository.go | 20 ++++++++++++++++++++ specs-go/v1/tags.go | 21 +++++++++++++++++++++ 3 files changed, 78 insertions(+) create mode 100644 specs-go/v1/error.go create mode 100644 specs-go/v1/repository.go create mode 100644 specs-go/v1/tags.go diff --git a/specs-go/v1/error.go b/specs-go/v1/error.go new file mode 100644 index 00000000..c25f3c76 --- /dev/null +++ b/specs-go/v1/error.go @@ -0,0 +1,37 @@ +// Copyright 2019 The Linux Foundation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package v1 + +// ErrorResponse is returned by a registry on an invalid request. +type ErrorResponse struct { + Errors []ErrorInfo `json:"errors"` +} + +// Error implements the Error interface. +func (er *ErrorResponse) Error() string { + return "distribution: registry returned error" +} + +// Detail returns an ErrorInfo +func (er *ErrorResponse) Detail() []ErrorInfo { + return er.Errors +} + +// ErrorInfo describes a server error returned from a registry. +type ErrorInfo struct { + Code string `json:"code"` + Message string `json:"message"` + Detail string `json:"detail"` +} diff --git a/specs-go/v1/repository.go b/specs-go/v1/repository.go new file mode 100644 index 00000000..5dae5707 --- /dev/null +++ b/specs-go/v1/repository.go @@ -0,0 +1,20 @@ +// Copyright 2019 The Linux Foundation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package v1 + +// RepositoryList returns a catalog of repositories maintained on the registry. +type RepositoryList struct { + Repositories []string `json:"repositories"` +} diff --git a/specs-go/v1/tags.go b/specs-go/v1/tags.go new file mode 100644 index 00000000..268e726e --- /dev/null +++ b/specs-go/v1/tags.go @@ -0,0 +1,21 @@ +// Copyright 2019 The Linux Foundation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package v1 + +// TagList is a list of tags for a given repository. +type TagList struct { + Name string `json:"name"` + Tags []string `json:"tags"` +} From 67ac29dcb7931502f9545ddceb1d016e92df0ffc Mon Sep 17 00:00:00 2001 From: Atlas Kerr Date: Thu, 31 Jan 2019 20:57:07 -0600 Subject: [PATCH 2/5] specs-go: Move version.go to specs-go dir. Signed-off-by: Atlas Kerr --- version.go => specs-go/version.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename version.go => specs-go/version.go (95%) diff --git a/version.go b/specs-go/version.go similarity index 95% rename from version.go rename to specs-go/version.go index aedfa5a0..b1038551 100644 --- a/version.go +++ b/specs-go/version.go @@ -1,4 +1,4 @@ -// Copyright 2018 The Linux Foundation +// Copyright 2019 The Linux Foundation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package distspec +package specs import "fmt" From 17d27c0050bba58561b50ab1ee260fdad4d378f9 Mon Sep 17 00:00:00 2001 From: Atlas Kerr Date: Fri, 1 Feb 2019 00:18:01 -0600 Subject: [PATCH 3/5] *: Update version.go path. Signed-off-by: Atlas Kerr --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 535db5a8..372c4f3a 100644 --- a/Makefile +++ b/Makefile @@ -54,7 +54,7 @@ $(OUTPUT_DIRNAME)/$(DOC_FILENAME).html: header.html $(DOC_FILES) $(FIGURE_FILES) ls -sh $(realpath $@) endif -header.html: .tool/genheader.go version.go +header.html: .tool/genheader.go specs-go/version.go go run .tool/genheader.go > $@ install.tools: .install.gitvalidation From 1d17c9decdbc72f7586a14c24ae3f7d307033320 Mon Sep 17 00:00:00 2001 From: Atlas Kerr Date: Fri, 1 Feb 2019 00:25:31 -0600 Subject: [PATCH 4/5] .tool: Update import paths. Signed-off-by: Atlas Kerr --- .tool/genheader.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.tool/genheader.go b/.tool/genheader.go index c8fa3457..5b89e97d 100644 --- a/.tool/genheader.go +++ b/.tool/genheader.go @@ -22,7 +22,7 @@ import ( "strings" "text/template" - distspec "github.com/opencontainers/distribution-spec" + specs "github.com/opencontainers/distribution-spec/specs-go" ) var headerTemplate = template.Must(template.New("gen").Parse(`distribution-spec {{.Version}} @@ -35,10 +35,10 @@ type Obj struct { func main() { obj := Obj{ - Version: distspec.Version, - Branch: distspec.Version, + Version: specs.Version, + Branch: specs.Version, } - if strings.HasSuffix(distspec.Version, "-dev") { + if strings.HasSuffix(specs.Version, "-dev") { cmd := exec.Command("git", "log", "-1", `--pretty=%H`, "HEAD") var out bytes.Buffer cmd.Stdout = &out From d10547bdcf1f4050b45e2f45b2e58aeb189807fb Mon Sep 17 00:00:00 2001 From: Atlas Kerr Date: Fri, 1 Feb 2019 00:32:12 -0600 Subject: [PATCH 5/5] specs-go: Add ErrRegistry variable. Signed-off-by: Atlas Kerr --- specs-go/v1/error.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/specs-go/v1/error.go b/specs-go/v1/error.go index c25f3c76..2be9162f 100644 --- a/specs-go/v1/error.go +++ b/specs-go/v1/error.go @@ -19,9 +19,12 @@ type ErrorResponse struct { Errors []ErrorInfo `json:"errors"` } +// ErrRegistry is the string returned by and ErrorResponse error. +var ErrRegistry = "distribution: registry returned error" + // Error implements the Error interface. func (er *ErrorResponse) Error() string { - return "distribution: registry returned error" + return ErrRegistry } // Detail returns an ErrorInfo