Commit 950f5a27 authored by roberthbailey's avatar roberthbailey

Merge pull request #873 from lavalamp/fix

Fix gofmt/boilerplate verification scripts and associated files.
parents 4b05cb0e ab24790e
/*
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 main
import "syscall"
......
......@@ -14,19 +14,16 @@
# See the License for the specific language governing permissions and
# limitations under the License.
REPO_ROOT="$(realpath "$(dirname $0)/..")"
REPO_ROOT="$(cd "$(dirname "$0")/../" && pwd -P)"
result=0
dirs=("pkg" "cmd")
for dir in ${dirs[@]}; do
for file in $(grep -r -l "" "${REPO_ROOT}/${dir}/" | grep "[.]go"); do
if [[ "$(${REPO_ROOT}/hooks/boilerplate.sh "${file}")" -eq "0" ]]; then
echo "Boilerplate header is wrong for: ${file}"
result=1
fi
done
gofiles="$(find ${REPO_ROOT} -type f | grep "[.]go$" | grep -v "third_party/\|release/\|output/\|target/")"
for file in ${gofiles}; do
if [[ "$(${REPO_ROOT}/hooks/boilerplate.sh "${file}")" -eq "0" ]]; then
echo "Boilerplate header is wrong for: ${file}"
result=1
fi
done
dirs=("cluster" "hack" "hooks")
......
......@@ -24,9 +24,11 @@ if [[ ${GO_VERSION[2]} != "go1.2" && ${GO_VERSION[2]} != "go1.3" ]]; then
exit 0
fi
REPO_ROOT="$(cd "$(dirname "$0")/../" && pwd -P)"
bad=$(gofmt -s -l pkg/ cmd/)
if [ "$?" != "0" ]; then
files="$(find ${REPO_ROOT} -type f | grep "[.]go$" | grep -v "third_party/\|release/\|output/\|target/")"
bad=$(gofmt -s -l ${files})
if [[ -n "${bad}" ]]; then
echo "$bad"
exit 1
fi
......@@ -321,7 +321,7 @@ func ValidateReplicationController(controller *ReplicationController) []error {
errors = append(errors, makeInvalidError("ReplicationController.ReplicaSelector", controller.DesiredState.ReplicaSelector))
}
if controller.DesiredState.Replicas < 0 {
errors = append(errors, makeInvalidError("ReplicationController.Replicas", controller.DesiredState.Replicas ))
errors = append(errors, makeInvalidError("ReplicationController.Replicas", controller.DesiredState.Replicas))
}
errors = append(errors, ValidateManifest(&controller.DesiredState.PodTemplate.DesiredState.Manifest)...)
return errors
......
......@@ -420,7 +420,7 @@ func TestValidateReplicationController(t *testing.T) {
"negative_replicas": {
JSONBase: JSONBase{ID: "abc"},
DesiredState: ReplicationControllerState{
Replicas: -1,
Replicas: -1,
ReplicaSelector: validSelector,
},
},
......
......@@ -111,7 +111,7 @@ func TestMinionProxy(t *testing.T) {
fmt.Sprintf("/%s", proxy.Host): "/",
}
for value, _ := range failureCases {
for value := range failureCases {
resp, err := http.Get(fmt.Sprintf("%s%s", server.URL, value))
if err != nil {
t.Errorf("unexpected error for %s: %v", value, err)
......
......@@ -9,7 +9,7 @@ You may obtain a copy of the License at
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 sied.
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.
*/
......
......@@ -73,11 +73,9 @@ func TestReadFromFile(t *testing.T) {
expected := CreatePodUpdate(kubelet.SET, kubelet.Pod{
Name: "test",
Manifest: api.ContainerManifest{
ID: "test",
Version: "v1beta1",
Containers: []api.Container{api.Container{
Image: "test/image"},
},
ID: "test",
Version: "v1beta1",
Containers: []api.Container{{Image: "test/image"}},
},
})
if !reflect.DeepEqual(expected, update) {
......
......@@ -9,7 +9,7 @@ You may obtain a copy of the License at
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 sied.
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.
*/
......
......@@ -106,7 +106,7 @@ func TestContainer(t *testing.T) {
if len(received) != 1 {
t.Errorf("Expected 1 manifest, but got %v", len(received))
}
expectedPods := []Pod{Pod{Name: "1", Manifest: expected[0]}}
expectedPods := []Pod{{Name: "1", Manifest: expected[0]}}
if !reflect.DeepEqual(expectedPods, received[0]) {
t.Errorf("Expected %#v, but got %#v", expectedPods, received[0])
}
......@@ -129,7 +129,7 @@ func TestContainers(t *testing.T) {
if len(received) != 1 {
t.Errorf("Expected 1 update, but got %v", len(received))
}
expectedPods := []Pod{Pod{Name: "1", Manifest: expected[0]}, Pod{Name: "2", Manifest: expected[1]}}
expectedPods := []Pod{{Name: "1", Manifest: expected[0]}, {Name: "2", Manifest: expected[1]}}
if !reflect.DeepEqual(expectedPods, received[0]) {
t.Errorf("Expected %#v, but got %#v", expectedPods, received[0])
}
......
......@@ -9,7 +9,7 @@ You may obtain a copy of the License at
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 cied.
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.
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment