Skip to content

Commit

Permalink
chore: suggested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
blgm committed Feb 9, 2024
1 parent 478f736 commit dc63f9c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
24 changes: 11 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ SECURITY_USER_NAME := $(or $(SECURITY_USER_NAME), gcp-broker)
SECURITY_USER_PASSWORD := $(or $(SECURITY_USER_PASSWORD), gcp-broker-pw)
GSB_PROVISION_DEFAULTS := $(or $(GSB_PROVISION_DEFAULTS), {"authorized_network_id": "https://www.googleapis.com/compute/v1/projects/$GOOGLE_PROJECT/global/networks/$GCP_PAS_NETWORK"})

GO=go
GOFMT=gofmt
BROKER_GO_OPTS=PORT=8080 \
DB_TYPE=sqlite3 \
DB_PATH=/tmp/csb-db \
Expand All @@ -44,8 +42,8 @@ GET_CSB="env CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags $(LDFLAGS)
.PHONY: deps-go-binary
deps-go-binary:
ifeq ($(SKIP_GO_VERSION_CHECK),)
@@if [ "$$($(GO) version | awk '{print $$3}')" != "${GO-VER}" ]; then \
echo "Go version does not match: expected: ${GO-VER}, got $$($(GO) version | awk '{print $$3}')"; \
@@if [ "$$(go version | awk '{print $$3}')" != "${GO-VER}" ]; then \
echo "Go version does not match: expected: ${GO-VER}, got $$(go version | awk '{print $$3}')"; \
exit 1; \
fi
endif
Expand Down Expand Up @@ -137,13 +135,13 @@ $(PAK_BUILD_CACHE_PATH):

.PHONY: latest-csb
latest-csb: ## point to the very latest CSB on GitHub
$(GO) get -d github.com/cloudfoundry/cloud-service-broker@main
$(GO) mod tidy
go get -d github.com/cloudfoundry/cloud-service-broker@main
go mod tidy

.PHONY: local-csb
local-csb: ## point to a local CSB repo
echo "replace \"github.com/cloudfoundry/cloud-service-broker\" => \"$$PWD/../cloud-service-broker\"" >>go.mod
$(GO) mod tidy
go mod tidy

.PHONY: lint
lint: checkgoformat checkgoimports checktfformat vet staticcheck ## checks format, imports and vet
Expand All @@ -155,26 +153,26 @@ checktfformat: ## checks that Terraform HCL is formatted correctly
fi

checkgoformat: ## checks that the Go code is formatted correctly
@@if [ -n "$$(${GOFMT} -s -e -l -d .)" ]; then \
@@if [ -n "$$(gofmt -s -e -l -d .)" ]; then \
echo "gofmt check failed: run 'make format'"; \
exit 1; \
fi

checkgoimports: ## checks that Go imports are formatted correctly
@@if [ -n "$$(${GO} run golang.org/x/tools/cmd/goimports -l -d .)" ]; then \
@@if [ -n "$$(go run golang.org/x/tools/cmd/goimports -l -d .)" ]; then \
echo "goimports check failed: run 'make format'"; \
exit 1; \
fi

vet: ## Runs go vet
${GO} vet ./...
go vet ./...

staticcheck: ## Runs staticcheck
${GO} run honnef.co/go/tools/cmd/staticcheck ./...
go run honnef.co/go/tools/cmd/staticcheck ./...

.PHONY: format
format: ## format the source
${GOFMT} -s -e -l -w .
${GO} run golang.org/x/tools/cmd/goimports -l -w .
gofmt -s -e -l -w .
go run golang.org/x/tools/cmd/goimports -l -w .
terraform fmt --recursive

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Available make targets can be listed by running `make`.
2. Launch an interactive shell into some supported image containing all necessary tools. For example:
```
# From the root of this repo run:
docker run -it --rm -v "${PWD}:/repo" --workdir "/repo" --entrypoint "/bin/bash" cflondonservices/csb-ci-main
docker run -it --rm -v "${PWD}:/repo" --workdir "/repo" --entrypoint "/bin/bash" golang:latest
make
```

Expand Down

0 comments on commit dc63f9c

Please sign in to comment.