Skip to content

Commit

Permalink
Remove dedoting for now
Browse files Browse the repository at this point in the history
Signed-off-by: chrismark <chrismarkou92@gmail.com>
  • Loading branch information
ChrsMark committed Jul 22, 2021
1 parent d42013f commit 701236c
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ type Config struct {

// Needed when resource is a Pod or Node
Node string `config:"node"`

LabelsDedot bool `config:"labels.dedot"`
AnnotationsDedot bool `config:"annotations.dedot"`
}

// Resources config section for resources' config blocks
Expand All @@ -47,8 +44,6 @@ func (c *Config) InitDefaults() {
c.CleanupTimeout = 60 * time.Second
c.SyncPeriod = 10 * time.Minute
c.Scope = "node"
c.LabelsDedot = true
c.AnnotationsDedot = true
}

// Validate ensures correctness of config
Expand Down
15 changes: 3 additions & 12 deletions x-pack/elastic-agent/pkg/composable/providers/kubernetes/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,22 +183,13 @@ func generateNodeData(node *kubernetes.Node, cfg *Config) *nodeData {
// Pass annotations to all events so that it can be used in templating and by annotation builders.
annotations := common.MapStr{}
for k, v := range node.GetObjectMeta().GetAnnotations() {
if cfg.AnnotationsDedot {
annotation := common.DeDot(k)
annotations.Put(annotation, v)
} else {
safemapstr.Put(annotations, k, v)
}
safemapstr.Put(annotations, k, v)
}

labels := common.MapStr{}
for k, v := range node.GetObjectMeta().GetLabels() {
if cfg.LabelsDedot {
label := common.DeDot(k)
labels.Put(label, v)
} else {
safemapstr.Put(labels, k, v)
}
// TODO: add dedoting option
safemapstr.Put(labels, k, v)
}

mapping := map[string]interface{}{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func TestGenerateNodeData(t *testing.T) {
},
}

data := generateNodeData(node, &Config{LabelsDedot: true, AnnotationsDedot: true})
data := generateNodeData(node, &Config{})

mapping := map[string]interface{}{
"node": map[string]interface{}{
Expand Down
22 changes: 4 additions & 18 deletions x-pack/elastic-agent/pkg/composable/providers/kubernetes/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,22 +129,13 @@ func generatePodData(pod *kubernetes.Pod, cfg *Config) providerData {
// Pass annotations to all events so that it can be used in templating and by annotation builders.
annotations := common.MapStr{}
for k, v := range pod.GetObjectMeta().GetAnnotations() {
if cfg.AnnotationsDedot {
annotation := common.DeDot(k)
annotations.Put(annotation, v)
} else {
safemapstr.Put(annotations, k, v)
}
safemapstr.Put(annotations, k, v)
}

labels := common.MapStr{}
for k, v := range pod.GetObjectMeta().GetLabels() {
if cfg.LabelsDedot {
label := common.DeDot(k)
labels.Put(label, v)
} else {
safemapstr.Put(labels, k, v)
}
// TODO: add dedoting option
safemapstr.Put(labels, k, v)
}

mapping := map[string]interface{}{
Expand Down Expand Up @@ -189,12 +180,7 @@ func generateContainerData(

labels := common.MapStr{}
for k, v := range pod.GetObjectMeta().GetLabels() {
if cfg.LabelsDedot {
label := common.DeDot(k)
labels.Put(label, v)
} else {
safemapstr.Put(labels, k, v)
}
safemapstr.Put(labels, k, v)
}

for _, c := range containers {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func TestGeneratePodData(t *testing.T) {
Status: kubernetes.PodStatus{PodIP: "127.0.0.5"},
}

data := generatePodData(pod, &Config{LabelsDedot: true, AnnotationsDedot: true})
data := generatePodData(pod, &Config{})

mapping := map[string]interface{}{
"namespace": pod.GetNamespace(),
Expand Down Expand Up @@ -129,7 +129,7 @@ func TestGenerateContainerPodData(t *testing.T) {
pod,
containers,
containerStatuses,
&Config{LabelsDedot: true, AnnotationsDedot: true})
&Config{})

mapping := map[string]interface{}{
"namespace": pod.GetNamespace(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,22 +105,13 @@ func generateServiceData(service *kubernetes.Service, cfg *Config) *serviceData
// Pass annotations to all events so that it can be used in templating and by annotation builders.
annotations := common.MapStr{}
for k, v := range service.GetObjectMeta().GetAnnotations() {
if cfg.AnnotationsDedot {
annotation := common.DeDot(k)
annotations.Put(annotation, v)
} else {
safemapstr.Put(annotations, k, v)
}
safemapstr.Put(annotations, k, v)
}

labels := common.MapStr{}
for k, v := range service.GetObjectMeta().GetLabels() {
if cfg.LabelsDedot {
label := common.DeDot(k)
labels.Put(label, v)
} else {
safemapstr.Put(labels, k, v)
}
// TODO: add dedoting option
safemapstr.Put(labels, k, v)
}

mapping := map[string]interface{}{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func TestGenerateServiceData(t *testing.T) {
},
}

data := generateServiceData(service, &Config{LabelsDedot: true, AnnotationsDedot: true})
data := generateServiceData(service, &Config{})

mapping := map[string]interface{}{
"service": map[string]interface{}{
Expand Down

0 comments on commit 701236c

Please sign in to comment.