ResolvedKey returns the profile's key, expanding it against the process environment when the WHOLE key is a `${VAR}` reference (the advertised form; see the config.yaml header). Lets config.yaml carry `key: ${MY_KEY}` instead of a plaintext secret: the reference is what round-trips on Save, the expa
()
| 232 | // ExpandEnv has no escape syntax to opt out. Use this at every site that |
| 233 | // dials out or branches on "is this profile keyed". |
| 234 | func (p *Profile) ResolvedKey() string { |
| 235 | key := p.Key |
| 236 | if name, ok := strings.CutPrefix(key, "${"); ok { |
| 237 | if name, ok = strings.CutSuffix(name, "}"); ok && isEnvName(name) { |
| 238 | return os.Getenv(name) |
| 239 | } |
| 240 | } |
| 241 | return key |
| 242 | } |
| 243 | |
| 244 | // isEnvName reports whether s is a POSIX environment variable name |
| 245 | // ([A-Za-z_][A-Za-z0-9_]*), the only content ${...} expands. |