serokell / deploy-rs

A simple multi-profile Nix-flake deploy tool.
Other
1.22k stars 100 forks source link

allow --ssh-opts starts with hyphen #277

Closed Anillc closed 3 weeks ago

Anillc commented 3 weeks ago

for example

deploy .#s --hostname example.com --ssh-opts '-p 1145'

without allow_hyphen_values:

error: Found argument '-p' which wasn't expected, or isn't valid in this context

workaround: add a space after quote

deploy .#s --hostname example.com --ssh-opts ' -p 1145'

but it might be better adding allow_hyphen_values = true

rvem commented 3 weeks ago

Hmm, I'm a bit confused since I don't have this issue when using --ssh-opts '-p <smth> locally. I'm using deploy-rs from 88b3059b020da69cbe16526b8d639bd5e0b51c8b. Which revision are you using?

rvem commented 3 weeks ago

Also, I don't think --ssh_opts is a correct option:

error: Found argument '--ssh_opts' which wasn't expected, or isn't valid in this context

    Did you mean '--ssh-opts'?

If you tried to supply `--ssh_opts` as a PATTERN use `-- --ssh_opts`
Anillc commented 3 weeks ago

I'm at https://github.com/serokell/deploy-rs/commit/b3ea6f333f9057b77efd9091119ba67089399ced

I have tested https://github.com/serokell/deploy-rs/commit/88b3059b020da69cbe16526b8d639bd5e0b51c8b. The result is the same

here is the log

image

Anillc commented 3 weeks ago

Also, I don't think --ssh_opts is a correct option:

error: Found argument '--ssh_opts' which wasn't expected, or isn't valid in this context

  Did you mean '--ssh-opts'?

If you tried to supply `--ssh_opts` as a PATTERN use `-- --ssh_opts`

sorry, It's my typo

rvem commented 3 weeks ago

Oh, right --ssh-opts='-p 1234' works, --ssh-opts '-p 1234 doesn't (note the absence of =)

rvem commented 3 weeks ago

It'd also be nice to add a regression test for this. Something like

diff --git a/nix/tests/default.nix b/nix/tests/default.nix
index b38e99d..3339f89 100644
--- a/nix/tests/default.nix
+++ b/nix/tests/default.nix
@@ -131,4 +131,9 @@ in {
     user = "deploy";
     deployArgs = "-s .#profile -- --offline";
   };
+  hyphen-ssh-opts-regression = mkTest {
+    name = "profile";
+    user = "deploy";
+    deployArgs = "-s .#profile --ssh-opts '-p 22' -- --offline";
+  };
 }

will do