Skip to content

Commit 59b148e

Browse files
pkcllpatrickhuie19
andauthored
loop/server: wire up ChipIngressInsecureConnection option (#1495)
Co-authored-by: Patrick <patrick.huie@smartcontract.com>
1 parent 8b25c98 commit 59b148e

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

pkg/loop/config.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ const (
6363
envTelemetryEmitterMaxQueueSize = "CL_TELEMETRY_EMITTER_MAX_QUEUE_SIZE"
6464
envTelemetryLogStreamingEnabled = "CL_TELEMETRY_LOG_STREAMING_ENABLED"
6565

66-
envChipIngressEndpoint = "CL_CHIP_INGRESS_ENDPOINT"
66+
envChipIngressEndpoint = "CL_CHIP_INGRESS_ENDPOINT"
67+
envChipIngressInsecureConnection = "CL_CHIP_INGRESS_INSECURE_CONNECTION"
6768
)
6869

6970
// EnvConfig is the configuration between the application and the LOOP executable. The values
@@ -118,7 +119,8 @@ type EnvConfig struct {
118119
TelemetryEmitterMaxQueueSize int
119120
TelemetryLogStreamingEnabled bool
120121

121-
ChipIngressEndpoint string
122+
ChipIngressEndpoint string
123+
ChipIngressInsecureConnection bool
122124
}
123125

124126
// AsCmdEnv returns a slice of environment variable key/value pairs for an exec.Cmd.
@@ -187,6 +189,7 @@ func (e *EnvConfig) AsCmdEnv() (env []string) {
187189
add(envTelemetryLogStreamingEnabled, strconv.FormatBool(e.TelemetryLogStreamingEnabled))
188190

189191
add(envChipIngressEndpoint, e.ChipIngressEndpoint)
192+
add(envChipIngressInsecureConnection, strconv.FormatBool(e.ChipIngressInsecureConnection))
190193

191194
return
192195
}
@@ -350,6 +353,10 @@ func (e *EnvConfig) parse() error {
350353
}
351354
// Optional
352355
e.ChipIngressEndpoint = os.Getenv(envChipIngressEndpoint)
356+
e.ChipIngressInsecureConnection, err = getBool(envChipIngressInsecureConnection)
357+
if err != nil {
358+
return fmt.Errorf("failed to parse %s: %w", envChipIngressInsecureConnection, err)
359+
}
353360
}
354361

355362
return nil

pkg/loop/config_test.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ func TestEnvConfig_parse(t *testing.T) {
7676
envTelemetryEmitterMaxQueueSize: "1000",
7777
envTelemetryLogStreamingEnabled: "false",
7878

79-
envChipIngressEndpoint: "http://chip-ingress.example.com",
79+
envChipIngressEndpoint: "chip-ingress.example.com:50051",
80+
envChipIngressInsecureConnection: "true",
8081
},
8182
expectError: false,
8283
expectConfig: envCfgFull,
@@ -174,7 +175,8 @@ var envCfgFull = EnvConfig{
174175
TelemetryEmitterMaxQueueSize: 1000,
175176
TelemetryLogStreamingEnabled: false,
176177

177-
ChipIngressEndpoint: "http://chip-ingress.example.com",
178+
ChipIngressEndpoint: "chip-ingress.example.com:50051",
179+
ChipIngressInsecureConnection: true,
178180
}
179181

180182
func TestEnvConfig_AsCmdEnv(t *testing.T) {
@@ -224,7 +226,8 @@ func TestEnvConfig_AsCmdEnv(t *testing.T) {
224226
assert.Equal(t, "false", got[envTelemetryLogStreamingEnabled])
225227

226228
// Assert ChipIngress environment variables
227-
assert.Equal(t, "http://chip-ingress.example.com", got[envChipIngressEndpoint])
229+
assert.Equal(t, "chip-ingress.example.com:50051", got[envChipIngressEndpoint])
230+
assert.Equal(t, "true", got[envChipIngressInsecureConnection])
228231
}
229232

230233
func TestGetMap(t *testing.T) {

pkg/loop/server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ func (s *Server) start() error {
127127
LogStreamingEnabled: s.EnvConfig.TelemetryLogStreamingEnabled,
128128
ChipIngressEmitterEnabled: s.EnvConfig.ChipIngressEndpoint != "",
129129
ChipIngressEmitterGRPCEndpoint: s.EnvConfig.ChipIngressEndpoint,
130-
ChipIngressInsecureConnection: s.EnvConfig.TelemetryInsecureConnection,
130+
ChipIngressInsecureConnection: s.EnvConfig.ChipIngressInsecureConnection,
131131
}
132132

133133
if tracingConfig.Enabled {

0 commit comments

Comments
 (0)