fix: json tags for label mappings

Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
pull/11602/head
Leonardo Di Donato 2019-01-24 16:44:31 +01:00 committed by Leo Di Donato
parent bd8bb5cb52
commit 4d5f39334e
1 changed files with 10 additions and 7 deletions

View File

@ -68,19 +68,22 @@ func (l *Label) Validate() error {
// It should not be shared directly over the HTTP API. // It should not be shared directly over the HTTP API.
type LabelMapping struct { type LabelMapping struct {
LabelID ID `json:"labelID"` LabelID ID `json:"labelID"`
ResourceID ID ResourceID ID `json:"resourceID"`
ResourceType ResourceType `json:"resourceType"`
} }
// Validate returns an error if the mapping is invalid. // Validate returns an error if the mapping is invalid.
func (l *LabelMapping) Validate() error { func (l *LabelMapping) Validate() error {
if !l.LabelID.Valid() {
// todo(leodido) > check LabelID is valid too? return &Error{
Code: EInvalid,
Msg: "label id is required",
}
}
if !l.ResourceID.Valid() { if !l.ResourceID.Valid() {
return &Error{ return &Error{
Code: EInvalid, Code: EInvalid,
Msg: "resourceID is required", Msg: "resource id is required",
} }
} }
if err := l.ResourceType.Valid(); err != nil { if err := l.ResourceType.Valid(); err != nil {