Skip to content

Commit

Permalink
Update cluster metadata detector
Browse files Browse the repository at this point in the history
Signed-off-by: Tamal Saha <[email protected]>
  • Loading branch information
tamalsaha committed Jun 11, 2024
1 parent b3cecde commit 500b3be
Show file tree
Hide file tree
Showing 417 changed files with 55,586 additions and 21,933 deletions.
46 changes: 22 additions & 24 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
module go.bytebuilders.dev/audit

go 1.22.0
go 1.22.1

toolchain go1.22.1
toolchain go1.22.4

require (
github.com/cloudevents/sdk-go/v2 v2.15.2
github.com/nats-io/nats.go v1.33.1
github.com/nats-io/nats.go v1.35.0
github.com/pkg/errors v0.9.1
go.bytebuilders.dev/license-verifier v0.14.1
go.bytebuilders.dev/license-verifier/kubernetes v0.14.1
gomodules.xyz/counter v0.0.1
gomodules.xyz/sync v0.1.0
k8s.io/api v0.29.2
k8s.io/apimachinery v0.29.2
k8s.io/client-go v0.29.2
k8s.io/api v0.30.1
k8s.io/apimachinery v0.30.1
k8s.io/client-go v0.30.1
k8s.io/klog/v2 v2.120.1
kmodules.xyz/client-go v0.29.14
kmodules.xyz/custom-resources v0.29.1
kmodules.xyz/resource-metadata v0.18.5-0.20240515103715-d1619175e49a
sigs.k8s.io/controller-runtime v0.17.4
kmodules.xyz/client-go v0.30.3
kmodules.xyz/resource-metadata v0.18.7
sigs.k8s.io/controller-runtime v0.18.4
)

require (
Expand All @@ -38,7 +37,7 @@ require (
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
github.com/evanphx/json-patch v5.7.0+incompatible // indirect
github.com/evanphx/json-patch/v5 v5.8.0 // indirect
github.com/evanphx/json-patch/v5 v5.9.0 // indirect
github.com/fatih/structs v1.1.0 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/go-logr/logr v1.4.1 // indirect
Expand Down Expand Up @@ -91,16 +90,16 @@ require (
go.bytebuilders.dev/license-proxyserver v0.0.8 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.26.0 // indirect
golang.org/x/crypto v0.21.0 // indirect
golang.org/x/crypto v0.22.0 // indirect
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect
golang.org/x/net v0.23.0 // indirect
golang.org/x/net v0.24.0 // indirect
golang.org/x/oauth2 v0.15.0 // indirect
golang.org/x/sync v0.5.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/term v0.18.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.19.0 // indirect
golang.org/x/term v0.19.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.5.0 // indirect
gomodules.xyz/encoding v0.0.7 // indirect
gomodules.xyz/encoding v0.0.8 // indirect
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
gomodules.xyz/jsonpath v0.0.2 // indirect
gomodules.xyz/mergo v0.3.13 // indirect
Expand All @@ -111,16 +110,15 @@ require (
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/apiextensions-apiserver v0.29.2 // indirect
k8s.io/apiserver v0.29.2 // indirect
k8s.io/component-base v0.29.2 // indirect
k8s.io/kube-aggregator v0.29.2 // indirect
k8s.io/kube-openapi v0.0.0-20240403164606-bc84c2ddaf99 // indirect
k8s.io/apiextensions-apiserver v0.30.1 // indirect
k8s.io/apiserver v0.30.1 // indirect
k8s.io/kube-aggregator v0.30.1 // indirect
k8s.io/kube-openapi v0.0.0-20240521193020-835d969ad83a // indirect
k8s.io/utils v0.0.0-20240102154912-e7106e64919e // indirect
kmodules.xyz/apiversion v0.2.0 // indirect
kmodules.xyz/go-containerregistry v0.0.12 // indirect
kmodules.xyz/offshoot-api v0.29.0 // indirect
kmodules.xyz/resource-metrics v0.29.5 // indirect
kmodules.xyz/offshoot-api v0.29.4 // indirect
kmodules.xyz/resource-metrics v0.30.1 // indirect
sigs.k8s.io/cli-utils v0.34.0 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
Expand Down
103 changes: 50 additions & 53 deletions go.sum

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions lib/publisher.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ import (
kmapi "kmodules.xyz/client-go/api/v1"
"kmodules.xyz/client-go/discovery"
"kmodules.xyz/client-go/tools/clusterid"
auditorapi "kmodules.xyz/custom-resources/apis/auditor/v1alpha1"
"kmodules.xyz/custom-resources/util/siteinfo"
identityapi "kmodules.xyz/resource-metadata/apis/identity/v1alpha1"
identitylib "kmodules.xyz/resource-metadata/pkg/identity"
cachex "sigs.k8s.io/controller-runtime/pkg/cache"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/client/apiutil"
Expand Down Expand Up @@ -71,7 +71,7 @@ type EventPublisher struct {
createEvent EventCreator

siMutex gosync.Mutex
si *auditorapi.SiteInfo
si *identityapi.SiteInfo
}

func NewEventPublisher(
Expand Down Expand Up @@ -232,16 +232,16 @@ func (p *EventPublisher) SetupSiteInfoPublisherWithManager(mgr manager.Manager)

func (p *EventPublisher) setupSiteInfoPublisher(cfg *rest.Config, kc kubernetes.Interface, nodeInformer cachex.Informer, listNodes funcNodeLister) error {
var err error
p.si, err = siteinfo.GetSiteInfo(cfg, kc, nil, "")
p.si, err = identitylib.GetSiteInfo(cfg, kc, nil, "")
if err != nil {
return err
}
if p.si.Product == nil {
p.si.Product = new(auditorapi.ProductInfo)
p.si.Product = new(identityapi.ProductInfo)
}

event := func(_ client.Object) (*api.Event, error) {
cmeta, err := clusterid.ClusterMetadata(kc.CoreV1().Namespaces())
cmeta, err := clusterid.ClusterMetadata(kc)
if err != nil {
return nil, err
}
Expand All @@ -252,7 +252,7 @@ func (p *EventPublisher) setupSiteInfoPublisher(cfg *rest.Config, kc kubernetes.

p.siMutex.Lock()
p.si.Kubernetes.Cluster = cmeta
siteinfo.RefreshNodeStats(p.si, nodes)
identitylib.RefreshNodeStats(p.si, nodes)
p.siMutex.Unlock()

p.once.Do(p.connect)
Expand All @@ -266,10 +266,10 @@ func (p *EventPublisher) setupSiteInfoPublisher(cfg *rest.Config, kc kubernetes.
ev := &api.Event{
Resource: p.si,
ResourceID: kmapi.ResourceID{
Group: auditorapi.SchemeGroupVersion.Group,
Version: auditorapi.SchemeGroupVersion.Version,
Name: auditorapi.ResourceSiteInfos,
Kind: auditorapi.ResourceKindSiteInfo,
Group: identityapi.SchemeGroupVersion.Group,
Version: identityapi.SchemeGroupVersion.Version,
Name: identityapi.ResourceSiteInfos,
Kind: identityapi.ResourceKindSiteInfo,
Scope: kmapi.ClusterScoped,
},
LicenseID: licenseID,
Expand Down
13 changes: 13 additions & 0 deletions vendor/github.com/evanphx/json-patch/v5/internal/json/encode.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 2 additions & 22 deletions vendor/github.com/evanphx/json-patch/v5/internal/json/stream.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

52 changes: 29 additions & 23 deletions vendor/github.com/evanphx/json-patch/v5/merge.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 500b3be

Please sign in to comment.