From b850d36166ba2a956e4629e65c5653626f761a3e Mon Sep 17 00:00:00 2001 From: Daniel Smith Date: Mon, 23 Jun 2014 11:32:11 -0700 Subject: [PATCH 1/2] Fix boilerplate everywhere --- cmd/cloudcfg/cloudcfg.go | 1 + cmd/kubelet/kubelet.go | 1 + cmd/proxy/proxy.go | 1 + pkg/apiserver/apiserver_test.go | 1 + pkg/client/client_test.go | 1 + pkg/client/container_info_test.go | 1 + pkg/cloudcfg/parse.go | 16 ++++++++++++++++ pkg/cloudcfg/parse_test.go | 16 ++++++++++++++++ pkg/kubelet/kubelet_server_test.go | 16 ++++++++++++++++ pkg/kubelet/kubelet_test.go | 1 + pkg/proxy/loadbalancer.go | 1 + pkg/proxy/roundrobbin.go | 1 + pkg/proxy/roundrobbin_test.go | 1 + pkg/registry/controller_registry_test.go | 1 + pkg/registry/endpoints_test.go | 1 + pkg/registry/etcd_registry_test.go | 1 + pkg/registry/interfaces.go | 1 + pkg/registry/manifest_factory.go | 1 + pkg/registry/manifest_factory_test.go | 1 + pkg/registry/memory_registry.go | 1 + pkg/registry/memory_registry_test.go | 1 + pkg/registry/mock_service_registry.go | 1 + pkg/registry/pod_registry.go | 1 + pkg/registry/pod_registry_test.go | 1 + pkg/registry/scheduler.go | 1 + pkg/util/etcd_tools_test.go | 16 ++++++++++++++++ pkg/util/fake_etcd_client.go | 1 + pkg/util/fake_handler.go | 1 + pkg/util/fake_handler_test.go | 16 ++++++++++++++++ pkg/util/stringlist.go | 1 + pkg/util/stringlist_test.go | 1 + pkg/util/util_test.go | 16 ++++++++++++++++ 32 files changed, 122 insertions(+) diff --git a/cmd/cloudcfg/cloudcfg.go b/cmd/cloudcfg/cloudcfg.go index 2ba1cc3216..457bd64511 100644 --- a/cmd/cloudcfg/cloudcfg.go +++ b/cmd/cloudcfg/cloudcfg.go @@ -13,6 +13,7 @@ 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 main import ( diff --git a/cmd/kubelet/kubelet.go b/cmd/kubelet/kubelet.go index 56308f9e55..077e334645 100644 --- a/cmd/kubelet/kubelet.go +++ b/cmd/kubelet/kubelet.go @@ -13,6 +13,7 @@ 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. */ + // The kubelet binary is responsible for maintaining a set of containers on a particular host VM. // It sync's data from both configuration file as well as from a quorum of etcd servers. // It then queries Docker to see what is currently running. It synchronizes the configuration data, diff --git a/cmd/proxy/proxy.go b/cmd/proxy/proxy.go index c9c48ccfee..330c68d8a1 100644 --- a/cmd/proxy/proxy.go +++ b/cmd/proxy/proxy.go @@ -13,6 +13,7 @@ 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 main import ( diff --git a/pkg/apiserver/apiserver_test.go b/pkg/apiserver/apiserver_test.go index 93748debe0..fd996ad52d 100644 --- a/pkg/apiserver/apiserver_test.go +++ b/pkg/apiserver/apiserver_test.go @@ -13,6 +13,7 @@ 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 apiserver import ( diff --git a/pkg/client/client_test.go b/pkg/client/client_test.go index dec1f65537..bbdf20edf3 100644 --- a/pkg/client/client_test.go +++ b/pkg/client/client_test.go @@ -13,6 +13,7 @@ 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 client import ( diff --git a/pkg/client/container_info_test.go b/pkg/client/container_info_test.go index e6bc28ba2e..1b0904f959 100644 --- a/pkg/client/container_info_test.go +++ b/pkg/client/container_info_test.go @@ -13,6 +13,7 @@ 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 client import ( diff --git a/pkg/cloudcfg/parse.go b/pkg/cloudcfg/parse.go index 4e1f4d0e17..d776fb9938 100644 --- a/pkg/cloudcfg/parse.go +++ b/pkg/cloudcfg/parse.go @@ -1,3 +1,19 @@ +/* +Copyright 2014 Google Inc. All rights reserved. + +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 cloudcfg import ( diff --git a/pkg/cloudcfg/parse_test.go b/pkg/cloudcfg/parse_test.go index f8ac85b89d..6f14067615 100644 --- a/pkg/cloudcfg/parse_test.go +++ b/pkg/cloudcfg/parse_test.go @@ -1,3 +1,19 @@ +/* +Copyright 2014 Google Inc. All rights reserved. + +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 cloudcfg import ( diff --git a/pkg/kubelet/kubelet_server_test.go b/pkg/kubelet/kubelet_server_test.go index 884f2b4370..e7b69a1128 100644 --- a/pkg/kubelet/kubelet_server_test.go +++ b/pkg/kubelet/kubelet_server_test.go @@ -1,3 +1,19 @@ +/* +Copyright 2014 Google Inc. All rights reserved. + +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 kubelet import ( diff --git a/pkg/kubelet/kubelet_test.go b/pkg/kubelet/kubelet_test.go index 32b75ab4fe..14e242d3d3 100644 --- a/pkg/kubelet/kubelet_test.go +++ b/pkg/kubelet/kubelet_test.go @@ -13,6 +13,7 @@ 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 kubelet import ( diff --git a/pkg/proxy/loadbalancer.go b/pkg/proxy/loadbalancer.go index 1dcd086b90..6481ee30bf 100644 --- a/pkg/proxy/loadbalancer.go +++ b/pkg/proxy/loadbalancer.go @@ -13,6 +13,7 @@ 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. */ + // Loadbalancer interface. Implementations use loadbalancer_ naming. package proxy diff --git a/pkg/proxy/roundrobbin.go b/pkg/proxy/roundrobbin.go index ca4707b9c8..fb11c4bf53 100644 --- a/pkg/proxy/roundrobbin.go +++ b/pkg/proxy/roundrobbin.go @@ -13,6 +13,7 @@ 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. */ + // RoundRobin Loadbalancer package proxy diff --git a/pkg/proxy/roundrobbin_test.go b/pkg/proxy/roundrobbin_test.go index 11f01b3d57..b4af90a981 100644 --- a/pkg/proxy/roundrobbin_test.go +++ b/pkg/proxy/roundrobbin_test.go @@ -13,6 +13,7 @@ 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 proxy import ( diff --git a/pkg/registry/controller_registry_test.go b/pkg/registry/controller_registry_test.go index 8d2257ec0d..6c35cabc2d 100644 --- a/pkg/registry/controller_registry_test.go +++ b/pkg/registry/controller_registry_test.go @@ -13,6 +13,7 @@ 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 registry import ( diff --git a/pkg/registry/endpoints_test.go b/pkg/registry/endpoints_test.go index 65bab95968..71250d04c6 100644 --- a/pkg/registry/endpoints_test.go +++ b/pkg/registry/endpoints_test.go @@ -13,6 +13,7 @@ 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 registry import ( diff --git a/pkg/registry/etcd_registry_test.go b/pkg/registry/etcd_registry_test.go index 407de8d7e3..9e794bc683 100644 --- a/pkg/registry/etcd_registry_test.go +++ b/pkg/registry/etcd_registry_test.go @@ -13,6 +13,7 @@ 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 registry import ( diff --git a/pkg/registry/interfaces.go b/pkg/registry/interfaces.go index de077447ff..f3190b18da 100644 --- a/pkg/registry/interfaces.go +++ b/pkg/registry/interfaces.go @@ -13,6 +13,7 @@ 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 registry import ( diff --git a/pkg/registry/manifest_factory.go b/pkg/registry/manifest_factory.go index cf904b0925..120418cee8 100644 --- a/pkg/registry/manifest_factory.go +++ b/pkg/registry/manifest_factory.go @@ -13,6 +13,7 @@ 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 registry import ( diff --git a/pkg/registry/manifest_factory_test.go b/pkg/registry/manifest_factory_test.go index ffbaa8787d..b956c373ea 100644 --- a/pkg/registry/manifest_factory_test.go +++ b/pkg/registry/manifest_factory_test.go @@ -13,6 +13,7 @@ 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 registry import ( diff --git a/pkg/registry/memory_registry.go b/pkg/registry/memory_registry.go index 994649df93..bd0e25cf10 100644 --- a/pkg/registry/memory_registry.go +++ b/pkg/registry/memory_registry.go @@ -13,6 +13,7 @@ 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 registry import ( diff --git a/pkg/registry/memory_registry_test.go b/pkg/registry/memory_registry_test.go index b9adb26d9c..3409ce0921 100644 --- a/pkg/registry/memory_registry_test.go +++ b/pkg/registry/memory_registry_test.go @@ -13,6 +13,7 @@ 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 registry import ( diff --git a/pkg/registry/mock_service_registry.go b/pkg/registry/mock_service_registry.go index 951054cd5e..712881f541 100644 --- a/pkg/registry/mock_service_registry.go +++ b/pkg/registry/mock_service_registry.go @@ -13,6 +13,7 @@ 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 registry import ( diff --git a/pkg/registry/pod_registry.go b/pkg/registry/pod_registry.go index fd9c6eb3c9..e80aa576ac 100644 --- a/pkg/registry/pod_registry.go +++ b/pkg/registry/pod_registry.go @@ -13,6 +13,7 @@ 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 registry import ( diff --git a/pkg/registry/pod_registry_test.go b/pkg/registry/pod_registry_test.go index 783bbe1c90..3a64fa1a2f 100644 --- a/pkg/registry/pod_registry_test.go +++ b/pkg/registry/pod_registry_test.go @@ -13,6 +13,7 @@ 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 registry import ( diff --git a/pkg/registry/scheduler.go b/pkg/registry/scheduler.go index bbe5c3ba40..ba057407bc 100644 --- a/pkg/registry/scheduler.go +++ b/pkg/registry/scheduler.go @@ -13,6 +13,7 @@ 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 registry import ( diff --git a/pkg/util/etcd_tools_test.go b/pkg/util/etcd_tools_test.go index ebf11e835c..30c4c6243b 100644 --- a/pkg/util/etcd_tools_test.go +++ b/pkg/util/etcd_tools_test.go @@ -1,3 +1,19 @@ +/* +Copyright 2014 Google Inc. All rights reserved. + +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 util import ( diff --git a/pkg/util/fake_etcd_client.go b/pkg/util/fake_etcd_client.go index 56e023fa85..24eca43228 100644 --- a/pkg/util/fake_etcd_client.go +++ b/pkg/util/fake_etcd_client.go @@ -13,6 +13,7 @@ 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 util import ( diff --git a/pkg/util/fake_handler.go b/pkg/util/fake_handler.go index 6ca4a3fabf..3bc3b82c14 100644 --- a/pkg/util/fake_handler.go +++ b/pkg/util/fake_handler.go @@ -13,6 +13,7 @@ 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 util import ( diff --git a/pkg/util/fake_handler_test.go b/pkg/util/fake_handler_test.go index c5c4d00d50..cfa7cd48ee 100644 --- a/pkg/util/fake_handler_test.go +++ b/pkg/util/fake_handler_test.go @@ -1,3 +1,19 @@ +/* +Copyright 2014 Google Inc. All rights reserved. + +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 util import ( diff --git a/pkg/util/stringlist.go b/pkg/util/stringlist.go index b26eafca9f..1c6ccb9822 100644 --- a/pkg/util/stringlist.go +++ b/pkg/util/stringlist.go @@ -13,6 +13,7 @@ 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 util import ( diff --git a/pkg/util/stringlist_test.go b/pkg/util/stringlist_test.go index 8c0c8ed3b7..219e9ba777 100644 --- a/pkg/util/stringlist_test.go +++ b/pkg/util/stringlist_test.go @@ -13,6 +13,7 @@ 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 util import ( diff --git a/pkg/util/util_test.go b/pkg/util/util_test.go index 3e8aeabac6..e48311c7ac 100644 --- a/pkg/util/util_test.go +++ b/pkg/util/util_test.go @@ -1,3 +1,19 @@ +/* +Copyright 2014 Google Inc. All rights reserved. + +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 util import ( From 756ba6958d24a1ae60ad8e257752de5c7d6ed372 Mon Sep 17 00:00:00 2001 From: Daniel Smith Date: Mon, 23 Jun 2014 11:34:44 -0700 Subject: [PATCH 2/2] Add boilerplate checking to hook --- hooks/boilerplate.sh | 13 +++++++++++++ hooks/boilerplate.txt | 16 ++++++++++++++++ hooks/prepare-commit-msg | 7 +++++++ 3 files changed, 36 insertions(+) create mode 100755 hooks/boilerplate.sh create mode 100644 hooks/boilerplate.txt diff --git a/hooks/boilerplate.sh b/hooks/boilerplate.sh new file mode 100755 index 0000000000..33c31cbf5b --- /dev/null +++ b/hooks/boilerplate.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +# Print 1 if the file in $1 has the correct boilerplate header, 0 otherwise. +FILE=$1 +LINES=$(cat "$(dirname $0)/boilerplate.txt" | wc -l) +DIFFER=$(head -$LINES "${FILE}" | diff -q - "$(dirname $0)/boilerplate.txt") + +if [[ -z "${DIFFER}" ]]; then + echo "1" + exit 0 +fi + +echo "0" diff --git a/hooks/boilerplate.txt b/hooks/boilerplate.txt new file mode 100644 index 0000000000..5fd3c3f815 --- /dev/null +++ b/hooks/boilerplate.txt @@ -0,0 +1,16 @@ +/* +Copyright 2014 Google Inc. All rights reserved. + +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. +*/ + diff --git a/hooks/prepare-commit-msg b/hooks/prepare-commit-msg index b6f43d3135..8fdd02b024 100755 --- a/hooks/prepare-commit-msg +++ b/hooks/prepare-commit-msg @@ -1,5 +1,7 @@ #!/bin/bash +KUBE_HOOKS_DIR="$(dirname "$(test -L "$0" && echo "$(dirname $0)/$(readlink "$0")" || echo "$0")")" + errors=0 for file in $(git diff --cached --name-only --diff-filter ACM | grep "\.go" | grep -v "third_party"); do diff="$(git show ":${file}" | gofmt -s -d)" @@ -7,6 +9,11 @@ for file in $(git diff --cached --name-only --diff-filter ACM | grep "\.go" | gr echo "# *** ERROR: *** File ${file} has not been gofmt'd." >> $1 errors=1 fi + boilerplate="$(${KUBE_HOOKS_DIR}/boilerplate.sh ${file})" + if [[ "$boilerplate" -eq "0" ]]; then + echo "# *** ERROR: *** File ${file} needs the boilerplate header in hooks/boilerplate.txt." >> $1 + errors=1 + fi done if [[ $errors == "1" ]]; then