Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@cretz
Copy link
Member

@cretz cretz commented Feb 25, 2025

What was changed

  • 💥 BREAKING CHANGE - --api-key now assumes TLS (i.e. --tls) by default, so users using API keys on non-TLS servers will have to explicitly disable TLS (i.e. --tls=false)
  • Added experimental temporal config commands
  • Changed internals to have env vars use envconfig approach
  • No longer log when env var overrides config-file-set values as was in [Feature Request] Log notice when --env is getting overrode by env var #293

Checklist

  1. Closes [Feature Request] Environment configuration #751

// To support legacy TLS environment variables, if they are present, we will
// have them force-override anything loaded from existing file or env
if !cctx.RootCommand.DisableConfigEnv {
oldEnvTLSCert, _ := cctx.Options.EnvLookup.LookupEnv("TEMPORAL_TLS_CERT")
Copy link
Member

Choose a reason for hiding this comment

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

Mentioned in the other PR, but this sure seems like a good reason to export the constants from the SDK

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think every SDK should export every environment variable name as part of its public API to users, it will be part of the spec.

implied-env: TEMPORAL_CONFIG_FILE
- name: profile
type: string
description: Profile to use for config file.
Copy link
Member

Choose a reason for hiding this comment

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

Should this use default as the default?

Copy link
Member Author

Choose a reason for hiding this comment

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

No because the default is actually determined by the Go SDK not by the CLI. A CLI flag (whether set via "default" or explicitly) would override where it may be otherwise set, e.g. env var or the actual default.

Comment on lines 725 to 731
Remove a full profile entirely _or_ remove a property within a profile.
When deleting an entire profile, the `--profile` must be set explicitly.
```
temporal env delete \
--profile my-profile
```
Copy link
Member

Choose a reason for hiding this comment

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

IMO adding an explicit --delete-whole-profile or something might be good in that instance, but, not hugely concerned.

Copy link
Member Author

Choose a reason for hiding this comment

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

👍 Yeah this just matches what we do for env today, but I do agree. Actually this should be a top-level command called delete-profile so delete can always require the --prop.

Copy link
Member Author

Choose a reason for hiding this comment

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

Moved to its own command. Leaving conversation open for others that may want to see that this changed.

@cretz cretz changed the base branch from next-server to main April 1, 2025 14:22
Comment on lines 135 to 143
// In the past, the presence of API key CLI arg did not imply TLS like it
// does with envconfig. Therefore if there is a user-provided API key and
// TLS is not present, explicitly disable it so API key presence doesn't
// enable it in ToClientOptions below.
// TODO(cretz): Or do we want to break compatibility to have TLS defaulted
// for all API keys?
if c.ApiKey != "" && clientProfile.TLS == nil {
clientProfile.TLS = &envconfig.ClientConfigTLS{Disabled: true}
}
Copy link
Member Author

@cretz cretz Apr 1, 2025

Choose a reason for hiding this comment

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

Thoughts here on just making TLS the default for API key and adding TLS disabled option? Technically a backwards incompatible break, but a good one IMO.

Copy link
Member

Choose a reason for hiding this comment

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

I think it makes sense

Copy link
Member Author

@cretz cretz Apr 3, 2025

Choose a reason for hiding this comment

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

Ok, I have made this breaking change and added tests

cretz added 2 commits April 1, 2025 10:57
# Conflicts:
#	go.mod
#	go.sum
#	temporalcli/client.go
#	temporalcli/commands.gen.go
#	temporalcli/commands.go
#	temporalcli/commandsgen/commands.yml
@cretz cretz changed the title Support environment config 💥 Support environment config [BREAKING CHANGES] Apr 3, 2025
type: string
description: |
File path to read TOML config from, defaults to
`$CONFIG_PATH/temporal/temporal.toml` where `$CONFIG_PATH` is defined
Copy link
Member Author

Choose a reason for hiding this comment

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

Suggested change
`$CONFIG_PATH/temporal/temporal.toml` where `$CONFIG_PATH` is defined
`$CONFIG_PATH/temporalio/temporal.toml` where `$CONFIG_PATH` is defined

Comment on lines 88 to 90
if namespaceExplicitlySet {
clientProfile.Namespace = c.Namespace
}
Copy link
Member Author

Choose a reason for hiding this comment

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

Suggested change
if namespaceExplicitlySet {
clientProfile.Namespace = c.Namespace
}
if namespaceExplicitlySet {
clientProfile.Namespace = c.Namespace
} else {
c.Namespace = clientProfile.Namespace
}

Some code is using c.Namespace flag in its output which is obviously not valid if it's overwritten by env config stuff. Need to either update c.Namespace with the valid value or have some other way to relay what is the now-current namespace value.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed

Copy link
Contributor

@yuandrew yuandrew left a comment

Choose a reason for hiding this comment

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

Primarily looked at the commandsgen stuff, just one clarity comment

# short: The single letter short version of name (i.e. a for address). (string)
# env: Binds the environment variable to this flag. (string)
# implied-env: Documents the environment variable as bound to the flag,
# but does actually bind it.
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be doesn't? Also missing the type (string)

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, I'm not seeing ImpliedEnv used anywhere, do we want it printed into the generated docs?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I meant doesn't, will fix. Yes, I do think it'd make sense to be in the docs just like env. I just had to make a separate field because it's effectively doc only, it has no runtime use.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed

@cretz cretz merged commit 4a0118a into temporalio:main Apr 21, 2025
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request] Environment configuration

3 participants