diff --git a/pkg/loop/config.go b/pkg/loop/config.go index 629809dd34..8bc42daa85 100644 --- a/pkg/loop/config.go +++ b/pkg/loop/config.go @@ -63,7 +63,8 @@ const ( envTelemetryEmitterMaxQueueSize = "CL_TELEMETRY_EMITTER_MAX_QUEUE_SIZE" envTelemetryLogStreamingEnabled = "CL_TELEMETRY_LOG_STREAMING_ENABLED" - envChipIngressEndpoint = "CL_CHIP_INGRESS_ENDPOINT" + envChipIngressEndpoint = "CL_CHIP_INGRESS_ENDPOINT" + envChipIngressInsecureConnection = "CL_CHIP_INGRESS_INSECURE_CONNECTION" ) // EnvConfig is the configuration between the application and the LOOP executable. The values @@ -118,7 +119,8 @@ type EnvConfig struct { TelemetryEmitterMaxQueueSize int TelemetryLogStreamingEnabled bool - ChipIngressEndpoint string + ChipIngressEndpoint string + ChipIngressInsecureConnection bool } // AsCmdEnv returns a slice of environment variable key/value pairs for an exec.Cmd. @@ -187,6 +189,7 @@ func (e *EnvConfig) AsCmdEnv() (env []string) { add(envTelemetryLogStreamingEnabled, strconv.FormatBool(e.TelemetryLogStreamingEnabled)) add(envChipIngressEndpoint, e.ChipIngressEndpoint) + add(envChipIngressInsecureConnection, strconv.FormatBool(e.ChipIngressInsecureConnection)) return } @@ -350,6 +353,10 @@ func (e *EnvConfig) parse() error { } // Optional e.ChipIngressEndpoint = os.Getenv(envChipIngressEndpoint) + e.ChipIngressInsecureConnection, err = getBool(envChipIngressInsecureConnection) + if err != nil { + return fmt.Errorf("failed to parse %s: %w", envChipIngressInsecureConnection, err) + } } return nil diff --git a/pkg/loop/config_test.go b/pkg/loop/config_test.go index 5f3b244640..72adf5825f 100644 --- a/pkg/loop/config_test.go +++ b/pkg/loop/config_test.go @@ -76,7 +76,8 @@ func TestEnvConfig_parse(t *testing.T) { envTelemetryEmitterMaxQueueSize: "1000", envTelemetryLogStreamingEnabled: "false", - envChipIngressEndpoint: "http://chip-ingress.example.com", + envChipIngressEndpoint: "chip-ingress.example.com:50051", + envChipIngressInsecureConnection: "true", }, expectError: false, expectConfig: envCfgFull, @@ -174,7 +175,8 @@ var envCfgFull = EnvConfig{ TelemetryEmitterMaxQueueSize: 1000, TelemetryLogStreamingEnabled: false, - ChipIngressEndpoint: "http://chip-ingress.example.com", + ChipIngressEndpoint: "chip-ingress.example.com:50051", + ChipIngressInsecureConnection: true, } func TestEnvConfig_AsCmdEnv(t *testing.T) { @@ -224,7 +226,8 @@ func TestEnvConfig_AsCmdEnv(t *testing.T) { assert.Equal(t, "false", got[envTelemetryLogStreamingEnabled]) // Assert ChipIngress environment variables - assert.Equal(t, "http://chip-ingress.example.com", got[envChipIngressEndpoint]) + assert.Equal(t, "chip-ingress.example.com:50051", got[envChipIngressEndpoint]) + assert.Equal(t, "true", got[envChipIngressInsecureConnection]) } func TestGetMap(t *testing.T) { diff --git a/pkg/loop/server.go b/pkg/loop/server.go index 1cd35419f5..6b6d5a0113 100644 --- a/pkg/loop/server.go +++ b/pkg/loop/server.go @@ -127,7 +127,7 @@ func (s *Server) start() error { LogStreamingEnabled: s.EnvConfig.TelemetryLogStreamingEnabled, ChipIngressEmitterEnabled: s.EnvConfig.ChipIngressEndpoint != "", ChipIngressEmitterGRPCEndpoint: s.EnvConfig.ChipIngressEndpoint, - ChipIngressInsecureConnection: s.EnvConfig.TelemetryInsecureConnection, + ChipIngressInsecureConnection: s.EnvConfig.ChipIngressInsecureConnection, } if tracingConfig.Enabled {