goss-org / goss

Quick and Easy server testing/validation
https://goss.rocks
Apache License 2.0
5.6k stars 473 forks source link

`dgoss edit` overwrites goss.yaml with goss_wait.yaml on exit #644

Closed jay7x closed 3 years ago

jay7x commented 4 years ago

Describe the bug dgoss edit overwrites goss.yaml with goss_wait.yaml contents on exit. Check following code:

This line will overwrite ${GOSS_FILE:-goss.yaml} with any file for which get_docker_file function was called:

docker cp "$id:$1" "${GOSS_FILES_PATH}/${GOSS_FILE:-goss.yaml}"

I'd suggest to pass 2nd argument into this function with the output file name desired.

How To Reproduce Create both goss.yaml and goss_wait.yaml then run dgoss edit and exit the shell after.

Expected Behavior goss_wait.yaml must be copied into the goss_wait.yaml file but not into the goss.yaml file.

Actual Behavior I have GOSS_FILE overridden here, so output filename is different. But from dgoss code it doesn't matters actually.

INFO: Creating docker container
INFO: Copy goss files into container
INFO: Starting docker container
INFO: Container ID: 6aae6002
INFO: Run goss add/autoadd to add resources
$ exit
INFO: Copied '/goss/goss.yaml' from container to './Test_2.249.1.yaml'
INFO: Copied '/goss/goss_wait.yaml' from container to './Test_2.249.1.yaml'
INFO: Deleting container

Environment:

aelsabbahy commented 4 years ago

Good catch! Definitely a bug. Marking as approved.

I can take a look at it later this week or next week. Unless, you have a fix handy that you're planning to submit.

jay7x commented 4 years ago

I made the PR for this :)