diff --git a/hack/update-gofmt.sh b/hack/update-gofmt.sh new file mode 100755 index 000000000..5a4ccfa4c --- /dev/null +++ b/hack/update-gofmt.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +# Copyright 2018 The Kubernetes 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. + +set -o errexit +set -o nounset +set -o pipefail + +find . -name "*.go" | grep -v "\/vendor\/" | xargs gofmt -s -w diff --git a/hack/verify-all.sh b/hack/verify-all.sh new file mode 100755 index 000000000..48910658d --- /dev/null +++ b/hack/verify-all.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +# Copyright 2018 The Kubernetes 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. + +set -o errexit +set -o nounset +set -o pipefail + +PKG_ROOT=$(git rev-parse --show-toplevel) + +${PKG_ROOT}/hack/verify-gofmt.sh +${PKG_ROOT}/hack/verify-govet.sh diff --git a/hack/verify-gofmt.sh b/hack/verify-gofmt.sh new file mode 100755 index 000000000..d8914af98 --- /dev/null +++ b/hack/verify-gofmt.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash +# Copyright 2018 The Kubernetes 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. + +set -o errexit +set -o nounset +set -o pipefail + +echo "Verifying gofmt" + +diff=$(find . -name "*.go" | grep -v "\/vendor\/" | xargs gofmt -s -d 2>&1) +if [[ -n "${diff}" ]]; then + echo "${diff}" + echo + echo "Please run hack/update-gofmt.sh" + exit 1 +fi diff --git a/hack/verify-govet.sh b/hack/verify-govet.sh new file mode 100755 index 000000000..33c4a4b47 --- /dev/null +++ b/hack/verify-govet.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash +# Copyright 2018 The Kubernetes 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. + +set -o errexit +set -o nounset +set -o pipefail + +echo "Verifying govet" + +go vet $(go list ./... | grep -v vendor) diff --git a/pkg/gce-csi-driver/controller_test.go b/pkg/gce-csi-driver/controller_test.go index 8e423c7ea..0c14a262b 100644 --- a/pkg/gce-csi-driver/controller_test.go +++ b/pkg/gce-csi-driver/controller_test.go @@ -205,7 +205,7 @@ func TestCreateVolumeArguments(t *testing.T) { if err != nil { t.Fatalf("Failed to create fake cloud provider: %v", err) } - err = gceDriver.SetupGCEDriver(fakeCloudProvider, driver, node) + err = gceDriver.SetupGCEDriver(fakeCloudProvider, nil, driver, node) if err != nil { t.Fatalf("Failed to setup GCE Driver: %v", err) } diff --git a/pkg/gce-csi-driver/identity.go b/pkg/gce-csi-driver/identity.go index 7e3d26574..e9057d963 100644 --- a/pkg/gce-csi-driver/identity.go +++ b/pkg/gce-csi-driver/identity.go @@ -43,7 +43,7 @@ func (gceIdentity *GCEIdentityServer) GetPluginCapabilities(ctx context.Context, glog.V(5).Infof("Using default GetPluginCapabilities") return &csi.GetPluginCapabilitiesResponse{ Capabilities: []*csi.PluginCapability{ - &csi.PluginCapability{ + { Type: &csi.PluginCapability_Service_{ Service: &csi.PluginCapability_Service{ Type: csi.PluginCapability_Service_CONTROLLER_SERVICE, diff --git a/test/remote/run_remote/run_remote.go b/test/remote/run_remote/run_remote.go index 1aab7c8b4..e34c068e3 100644 --- a/test/remote/run_remote/run_remote.go +++ b/test/remote/run_remote/run_remote.go @@ -466,7 +466,7 @@ func addPubKeyToInstance(project, zone, name, pubKeyFile string) error { newMeta := &compute.Metadata{ Fingerprint: fingerprint, Items: []*compute.MetadataItems{ - &compute.MetadataItems{ + { Key: "ssh-keys", Value: &newKeys, },