From 4d5f39334e08f46ee37130aa6155c4125f0ac71c Mon Sep 17 00:00:00 2001 From: Leonardo Di Donato Date: Thu, 24 Jan 2019 16:44:31 +0100 Subject: [PATCH] fix: json tags for label mappings Signed-off-by: Leonardo Di Donato --- label.go | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/label.go b/label.go index 4e3ddc7ade..4cfd7ff897 100644 --- a/label.go +++ b/label.go @@ -67,20 +67,23 @@ func (l *Label) Validate() error { // LabelMapping is used to map resource to its labels. // It should not be shared directly over the HTTP API. type LabelMapping struct { - LabelID ID `json:"labelID"` - ResourceID ID - ResourceType + LabelID ID `json:"labelID"` + ResourceID ID `json:"resourceID"` + ResourceType `json:"resourceType"` } // Validate returns an error if the mapping is invalid. func (l *LabelMapping) Validate() error { - - // todo(leodido) > check LabelID is valid too? - + if !l.LabelID.Valid() { + return &Error{ + Code: EInvalid, + Msg: "label id is required", + } + } if !l.ResourceID.Valid() { return &Error{ Code: EInvalid, - Msg: "resourceID is required", + Msg: "resource id is required", } } if err := l.ResourceType.Valid(); err != nil {