forked from TrueCloudLab/distribution
Change errors export from Descriptors to ErrorDescriptors
This commit is contained in:
parent
e14e5d14b1
commit
92dca269f0
3 changed files with 8 additions and 8 deletions
|
@ -26,9 +26,9 @@ type ErrorDescriptor struct {
|
||||||
HTTPStatusCodes []int
|
HTTPStatusCodes []int
|
||||||
}
|
}
|
||||||
|
|
||||||
// Descriptors provides a list of HTTP API Error codes that may be encountered
|
// ErrorDescriptors provides a list of HTTP API Error codes that may be
|
||||||
// when interacting with the registry API.
|
// encountered when interacting with the registry API.
|
||||||
var Descriptors = []ErrorDescriptor{
|
var ErrorDescriptors = []ErrorDescriptor{
|
||||||
{
|
{
|
||||||
Code: ErrorCodeUnknown,
|
Code: ErrorCodeUnknown,
|
||||||
Value: "UNKNOWN",
|
Value: "UNKNOWN",
|
||||||
|
@ -131,10 +131,10 @@ var errorCodeToDescriptors map[ErrorCode]ErrorDescriptor
|
||||||
var idToDescriptors map[string]ErrorDescriptor
|
var idToDescriptors map[string]ErrorDescriptor
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
errorCodeToDescriptors = make(map[ErrorCode]ErrorDescriptor, len(Descriptors))
|
errorCodeToDescriptors = make(map[ErrorCode]ErrorDescriptor, len(ErrorDescriptors))
|
||||||
idToDescriptors = make(map[string]ErrorDescriptor, len(Descriptors))
|
idToDescriptors = make(map[string]ErrorDescriptor, len(ErrorDescriptors))
|
||||||
|
|
||||||
for _, descriptor := range Descriptors {
|
for _, descriptor := range ErrorDescriptors {
|
||||||
errorCodeToDescriptors[descriptor.Code] = descriptor
|
errorCodeToDescriptors[descriptor.Code] = descriptor
|
||||||
idToDescriptors[descriptor.Value] = descriptor
|
idToDescriptors[descriptor.Value] = descriptor
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ import (
|
||||||
// TestErrorCodes ensures that error code format, mappings and
|
// TestErrorCodes ensures that error code format, mappings and
|
||||||
// marshaling/unmarshaling. round trips are stable.
|
// marshaling/unmarshaling. round trips are stable.
|
||||||
func TestErrorCodes(t *testing.T) {
|
func TestErrorCodes(t *testing.T) {
|
||||||
for _, desc := range Descriptors {
|
for _, desc := range ErrorDescriptors {
|
||||||
if desc.Code.String() != desc.Value {
|
if desc.Code.String() != desc.Value {
|
||||||
t.Fatalf("error code string incorrect: %q != %q", desc.Code.String(), desc.Value)
|
t.Fatalf("error code string incorrect: %q != %q", desc.Code.String(), desc.Value)
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,7 +61,7 @@ func dumpErrors(wr io.Writer) {
|
||||||
|
|
||||||
fmt.Fprintln(writer, "\n"+divider)
|
fmt.Fprintln(writer, "\n"+divider)
|
||||||
|
|
||||||
for _, descriptor := range errors.Descriptors {
|
for _, descriptor := range errors.ErrorDescriptors {
|
||||||
fmt.Fprint(writer, "|")
|
fmt.Fprint(writer, "|")
|
||||||
|
|
||||||
v := reflect.ValueOf(descriptor)
|
v := reflect.ValueOf(descriptor)
|
||||||
|
|
Loading…
Reference in a new issue