feat: allow fetching token from shell command#1405
Open
phm07 wants to merge 1 commit into
Open
Conversation
jooola
reviewed
May 12, 2026
Comment on lines
+39
to
+43
| if runtime.GOOS == "windows" { | ||
| cmd = exec.Command("cmd", "/C", cmdStr) | ||
| } else { | ||
| cmd = exec.Command("sh", "-c", cmdStr) | ||
| } |
Member
There was a problem hiding this comment.
A few questions:
- How can one define this config globally and pick the right context? See point below.
- Why not pass down more details about the current context? E.g. as environment variables?
- Why use a shell at all? I'd leave this for the users to pick a shell if needed
- Could we store the command as list of strings, instead of a string? This makes passing down the arguments cleaner. Or we implement a similar approach like the docker CMD: If we have a list of string, no shell, if we have a string command, wrap it inside a shell?
Comment on lines
+44
to
+47
| out, err := cmd.Output() | ||
| if err != nil { | ||
| return "", fmt.Errorf("could not retrieve token: %w", err) | ||
| } |
Member
There was a problem hiding this comment.
Should we forward the command stderr to the cli stderr?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR allows the CLI to run a shell command to fetch the HCLOUD_TOKEN for each run, making it possible to use a keyring or password manager to securely store the token.
Fixes #808