Skip to content

Commit

Permalink
Fix linter errors
Browse files Browse the repository at this point in the history
  • Loading branch information
swiatekm committed Sep 30, 2024
1 parent 2b0ce89 commit 0f1cedc
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
10 changes: 6 additions & 4 deletions kubernetes/metadata/namespace.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,12 @@ func NewNamespaceMetadataGenerator(cfg *config.C, namespaces cache.Store, client

// Generate generates pod metadata from a resource object
// Metadata map is in the following form:
// {
// "kubernetes": {},
// "some.ecs.field": "asdf"
// }
//
// {
// "kubernetes": {},
// "some.ecs.field": "asdf"
// }
//
// All Kubernetes fields that need to be stored under kuberentes. prefix are populetad by
// GenerateK8s method while fields that are part of ECS are generated by GenerateECS method
func (n *namespace) Generate(obj kubernetes.Resource, opts ...FieldOptions) mapstr.M {
Expand Down
10 changes: 6 additions & 4 deletions kubernetes/metadata/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,12 @@ func NewNodeMetadataGenerator(cfg *config.C, nodes cache.Store, client k8s.Inter

// Generate generates node metadata from a resource object
// Metadata map is in the following form:
// {
// "kubernetes": {},
// "some.ecs.field": "asdf"
// }
//
// {
// "kubernetes": {},
// "some.ecs.field": "asdf"
// }
//
// All Kubernetes fields that need to be stored under kuberentes. prefix are populetad by
// GenerateK8s method while fields that are part of ECS are generated by GenerateECS method
func (n *node) Generate(obj kubernetes.Resource, opts ...FieldOptions) mapstr.M {
Expand Down
5 changes: 2 additions & 3 deletions kubernetes/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"context"
"errors"
"fmt"
"io/ioutil"
"os"
"strings"

Expand Down Expand Up @@ -200,7 +199,7 @@ func (hd *DefaultDiscoveryUtils) GetMachineID() string {
"/etc/machine-id",
"/var/lib/dbus/machine-id",
} {
id, err := ioutil.ReadFile(file)
id, err := os.ReadFile(file)
if err == nil {
return strings.TrimSpace(string(id))
}
Expand All @@ -221,7 +220,7 @@ func (hd *DefaultDiscoveryUtils) GetPodName() (string, error) {
// InClusterNamespace gets namespace from serviceaccount when beat is in cluster. // code borrowed from client-go with some changes.
func InClusterNamespace() (string, error) {
// get namespace associated with the service account token, if available
data, err := ioutil.ReadFile("/var/run/secrets/kubernetes.io/serviceaccount/namespace")
data, err := os.ReadFile("/var/run/secrets/kubernetes.io/serviceaccount/namespace")
if err != nil {
return "", err
}
Expand Down
5 changes: 4 additions & 1 deletion kubernetes/watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func NewNamedWatcher(name string, client kubernetes.Interface, resource Resource
handler: NoOpEventHandlerFuncs{},
}

w.informer.AddEventHandler(cache.ResourceEventHandlerFuncs{
_, err = w.informer.AddEventHandler(cache.ResourceEventHandlerFuncs{
AddFunc: func(o interface{}) {
w.enqueue(o, add)
},
Expand Down Expand Up @@ -175,6 +175,9 @@ func NewNamedWatcher(name string, client kubernetes.Interface, resource Resource
}
},
})
if err != nil {
return nil, err
}

return w, nil
}
Expand Down

0 comments on commit 0f1cedc

Please sign in to comment.