From 1c8262be12c120b43ed18e83321d47e1bd449ea0 Mon Sep 17 00:00:00 2001 From: Jonathan Boulle Date: Wed, 13 Apr 2016 16:06:32 +0200 Subject: [PATCH 1/3] Add script to check for missing license headers Also adds a `check_license` target to the Makefile to run the script --- Makefile | 6 +++++- scripts/check_license.sh | 10 ++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100755 scripts/check_license.sh diff --git a/Makefile b/Makefile index 5979b35775..5b02d736b7 100644 --- a/Makefile +++ b/Makefile @@ -25,6 +25,10 @@ style: @echo ">> checking code style" @! gofmt -d $(shell find . -path ./vendor -prune -o -name '*.go' -print) | grep '^' +check_license: + @echo ">> checking license header" + @./scripts/check_license.sh + test: @echo ">> running tests" @$(GO) test -short $(pkgs) @@ -54,5 +58,5 @@ assets: @go-bindata $(bindata_flags) -pkg ui -o web/ui/bindata.go -ignore '(.*\.map|bootstrap\.js|bootstrap-theme\.css|bootstrap\.css)' web/ui/templates/... web/ui/static/... -.PHONY: all style format build test vet docker assets tarballs +.PHONY: all style check_license format build test vet docker assets tarballs diff --git a/scripts/check_license.sh b/scripts/check_license.sh new file mode 100755 index 0000000000..d3882c6b66 --- /dev/null +++ b/scripts/check_license.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +licRes=$( +for file in $(find . -type f -iname '*.go' ! -path './vendor/*'); do + head -n3 "${file}" | grep -Eq "(Copyright|generated|GENERATED)" || echo -e " ${file}" +done;) +if [ -n "${licRes}" ]; then + echo -e "license header checking failed:\n${licRes}" + exit 255 +fi From 38098f8c9597e7cae803b1430526d57e3e364e03 Mon Sep 17 00:00:00 2001 From: Jonathan Boulle Date: Wed, 13 Apr 2016 16:08:22 +0200 Subject: [PATCH 2/3] Add missing license headers Prometheus is Apache 2 licensed, and most source files have the appropriate copyright license header, but some were missing it without apparent reason. Correct that by adding it. --- promql/engine_test.go | 13 +++++++++++++ retrieval/discovery/file_test.go | 13 +++++++++++++ storage/local/locker.go | 13 +++++++++++++ storage/local/locker_test.go | 13 +++++++++++++ storage/local/mapper.go | 13 +++++++++++++ storage/local/mapper_test.go | 13 +++++++++++++ storage/remote/opentsdb/tagvalue.go | 13 +++++++++++++ storage/remote/opentsdb/tagvalue_test.go | 13 +++++++++++++ util/flock/flock.go | 13 +++++++++++++ util/flock/flock_plan9.go | 13 +++++++++++++ util/flock/flock_solaris.go | 13 +++++++++++++ util/flock/flock_test.go | 13 +++++++++++++ util/flock/flock_unix.go | 13 +++++++++++++ util/flock/flock_windows.go | 13 +++++++++++++ util/treecache/treecache.go | 13 +++++++++++++ web/api/v1/api.go | 13 +++++++++++++ web/api/v1/api_test.go | 13 +++++++++++++ web/web_test.go | 13 +++++++++++++ 18 files changed, 234 insertions(+) diff --git a/promql/engine_test.go b/promql/engine_test.go index c3bec13156..bf74e12eb1 100644 --- a/promql/engine_test.go +++ b/promql/engine_test.go @@ -1,3 +1,16 @@ +// Copyright 2016 The Prometheus Authors +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package promql import ( diff --git a/retrieval/discovery/file_test.go b/retrieval/discovery/file_test.go index a096ad908a..1f8b194878 100644 --- a/retrieval/discovery/file_test.go +++ b/retrieval/discovery/file_test.go @@ -1,3 +1,16 @@ +// Copyright 2016 The Prometheus Authors +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package discovery import ( diff --git a/storage/local/locker.go b/storage/local/locker.go index f15c2438bf..8ad30cc558 100644 --- a/storage/local/locker.go +++ b/storage/local/locker.go @@ -1,3 +1,16 @@ +// Copyright 2016 The Prometheus Authors +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package local import ( diff --git a/storage/local/locker_test.go b/storage/local/locker_test.go index 46e8c68c43..8450afcbbf 100644 --- a/storage/local/locker_test.go +++ b/storage/local/locker_test.go @@ -1,3 +1,16 @@ +// Copyright 2016 The Prometheus Authors +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package local import ( diff --git a/storage/local/mapper.go b/storage/local/mapper.go index 0d21de2cbd..e31df2b9b9 100644 --- a/storage/local/mapper.go +++ b/storage/local/mapper.go @@ -1,3 +1,16 @@ +// Copyright 2016 The Prometheus Authors +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package local import ( diff --git a/storage/local/mapper_test.go b/storage/local/mapper_test.go index 05747f6dde..f37a016575 100644 --- a/storage/local/mapper_test.go +++ b/storage/local/mapper_test.go @@ -1,3 +1,16 @@ +// Copyright 2016 The Prometheus Authors +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package local import ( diff --git a/storage/remote/opentsdb/tagvalue.go b/storage/remote/opentsdb/tagvalue.go index e789e2312c..d96f9017af 100644 --- a/storage/remote/opentsdb/tagvalue.go +++ b/storage/remote/opentsdb/tagvalue.go @@ -1,3 +1,16 @@ +// Copyright 2016 The Prometheus Authors +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package opentsdb import ( diff --git a/storage/remote/opentsdb/tagvalue_test.go b/storage/remote/opentsdb/tagvalue_test.go index 821c3565c9..100aed29f3 100644 --- a/storage/remote/opentsdb/tagvalue_test.go +++ b/storage/remote/opentsdb/tagvalue_test.go @@ -1,3 +1,16 @@ +// Copyright 2016 The Prometheus Authors +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package opentsdb import ( diff --git a/util/flock/flock.go b/util/flock/flock.go index 51e3469a97..5dc22a2fae 100644 --- a/util/flock/flock.go +++ b/util/flock/flock.go @@ -1,3 +1,16 @@ +// Copyright 2016 The Prometheus Authors +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + // Package flock provides portable file locking. It is essentially ripped out // from the code of github.com/syndtr/goleveldb. Strange enough that the // standard library does not provide this functionality. Once this package has diff --git a/util/flock/flock_plan9.go b/util/flock/flock_plan9.go index 362911bec8..004e85c0fe 100644 --- a/util/flock/flock_plan9.go +++ b/util/flock/flock_plan9.go @@ -1,3 +1,16 @@ +// Copyright 2016 The Prometheus Authors +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package flock import "os" diff --git a/util/flock/flock_solaris.go b/util/flock/flock_solaris.go index 462daea06a..299fc87446 100644 --- a/util/flock/flock_solaris.go +++ b/util/flock/flock_solaris.go @@ -1,3 +1,16 @@ +// Copyright 2016 The Prometheus Authors +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + // +build solaris package flock diff --git a/util/flock/flock_test.go b/util/flock/flock_test.go index 6c26fd5f64..10e4c47f62 100644 --- a/util/flock/flock_test.go +++ b/util/flock/flock_test.go @@ -1,3 +1,16 @@ +// Copyright 2016 The Prometheus Authors +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package flock import ( diff --git a/util/flock/flock_unix.go b/util/flock/flock_unix.go index 2bfb48fbc2..7d71f8fc09 100644 --- a/util/flock/flock_unix.go +++ b/util/flock/flock_unix.go @@ -1,3 +1,16 @@ +// Copyright 2016 The Prometheus Authors +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + // +build darwin dragonfly freebsd linux netbsd openbsd package flock diff --git a/util/flock/flock_windows.go b/util/flock/flock_windows.go index 643f2a02b4..bf7266f14c 100644 --- a/util/flock/flock_windows.go +++ b/util/flock/flock_windows.go @@ -1,3 +1,16 @@ +// Copyright 2016 The Prometheus Authors +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package flock import "syscall" diff --git a/util/treecache/treecache.go b/util/treecache/treecache.go index c23766f3c8..2de4e073d8 100644 --- a/util/treecache/treecache.go +++ b/util/treecache/treecache.go @@ -1,3 +1,16 @@ +// Copyright 2016 The Prometheus Authors +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package treecache import ( diff --git a/web/api/v1/api.go b/web/api/v1/api.go index 6858938fbd..df8ce0b344 100644 --- a/web/api/v1/api.go +++ b/web/api/v1/api.go @@ -1,3 +1,16 @@ +// Copyright 2016 The Prometheus Authors +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package v1 import ( diff --git a/web/api/v1/api_test.go b/web/api/v1/api_test.go index 2cc8e467c3..51976eaa94 100644 --- a/web/api/v1/api_test.go +++ b/web/api/v1/api_test.go @@ -1,3 +1,16 @@ +// Copyright 2016 The Prometheus Authors +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package v1 import ( diff --git a/web/web_test.go b/web/web_test.go index de8d2c3230..2971097f85 100644 --- a/web/web_test.go +++ b/web/web_test.go @@ -1,3 +1,16 @@ +// Copyright 2016 The Prometheus Authors +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package web import ( From 096219d53551aaf0fcddf563c20f15264d2333d6 Mon Sep 17 00:00:00 2001 From: Jonathan Boulle Date: Wed, 13 Apr 2016 16:09:52 +0200 Subject: [PATCH 3/3] Add check_style to travis configuration --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 162b330946..316c6a08f4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,4 +6,4 @@ go: - 1.5 script: -- make style test +- make check_license style test