fix(cli): add backwards compat for old telemetry env and tests (#15476)

This commit is contained in:
Mathias Fredriksson
2024-11-14 01:07:52 +02:00
committed by GitHub
parent 99dd13d4cd
commit e55e8ee1b2
4 changed files with 58 additions and 11 deletions
+22 -8
View File
@@ -1143,6 +1143,16 @@ when required by your organization's security policy.`,
Group: &deploymentGroupEmailTLS,
YAML: "certKeyFile",
}
telemetryEnable := serpent.Option{
Name: "Telemetry Enable",
Description: "Whether telemetry is enabled or not. Coder collects anonymized usage data to help improve our product.",
Flag: "telemetry",
Env: "CODER_TELEMETRY_ENABLE",
Default: strconv.FormatBool(flag.Lookup("test.v") == nil || os.Getenv("CODER_TEST_TELEMETRY_DEFAULT_ENABLE") == "true"),
Value: &c.Telemetry.Enable,
Group: &deploymentGroupTelemetry,
YAML: "enable",
}
opts := serpent.OptionSet{
{
Name: "Access URL",
@@ -1903,15 +1913,19 @@ when required by your organization's security policy.`,
YAML: "dangerousSkipIssuerChecks",
},
// Telemetry settings
telemetryEnable,
{
Name: "Telemetry Enable",
Description: "Whether telemetry is enabled or not. Coder collects anonymized usage data to help improve our product.",
Flag: "telemetry",
Env: "CODER_TELEMETRY_ENABLE",
Default: strconv.FormatBool(flag.Lookup("test.v") == nil),
Value: &c.Telemetry.Enable,
Group: &deploymentGroupTelemetry,
YAML: "enable",
Hidden: true,
Name: "Telemetry (backwards compatibility)",
// Note the flip-flop of flag and env to maintain backwards
// compatibility and consistency. Inconsistently, the env
// was renamed to CODER_TELEMETRY_ENABLE in the past, but
// the flag was not renamed -enable.
Flag: "telemetry-enable",
Env: "CODER_TELEMETRY",
Value: &c.Telemetry.Enable,
Group: &deploymentGroupTelemetry,
UseInstead: []serpent.Option{telemetryEnable},
},
{
Name: "Telemetry URL",