fix(influxdb): label mappings reference label ID, resource ID, and resource type now

pull/11602/head
Leonardo Di Donato 2019-01-22 18:54:32 +01:00 committed by Leo Di Donato
parent ead0cb3dcf
commit 72679393b9
1 changed files with 12 additions and 2 deletions

View File

@ -67,18 +67,28 @@ 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
LabelID ID `json:"labelID"`
ResourceID ID
ResourceType
}
// Validate returns an error if the mapping is invalid.
func (l *LabelMapping) Validate() error {
// todo(leodido) > check LabelID is valid too?
if !l.ResourceID.Valid() {
return &Error{
Code: EInvalid,
Msg: "resourceID is required",
}
}
if err := l.ResourceType.Valid(); err != nil {
return &Error{
Code: EInvalid,
Err: err,
}
}
return nil
}