Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions pkg/loop/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a variety of config parameters like this now (TLS or local mode), and I think some are formatted as secure while others are formatted as insecure. insecure is probably the way to go, so no action here.

)

// EnvConfig is the configuration between the application and the LOOP executable. The values
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
Expand Down
9 changes: 6 additions & 3 deletions pkg/loop/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/loop/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Loading