mirror of
https://github.com/Icinga/icingadb.git
synced 2026-05-28 04:35:54 -04:00
Make NameCiMeta an Initer
This commit is contained in:
parent
4d24c97d90
commit
ecf3dd74ae
5 changed files with 32 additions and 0 deletions
|
|
@ -54,3 +54,9 @@ type EntityFactoryFunc func() Entity
|
|||
type Waiter interface {
|
||||
Wait() error // Wait waits for execution to complete.
|
||||
}
|
||||
|
||||
// Initer implements the Init method,
|
||||
// which initializes the object in addition to zeroing.
|
||||
type Initer interface {
|
||||
Init() // Init initializes the object.
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package v1
|
||||
|
||||
import (
|
||||
"github.com/icinga/icingadb/pkg/contracts"
|
||||
"github.com/icinga/icingadb/pkg/types"
|
||||
)
|
||||
|
||||
|
|
@ -38,3 +39,8 @@ type Checkable struct {
|
|||
Zone string `json:"zone"`
|
||||
ZoneId types.Binary `json:"zone_id"`
|
||||
}
|
||||
|
||||
// Assert interface compliance.
|
||||
var (
|
||||
_ contracts.Initer = (*Checkable)(nil)
|
||||
)
|
||||
|
|
|
|||
|
|
@ -49,3 +49,8 @@ func NewHost() contracts.Entity {
|
|||
|
||||
return h
|
||||
}
|
||||
|
||||
// Assert interface compliance.
|
||||
var (
|
||||
_ contracts.Initer = (*Host)(nil)
|
||||
)
|
||||
|
|
|
|||
|
|
@ -51,3 +51,13 @@ type NameCiMeta struct {
|
|||
NameMeta
|
||||
NameCi *string `json:"name_ci"`
|
||||
}
|
||||
|
||||
// Init implements the contracts.Initer interface.
|
||||
func (n *NameCiMeta) Init() {
|
||||
n.NameCi = &n.Name
|
||||
}
|
||||
|
||||
// Assert interface compliance.
|
||||
var (
|
||||
_ contracts.Initer = (*NameCiMeta)(nil)
|
||||
)
|
||||
|
|
|
|||
|
|
@ -17,3 +17,8 @@ func NewService() contracts.Entity {
|
|||
|
||||
return s
|
||||
}
|
||||
|
||||
// Assert interface compliance.
|
||||
var (
|
||||
_ contracts.Initer = (*Service)(nil)
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue