Skip to content

Commit ba825c1

Browse files
authored
Merge pull request #473 from docker/feat/license
feat: license check ci and commands
2 parents 2b851c9 + cf37eb7 commit ba825c1

31 files changed

+459
-5
lines changed

.github/workflows/lint.yml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,25 @@ on:
44
branches:
55
- main
66
pull_request:
7+
permissions:
8+
contents: read # to fetch code (actions/checkout)
79
jobs:
8-
lint:
9-
name: Lint
10+
validate:
11+
name: Validate license and lint
1012
runs-on: ubuntu-latest
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
target:
17+
- validate-headers
18+
- lint
1119
permissions:
1220
id-token: write
1321
pull-requests: write
1422
contents: write
1523
steps:
16-
- uses: actions/checkout@v4
24+
- name: Checkout
25+
uses: actions/checkout@v4
1726
- name: Setup Go
1827
uses: actions/setup-go@v5
1928
with:
@@ -31,4 +40,4 @@ jobs:
3140
endpoint: "docker/secrets-engine"
3241
install: true
3342
- name: Lint
34-
run: make BUILDER=${{ steps.buildx.outputs.name }} lint
43+
run: make BUILDER=${{ steps.buildx.outputs.name }} ${{ matrix.target }}

Dockerfile

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,27 @@
1+
# Copyright 2026 Docker, Inc.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
115
#syntax=docker/dockerfile:1
216

17+
ARG ALPINE_VERSION=3.23.3
318
ARG GO_VERSION=latest
419
ARG GOLANGCI_LINT_VERSION=v2.2.1
520
ARG OSXCROSS_VERSION=15.5
21+
ARG ADDLICENSE_VERSION=v1.2.0
22+
ARG LICENSE_ARGS="-c 'Docker, Inc.' -l apache -ignore '**/*.yaml' -ignore '**/*.yml' -ignore '.github/**' -ignore 'store/keychain/internal/go-keychain/**' -ignore 'vendor/**' -ignore '.git/**' ."
23+
24+
FROM ghcr.io/google/addlicense:${ADDLICENSE_VERSION} AS addlicense
625

726
FROM --platform=${BUILDPLATFORM} golangci/golangci-lint:${GOLANGCI_LINT_VERSION}-alpine AS lint-base
827

@@ -13,6 +32,32 @@ FROM --platform=${BUILDPLATFORM} crazymax/osxcross:${OSXCROSS_VERSION}-alpine AS
1332
FROM --platform=${BUILDPLATFORM} golang:${GO_VERSION}-alpine AS gobase
1433
RUN apk add --no-cache findutils build-base git
1534

35+
FROM alpine:${ALPINE_VERSION} AS license-validate
36+
ARG LICENSE_ARGS
37+
COPY --link --from=addlicense /app/addlicense /usr/bin/addlicense
38+
WORKDIR /src
39+
RUN --mount=type=bind,target=.,ro <<EOT
40+
set -eu
41+
echo "== Checking license headers =="
42+
eval "/usr/bin/addlicense -check $LICENSE_ARGS"
43+
EOT
44+
45+
FROM alpine:${ALPINE_VERSION} AS do-license-update
46+
ARG LICENSE_ARGS
47+
COPY --from=addlicense /app/addlicense /usr/bin/addlicense
48+
RUN mkdir -p /generate/out
49+
WORKDIR /src
50+
RUN apk add --no-cache git
51+
RUN --mount=type=bind,target=.,rw <<EOT
52+
set -eu
53+
echo "== Checking license headers =="
54+
eval "/usr/bin/addlicense -v $LICENSE_ARGS"
55+
./scripts/copy-only-diff /generate/out
56+
EOT
57+
58+
FROM scratch AS license-update
59+
COPY --from=do-license-update /generate/out .
60+
1661
FROM gobase AS linux-base
1762
ARG TARGETARCH
1863
ENV GOOS=linux

Makefile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,4 +132,12 @@ help: ## Show this help
132132
@echo Please specify a build target. The choices are:
133133
@grep -E '^[0-9a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "$(INFO_COLOR)%-30s$(NO_COLOR) %s\n", $$1, $$2}'
134134

135-
.PHONY: run bin format lint proto-lint proto-generate clean help keychain-linux-unit-tests keychain-unit-tests
135+
.PHONY: validate-headers
136+
validate-headers: ## Check license header for all files
137+
@docker buildx build --progress=plain --platform=linux/amd64 --target=license-validate .
138+
139+
.PHONY: update-license-headers
140+
update-license-headers: ## Update license headers for all files
141+
@docker buildx build -o . --progress=plain --platform=linux/amd64 --target=license-update .
142+
143+
.PHONY: run bin format lint proto-lint proto-generate clean help keychain-linux-unit-tests keychain-unit-tests validate-headers update-license-headers

client/client_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
// Copyright 2026 Docker, Inc.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
115
package client
216

317
import (

client/realms/docker.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
// Copyright 2026 Docker, Inc.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
115
// Package realms exposes the canonical set of Docker realm patterns that
216
// clients use to scope secret queries.
317
//

plugin/config_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
// Copyright 2026 Docker, Inc.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
115
package plugin
216

317
import (

plugin/resolver_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
// Copyright 2026 Docker, Inc.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
115
package plugin
216

317
import (

plugin/setup_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
// Copyright 2026 Docker, Inc.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
115
package plugin
216

317
import (

plugins/credentialhelper/store_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
// Copyright 2026 Docker, Inc.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
115
package credentialhelper
216

317
import (

plugins/pass/command_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
// Copyright 2026 Docker, Inc.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
115
package pass
216

317
import (

0 commit comments

Comments
 (0)