-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Go mod files after linting * Hack utility added
- Loading branch information
1 parent
990f7da
commit 5816832
Showing
12 changed files
with
226 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,15 +18,21 @@ VERSION=v0.0.1 | |
GIT_COMMIT?=$(shell git rev-parse HEAD) | ||
BUILD_DATE?=$(shell date -u +"%Y-%m-%dT%H:%M:%SZ") | ||
LDFLAGS?="-X ${PKG}/pkg/driver.driverVersion=${VERSION} -X ${PKG}/pkg/driver.gitCommit=${GIT_COMMIT} -X ${PKG}/pkg/driver.buildDate=${BUILD_DATE} -s -w" | ||
|
||
GO111MODULE=on | ||
GOPROXY=direct | ||
GOPATH=$(shell go env GOPATH) | ||
GOOS=$(shell go env GOOS) | ||
GOBIN=$(shell pwd)/bin | ||
|
||
PLATFORM=linux/ppc64le | ||
|
||
|
||
.EXPORT_ALL_VARIABLES: | ||
|
||
bin: | ||
@mkdir -p $@ | ||
|
||
.PHONY: bin/ibm-powervs-block-csi-driver | ||
bin/ibm-powervs-block-csi-driver: | bin | ||
CGO_ENABLED=0 GOOS=linux GOARCH=ppc64le go build -ldflags ${LDFLAGS} -o bin/ibm-powervs-block-csi-driver ./cmd/ | ||
|
@@ -54,3 +60,26 @@ push: | |
.PHONY: clean | ||
clean: | ||
rm -rf bin/* | ||
|
||
bin/mockgen: | bin | ||
go install github.com/golang/mock/[email protected] | ||
|
||
bin/golangci-lint: | bin | ||
echo "Installing golangci-lint..." | ||
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.43.0 | ||
|
||
mockgen: bin/mockgen | ||
./hack/update-gomock | ||
|
||
.PHONY: verify | ||
verify: bin/golangci-lint | ||
echo "verifying and linting files ..." | ||
./hack/verify-all | ||
echo "Congratulations! All Go source files have been linted." | ||
|
||
.PHONY: verify-vendor | ||
test: verify-vendor | ||
verify: verify-vendor | ||
verify-vendor: | ||
@ echo; echo "### $@:" | ||
@ ./hack/verify-vendor.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/bash | ||
|
||
# Copyright 2022 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 -euo pipefail | ||
|
||
find . -name "*.go" | grep -v "\/vendor\/" | xargs gofmt -s -w |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/bash | ||
|
||
# Copyright 2022 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 -euo pipefail | ||
|
||
bin/mockgen -package mocks -destination=pkg/cloud/mocks/mock_cloud.go -source ./pkg/cloud/cloud_interface.go | ||
bin/mockgen -package mocks -destination=pkg/driver/mocks/mock_mounter.go -source ./pkg/driver/mount.go |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/bin/bash | ||
|
||
# Copyright 2022 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 -euo pipefail | ||
set -x | ||
|
||
VERSION=${1#"v"} | ||
if [ -z "$VERSION" ]; then | ||
echo "Must specify version!" | ||
exit 1 | ||
fi | ||
MODS=($( | ||
curl -sS https://raw.githubusercontent.com/kubernetes/kubernetes/v${VERSION}/go.mod | | ||
sed -n 's|.*k8s.io/\(.*\) => ./staging/src/k8s.io/.*|k8s.io/\1|p' | ||
)) | ||
echo $MODS | ||
for MOD in "${MODS[@]}"; do | ||
echo $MOD | ||
V=$( | ||
go mod download -json "${MOD}@kubernetes-${VERSION}" | | ||
sed -n 's|.*"Version": "\(.*\)".*|\1|p' | ||
) | ||
go mod edit "-replace=${MOD}=${MOD}@${V}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/bin/bash | ||
|
||
# Copyright 2022 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 -euo pipefail | ||
|
||
PKG_ROOT=$(git rev-parse --show-toplevel) | ||
|
||
${PKG_ROOT}/hack/verify-gofmt | ||
${PKG_ROOT}/hack/verify-govet | ||
${PKG_ROOT}/bin/golangci-lint run --deadline=10m | ||
${PKG_ROOT}/hack/verify-vendor.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/bin/bash | ||
|
||
# Copyright 2022 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 -euo 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 to fix the issue(s)" | ||
exit 1 | ||
fi | ||
echo "No issue found" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/bin/bash | ||
|
||
# Copyright 2022 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 -euo pipefail | ||
|
||
echo "Verifying govet" | ||
|
||
go vet $(go list ./... | grep -v vendor) | ||
|
||
echo "Done" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Copyright 2022 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. | ||
|
||
|
||
echo "Repo uses 'go mod'." | ||
if ! (set -x; env GO111MODULE=on go mod tidy); then | ||
echo "ERROR: vendor check failed." | ||
exit 1 | ||
elif [ "$(git status --porcelain -- go.mod go.sum | wc -l)" -gt 0 ]; then | ||
echo "ERROR: go module files *not* up-to-date, they did get modified by 'GO111MODULE=on go mod tidy':"; | ||
git diff -- go.mod go.sum | ||
exit 1 | ||
elif [ -d vendor ]; then | ||
if ! (set -x; env GO111MODULE=on go mod vendor); then | ||
echo "ERROR: vendor check failed." | ||
exit 1 | ||
elif [ "$(git status --porcelain -- vendor | wc -l)" -gt 0 ]; then | ||
echo "ERROR: vendor directory *not* up-to-date, it did get modified by 'GO111MODULE=on go mod vendor':" | ||
git status -- vendor | ||
git diff -- vendor | ||
exit 1 | ||
else | ||
echo "Go dependencies and vendor directory up-to-date." | ||
fi | ||
else | ||
echo "Go dependencies up-to-date." | ||
fi |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.