Skip to content

Commit cab510f

Browse files
committed
check for license headers in CI
Also update license information to reflect latest authors. Updates #cleanup Signed-off-by: Percy Wegmann <[email protected]>
1 parent 521047c commit cab510f

31 files changed

+170
-0
lines changed

.github/workflows/ci.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,11 @@ jobs:
3131
3232
- name: Run tests
3333
run: go test -race ./...
34+
35+
licenses:
36+
runs-on: ubuntu-latest
37+
steps:
38+
- name: checkout
39+
uses: actions/checkout@v4
40+
- name: check licenses
41+
run: ./scripts/check_license_headers.sh .

LICENSE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
MIT License
22

33
Copyright (c) 2021 David Bond
4+
Copyright (c) 2024 Tailscale Inc & Contributors
45

56
Permission is hereby granted, free of charge, to any person obtaining a copy
67
of this software and associated documentation files (the "Software"), to deal

scripts/check_license_headers.sh

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#!/bin/sh
2+
#
3+
# Copyright (c) David Bond, Tailscale Inc, & Contributors
4+
# SPDX-License-Identifier: MIT
5+
6+
# check_license_headers.sh checks that all Go files in the given
7+
# directory tree have a correct-looking license header.
8+
9+
check_file() {
10+
got=$1
11+
12+
want=$(cat <<EOF
13+
// Copyright (c) David Bond, Tailscale Inc, & Contributors
14+
// SPDX-License-Identifier: MIT
15+
EOF
16+
)
17+
if [ "$got" = "$want" ]; then
18+
return 0
19+
fi
20+
return 1
21+
}
22+
23+
if [ $# != 1 ]; then
24+
echo "Usage: $0 rootdir" >&2
25+
exit 1
26+
fi
27+
28+
fail=0
29+
for file in $(find $1 \( -name '*.go' -or -name '*.tsx' -or -name '*.ts' -not -name '*.config.ts' \) -not -path '*/.git/*' -not -path '*/node_modules/*'); do
30+
case $file in
31+
$1/tempfork/*)
32+
# Skip, tempfork of third-party code
33+
;;
34+
$1/wgengine/router/ifconfig_windows.go)
35+
# WireGuard copyright.
36+
;;
37+
$1/cmd/tailscale/cli/authenticode_windows.go)
38+
# WireGuard copyright.
39+
;;
40+
*_string.go)
41+
# Generated file from go:generate stringer
42+
;;
43+
$1/control/controlbase/noiseexplorer_test.go)
44+
# Noiseexplorer.com copyright.
45+
;;
46+
*/zsyscall_windows.go)
47+
# Generated syscall wrappers
48+
;;
49+
$1/util/winutil/subprocess_windows_test.go)
50+
# Subprocess test harness code
51+
;;
52+
$1/util/winutil/testdata/testrestartableprocesses/main.go)
53+
# Subprocess test harness code
54+
;;
55+
*$1/k8s-operator/apis/v1alpha1/zz_generated.deepcopy.go)
56+
# Generated kube deepcopy funcs file starts with a Go build tag + an empty line
57+
header="$(head -5 $file | tail -n+3 )"
58+
;;
59+
$1/derp/xdp/bpf_bpfe*.go)
60+
# Generated eBPF management code
61+
;;
62+
*)
63+
header="$(head -2 $file)"
64+
;;
65+
esac
66+
if [ ! -z "$header" ]; then
67+
if ! check_file "$header"; then
68+
fail=1
69+
echo "${file#$1/} doesn't have the right copyright header:"
70+
echo "$header" | sed -e 's/^/ /g'
71+
fi
72+
fi
73+
done
74+
75+
if [ $fail -ne 0 ]; then
76+
exit 1
77+
fi

tailscale/client.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// Copyright (c) David Bond, Tailscale Inc, & Contributors
2+
// SPDX-License-Identifier: MIT
3+
14
// Package tailscale contains a basic implementation of a client for the Tailscale HTTP api. Documentation is here:
25
// https://github.com/tailscale/tailscale/blob/main/api.md
36
package tailscale

tailscale/client_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// Copyright (c) David Bond, Tailscale Inc, & Contributors
2+
// SPDX-License-Identifier: MIT
3+
14
package tailscale_test
25

36
import (

tailscale/tailscale_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// Copyright (c) David Bond, Tailscale Inc, & Contributors
2+
// SPDX-License-Identifier: MIT
3+
14
package tailscale_test
25

36
import (

tailscale/time_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// Copyright (c) David Bond, Tailscale Inc, & Contributors
2+
// SPDX-License-Identifier: MIT
3+
14
package tailscale_test
25

36
import (

v2/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// Copyright (c) David Bond, Tailscale Inc, & Contributors
2+
// SPDX-License-Identifier: MIT
3+
14
# tailscale-client-go/v2
25

36
[![Go Reference](https://pkg.go.dev/badge/github.com/tailscale/tailscale-client-go/v2.svg)](https://pkg.go.dev/github.com/tailscale/tailscale-client-go/v2)

v2/client.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// Copyright (c) David Bond, Tailscale Inc, & Contributors
2+
// SPDX-License-Identifier: MIT
3+
14
// Package tsclient contains a basic implementation of a client for the Tailscale HTTP api. Documentation is here:
25
// https://tailscale.com/api
36
package tsclient

v2/client_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// Copyright (c) David Bond, Tailscale Inc, & Contributors
2+
// SPDX-License-Identifier: MIT
3+
14
package tsclient
25

36
import (

0 commit comments

Comments
 (0)