From 66d155cdb3efec50508bd3e14fdd49e8639a5066 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Wed, 10 Mar 2021 18:22:48 +0100 Subject: [PATCH] Group related types --- pkg/icingadb/v1/customvar.go | 10 ++++++++++ pkg/icingadb/v1/customvar_flat.go | 14 -------------- pkg/icingadb/v1/host.go | 12 ++++++++++++ pkg/icingadb/v1/host_customvar.go | 19 ------------------- pkg/icingadb/v1/service.go | 11 +++++++++++ pkg/icingadb/v1/service_customvar.go | 19 ------------------- 6 files changed, 33 insertions(+), 52 deletions(-) delete mode 100644 pkg/icingadb/v1/customvar_flat.go delete mode 100644 pkg/icingadb/v1/host_customvar.go delete mode 100644 pkg/icingadb/v1/service_customvar.go diff --git a/pkg/icingadb/v1/customvar.go b/pkg/icingadb/v1/customvar.go index 606921e8..003bfd16 100644 --- a/pkg/icingadb/v1/customvar.go +++ b/pkg/icingadb/v1/customvar.go @@ -2,6 +2,7 @@ package v1 import ( "github.com/icinga/icingadb/pkg/contracts" + "github.com/icinga/icingadb/pkg/types" ) type Customvar struct { @@ -11,6 +12,15 @@ type Customvar struct { Value string `json:"value"` } +type CustomvarFlat struct { + EntityWithoutChecksum `json:",inline"` + EnvironmentMeta `json:",inline"` + CustomvarId types.Binary `json:"customvar_id"` + Flatname string `json:"flatname"` + FlatnameChecksum types.Binary `json:"flatname_checksum"` + Flatvalue string `json:"flatvalue"` +} + func NewCustomvar() contracts.Entity { return &Customvar{} } diff --git a/pkg/icingadb/v1/customvar_flat.go b/pkg/icingadb/v1/customvar_flat.go deleted file mode 100644 index e23d75ca..00000000 --- a/pkg/icingadb/v1/customvar_flat.go +++ /dev/null @@ -1,14 +0,0 @@ -package v1 - -import ( - "github.com/icinga/icingadb/pkg/types" -) - -type CustomvarFlat struct { - EntityWithoutChecksum `json:",inline"` - EnvironmentMeta `json:",inline"` - CustomvarId types.Binary `json:"customvar_id"` - Flatname string `json:"flatname"` - FlatnameChecksum types.Binary `json:"flatname_checksum"` - Flatvalue string `json:"flatvalue"` -} diff --git a/pkg/icingadb/v1/host.go b/pkg/icingadb/v1/host.go index bc1a0af7..01b413af 100644 --- a/pkg/icingadb/v1/host.go +++ b/pkg/icingadb/v1/host.go @@ -2,6 +2,7 @@ package v1 import ( "github.com/icinga/icingadb/pkg/contracts" + "github.com/icinga/icingadb/pkg/types" ) type Host struct { @@ -10,10 +11,21 @@ type Host struct { Address6 string `json:"address6"` } +type HostCustomvar struct { + EntityWithoutChecksum `json:",inline"` + EnvironmentMeta `json:",inline"` + HostId types.Binary `json:"object_id"` + CustomvarId types.Binary `json:"customvar_id"` +} + func NewHost() contracts.Entity { return &Host{} } +func NewHostCustomvar() contracts.Entity { + return &HostCustomvar{} +} + // Assert interface compliance. var ( _ contracts.Initer = (*Host)(nil) diff --git a/pkg/icingadb/v1/host_customvar.go b/pkg/icingadb/v1/host_customvar.go deleted file mode 100644 index 4bd61425..00000000 --- a/pkg/icingadb/v1/host_customvar.go +++ /dev/null @@ -1,19 +0,0 @@ -package v1 - -import ( - "github.com/icinga/icingadb/pkg/contracts" - "github.com/icinga/icingadb/pkg/types" -) - -type HostCustomvar struct { - EntityWithoutChecksum `json:",inline"` - EnvironmentMeta `json:",inline"` - HostId types.Binary `json:"object_id"` - CustomvarId types.Binary `json:"customvar_id"` -} - -func NewHostCustomvar() contracts.Entity { - cv := &HostCustomvar{} - - return cv -} diff --git a/pkg/icingadb/v1/service.go b/pkg/icingadb/v1/service.go index b29d8e25..2011ed1e 100644 --- a/pkg/icingadb/v1/service.go +++ b/pkg/icingadb/v1/service.go @@ -10,10 +10,21 @@ type Service struct { HostId types.Binary `json:"host_id"` } +type ServiceCustomvar struct { + EntityWithoutChecksum `json:",inline"` + EnvironmentMeta `json:",inline"` + ServiceId types.Binary `json:"object_id"` + CustomvarId types.Binary `json:"customvar_id"` +} + func NewService() contracts.Entity { return &Service{} } +func NewServiceCustomvar() contracts.Entity { + return &ServiceCustomvar{} +} + // Assert interface compliance. var ( _ contracts.Initer = (*Service)(nil) diff --git a/pkg/icingadb/v1/service_customvar.go b/pkg/icingadb/v1/service_customvar.go deleted file mode 100644 index 75e4189c..00000000 --- a/pkg/icingadb/v1/service_customvar.go +++ /dev/null @@ -1,19 +0,0 @@ -package v1 - -import ( - "github.com/icinga/icingadb/pkg/contracts" - "github.com/icinga/icingadb/pkg/types" -) - -type ServiceCustomvar struct { - EntityWithoutChecksum `json:",inline"` - EnvironmentMeta `json:",inline"` - ServiceId types.Binary `json:"object_id"` - CustomvarId types.Binary `json:"customvar_id"` -} - -func NewServiceCustomvar() contracts.Entity { - cv := &ServiceCustomvar{} - - return cv -}