Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

novops run keeps parsing arguments even after positional arguments started #121

Closed
teto opened this issue Aug 18, 2024 · 3 comments
Closed

Comments

@teto
Copy link
Collaborator

teto commented Aug 18, 2024

Let's assume the following .novops.yml

environments:
  prod-ro:
    variables:
    - name: AWS_DEFAULT_REGION
      value: eu-central-1

  prod-rw:
    variables:
    - name: AWS_DEFAULT_REGION
      value: eu-west-1

If I run

➜ novops run -e prod-rw sh -c "echo test=$AWS_DEFAULT_REGION"
Error: An error occured. Set environment variable RUST_LOG=[trace|debug|info|warn] or RUST_BACKTRACE=1 for more verbosity.

Caused by:
    0: Failed to load environment and exec command.
    1: Error reading config file.
    2: Failed to open Novops config "echo test=eu-central-1"
    3: No such file or directory (os error 2)

In 0, it would be nice to show what environment it tried to load in Failed to load environment <prod-rw>
As for 2. I think novops is trying to load its own config file and parsing the -c as its own instead of sh's.
Not sure how it works but maybe the argument parsing could stop after the first positional argument ? i.e., once it sees sh then all of the rest is the command to be run ?
Alternatively make more proeminent that novops run should be run as novops run --

@PierreBeucher
Copy link
Owner

Hi, thanks for the report !

Indeed intended usage is

novops run -e  prod-rw  -- sh -c "echo test=$AWS_DEFAULT_REGION"

with -- to separate Novops args from your command's args.

In 0, it would be nice to show what environment it tried to load in Failed to load environment

Certainly :)

once it sees sh then all of the rest is the command to be run ?

I'm not sure how practical that is. Tools like kubectl exec enforce -- usage (eg. kubectl exec -it [...] -- sh -c "echo foo". I'll try to see if it's possible.

Alternatively make more proeminent that novops run should be run as novops run --

Will do

@PierreBeucher
Copy link
Owner

Added doc + warning in #123

@PierreBeucher
Copy link
Owner

Released with https://github.com/PierreBeucher/novops/releases/tag/v0.16.0 :) Let me know so we can close this

@teto teto closed this as completed Aug 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants