Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

Commit f8ebdf6

Browse files
committed
Merge branch 'main' of github.com:docker/scan-cli-plugin
2 parents 11d5dc9 + c3104a7 commit f8ebdf6

10 files changed

Lines changed: 148 additions & 396 deletions

File tree

.github/workflows/build-pr.yml

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,17 @@ jobs:
88
env:
99
GO111MODULE: "on"
1010
steps:
11+
- name: Checkout code into the Go module directory
12+
uses: actions/checkout@v2
13+
1114
- name: Set up Go 1.17
12-
uses: actions/setup-go@v1
15+
uses: actions/setup-go@v3
1316
with:
14-
go-version: 1.17
17+
go-version-file: go.mod
18+
check-latest: true
19+
cache: true
1520
id: go
1621

17-
- name: Checkout code into the Go module directory
18-
uses: actions/checkout@v2
19-
2022
- name: Check license headers
2123
run: make validate
2224

@@ -38,22 +40,16 @@ jobs:
3840
- name: Docker version
3941
run: docker version
4042

41-
- name: Set up Go 1.17
42-
uses: actions/setup-go@v1
43-
with:
44-
go-version: 1.17
45-
id: go
46-
4743
- name: Checkout code into the Go module directory
4844
uses: actions/checkout@v2
4945

50-
- name: Golang cache
51-
uses: actions/cache@v1
46+
- name: Set up Go 1.17
47+
uses: actions/setup-go@v3
5248
with:
53-
path: ~/go/pkg/mod
54-
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
55-
restore-keys: |
56-
${{ runner.os }}-go-
49+
go-version-file: go.mod
50+
check-latest: true
51+
cache: true
52+
id: go
5753

5854
- name: Download binaries
5955
run: make -f builder.Makefile download

.github/workflows/release-weekly-build.yml

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,32 +53,54 @@ jobs:
5353
# Only the CLI is needed to run docker-scan e2e
5454
run: brew install docker
5555

56-
- name: Set up Go 1.17
57-
uses: actions/setup-go@v2
58-
with:
59-
go-version: 1.17
60-
id: go
61-
6256
- name: Checkout code into the Go module directory
6357
uses: actions/checkout@v2
6458
with:
6559
ref: ${{ github.event.inputs.branch }}
6660

61+
- name: Set up Go 1.17
62+
uses: actions/setup-go@v3
63+
with:
64+
go-version-file: go.mod
65+
check-latest: true
66+
cache: true
67+
id: go
68+
6769
- name: Download binaries
6870
run: make -f builder.Makefile download
6971

70-
- name: Build binary and run tests
72+
- name: Build binary
73+
env:
74+
E2E_TEST_AUTH_TOKEN: ${{ secrets.E2E_TEST_AUTH_TOKEN }}
75+
E2E_HUB_URL: ${{ secrets.E2E_HUB_URL }}
76+
E2E_HUB_USERNAME: ${{ secrets.E2E_HUB_USERNAME }}
77+
E2E_HUB_TOKEN: ${{ secrets.E2E_HUB_TOKEN }}
78+
run: make TAG_NAME=${{ github.event.inputs.tag }} -f builder.Makefile build
79+
80+
- name: E2E
7181
env:
7282
E2E_TEST_AUTH_TOKEN: ${{ secrets.E2E_TEST_AUTH_TOKEN }}
7383
E2E_HUB_URL: ${{ secrets.E2E_HUB_URL }}
7484
E2E_HUB_USERNAME: ${{ secrets.E2E_HUB_USERNAME }}
7585
E2E_HUB_TOKEN: ${{ secrets.E2E_HUB_TOKEN }}
76-
run: make TAG_NAME=${{ github.event.inputs.tag }} -f builder.Makefile build test-unit e2e
86+
run: make TAG_NAME=${{ github.event.inputs.tag }} -f builder.Makefile e2e
87+
88+
- name: Unit test
89+
env:
90+
E2E_TEST_AUTH_TOKEN: ${{ secrets.E2E_TEST_AUTH_TOKEN }}
91+
E2E_HUB_URL: ${{ secrets.E2E_HUB_URL }}
92+
E2E_HUB_USERNAME: ${{ secrets.E2E_HUB_USERNAME }}
93+
E2E_HUB_TOKEN: ${{ secrets.E2E_HUB_TOKEN }}
94+
run: make TAG_NAME=${{ github.event.inputs.tag }} -f builder.Makefile test-unit
7795

7896
- name: Build Mac arm64 binary
7997
if: ${{ matrix.os == 'macos-latest' }}
8098
run: make TAG_NAME=${{ github.event.inputs.tag }} -f builder.Makefile build-mac-arm64
8199

100+
- name: Build Linux arm64 binary
101+
if: ${{ matrix.os == 'ubuntu-latest' }}
102+
run: make TAG_NAME=${{ github.event.inputs.tag }} -f builder.Makefile build-linux-arm64
103+
82104
- name: Upload binary artifact
83105
if: ${{ github.event.inputs.tag != '' }} # don't push artifacts if no tag is specified
84106
uses: actions/upload-artifact@v2

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ lint: ## Run the go linter
7373

7474
.PHONY: validate-headers
7575
validate-headers: ## Validate files license header
76-
docker run --rm -v $(CURDIR):/work -w /work \
76+
docker run --rm -v $(CURDIR):/work -w /work -e LTAG_VERSION=$(LTAG_VERSION) \
7777
golang:${GO_VERSION} \
78-
bash -c 'go get -u github.com/kunalkushwaha/ltag && ./scripts/validate/fileheader'
78+
bash -c 'go install github.com/kunalkushwaha/ltag@$(LTAG_VERSION) && ./scripts/validate/fileheader'
7979

8080
.PHONY: validate-go-mod
8181
validate-go-mod: ## Validate go.mod and go.sum are up-to-date

builder.Makefile

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ PWD:=$(shell pwd)
2525
ifeq ($(GOOS),windows)
2626
SNYK_DOWNLOAD_NAME:=snyk-win.exe
2727
SNYK_BINARY=snyk.exe
28-
PWD=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
28+
PWD=$(subst \,/,$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST)))))
2929
endif
3030
ifeq ($(GOOS),darwin)
3131
SNYK_DOWNLOAD_NAME:=snyk-macos
@@ -61,6 +61,7 @@ test-unit:
6161

6262
cross:
6363
GOOS=linux GOARCH=amd64 $(GO_BUILD) -o dist/docker-scan_linux_amd64 ./cmd/docker-scan
64+
GOOS=linux GOARCH=arm64 $(GO_BUILD) -o dist/docker-scan_linux_arm64 ./cmd/docker-scan
6465
GOOS=darwin GOARCH=amd64 $(GO_BUILD) -o dist/docker-scan_darwin_amd64 ./cmd/docker-scan
6566
GOOS=darwin GOARCH=arm64 $(GO_BUILD) -o dist/docker-scan_darwin_arm64 ./cmd/docker-scan
6667
GOOS=windows GOARCH=amd64 $(GO_BUILD) -o dist/docker-scan_windows_amd64.exe ./cmd/docker-scan
@@ -69,6 +70,10 @@ build-mac-arm64:
6970
mkdir -p bin
7071
GOOS=darwin GOARCH=arm64 $(GO_BUILD) -o bin/docker-scan_darwin_arm64 ./cmd/docker-scan
7172

73+
build-linux-arm64:
74+
mkdir -p bin
75+
GOOS=linux GOARCH=arm64 $(GO_BUILD) -o bin/docker-scan_linux_arm64 ./cmd/docker-scan
76+
7277
.PHONY: build
7378
build:
7479
mkdir -p bin
@@ -89,4 +94,4 @@ download:
8994
curl https://github.com/snyk/snyk/releases/download/v${SNYK_DESKTOP_VERSION}/${SNYK_DOWNLOAD_NAME} -L -s -S -o docker-config/snyk-desktop/${SNYK_BINARY}
9095
chmod +x docker-config/snyk-desktop/${SNYK_BINARY}
9196

92-
GO111MODULE=on go get gotest.tools/gotestsum@v${GOTESTSUM_VERSION}
97+
GO111MODULE=on go install gotest.tools/gotestsum@v${GOTESTSUM_VERSION}

e2e/plugin_test.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,15 @@ sleep 1000`), 0700))
6262

6363
// Add mock snyk binary to the $PATH
6464
path := os.Getenv("PATH")
65-
defer env.Patch(t, "PATH", fmt.Sprintf(pathFormat(), configDir+"/scan", path))()
65+
path = fmt.Sprintf(pathFormat(), configDir+"/scan", path)
66+
env.Patch(t, "PATH", path)()
67+
// force the env variable on command side on Windows
68+
if runtime.GOOS == "windows" {
69+
cmd.Env = append(cmd.Env, fmt.Sprintf("PATH=%s", path))
70+
}
6671

6772
cmd.Command = dockerCli.Command("scan", "--version")
73+
6874
icmd.StartCmd(cmd)
6975
time.Sleep(1 * time.Second)
7076

go.mod

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,27 @@ go 1.17
44

55
require (
66
github.com/Masterminds/semver/v3 v3.1.1
7-
github.com/docker/cli v20.10.9+incompatible
8-
github.com/docker/docker v20.10.9+incompatible
7+
github.com/docker/cli v20.10.17+incompatible
8+
github.com/docker/docker v20.10.17+incompatible
99
github.com/google/uuid v1.3.0
1010
github.com/mitchellh/go-homedir v1.1.0
1111
github.com/mitchellh/go-ps v1.0.0
12-
github.com/opencontainers/image-spec v1.0.2
12+
github.com/opencontainers/image-spec v1.0.3-0.20211202183452-c5a74bcca799
1313
github.com/pkg/errors v0.9.1
14-
github.com/spf13/cobra v1.2.1
14+
github.com/spf13/cobra v1.5.0
1515
gopkg.in/square/go-jose.v2 v2.6.0
1616
gotest.tools/v3 v3.0.3
1717
)
1818

1919
require (
2020
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
2121
github.com/Microsoft/go-winio v0.5.2 // indirect
22-
github.com/Microsoft/hcsshim v0.9.2 // indirect
22+
github.com/Microsoft/hcsshim v0.9.4 // indirect
2323
github.com/beorn7/perks v1.0.1 // indirect
2424
github.com/cespare/xxhash/v2 v2.1.2 // indirect
25-
github.com/containerd/cgroups v1.0.3 // indirect
26-
github.com/containerd/containerd v1.6.0 // indirect
27-
github.com/docker/distribution v2.8.0+incompatible // indirect
25+
github.com/containerd/cgroups v1.0.4 // indirect
26+
github.com/containerd/containerd v1.6.6 // indirect
27+
github.com/docker/distribution v2.8.1+incompatible // indirect
2828
github.com/docker/docker-credential-helpers v0.6.4 // indirect
2929
github.com/docker/go v1.5.1-1.0.20160303222718-d30aec9fd63c // indirect
3030
github.com/docker/go-connections v0.4.0 // indirect
@@ -34,30 +34,28 @@ require (
3434
github.com/gogo/protobuf v1.3.2 // indirect
3535
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
3636
github.com/golang/protobuf v1.5.2 // indirect
37-
github.com/google/go-cmp v0.5.6 // indirect
37+
github.com/google/go-cmp v0.5.8 // indirect
3838
github.com/gorilla/mux v1.8.0 // indirect
3939
github.com/inconshreveable/mousetrap v1.0.0 // indirect
4040
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
41-
github.com/miekg/pkcs11 v1.0.3 // indirect
42-
github.com/moby/sys/mount v0.2.0 // indirect
43-
github.com/moby/sys/mountinfo v0.6.0 // indirect
41+
github.com/miekg/pkcs11 v1.1.1 // indirect
42+
github.com/moby/sys/mount v0.3.3 // indirect
43+
github.com/moby/sys/mountinfo v0.6.2 // indirect
4444
github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6 // indirect
4545
github.com/morikuni/aec v1.0.0 // indirect
4646
github.com/opencontainers/go-digest v1.0.0 // indirect
47-
github.com/opencontainers/runc v1.1.0 // indirect
48-
github.com/prometheus/client_golang v1.11.0 // indirect
47+
github.com/opencontainers/runc v1.1.3 // indirect
48+
github.com/prometheus/client_golang v1.12.2 // indirect
4949
github.com/prometheus/client_model v0.2.0 // indirect
50-
github.com/prometheus/common v0.30.0 // indirect
51-
github.com/prometheus/procfs v0.7.3 // indirect
52-
github.com/sirupsen/logrus v1.8.1 // indirect
50+
github.com/prometheus/common v0.37.0 // indirect
51+
github.com/prometheus/procfs v0.8.0 // indirect
52+
github.com/sirupsen/logrus v1.9.0 // indirect
5353
github.com/spf13/pflag v1.0.5 // indirect
5454
github.com/theupdateframework/notary v0.7.0 // indirect
5555
go.opencensus.io v0.23.0 // indirect
56-
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 // indirect
57-
golang.org/x/net v0.0.0-20220225172249-27dd8689420f // indirect
58-
golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9 // indirect
59-
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
60-
google.golang.org/genproto v0.0.0-20220228195345-15d65a4533f7 // indirect
61-
google.golang.org/grpc v1.44.0 // indirect
62-
google.golang.org/protobuf v1.27.1 // indirect
56+
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa // indirect
57+
golang.org/x/net v0.0.0-20220802222814-0bcc04d9c69b // indirect
58+
golang.org/x/sys v0.0.0-20220803195053-6e608f9ce704 // indirect
59+
golang.org/x/term v0.0.0-20220722155259-a9ba230a4035 // indirect
60+
google.golang.org/protobuf v1.28.1 // indirect
6361
)

0 commit comments

Comments
 (0)