icinga

Icinga2 API client in Go
git clone https://git.olowe.co/icinga
Log | Files | Refs | README | LICENSE

commit fc8956331f70b23ffe89c8307de77bbc0ecccb39
parent 730f973b47017c91cc9487391554c7ecc861dfc8
Author: Oliver Lowe <o@olowe.co>
Date:   Wed, 12 Jan 2022 07:10:19 +1100

Deduplicate case conditions

Encoding a Host, Service and User as JSON is the same so
there's no point having different statements.

Diffstat:
Mobject.go | 10+---------
1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/object.go b/object.go @@ -75,15 +75,7 @@ func (c *Client) filterObjects(objpath, expr string) ([]object, error) { func (c *Client) createObject(obj object) error { buf := &bytes.Buffer{} switch v := obj.(type) { - case Host: - if err := json.NewEncoder(buf).Encode(v); err != nil { - return err - } - case Service: - if err := json.NewEncoder(buf).Encode(v); err != nil { - return err - } - case User: + case Host, Service, User: if err := json.NewEncoder(buf).Encode(v); err != nil { return err }