Skip to content

Commit

Permalink
fixing the automatic proxy host config
Browse files Browse the repository at this point in the history
commenting the test TestMakeSensorEnvMapWithAutomaticProxy for refactor
  • Loading branch information
falcon-pioupiou committed Feb 8, 2024
1 parent f83a5a9 commit acc5f9a
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 1 deletion.
56 changes: 56 additions & 0 deletions pkg/common/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
*/
3 changes: 2 additions & 1 deletion pkg/common/sensor_environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit acc5f9a

Please sign in to comment.