Skip to content
Open
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
8 changes: 7 additions & 1 deletion internal/temporalcli/commands.config.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,19 @@ func (c *TemporalConfigGetCommand) run(cctx *CommandContext, _ []string) error {
}
return cctx.Printer.PrintStructured(tomlConf.Profiles[profileName], printer.StructuredOptions{})
} else {
// Capture whether TLS is configured before the loop below. Looking up
// any "tls.*" property via reflectEnvConfigProp lazily initializes
// confProfile.TLS to a non-nil empty struct, which would otherwise make
// TLS appear configured when it is not (#1077).
tlsConfigured := confProfile.TLS != nil

// Get every property individually as a property-value pair except zero
// vals
var props []prop
for k := range envConfigPropsToFieldNames {
// TLS is a special case
if k == "tls" {
if confProfile.TLS != nil {
if tlsConfigured {
props = append(props, prop{Property: "tls", Value: true})
}
continue
Expand Down
24 changes: 24 additions & 0 deletions internal/temporalcli/commands.config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,30 @@ disable_host_verification = true`))
}
}

func TestConfig_Get_NoTLSWhenUnconfigured(t *testing.T) {
// Regression test for #1077: `config get` (table output) must not display
// "tls true" for a profile that has no TLS configuration.
h := NewCommandHarness(t)
defer h.Close()

f, err := os.CreateTemp("", "")
h.NoError(err)
defer os.Remove(f.Name())
_, err = f.Write([]byte(`
[profile.devtest]
address = "localhost:17233"
namespace = "default"`))
f.Close()
h.NoError(err)
h.Options.EnvLookup = EnvLookupMap{"TEMPORAL_CONFIG_FILE": f.Name(), "TEMPORAL_PROFILE": "devtest"}

res := h.Execute("config", "get")
h.NoError(res.Err)
h.Contains(res.Stdout.String(), "localhost:17233")
// No TLS section was configured, so "tls" should not appear at all.
h.NotContains(res.Stdout.String(), "tls")
}

func TestConfig_TLS_Boolean(t *testing.T) {
h := NewCommandHarness(t)
defer h.Close()
Expand Down
Loading