Skip to content

Commit

Permalink
Use types from Icinga Go Library
Browse files Browse the repository at this point in the history
  • Loading branch information
lippserd committed May 24, 2024
1 parent 1a33c5f commit be1e77e
Show file tree
Hide file tree
Showing 33 changed files with 107 additions and 528 deletions.
12 changes: 6 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
module github.com/icinga/icinga-kubernetes

go 1.21
go 1.22

require (
github.com/creasty/defaults v1.7.0
github.com/go-co-op/gocron v1.37.0
github.com/go-logr/logr v1.4.1
github.com/go-sql-driver/mysql v1.8.0
github.com/go-sql-driver/mysql v1.8.1
github.com/goccy/go-yaml v1.11.3
github.com/google/uuid v1.6.0
github.com/jmoiron/sqlx v1.3.5
github.com/icinga/icinga-go-library v0.1.0
github.com/jmoiron/sqlx v1.4.0
github.com/lib/pq v1.10.9
github.com/pkg/errors v0.9.1
golang.org/x/exp v0.0.0-20240222234643-814bf88cf225
golang.org/x/sync v0.6.0
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842
golang.org/x/sync v0.7.0
k8s.io/api v0.29.2
k8s.io/apimachinery v0.29.2
k8s.io/client-go v0.29.2
Expand All @@ -40,7 +41,6 @@ require (
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-sqlite3 v1.14.16 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
Expand Down
29 changes: 14 additions & 15 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD87
github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA=
github.com/go-playground/validator/v10 v10.4.1 h1:pH2c5ADXtd66mxoE0Zm9SUhxE20r7aM3F26W0hOn+GE=
github.com/go-playground/validator/v10 v10.4.1/go.mod h1:nlOn6nFhuKACm19sB/8EGNn9GlaMV7XkbRSipzJ0Ii4=
github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
github.com/go-sql-driver/mysql v1.8.0 h1:UtktXaU2Nb64z/pLiGIxY4431SJ4/dR5cjMmlVHgnT4=
github.com/go-sql-driver/mysql v1.8.0/go.mod h1:wEBSXgmK//2ZFJyE+qWnIsVGmvmEKlqwuVSjsCm7DZg=
github.com/go-sql-driver/mysql v1.8.1 h1:LedoTUt/eveggdHS9qUFC1EFSa8bU2+1pZjSRpvNJ1Y=
github.com/go-sql-driver/mysql v1.8.1/go.mod h1:wEBSXgmK//2ZFJyE+qWnIsVGmvmEKlqwuVSjsCm7DZg=
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI=
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls=
github.com/goccy/go-yaml v1.11.3 h1:B3W9IdWbvrUu2OYQGwvU1nZtvMQJPBKgBUuweJjLj6I=
Expand All @@ -53,10 +52,12 @@ github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLe
github.com/google/uuid v1.4.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/icinga/icinga-go-library v0.1.0 h1:CKnEBsxl65Ik0F0yHn2N7dX77mIFanPye927lsqu9yI=
github.com/icinga/icinga-go-library v0.1.0/go.mod h1:YN7XJN3W0FodD+j4kirO89zk2tgvanXWt1RMV8UgOLo=
github.com/imdario/mergo v0.3.16 h1:wwQJbIsHYGMUyLSPrEq1CT16AhnhNJQ51+4fdHUnCl4=
github.com/imdario/mergo v0.3.16/go.mod h1:WBLT9ZmE3lPoWsEzCh9LPo3TiwVN+ZKEjmz+hD27ysY=
github.com/jmoiron/sqlx v1.3.5 h1:vFFPA71p1o5gAeqtEAwLU4dnX2napprKtHr7PYIcN3g=
github.com/jmoiron/sqlx v1.3.5/go.mod h1:nRVWtLre0KfCLJvgxzCsLVMogSvQ1zNJtpYr2Ccp0mQ=
github.com/jmoiron/sqlx v1.4.0 h1:1PLqN7S1UYp5t4SrVVnt4nUVNemrDAtxlulVe+Qgm3o=
github.com/jmoiron/sqlx v1.4.0/go.mod h1:ZrZ7UsYB/weZdl2Bxg6jCRO9c3YHl8r3ahlKmRT4JLY=
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
Expand All @@ -74,7 +75,6 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y=
github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII=
github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw=
github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
Expand All @@ -84,9 +84,8 @@ github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovk
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-sqlite3 v1.14.6/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
github.com/mattn/go-sqlite3 v1.14.16 h1:yOQRA0RpS5PFz/oikGwBEqvAWhWg5ufRz4ETLjwpU1Y=
github.com/mattn/go-sqlite3 v1.14.16/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg=
github.com/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o4kU=
github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
Expand Down Expand Up @@ -132,8 +131,8 @@ golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPh
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA=
golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs=
golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 h1:LfspQV/FYTatPTr/3HzIcmiUFH7PGP+OQ6mgDYo3yuQ=
golang.org/x/exp v0.0.0-20240222234643-814bf88cf225/go.mod h1:CxmFvTBINI24O/j8iY7H1xHzx2i4OsyguNBmN/uPtqc=
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 h1:vr/HnozRka3pE4EsMEg1lgkXJkTFJCVUX+S/ZT6wYzM=
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc=
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
Expand All @@ -151,8 +150,8 @@ golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ=
golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
Expand Down Expand Up @@ -181,8 +180,8 @@ golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtn
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/tools v0.18.0 h1:k8NLag8AGHnn+PHbl7g43CtqZAwG60vZkLqgyZgIHgQ=
golang.org/x/tools v0.18.0/go.mod h1:GL7B4CwcLLeo59yx/9UWWuNOW1n3VZ4f5axWfML7Lcg=
golang.org/x/tools v0.21.0 h1:qc0xYgIbsSDt9EyWz05J5wfa7LOVW0YTLOXrqdLAWIw=
golang.org/x/tools v0.21.0/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
Expand Down
2 changes: 1 addition & 1 deletion pkg/database/cleanup.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package database
import (
"context"
"fmt"
"github.com/icinga/icinga-go-library/types"
"github.com/icinga/icinga-kubernetes/internal"
"github.com/icinga/icinga-kubernetes/pkg/com"
"github.com/icinga/icinga-kubernetes/pkg/types"
"time"
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/database/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
sqlDriver "database/sql/driver"
"fmt"
"github.com/go-sql-driver/mysql"
"github.com/icinga/icinga-go-library/types"
"github.com/icinga/icinga-kubernetes/pkg/strcase"
"github.com/icinga/icinga-kubernetes/pkg/types"
"github.com/lib/pq"
"github.com/pkg/errors"
"net"
Expand Down
9 changes: 5 additions & 4 deletions pkg/schema/v1/config_map.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package v1

import (
"github.com/icinga/icinga-go-library/types"
"github.com/icinga/icinga-go-library/utils"
"github.com/icinga/icinga-kubernetes/pkg/database"
"github.com/icinga/icinga-kubernetes/pkg/types"
kcorev1 "k8s.io/api/core/v1"
kmetav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"strings"
Expand Down Expand Up @@ -37,7 +38,7 @@ func (c *ConfigMap) Obtain(k8s kmetav1.Object) {

configMap := k8s.(*kcorev1.ConfigMap)

c.Id = types.Checksum(configMap.Namespace + "/" + configMap.Name)
c.Id = utils.Checksum(configMap.Namespace + "/" + configMap.Name)

var immutable bool
if configMap.Immutable != nil {
Expand All @@ -49,7 +50,7 @@ func (c *ConfigMap) Obtain(k8s kmetav1.Object) {
}

for dataName, dataValue := range configMap.Data {
dataId := types.Checksum(dataName + ":" + dataValue)
dataId := utils.Checksum(dataName + ":" + dataValue)
c.Data = append(c.Data, Data{
Id: dataId,
Name: dataName,
Expand All @@ -62,7 +63,7 @@ func (c *ConfigMap) Obtain(k8s kmetav1.Object) {
}

for labelName, labelValue := range configMap.Labels {
labelId := types.Checksum(strings.ToLower(labelName + ":" + labelValue))
labelId := utils.Checksum(strings.ToLower(labelName + ":" + labelValue))
c.Labels = append(c.Labels, Label{
Id: labelId,
Name: labelName,
Expand Down
2 changes: 1 addition & 1 deletion pkg/schema/v1/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import (
"database/sql"
"errors"
"github.com/go-co-op/gocron"
"github.com/icinga/icinga-go-library/types"
"github.com/icinga/icinga-kubernetes/pkg/com"
"github.com/icinga/icinga-kubernetes/pkg/database"
"github.com/icinga/icinga-kubernetes/pkg/types"
"golang.org/x/sync/errgroup"
"io"
kcorev1 "k8s.io/api/core/v1"
Expand Down
2 changes: 1 addition & 1 deletion pkg/schema/v1/contracts.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package v1

import (
"github.com/icinga/icinga-kubernetes/pkg/types"
"github.com/icinga/icinga-go-library/types"
kmetav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
ktypes "k8s.io/apimachinery/pkg/types"
)
Expand Down
7 changes: 4 additions & 3 deletions pkg/schema/v1/cron_job.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package v1

import (
"github.com/icinga/icinga-go-library/types"
"github.com/icinga/icinga-go-library/utils"
"github.com/icinga/icinga-kubernetes/pkg/database"
"github.com/icinga/icinga-kubernetes/pkg/types"
kbatchv1 "k8s.io/api/batch/v1"
kmetav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"strings"
Expand Down Expand Up @@ -67,7 +68,7 @@ func (c *CronJob) Obtain(k8s kmetav1.Object) {
c.LastSuccessfulTime = types.UnixMilli(cronJob.Status.LastSuccessfulTime.Time)
}

c.Id = types.Checksum(c.Namespace + "/" + c.Name)
c.Id = utils.Checksum(c.Namespace + "/" + c.Name)
c.Schedule = cronJob.Spec.Schedule
c.Timezone = timeZone
c.StartingDeadlineSeconds = startingDeadlineSeconds
Expand All @@ -78,7 +79,7 @@ func (c *CronJob) Obtain(k8s kmetav1.Object) {
c.Active = int32(len(cronJob.Status.Active))

for labelName, labelValue := range cronJob.Labels {
labelId := types.Checksum(strings.ToLower(labelName + ":" + labelValue))
labelId := utils.Checksum(strings.ToLower(labelName + ":" + labelValue))
c.Labels = append(c.Labels, Label{
Id: labelId,
Name: labelName,
Expand Down
7 changes: 4 additions & 3 deletions pkg/schema/v1/daemon_set.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package v1

import (
"github.com/icinga/icinga-go-library/types"
"github.com/icinga/icinga-go-library/utils"
"github.com/icinga/icinga-kubernetes/pkg/database"
"github.com/icinga/icinga-kubernetes/pkg/strcase"
"github.com/icinga/icinga-kubernetes/pkg/types"
kappsv1 "k8s.io/api/apps/v1"
kmetav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"strings"
Expand Down Expand Up @@ -49,7 +50,7 @@ func (d *DaemonSet) Obtain(k8s kmetav1.Object) {

daemonSet := k8s.(*kappsv1.DaemonSet)

d.Id = types.Checksum(daemonSet.Namespace + "/" + daemonSet.Name)
d.Id = utils.Checksum(daemonSet.Namespace + "/" + daemonSet.Name)
d.UpdateStrategy = strcase.Snake(string(daemonSet.Spec.UpdateStrategy.Type))
d.MinReadySeconds = daemonSet.Spec.MinReadySeconds
d.DesiredNumberScheduled = daemonSet.Status.DesiredNumberScheduled
Expand All @@ -72,7 +73,7 @@ func (d *DaemonSet) Obtain(k8s kmetav1.Object) {
}

for labelName, labelValue := range daemonSet.Labels {
labelId := types.Checksum(strings.ToLower(labelName + ":" + labelValue))
labelId := utils.Checksum(strings.ToLower(labelName + ":" + labelValue))
d.Labels = append(d.Labels, Label{
Id: labelId,
Name: labelName,
Expand Down
2 changes: 1 addition & 1 deletion pkg/schema/v1/data.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package v1

import "github.com/icinga/icinga-kubernetes/pkg/types"
import "github.com/icinga/icinga-go-library/types"

type Data struct {
Id types.Binary
Expand Down
7 changes: 4 additions & 3 deletions pkg/schema/v1/deployment.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package v1

import (
"github.com/icinga/icinga-go-library/types"
"github.com/icinga/icinga-go-library/utils"
"github.com/icinga/icinga-kubernetes/pkg/database"
"github.com/icinga/icinga-kubernetes/pkg/strcase"
"github.com/icinga/icinga-kubernetes/pkg/types"
kappsv1 "k8s.io/api/apps/v1"
kmetav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"strings"
Expand Down Expand Up @@ -58,7 +59,7 @@ func (d *Deployment) Obtain(k8s kmetav1.Object) {
if deployment.Spec.ProgressDeadlineSeconds != nil {
progressDeadlineSeconds = *deployment.Spec.ProgressDeadlineSeconds
}
d.Id = types.Checksum(deployment.Namespace + "/" + deployment.Name)
d.Id = utils.Checksum(deployment.Namespace + "/" + deployment.Name)
d.DesiredReplicas = replicas
d.Strategy = strcase.Snake(string(deployment.Spec.Strategy.Type))
d.MinReadySeconds = deployment.Spec.MinReadySeconds
Expand Down Expand Up @@ -86,7 +87,7 @@ func (d *Deployment) Obtain(k8s kmetav1.Object) {
}

for labelName, labelValue := range deployment.Labels {
labelId := types.Checksum(strings.ToLower(labelName + ":" + labelValue))
labelId := utils.Checksum(strings.ToLower(labelName + ":" + labelValue))
d.Labels = append(d.Labels, Label{
Id: labelId,
Name: labelName,
Expand Down
9 changes: 5 additions & 4 deletions pkg/schema/v1/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ package v1

import (
"database/sql"
"github.com/icinga/icinga-go-library/types"
"github.com/icinga/icinga-go-library/utils"
"github.com/icinga/icinga-kubernetes/pkg/database"
"github.com/icinga/icinga-kubernetes/pkg/types"
v1 "k8s.io/api/core/v1"
kdiscoveryv1 "k8s.io/api/discovery/v1"
kmetav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -60,11 +61,11 @@ func (e *EndpointSlice) Obtain(k8s kmetav1.Object) {

endpointSlice := k8s.(*kdiscoveryv1.EndpointSlice)

e.Id = types.Checksum(strings.ToLower(endpointSlice.Namespace + "/" + endpointSlice.Name))
e.Id = utils.Checksum(strings.ToLower(endpointSlice.Namespace + "/" + endpointSlice.Name))
e.AddressType = string(endpointSlice.AddressType)

for labelName, labelValue := range endpointSlice.Labels {
labelId := types.Checksum(strings.ToLower(labelName + ":" + labelValue))
labelId := utils.Checksum(strings.ToLower(labelName + ":" + labelValue))
e.Labels = append(e.Labels, Label{
Id: labelId,
Name: labelName,
Expand Down Expand Up @@ -113,7 +114,7 @@ func (e *EndpointSlice) Obtain(k8s kmetav1.Object) {
appProtocol = *endpointPort.AppProtocol
}
for _, address := range endpoint.Addresses {
endpointId := types.Checksum(e.Id.String() + name + address + string(port))
endpointId := utils.Checksum(e.Id.String() + name + address + string(port))
e.Endpoints = append(e.Endpoints, Endpoint{
Id: endpointId,
EndpointSliceId: e.Id,
Expand Down
5 changes: 3 additions & 2 deletions pkg/schema/v1/event.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package v1

import (
"github.com/icinga/icinga-kubernetes/pkg/types"
"github.com/icinga/icinga-go-library/types"
"github.com/icinga/icinga-go-library/utils"
keventsv1 "k8s.io/api/events/v1"
kmetav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
Expand Down Expand Up @@ -32,7 +33,7 @@ func (e *Event) Obtain(k8s kmetav1.Object) {

event := k8s.(*keventsv1.Event)

e.Id = types.Checksum(event.Namespace + "/" + event.Name)
e.Id = utils.Checksum(event.Namespace + "/" + event.Name)
e.ReportingController = event.ReportingController
e.ReportingInstance = event.ReportingInstance
e.Action = event.Action
Expand Down
Loading

0 comments on commit be1e77e

Please sign in to comment.