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