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 | // like "pa$$word" become "paword", then 401 with no hint anywhere), and |
| 233 | // ExpandEnv has no escape syntax to opt out. Use this at every site that |
| 234 | // dials out or branches on "is this profile keyed". |
| 235 | func (p *Profile) ResolvedKey() string { |
| 236 | key := p.Key |
| 237 | if name, ok := strings.CutPrefix(key, "${"); ok { |
| 238 | if name, ok = strings.CutSuffix(name, "}"); ok && isEnvName(name) { |
| 239 | return os.Getenv(name) |
| 240 | } |
| 241 | } |
| 242 | return key |
| 243 | } |
| 244 | |
| 245 | // isEnvName reports whether s is a POSIX environment variable name |