Add local and NetBox server notes and improve reliability
Release / release (push) Successful in 6m52s

This commit is contained in:
Sebastian Unterschütz committed 2026-10-27 17:51:59 +01:00
1 parent 2852dff2c4
commit 12cc64fdd9
17 files changed
+848 -83

No files matched your search

+6
View File
@@ -88,6 +88,9 @@ func ReplaceHost(args []string, destIdx int, newHost string) []string {
// HasPortFlag reports whether a port was specified via -p in args.
func HasPortFlag(args []string) bool {
if parsed := Parse(args); parsed != nil {
args = args[:parsed.DestIdx]
}
for i, a := range args {
if a == "-p" && i+1 < len(args) {
return true
@@ -102,6 +105,9 @@ func HasPortFlag(args []string) bool {
// HasUserFlag reports whether a user was specified via -l in args.
// Used to avoid overriding an explicit -l with the configured default user.
func HasUserFlag(args []string) bool {
if parsed := Parse(args); parsed != nil {
args = args[:parsed.DestIdx]
}
for i, a := range args {
if a == "-l" && i+1 < len(args) {
return true
+7
View File
@@ -190,3 +190,10 @@ func assertParsed(t *testing.T, got *ParsedArgs, host, user string, destIdx int)
t.Errorf("destIdx: got %d, want %d", got.DestIdx, destIdx)
}
}
func TestRemoteCommandFlagsDoNotOverrideDefaults(t *testing.T) {
args := []string{"web01", "command", "-p", "1234", "-lroot"}
if HasPortFlag(args) || HasUserFlag(args) {
t.Fatal("remote command interpreted as SSH options")
}
}