Skip to content

Commit

Permalink
fix merge conflict issue
Browse files Browse the repository at this point in the history
  • Loading branch information
newly12 committed Nov 4, 2021
1 parent 9556f83 commit 3a1a5ac
Showing 1 changed file with 25 additions and 16 deletions.
41 changes: 25 additions & 16 deletions libbeat/common/kubernetes/metadata/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@ import (
)

type pod struct {
store cache.Store
client k8s.Interface
node MetaGen
namespace MetaGen
resource *Resource
store cache.Store
client k8s.Interface
node MetaGen
namespace MetaGen
resource *Resource
addDeployment bool
}

// NewPodMetadataGenerator creates a metagen for pod resources
Expand All @@ -42,13 +43,19 @@ func NewPodMetadataGenerator(
pods cache.Store,
client k8s.Interface,
node MetaGen,
namespace MetaGen) MetaGen {
namespace MetaGen,
metaCfg *AddResourceMetadataConfig) MetaGen {
addDeploymentMeta := true
if metaCfg != nil {
addDeploymentMeta = metaCfg.Deployment
}
return &pod{
resource: NewResourceMetadataGenerator(cfg, client),
store: pods,
node: node,
namespace: namespace,
client: client,
resource: NewResourceMetadataGenerator(cfg, client),
store: pods,
node: node,
namespace: namespace,
client: client,
addDeployment: addDeploymentMeta,
}
}

Expand Down Expand Up @@ -84,11 +91,13 @@ func (p *pod) GenerateK8s(obj kubernetes.Resource, opts ...FieldOptions) common.
out := p.resource.GenerateK8s("pod", obj, opts...)

// check if Pod is handled by a ReplicaSet which is controlled by a Deployment
rsName, _ := out.GetValue("replicaset.name")
if rsName, ok := rsName.(string); ok {
dep := p.getRSDeployment(rsName, po.GetNamespace())
if dep != "" {
out.Put("deployment.name", dep)
if p.addDeployment {
rsName, _ := out.GetValue("replicaset.name")
if rsName, ok := rsName.(string); ok {
dep := p.getRSDeployment(rsName, po.GetNamespace())
if dep != "" {
out.Put("deployment.name", dep)
}
}
}

Expand Down

0 comments on commit 3a1a5ac

Please sign in to comment.