-
Notifications
You must be signed in to change notification settings - Fork 228
Use the new knownhosts package in fluxcd/toolkit #617
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍, one nit with the path expansion.
cmd/ignited/cmd/gitops.go
Outdated
return "", fmt.Errorf("Couldn't lookup home directory for user") | ||
} | ||
// replace the first tilde in the path with $HOME | ||
return strings.Replace(path, "~", homeEnv, 1), nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will perform an illicit replace if the ~ is not the first character of the string. We should likely do something like this (which also retrieves the home directory correctly): https://stackoverflow.com/a/43578461 if this function is really needed (see other comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
true. using https://github.com/mitchellh/go-homedir/blob/master/homedir.go now 👍
@@ -61,9 +67,24 @@ func NewCmdGitOps(out io.Writer) *cobra.Command { | |||
} | |||
if f.identityFile != "" { | |||
var err error | |||
// support ~ prefixes in the path |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you verified that this is necessary, since the shell will expand ~ before it is passed to the program? Unless this this config is read from a file, I don't see the need to do manual path expansion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is needed, as we have the (non-expanded) part as a default
ref: weaveworks/libgitops#9
/cc @twelho @stealthybox