diff --git a/pkg/common/common_test.go b/pkg/common/common_test.go index 7bee957a..04ab9c3f 100644 --- a/pkg/common/common_test.go +++ b/pkg/common/common_test.go @@ -175,3 +175,59 @@ func TestMakeSensorEnvMap(t *testing.T) { t.Errorf("MakeSensorEnvMap() = %v, want %v", got, sensorConfig) } } + +/* +func TestMakeSensorEnvMapWithAutomaticProxy(t *testing.T) { + falconNode := falconv1alpha1.FalconNodeSensor{} + falconSensor := falconNode.Spec.Falcon + sensorConfig := make(map[string]string) + pDisabled := false + cid := "test" + + falconSensor.APD = &pDisabled + falconSensor.Billing = "test" + falconSensor.CID = &cid + falconSensor.PToken = "test" + falconSensor.Tags = []string{"test"} + falconSensor.Trace = "debug" + + os.Setenv("HTTPS_PROXY", "https://test.proxy:666") + proxy := NewProxyInfo() + + // Set proxy values from environment variables if they exist + if proxy.Host() != "" { + sensorConfig["FALCONCTL_OPT_APH"] = strings.TrimPrefix(proxy.Host(), "https://") + sensorConfig["FALCONCTL_OPT_APH"] = strings.TrimPrefix(proxy.Host(), "http://") + } + if proxy.Port() != "" { + sensorConfig["FALCONCTL_OPT_APP"] = proxy.Port() + } + + // Set sensor values from CRD + if falconSensor.APD != nil { + sensorConfig["FALCONCTL_OPT_APD"] = strconv.FormatBool(*falconSensor.APD) + } + if falconSensor.APH != "" { + sensorConfig["FALCONCTL_OPT_APH"] = falconSensor.APH + } + if falconSensor.APP != nil { + sensorConfig["FALCONCTL_OPT_APP"] = strconv.Itoa(*falconSensor.APP) + } + if falconSensor.Billing != "" { + sensorConfig["FALCONCTL_OPT_BILLING"] = falconSensor.Billing + } + if falconSensor.PToken != "" { + sensorConfig["FALCONCTL_OPT_PROVISIONING_TOKEN"] = falconSensor.PToken + } + if len(falconSensor.Tags) > 0 { + sensorConfig["FALCONCTL_OPT_TAGS"] = strings.Join(falconSensor.Tags, ",") + } + if falconSensor.Trace != "" { + sensorConfig["FALCONCTL_OPT_TRACE"] = falconSensor.Trace + } + + if got := MakeSensorEnvMap(falconSensor); !reflect.DeepEqual(got, sensorConfig) { + t.Errorf("MakeSensorEnvMap() = %v, want %v", got, sensorConfig) + } +} +*/ diff --git a/pkg/common/sensor_environment.go b/pkg/common/sensor_environment.go index 9ab18160..c9d730be 100644 --- a/pkg/common/sensor_environment.go +++ b/pkg/common/sensor_environment.go @@ -13,7 +13,8 @@ func MakeSensorEnvMap(falconSensor falconv1alpha1.FalconSensor) map[string]strin // Set proxy values from environment variables if they exist if proxy.Host() != "" { - sensorConfig["FALCONCTL_OPT_APH"] = proxy.Host() + sensorConfig["FALCONCTL_OPT_APH"] = strings.TrimPrefix(proxy.Host(), "https://") + sensorConfig["FALCONCTL_OPT_APH"] = strings.TrimPrefix(proxy.Host(), "http://") } if proxy.Port() != "" { sensorConfig["FALCONCTL_OPT_APP"] = proxy.Port()