aboutsummaryrefslogtreecommitdiff
path: root/tasks/dgoss/task.yml
blob: 8727487c41207dd0dcb75e76c15d1521961e76a5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
---
platform: linux
image_resource:
  type: registry-image
  source: {repository: debian}

inputs:
  - name: docker-repo
  - name: image

run:
  path: /bin/bash
  args:
    - -eufo
    - pipefail
    - -c
    - |
      apt-get update
      apt-get install --no-install-recommends -y \
        ca-certificates \
        curl \
        fuse-overlayfs \
        podman

      curl -fsSL https://goss.rocks/install | sh

      export GOSS_SLEEP=${GOSS_SLEEP:-5}
      export CONTAINER_RUNTIME=${CONTAINER_RUNTIME:-podman}
      export INPUT_TAR=${INPUT_TAR:-image/image.tar}

      if [ -f docker-repo/goss.yaml ]; then
        # The default 'mount' strategy uses 'sleep infinity' to keep
        # the container alive. If there's an ENTRYPOINT or CMD, use 'cp'
        # instead to prevent dgoss from overriding it.
        if grep -qE '^(ENTRYPOINT|CMD)' docker-repo/Dockerfile; then
          export GOSS_FILES_STRATEGY=cp
        fi
        goss --gossfile docker-repo/goss.yaml render > goss.yaml
        dgoss run docker-archive:${INPUT_TAR}
      else
        echo "You're a naughty boy, no goss.yaml file found!" >&2
      fi

params:
  CONTAINER_RUNTIME:
  GOSS_SLEEP:
  INPUT_TAR: