diff --git a/Makefile b/Makefile index bb780f0..73928df 100644 --- a/Makefile +++ b/Makefile @@ -18,9 +18,25 @@ test: lint: bootstrap golangci-lint run --max-same-issues 0 +.PHONY: mocks +mocks: bootstrap + mockgen -source ./pkg/repository/repository.go -destination ./pkg/repository/mock/repository.go -package mock + mockgen -source ./pkg/listers/limitrange.go -destination ./pkg/listers/mock/limitrange.go -package mock + mockgen -source ./pkg/listers/node.go -destination ./pkg/listers/mock/node.go -package mock + mockgen -source ./pkg/listers/pod.go -destination ./pkg/listers/mock/pod.go -package mock + mockgen -source ./pkg/listers/radixregistration.go -destination ./pkg/listers/mock/radixregistration.go -package mock + mockgen -source ./pkg/listers/containerbulkdto.go -destination ./pkg/listers/mock/containerbulkdto.go -package mock + mockgen -source ./pkg/listers/nodebulkdto.go -destination ./pkg/listers/mock/nodebulkdto.go -package mock + + + HAS_GOLANGCI_LINT := $(shell command -v golangci-lint;) +HAS_MOCKGEN := $(shell command -v mockgen;) bootstrap: ifndef HAS_GOLANGCI_LINT curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.55.2 endif +ifndef HAS_MOCKGEN + go install github.com/golang/mock/mockgen@v1.6.0 +endif diff --git a/README.md b/README.md index a5f7958..1be3286 100644 --- a/README.md +++ b/README.md @@ -20,15 +20,13 @@ sqlcmd -S ${SERVER_NAME}.database.windows.net -d ${DATABASE_NAME} -G --variables ## Deploy to cluster -Installation on cluster is handled by flux through [flux repo](https://github.com/equinor/radix-flux). Before being installed, it requires that there exist a namespace called `radix-cost-allocation`. In that namespace there must be a secret called `cost-db-secret` that contains the database password. This is handled through the setup script in [radix-platform](https://github.com/equinor/radix-platform) +Installation on cluster is handled by flux through [flux repo](https://github.com/equinor/radix-flux). -tag in git repository (in master branch) - matching to the version of Version in docs/docs.go +tag in git repository (in master branch) - matching to the version of Version in charts/Chart.yaml ## Developing -You need Go installed. Make sure `GOPATH` and `GOROOT` are properly set up. - -Also needed: +You need: - [`gomock`](https://github.com/golang/mock) (GO111MODULE=on go get github.com/golang/mock/mockgen@v1.5.0) @@ -42,18 +40,8 @@ Want to contribute? Read our [contributing guidelines](./CONTRIBUTING.md) We use gomock to generate mocks used in unit test. You need to regenerate mocks if you make changes to any of the interface types used by the application; **Repository** -Repository: -``` -$ mockgen -source ./pkg/repository/repository.go -destination ./pkg/repository/mock/repository.go -package mock -``` -listers: ``` -$ mockgen -source ./pkg/listers/limitrange.go -destination ./pkg/listers/mock/limitrange.go -package mock -$ mockgen -source ./pkg/listers/node.go -destination ./pkg/listers/mock/node.go -package mock -$ mockgen -source ./pkg/listers/pod.go -destination ./pkg/listers/mock/pod.go -package mock -$ mockgen -source ./pkg/listers/radixregistration.go -destination ./pkg/listers/mock/radixregistration.go -package mock -$ mockgen -source ./pkg/listers/containerbulkdto.go -destination ./pkg/listers/mock/containerbulkdto.go -package mock -$ mockgen -source ./pkg/listers/nodebulkdto.go -destination ./pkg/listers/mock/nodebulkdto.go -package mock +make mocks ``` ## Update version