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)
2021-02-23 11:28:05 -07:00
TAG ?= " minio/console: $( BUILD_VERSION) -dev "
2022-01-15 12:24:54 -05:00
MINIO_VERSION ?= "quay.io/minio/minio:latest"
2020-04-09 11:29:49 -07:00
2020-07-26 00:34:17 -07:00
default : console
2020-04-01 18:18:57 -07:00
2020-07-26 00:34:17 -07:00
.PHONY : console
console :
@echo "Building Console binary to './console'"
2022-01-19 11:13:26 -08:00
@( GO111MODULE = on CGO_ENABLED = 0 go build -trimpath --tags= kqueue,operator --ldflags "-s -w" -o console ./cmd/console)
2020-05-18 21:55:54 -07:00
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)
2020-07-26 00:34:17 -07:00
@echo "Done, now restart your console deployment"
2020-07-02 21:33:55 -07:00
2020-05-18 21:55:54 -07:00
getdeps :
@mkdir -p ${ GOPATH } /bin
2022-01-25 10:48:49 -08:00
@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.43.0)
2020-05-18 21:55:54 -07:00
verifiers : getdeps fmt lint
fmt :
@echo " Running $@ check "
2020-08-02 12:29:58 -07:00
@GO111MODULE= on gofmt -d restapi/
2020-05-18 21:55:54 -07:00
@GO111MODULE= on gofmt -d pkg/
2020-08-02 12:29:58 -07:00
@GO111MODULE= on gofmt -d cmd/
@GO111MODULE= on gofmt -d cluster/
2020-05-18 21:55:54 -07:00
2020-12-01 23:48:34 -08:00
crosscompile :
2021-06-18 11:44:01 -07:00
@( env bash $( PWD) /cross-compile.sh $( arg1) )
2020-12-01 23:48:34 -08:00
2020-05-18 21:55:54 -07:00
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
2020-07-26 00:34:17 -07:00
install : console
@echo " Installing console binary to ' $( GOPATH) /bin/console' "
@mkdir -p $( GOPATH) /bin && cp -f $( PWD) /console $( GOPATH) /bin/console
@echo "Installation successful. To learn more, try \"console --help\"."
2020-04-01 21:54:47 -07:00
2021-07-19 11:48:50 -07:00
swagger-gen : clean -swagger swagger -console swagger -operator
@echo "Done Generating swagger server code from yaml"
clean-swagger :
@echo "cleaning"
2020-06-22 20:56:52 -07:00
@rm -rf models
@rm -rf restapi/operations
2021-07-19 11:48:50 -07:00
@rm -rf operatorapi/operations
swagger-console :
@echo "Generating swagger server code from yaml"
@swagger generate server -A console --main-package= management --server-package= restapi --exclude-main -P models.Principal -f ./swagger-console.yml -r NOTICE
swagger-operator :
@echo "Generating swagger server code from yaml"
@swagger generate server -A operator --main-package= operator --server-package= operatorapi --exclude-main -P models.Principal -f ./swagger-operator.yml -r NOTICE
2020-04-01 18:18:57 -07:00
2020-04-09 11:29:49 -07:00
assets :
2021-12-26 20:46:36 -08:00
@( cd portal-ui; yarn install; make build-static; yarn prettier --write . --loglevel warn; cd ..)
2020-04-01 21:54:47 -07:00
2021-11-10 12:10:29 -08:00
test-integration :
2022-01-15 12:24:54 -05:00
@echo "docker run with MinIO Version below:"
@echo $( MINIO_VERSION)
@( docker run -d --name minio --rm -p 9000:9000 $( MINIO_VERSION) server /data{ 1...4} && sleep 5)
2021-11-10 12:10:29 -08:00
@( GO111MODULE = on go test -race -v github.com/minio/console/integration/...)
@( docker stop minio)
2022-01-14 17:04:40 -08:00
test-permissions :
@( docker run -d --name minio --rm -p 9000:9000 quay.io/minio/minio:latest server /data{ 1...4} )
@( env bash $( PWD) /portal-ui/tests/scripts/permissions.sh)
@( docker stop minio)
2022-01-20 16:50:52 -08:00
test-apply-permissions :
2022-01-14 17:04:40 -08:00
@( env bash $( PWD) /portal-ui/tests/scripts/initialize-env.sh)
2022-01-20 16:50:52 -08:00
test-start-docker-minio :
@( docker run -d --name minio --rm -p 9000:9000 quay.io/minio/minio:latest server /data{ 1...4} )
initialize-permissions : test -start -docker -minio test -apply -permissions
@echo "Done initializing permissions test"
2022-01-14 17:04:40 -08:00
cleanup-permissions :
@( env bash $( PWD) /portal-ui/tests/scripts/cleanup-env.sh)
@( docker stop minio)
2020-04-02 09:57:59 -07:00
test :
2020-07-26 00:34:17 -07:00
@( GO111MODULE = on go test -race -v github.com/minio/console/restapi/...)
2021-06-18 11:23:39 -07:00
test-pkg :
2020-07-26 00:34:17 -07:00
@( GO111MODULE = on go test -race -v github.com/minio/console/pkg/...)
2020-04-02 09:57:59 -07:00
coverage :
2020-07-26 00:34:17 -07:00
@( GO111MODULE = on go test -v -coverprofile= coverage.out github.com/minio/console/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-07-26 00:34:17 -07:00
@rm -vf console
2020-07-10 19:14:28 -07:00
docker :
2021-11-02 16:41:52 -07:00
@docker buildx build --output= type = docker --platform linux/amd64 -t $( TAG) --build-arg build_version = $( BUILD_VERSION) --build-arg build_time = '$(BUILD_TIME)' .