Skip to content

Commit

Permalink
Add new runtime environment variable to dgoss to copy additional files (
Browse files Browse the repository at this point in the history
#898)

* Add an option to dgoss to copy additional directories.

* remove new line
  • Loading branch information
dklimpel authored May 16, 2024
1 parent 1b523c0 commit 794ae12
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
11 changes: 11 additions & 0 deletions extras/dgoss/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,17 @@ Time to sleep after running container (and optionally `goss_wait.yaml`) and befo

Location of the goss yaml files. (Default: `.`)

#### GOSS_ADDITIONAL_COPY_PATH

Colon-seperated list of additional directories to copy to container.

By default dgoss copies `goss.yaml` from the current working directory and
nothing else. You may need other files like scripts and configurations copied
as well. Specify `GOSS_ADDITIONAL_COPY_PATH` similar to `$PATH` as colon seperated
list of directories for each additional directory you'd like to recursively copy.
These will be copied as directories next to `goss.yaml` in the temporary
directory `DGOSS_TEMP_DIR`. (Default: `''`)

#### GOSS_VARS

The name of the variables file relative to `GOSS_FILES_PATH` to copy into the
Expand Down
6 changes: 6 additions & 0 deletions extras/dgoss/dgoss
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ run(){
[[ -e "${GOSS_FILES_PATH}/${GOSS_FILE:-goss.yaml}" ]] && cp "${GOSS_FILES_PATH}/${GOSS_FILE:-goss.yaml}" "$tmp_dir/goss.yaml" && chmod 644 "$tmp_dir/goss.yaml"
[[ -e "${GOSS_FILES_PATH}/goss_wait.yaml" ]] && cp "${GOSS_FILES_PATH}/goss_wait.yaml" "$tmp_dir" && chmod 644 "$tmp_dir/goss_wait.yaml"
[[ -n "${GOSS_VARS}" ]] && [[ -e "${GOSS_FILES_PATH}/${GOSS_VARS}" ]] && cp "${GOSS_FILES_PATH}/${GOSS_VARS}" "$tmp_dir" && chmod 644 "$tmp_dir/${GOSS_VARS}"
if [ -n "$GOSS_ADDITIONAL_COPY_PATH" ]; then
for dir in "$(echo "$GOSS_ADDITIONAL_COPY_PATH" | sed 's/:/ /g')"; do
cp -r ${dir} "${tmp_dir}/"
chmod -R 755 "$tmp_dir/$(basename ${dir})"
done
fi

# Switch between mount or cp files strategy
GOSS_FILES_STRATEGY=${GOSS_FILES_STRATEGY:="mount"}
Expand Down

0 comments on commit 794ae12

Please sign in to comment.