Skip to content

Commit

Permalink
🐛 Call the callback method which is UpdateTargets
Browse files Browse the repository at this point in the history
  • Loading branch information
mertyildiran committed Oct 8, 2023
1 parent 1478969 commit c7228f8
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pkg/kubernetes/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"k8s.io/client-go/rest"
)

func NewFromInCluster(errOut chan error, callback func(pods *[]v1.Pod) error) *Watcher {
func NewFromInCluster(errOut chan error, callback func(pods []v1.Pod) error) *Watcher {
config, err := rest.InClusterConfig()
if err != nil {
log.Warn().Err(err).Send()
Expand Down
3 changes: 2 additions & 1 deletion pkg/kubernetes/target.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func updateCurrentlyTargetedPods(
clientSet *kubernetes.Clientset,
regex *regexp.Regexp,
namespaces []string,
callback func(pods *[]v1.Pod) error,
callback func(pods []v1.Pod) error,
) (err error, changesFound bool) {
if matchingPods, err := listAllRunningPodsMatchingRegex(ctx, clientSet, regex, namespaces); err != nil {
return err, false
Expand All @@ -125,6 +125,7 @@ func updateCurrentlyTargetedPods(

if len(addedPods) > 0 || len(removedPods) > 0 {
SetTargetedPods(podsToTarget)
callback(podsToTarget)
}
return nil, false
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/kubernetes/watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type Watcher struct {
namespaces []string
isStarted bool
errOut chan error
callback func(pods *[]v1.Pod) error
callback func(pods []v1.Pod) error
}

func (watcher *Watcher) Start(ctx context.Context, clusterMode bool) {
Expand Down
6 changes: 3 additions & 3 deletions tls_process_discoverer.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (

var numberRegex = regexp.MustCompile("[0-9]+")

func UpdateTargets(pods *[]v1.Pod) error {
func UpdateTargets(pods []v1.Pod) error {
containerIds := buildContainerIdsMap(pods)
containerPids, err := findContainerPids(tracer.procfs, containerIds)

Expand Down Expand Up @@ -87,10 +87,10 @@ func findContainerPids(procfs string, containerIds map[string]v1.Pod) (map[uint3
return result, nil
}

func buildContainerIdsMap(pods *[]v1.Pod) map[string]v1.Pod {
func buildContainerIdsMap(pods []v1.Pod) map[string]v1.Pod {
result := make(map[string]v1.Pod)

for _, pod := range *pods {
for _, pod := range pods {
for _, container := range pod.Status.ContainerStatuses {
parsedUrl, err := url.Parse(container.ContainerID)

Expand Down

0 comments on commit c7228f8

Please sign in to comment.