Skip to content

Commit

Permalink
specs-go: Add go structs.
Browse files Browse the repository at this point in the history
Signed-off-by: Atlas Kerr <[email protected]>
  • Loading branch information
bsatlas committed Jan 31, 2019
1 parent fb183ce commit dfd491b
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 0 deletions.
37 changes: 37 additions & 0 deletions specs-go/v1/error.go
Original file line number Diff line number Diff line change
@@ -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"`
}
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"`
}

0 comments on commit dfd491b

Please sign in to comment.