Skip to content

Commit 8817cc6

Browse files
committed
fix: actually use SIDEROV1_KEYS_DIR env var if it's provided
Use SIDEROV1_KEYS_DIR env var if it's provided Signed-off-by: Oguz Kilcan <oguz.kilcan@siderolabs.com>
1 parent b08b20a commit 8817cc6

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

cmd/talosctl/pkg/talos/global/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func (c *Args) WithClientNoNodes(action func(context.Context, *client.Client) er
4848
opts := []client.OptionFunc{
4949
client.WithConfig(cfg),
5050
client.WithGRPCDialOptions(dialOptions...),
51-
client.WithSideroV1KeysDir(c.SideroV1KeysDir),
51+
client.WithSideroV1KeysDir(clientconfig.CustomSideroV1KeysDirPath(c.SideroV1KeysDir)),
5252
}
5353

5454
if c.CmdContext != "" {

pkg/machinery/client/config/path.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,21 @@ func GetDefaultPaths() ([]Path, error) {
6161
return result, nil
6262
}
6363

64+
// CustomSideroV1KeysDirPath returns the custom SideroV1 auth keys directory path if it's provided as command line flag or with environment variable.
65+
// If not provided, it returns an empty string.
66+
func CustomSideroV1KeysDirPath(path string) string {
67+
if path != "" {
68+
return path
69+
}
70+
71+
path = os.Getenv(constants.SideroV1KeysDirEnvVar)
72+
if path != "" {
73+
return path
74+
}
75+
76+
return ""
77+
}
78+
6479
// firstValidPath iterates over the default paths and returns the first one that exists and readable.
6580
// If no path is found, it will ensure that the first path that allows writes is created and returned.
6681
// If no path is found that is writable, an error is returned.

0 commit comments

Comments
 (0)