2020-04-09 11:29:49 -07:00
PWD := $( shell pwd )
GOPATH := $( shell go env GOPATH)
2020-07-02 21:33:55 -07:00
# Sets the build version based on the output of the following command, if we are building for a tag, that's the build else it uses the current git branch as the build
BUILD_VERSION := $( shell git describe --exact-match --tags $( git log -n1 --pretty= '%h' ) 2>/dev/null || git rev-parse --abbrev-ref HEAD 2>/dev/null)
BUILD_TIME := $( shell date 2>/dev/null)
TAG ?= " minio/m3: $( VERSION) -dev "
2020-04-09 11:29:49 -07:00
2020-04-01 18:18:57 -07:00
default : mcs
.PHONY : mcs
mcs :
@echo "Building mcs binary to './mcs'"
2020-05-18 21:55:54 -07:00
@( GO111MODULE = on CGO_ENABLED = 0 go build -trimpath --tags= kqueue --ldflags "-s -w" -o mcs ./cmd/mcs)
2020-07-02 21:33:55 -07:00
k8sdev :
@docker build -t $( TAG) --build-arg build_version = $( BUILD_VERSION) --build-arg build_time = '$(BUILD_TIME)' .
@kind load docker-image $( TAG)
@echo "Done, now restart your mcs deployment"
2020-05-18 21:55:54 -07:00
getdeps :
@mkdir -p ${ GOPATH } /bin
@which golangci-lint 1>/dev/null || ( echo "Installing golangci-lint" && curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $( GOPATH) /bin v1.27.0)
verifiers : getdeps fmt lint
fmt :
@echo " Running $@ check "
@GO111MODULE= on gofmt -d cmd/
@GO111MODULE= on gofmt -d pkg/
lint :
@echo " Running $@ check "
@GO111MODULE= on ${ GOPATH } /bin/golangci-lint cache clean
@GO111MODULE= on ${ GOPATH } /bin/golangci-lint run --timeout= 5m --config ./.golangci.yml
2020-04-09 11:29:49 -07:00
install : mcs
@echo " Installing mcs binary to ' $( GOPATH) /bin/mcs' "
@mkdir -p $( GOPATH) /bin && cp -f $( PWD) /mcs $( GOPATH) /bin/mcs
@echo "Installation successful. To learn more, try \"mcs --help\"."
2020-04-01 21:54:47 -07:00
2020-04-01 18:18:57 -07:00
swagger-gen :
@echo "Generating swagger server code from yaml"
2020-06-22 20:56:52 -07:00
@rm -rf models
@rm -rf restapi/operations
2020-04-02 12:06:52 -07:00
@swagger generate server -A mcs --main-package= mcs --exclude-main -P models.Principal -f ./swagger.yml -r NOTICE
2020-04-01 18:18:57 -07:00
2020-04-09 11:29:49 -07:00
assets :
2020-04-02 19:40:26 -07:00
@( cd portal-ui; yarn install; make build-static; cd ..)
2020-04-01 21:54:47 -07:00
2020-04-02 09:57:59 -07:00
test :
2020-05-18 21:55:54 -07:00
@( GO111MODULE = on go test -race -v github.com/minio/mcs/restapi/...)
@( GO111MODULE = on go test -race -v github.com/minio/mcs/pkg/...)
2020-04-02 09:57:59 -07:00
coverage :
2020-05-18 21:55:54 -07:00
@( GO111MODULE = on go test -v -coverprofile= coverage.out github.com/minio/mcs/restapi/... && go tool cover -html= coverage.out && open coverage.html)
2020-04-02 09:57:59 -07:00
2020-04-01 21:54:47 -07:00
clean :
2020-04-09 11:29:49 -07:00
@echo "Cleaning up all the generated files"
@find . -name '*.test' | xargs rm -fv
@find . -name '*~' | xargs rm -fv
2020-04-01 21:54:47 -07:00
@rm -vf mcs