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

Command optional exec style #1016

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft

Conversation

javierfreire
Copy link

@javierfreire javierfreire commented Jan 27, 2025

Checklist
  • make test-all (UNIX) passes. CI will also test this
  • unit and/or integration tests are included (if applicable)
  • documentation is changed or added (if applicable)

Description of change

This PR completes the work done by @berney on #871

This change allows specifying a command to be executed exec style without a shell.
This change is backwards compatible, and existing goss configuration files should continue to work as expected.
This change is needed for operating in environments where a shell doesn't exist, such as testing a distroless docker image.
The syntax is inspired by the Dockerfile RUN, ENTRYPOINT, CMD instructions that can take either a string (shell style), or a list (exec style). This allows specifying arguments that contain spaces, etc, as the argument list is explicit.

Shell syntax (unchanged from before):

command:
  figlet:
    exit-status: 0
    exec: figlet test

This would be wrapped and executed as sh -c "figlet test"

Exec syntax (this change introduces):

command:
  figlet:
    exit-status: 0
    exec:
      - figlet
      - test

This would be executed directly, without a shell, as figlet test, where figlet is arg 0 and test is arg 1.

The above could use alternative yaml syntax:

command:
  figlet:
    exit-status: 0
    exec: [figlet, test]

📚 Documentation preview 📚: https://goss--1016.org.readthedocs.build/en/1016/

@javierfreire javierfreire changed the title F exec Command optional exec style Jan 27, 2025
@javierfreire
Copy link
Author

@aelsabbahy I completed #871 with the changes required. The integration tests are failing, but I think that's due to the code in the master branch, right? I have the same errors as in this #1013 (actions).

@javierfreire
Copy link
Author

@aelsabbahy When you have a moment, I'd like to hear your thoughts on this.

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

Successfully merging this pull request may close these issues.

1 participant