Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Go structs #48

Merged
merged 5 commits into from
Dec 16, 2019
Merged
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
8 changes: 4 additions & 4 deletions .tool/genheader.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(`<title>distribution-spec {{.Version}}</title>
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
40 changes: 40 additions & 0 deletions specs-go/v1/error.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// 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"`
}

// 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 ErrRegistry
}

// 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"`
}
20 changes: 20 additions & 0 deletions specs-go/v1/repository.go
Original file line number Diff line number Diff line change
@@ -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"`
}
21 changes: 21 additions & 0 deletions specs-go/v1/tags.go
Original file line number Diff line number Diff line change
@@ -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"`
}
4 changes: 2 additions & 2 deletions version.go → specs-go/version.go
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package distspec
package specs

import "fmt"

Expand Down