Skip to content

Commit

Permalink
{all}: check for license headers in CI (#431)
Browse files Browse the repository at this point in the history
Check license headers in CI runs with scripts/check_license_headers.sh.
Also adjust LICENSE to reflect the current authors.

Updates #cleanup

Signed-off-by: Mario Minardi <[email protected]>
  • Loading branch information
mpminardi authored Sep 13, 2024
1 parent ed15c6e commit a46f500
Show file tree
Hide file tree
Showing 48 changed files with 221 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,11 @@ jobs:
run: |
git add .
git diff --staged --exit-code
licenses:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
- name: check licenses
run: ./scripts/check_license_headers.sh .
1 change: 1 addition & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
MIT License

Copyright (c) 2021 David Bond
Copyright (c) 2024 Tailscale Inc & Contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
3 changes: 3 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) David Bond, Tailscale Inc, & Contributors
// SPDX-License-Identifier: MIT

//go:generate tfplugindocs
package main

Expand Down
77 changes: 77 additions & 0 deletions scripts/check_license_headers.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#!/bin/sh
#
# Copyright (c) David Bond, Tailscale Inc, & Contributors
# SPDX-License-Identifier: MIT

# check_license_headers.sh checks that all Go files in the given
# directory tree have a correct-looking license header.

check_file() {
got=$1

want=$(cat <<EOF
// Copyright (c) David Bond, Tailscale Inc, & Contributors
// SPDX-License-Identifier: MIT
EOF
)
if [ "$got" = "$want" ]; then
return 0
fi
return 1
}

if [ $# != 1 ]; then
echo "Usage: $0 rootdir" >&2
exit 1
fi

fail=0
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
case $file in
$1/tempfork/*)
# Skip, tempfork of third-party code
;;
$1/wgengine/router/ifconfig_windows.go)
# WireGuard copyright.
;;
$1/cmd/tailscale/cli/authenticode_windows.go)
# WireGuard copyright.
;;
*_string.go)
# Generated file from go:generate stringer
;;
$1/control/controlbase/noiseexplorer_test.go)
# Noiseexplorer.com copyright.
;;
*/zsyscall_windows.go)
# Generated syscall wrappers
;;
$1/util/winutil/subprocess_windows_test.go)
# Subprocess test harness code
;;
$1/util/winutil/testdata/testrestartableprocesses/main.go)
# Subprocess test harness code
;;
*$1/k8s-operator/apis/v1alpha1/zz_generated.deepcopy.go)
# Generated kube deepcopy funcs file starts with a Go build tag + an empty line
header="$(head -5 $file | tail -n+3 )"
;;
$1/derp/xdp/bpf_bpfe*.go)
# Generated eBPF management code
;;
*)
header="$(head -2 $file)"
;;
esac
if [ ! -z "$header" ]; then
if ! check_file "$header"; then
fail=1
echo "${file#$1/} doesn't have the right copyright header:"
echo "$header" | sed -e 's/^/ /g'
fi
fi
done

if [ $fail -ne 0 ]; then
exit 1
fi
3 changes: 3 additions & 0 deletions tailscale/data_source_4via6.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) David Bond, Tailscale Inc, & Contributors
// SPDX-License-Identifier: MIT

package tailscale

import (
Expand Down
3 changes: 3 additions & 0 deletions tailscale/data_source_4via6_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) David Bond, Tailscale Inc, & Contributors
// SPDX-License-Identifier: MIT

package tailscale

import (
Expand Down
3 changes: 3 additions & 0 deletions tailscale/data_source_acl.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) David Bond, Tailscale Inc, & Contributors
// SPDX-License-Identifier: MIT

package tailscale

import (
Expand Down
3 changes: 3 additions & 0 deletions tailscale/data_source_acl_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) David Bond, Tailscale Inc, & Contributors
// SPDX-License-Identifier: MIT

package tailscale

import (
Expand Down
3 changes: 3 additions & 0 deletions tailscale/data_source_device.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) David Bond, Tailscale Inc, & Contributors
// SPDX-License-Identifier: MIT

package tailscale

import (
Expand Down
3 changes: 3 additions & 0 deletions tailscale/data_source_devices.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) David Bond, Tailscale Inc, & Contributors
// SPDX-License-Identifier: MIT

package tailscale

import (
Expand Down
3 changes: 3 additions & 0 deletions tailscale/data_source_user.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) David Bond, Tailscale Inc, & Contributors
// SPDX-License-Identifier: MIT

package tailscale

import (
Expand Down
3 changes: 3 additions & 0 deletions tailscale/data_source_users.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) David Bond, Tailscale Inc, & Contributors
// SPDX-License-Identifier: MIT

package tailscale

import (
Expand Down
3 changes: 3 additions & 0 deletions tailscale/data_source_users_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) David Bond, Tailscale Inc, & Contributors
// SPDX-License-Identifier: MIT

package tailscale

import (
Expand Down
3 changes: 3 additions & 0 deletions tailscale/datasource_devices_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) David Bond, Tailscale Inc, & Contributors
// SPDX-License-Identifier: MIT

package tailscale

import (
Expand Down
3 changes: 3 additions & 0 deletions tailscale/provider.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) David Bond, Tailscale Inc, & Contributors
// SPDX-License-Identifier: MIT

// Package tailscale describes the resources and data sources provided by the terraform provider. Each resource
// or data source is described within its own file.
package tailscale
Expand Down
3 changes: 3 additions & 0 deletions tailscale/provider_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) David Bond, Tailscale Inc, & Contributors
// SPDX-License-Identifier: MIT

package tailscale

import (
Expand Down
3 changes: 3 additions & 0 deletions tailscale/resource_acl.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) David Bond, Tailscale Inc, & Contributors
// SPDX-License-Identifier: MIT

package tailscale

import (
Expand Down
3 changes: 3 additions & 0 deletions tailscale/resource_acl_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) David Bond, Tailscale Inc, & Contributors
// SPDX-License-Identifier: MIT

package tailscale

import (
Expand Down
3 changes: 3 additions & 0 deletions tailscale/resource_contacts.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) David Bond, Tailscale Inc, & Contributors
// SPDX-License-Identifier: MIT

package tailscale

import (
Expand Down
3 changes: 3 additions & 0 deletions tailscale/resource_contacts_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) David Bond, Tailscale Inc, & Contributors
// SPDX-License-Identifier: MIT

package tailscale

import (
Expand Down
3 changes: 3 additions & 0 deletions tailscale/resource_device_authorization.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) David Bond, Tailscale Inc, & Contributors
// SPDX-License-Identifier: MIT

package tailscale

import (
Expand Down
3 changes: 3 additions & 0 deletions tailscale/resource_device_authorization_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) David Bond, Tailscale Inc, & Contributors
// SPDX-License-Identifier: MIT

package tailscale

import (
Expand Down
3 changes: 3 additions & 0 deletions tailscale/resource_device_key.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) David Bond, Tailscale Inc, & Contributors
// SPDX-License-Identifier: MIT

package tailscale

import (
Expand Down
3 changes: 3 additions & 0 deletions tailscale/resource_device_key_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) David Bond, Tailscale Inc, & Contributors
// SPDX-License-Identifier: MIT

package tailscale

import (
Expand Down
3 changes: 3 additions & 0 deletions tailscale/resource_device_subnet_routes.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) David Bond, Tailscale Inc, & Contributors
// SPDX-License-Identifier: MIT

package tailscale

import (
Expand Down
3 changes: 3 additions & 0 deletions tailscale/resource_device_subnet_routes_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) David Bond, Tailscale Inc, & Contributors
// SPDX-License-Identifier: MIT

package tailscale

import (
Expand Down
3 changes: 3 additions & 0 deletions tailscale/resource_device_tags.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) David Bond, Tailscale Inc, & Contributors
// SPDX-License-Identifier: MIT

package tailscale

import (
Expand Down
3 changes: 3 additions & 0 deletions tailscale/resource_device_tags_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) David Bond, Tailscale Inc, & Contributors
// SPDX-License-Identifier: MIT

package tailscale

import (
Expand Down
3 changes: 3 additions & 0 deletions tailscale/resource_dns_nameservers.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) David Bond, Tailscale Inc, & Contributors
// SPDX-License-Identifier: MIT

package tailscale

import (
Expand Down
3 changes: 3 additions & 0 deletions tailscale/resource_dns_nameservers_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) David Bond, Tailscale Inc, & Contributors
// SPDX-License-Identifier: MIT

package tailscale

import (
Expand Down
3 changes: 3 additions & 0 deletions tailscale/resource_dns_preferences.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) David Bond, Tailscale Inc, & Contributors
// SPDX-License-Identifier: MIT

package tailscale

import (
Expand Down
3 changes: 3 additions & 0 deletions tailscale/resource_dns_preferences_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) David Bond, Tailscale Inc, & Contributors
// SPDX-License-Identifier: MIT

package tailscale

import (
Expand Down
3 changes: 3 additions & 0 deletions tailscale/resource_dns_search_paths.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) David Bond, Tailscale Inc, & Contributors
// SPDX-License-Identifier: MIT

package tailscale

import (
Expand Down
3 changes: 3 additions & 0 deletions tailscale/resource_dns_search_paths_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) David Bond, Tailscale Inc, & Contributors
// SPDX-License-Identifier: MIT

package tailscale

import (
Expand Down
3 changes: 3 additions & 0 deletions tailscale/resource_dns_split_nameservers.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) David Bond, Tailscale Inc, & Contributors
// SPDX-License-Identifier: MIT

package tailscale

import (
Expand Down
3 changes: 3 additions & 0 deletions tailscale/resource_dns_split_nameservers_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) David Bond, Tailscale Inc, & Contributors
// SPDX-License-Identifier: MIT

package tailscale

import (
Expand Down
3 changes: 3 additions & 0 deletions tailscale/resource_logstream_configuration.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) David Bond, Tailscale Inc, & Contributors
// SPDX-License-Identifier: MIT

package tailscale

import (
Expand Down
3 changes: 3 additions & 0 deletions tailscale/resource_logstream_configuration_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) David Bond, Tailscale Inc, & Contributors
// SPDX-License-Identifier: MIT

package tailscale

import (
Expand Down
3 changes: 3 additions & 0 deletions tailscale/resource_posture_integration.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) David Bond, Tailscale Inc, & Contributors
// SPDX-License-Identifier: MIT

package tailscale

import (
Expand Down
3 changes: 3 additions & 0 deletions tailscale/resource_posture_integration_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) David Bond, Tailscale Inc, & Contributors
// SPDX-License-Identifier: MIT

package tailscale

import (
Expand Down
3 changes: 3 additions & 0 deletions tailscale/resource_tailnet_key.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) David Bond, Tailscale Inc, & Contributors
// SPDX-License-Identifier: MIT

package tailscale

import (
Expand Down
3 changes: 3 additions & 0 deletions tailscale/resource_tailnet_key_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) David Bond, Tailscale Inc, & Contributors
// SPDX-License-Identifier: MIT

package tailscale

import (
Expand Down
3 changes: 3 additions & 0 deletions tailscale/resource_tailnet_settings.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) David Bond, Tailscale Inc, & Contributors
// SPDX-License-Identifier: MIT

package tailscale

import (
Expand Down
3 changes: 3 additions & 0 deletions tailscale/resource_tailnet_settings_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) David Bond, Tailscale Inc, & Contributors
// SPDX-License-Identifier: MIT

package tailscale

import (
Expand Down
3 changes: 3 additions & 0 deletions tailscale/resource_webhook.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) David Bond, Tailscale Inc, & Contributors
// SPDX-License-Identifier: MIT

package tailscale

import (
Expand Down
3 changes: 3 additions & 0 deletions tailscale/resource_webhook_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) David Bond, Tailscale Inc, & Contributors
// SPDX-License-Identifier: MIT

package tailscale

import (
Expand Down
Loading

0 comments on commit a46f500

Please sign in to comment.