Skip to content

Commit

Permalink
Added input option support (#34)
Browse files Browse the repository at this point in the history
* Added input option support

* Fix position of input flag

* update readme

* Update README.md

Co-authored-by: Simarpreet Singh <[email protected]>
  • Loading branch information
rahul2393 and simar7 authored Mar 24, 2021
1 parent 6890ac5 commit e2054f8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ Following inputs can be used as `step.with` keys:
| Name | Type | Default | Description |
|------------------|---------|------------------------------------|-----------------------------------------------|
| `scan-type` | String | `image` | Scan type, e.g. `image` or `fs`|
| `input` | String | | Tar reference, e.g. `alpine-latest.tar` |
| `image-ref` | String | | Image reference, e.g. `alpine:3.10.2` |
| `scan-ref` | String | `/github/workspace/` | Scan reference, e.g. `/github/workspace/` or `.`|
| `format` | String | `table` | Output format (`table`, `json`, `template`) |
Expand Down
5 changes: 5 additions & 0 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ inputs:
image-ref:
description: 'image reference(for backward compatibility)'
required: true
input:
description: 'reference of tar file to scan'
required: false
default: ''
scan-ref:
description: 'Scan reference'
required: false
Expand Down Expand Up @@ -60,3 +64,4 @@ runs:
- '-i ${{ inputs.image-ref }}'
- '-j ${{ inputs.scan-ref }}'
- '-k ${{ inputs.skip-dirs }}'
- '-l ${{ inputs.input }}'
9 changes: 8 additions & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
set -e
while getopts "a:b:c:d:e:f:g:h:i:j:k:" o; do
while getopts "a:b:c:d:e:f:g:h:i:j:k:l:" o; do
case "${o}" in
a)
export scanType=${OPTARG}
Expand Down Expand Up @@ -35,6 +35,9 @@ while getopts "a:b:c:d:e:f:g:h:i:j:k:" o; do
k)
export skipDirs=${OPTARG}
;;
l)
export input=${OPTARG}
;;
esac
done

Expand All @@ -43,6 +46,10 @@ export artifactRef="${imageRef}"
if [ "${scanType}" = "fs" ];then
artifactRef=$(echo $scanRef | tr -d '\r')
fi
input=$(echo $input | tr -d '\r')
if [ $input ]; then
artifactRef="--input $input"
fi
ignoreUnfixed=$(echo $ignoreUnfixed | tr -d '\r')

ARGS=""
Expand Down

0 comments on commit e2054f8

Please sign in to comment.