Skip to content

Commit

Permalink
Add run-writable subcommand.
Browse files Browse the repository at this point in the history
This is to support the few plugins that expect that the target directory
is writable (e.g. to generate a lockfile).
  • Loading branch information
ZoogieZork committed Oct 28, 2024
1 parent 03c57b5 commit f8ce507
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
8 changes: 8 additions & 0 deletions backend/utilities/plugin_runner/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ Run the "gosec" plugin and start a debug shell in the container:
bash-5.0#
```

By default, the target directory is mounted as read-only to avoid unexpected changes that would change the results from run-to-run.
This is fine for most plugins, but some plugins expect the target directory to be writable.
For those plugins, use `run-writable` instead of `run`:

```bash
./plugin.sh run-writable gosec ~/git/my-repo
```

Stop all containers and release resources:

```bash
Expand Down
9 changes: 8 additions & 1 deletion backend/utilities/plugin_runner/plugin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@ readonly BASEDIR
readonly TEMPDIR="$BASEDIR/tmp"
readonly COMPOSEFILE="$TEMPDIR/docker-compose.yml"

workdir_readonly=true

# Print usage info to stderr.
function usage {
cat <<EOD >&2
Usage: $0 (subcommand)
Available subcommands:
run - Run a core plugin in local containers.
run-writable - Same as "run", but mounts target directory as read-write.
clean - Stop and clean up all containers.
EOD
}
Expand Down Expand Up @@ -142,7 +145,7 @@ services:
- type: bind
source: "$target"
target: /work/base
read_only: true
read_only: $workdir_readonly
EOD
}

Expand Down Expand Up @@ -214,6 +217,10 @@ case "$cmd" in
run)
do_run "$@" || exit 1
;;
run-writable)
workdir_readonly=false
do_run "$@" || exit 1
;;
clean)
do_clean "$@" || exit 1
;;
Expand Down

0 comments on commit f8ce507

Please sign in to comment.