From 86f68b9374a8b0393745cdb1b5bebb858bee63b7 Mon Sep 17 00:00:00 2001 From: Marek Siarkowicz Date: Tue, 29 Jun 2021 11:57:53 +0200 Subject: [PATCH] *: Add missing file licenses and Fix static analysis prevent skipping them in future --- client/pkg/transport/listener_opts.go | 14 ++++++++++++++ client/pkg/transport/sockopt.go | 14 ++++++++++++++ client/pkg/transport/sockopt_unix.go | 14 ++++++++++++++ client/pkg/transport/sockopt_windows.go | 14 ++++++++++++++ client/v3/naming/endpoints/endpoints.go | 14 ++++++++++++++ client/v3/naming/endpoints/endpoints_impl.go | 14 ++++++++++++++ client/v3/naming/endpoints/internal/update.go | 14 ++++++++++++++ client/v3/naming/resolver/resolver.go | 14 ++++++++++++++ pkg/grpc_testing/stub_server.go | 14 ++++++++++++++ server/etcdserver/adapters.go | 14 ++++++++++++++ server/etcdserver/version/monitor.go | 14 ++++++++++++++ test.sh | 17 ++++++----------- tools/mod/go.mod | 1 + tools/mod/go.sum | 2 ++ tools/mod/tools.go | 1 + 15 files changed, 164 insertions(+), 11 deletions(-) diff --git a/client/pkg/transport/listener_opts.go b/client/pkg/transport/listener_opts.go index ad4f6904d..7536f6aff 100644 --- a/client/pkg/transport/listener_opts.go +++ b/client/pkg/transport/listener_opts.go @@ -1,3 +1,17 @@ +// Copyright 2021 The etcd 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 transport import ( diff --git a/client/pkg/transport/sockopt.go b/client/pkg/transport/sockopt.go index fe028c613..49b48dc87 100644 --- a/client/pkg/transport/sockopt.go +++ b/client/pkg/transport/sockopt.go @@ -1,3 +1,17 @@ +// Copyright 2021 The etcd 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 transport import ( diff --git a/client/pkg/transport/sockopt_unix.go b/client/pkg/transport/sockopt_unix.go index 432b52e0f..cda7fc7de 100644 --- a/client/pkg/transport/sockopt_unix.go +++ b/client/pkg/transport/sockopt_unix.go @@ -1,3 +1,17 @@ +// Copyright 2021 The etcd 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. + //go:build !windows // +build !windows diff --git a/client/pkg/transport/sockopt_windows.go b/client/pkg/transport/sockopt_windows.go index 4e5af70b1..3e28ed48b 100644 --- a/client/pkg/transport/sockopt_windows.go +++ b/client/pkg/transport/sockopt_windows.go @@ -1,3 +1,17 @@ +// Copyright 2021 The etcd 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. + //go:build windows // +build windows diff --git a/client/v3/naming/endpoints/endpoints.go b/client/v3/naming/endpoints/endpoints.go index 72bd22787..ffe77eff7 100644 --- a/client/v3/naming/endpoints/endpoints.go +++ b/client/v3/naming/endpoints/endpoints.go @@ -1,3 +1,17 @@ +// Copyright 2021 The etcd 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 endpoints import ( diff --git a/client/v3/naming/endpoints/endpoints_impl.go b/client/v3/naming/endpoints/endpoints_impl.go index 37f04803e..7796f7c9c 100644 --- a/client/v3/naming/endpoints/endpoints_impl.go +++ b/client/v3/naming/endpoints/endpoints_impl.go @@ -1,3 +1,17 @@ +// Copyright 2021 The etcd 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 endpoints // TODO: The API is not yet implemented. diff --git a/client/v3/naming/endpoints/internal/update.go b/client/v3/naming/endpoints/internal/update.go index 71aa83fed..d42f49062 100644 --- a/client/v3/naming/endpoints/internal/update.go +++ b/client/v3/naming/endpoints/internal/update.go @@ -1,3 +1,17 @@ +// Copyright 2021 The etcd 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 internal // Operation describes action performed on endpoint (addition vs deletion). diff --git a/client/v3/naming/resolver/resolver.go b/client/v3/naming/resolver/resolver.go index a44f61ae0..86a514837 100644 --- a/client/v3/naming/resolver/resolver.go +++ b/client/v3/naming/resolver/resolver.go @@ -1,3 +1,17 @@ +// Copyright 2021 The etcd 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 resolver import ( diff --git a/pkg/grpc_testing/stub_server.go b/pkg/grpc_testing/stub_server.go index f21b4db9a..e9f0d094f 100644 --- a/pkg/grpc_testing/stub_server.go +++ b/pkg/grpc_testing/stub_server.go @@ -1,3 +1,17 @@ +// Copyright 2021 The etcd 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 grpc_testing import ( diff --git a/server/etcdserver/adapters.go b/server/etcdserver/adapters.go index 4e97c430c..b00e721f7 100644 --- a/server/etcdserver/adapters.go +++ b/server/etcdserver/adapters.go @@ -1,3 +1,17 @@ +// Copyright 2021 The etcd 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 etcdserver import ( diff --git a/server/etcdserver/version/monitor.go b/server/etcdserver/version/monitor.go index d53b33d4c..0db7be625 100644 --- a/server/etcdserver/version/monitor.go +++ b/server/etcdserver/version/monitor.go @@ -1,3 +1,17 @@ +// Copyright 2021 The etcd 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 version import ( diff --git a/test.sh b/test.sh index cb8d344f8..7a3371008 100755 --- a/test.sh +++ b/test.sh @@ -473,20 +473,15 @@ function nakedret_pass { run_for_modules generic_checker run_go_tool "github.com/alexkohler/nakedret" } -function license_header_pass { +function license_header_per_module { # bash 3.x compatible replacement of: mapfile -t gofiles < <(go_srcs_in_module "$1") local gofiles=() while IFS= read -r line; do gofiles+=("$line"); done < <(go_srcs_in_module "$1") - - for file in "${gofiles[@]}"; do - if ! head -n3 "${file}" | grep -Eq "(Copyright|generated|GENERATED)" ; then - licRes="${licRes}"$(echo -e " ${file}") - fi - done - if [ -n "${licRes}" ]; then - log_error -e "license header checking failed:\\n${licRes}" - return 255 - fi + run_go_tool "github.com/google/addlicense" --check "${gofiles[@]}" +} + +function license_header_pass { + run_for_modules generic_checker license_header_per_module } function receiver_name_for_package { diff --git a/tools/mod/go.mod b/tools/mod/go.mod index f57f3e6b0..c67cd7655 100644 --- a/tools/mod/go.mod +++ b/tools/mod/go.mod @@ -10,6 +10,7 @@ require ( github.com/go-openapi/loads v0.19.5 // indirect github.com/go-openapi/spec v0.19.9 // indirect github.com/gogo/protobuf v1.3.2 + github.com/google/addlicense v0.0.0-20210428195630-6d92264d7170 // indirect github.com/gordonklaus/ineffassign v0.0.0-20200809085317-e36bfde3bb78 github.com/grpc-ecosystem/grpc-gateway v1.14.6 github.com/gyuho/gocovmerge v0.0.0-20171205171859-50c7e6afd535 diff --git a/tools/mod/go.sum b/tools/mod/go.sum index a4c881fdb..111a8e51a 100644 --- a/tools/mod/go.sum +++ b/tools/mod/go.sum @@ -140,6 +140,8 @@ github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvq github.com/golang/protobuf v1.4.1 h1:ZFgWrT+bLgsYPirOnRfKLYJLvssAegOj/hgyMFdJZe0= github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/google/addlicense v0.0.0-20210428195630-6d92264d7170 h1:jLUa4MO3autxlRJmC4KubeE5QGIb5JqW9oEaqYTb/fA= +github.com/google/addlicense v0.0.0-20210428195630-6d92264d7170/go.mod h1:EMjYTRimagHs1FwlIqKyX3wAM0u3rA+McvlIIWmSamA= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= diff --git a/tools/mod/tools.go b/tools/mod/tools.go index 43796931b..9f6305e98 100644 --- a/tools/mod/tools.go +++ b/tools/mod/tools.go @@ -24,6 +24,7 @@ import ( _ "github.com/alexkohler/nakedret" _ "github.com/chzchzchz/goword" _ "github.com/coreos/license-bill-of-materials" + _ "github.com/google/addlicense" _ "github.com/gordonklaus/ineffassign" _ "github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway" _ "github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger"