Skip to content

Commit

Permalink
Improve logic.
Browse files Browse the repository at this point in the history
  • Loading branch information
musa-asad committed Oct 16, 2024
1 parent 43478d0 commit a29555a
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions integration-tests/manifests/cmd/validate_instrumentation_vars.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"context"
"encoding/json"
"fmt"
"github.com/aws/amazon-cloudwatch-agent-operator/internal/manifests/collector/adapters"
"io/ioutil"
"os"
"path/filepath"
Expand Down Expand Up @@ -104,23 +103,23 @@ func verifyInstrumentationEnvVariables(clientset *kubernetes.Clientset, namespac
fmt.Println("Error retrieving configmap:", err)
return false
}
fmt.Println("ConfigMap data:", cloudwatchAgentConfigMap.Data["cwagentconfig.json"])

if jsonPath == "integration-tests/jmx/default_instrumentation_jmx_env_variables_no_app_signals.json" {
cfg, ok := cloudwatchAgentConfigMap.Data["cwagentconfig.json"]
if !ok {
fmt.Println("Error retrieving cwagentconfig.json:", err)
return false
}

if !strings.Contains(cfg, "application_signals") {
fmt.Println("Checking if application signal environment variables are present")
for _, key := range appSignalsEnvVarKeys {
if _, exists := jsonData[key]; exists {
fmt.Printf("Error: Key '%s' should not exist in jsonData when app signals is not enabled\n", key)
fmt.Printf("Error: Key '%s' should not exist in environment variables when app signals is not enabled\n", key)
return false
}
}
}

var config adapters.CwaConfig
err = json.Unmarshal([]byte(cloudwatchAgentConfigMap.Data["cwagentconfig.json"]), &config) // make sure to check if Data exists then map exists
fmt.Println("Error decoding configmap, ", err)
fmt.Println("The config:", config)
fmt.Println("AppSignals Config:", config.GetApplicationSignalsConfig())

for key, value := range jsonData {
if val, ok := envMap[key]; ok {
if strings.ReplaceAll(val, " ", "") != strings.ReplaceAll(value, " ", "") {
Expand Down

0 comments on commit a29555a

Please sign in to comment.