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"
2022-06-03 18:43:24 -04:00
TARGET_BUCKET ?= "target"
2022-08-05 17:54:47 -07:00
NODE_VERSION := $( shell cat .nvmrc)
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'"
2023-03-02 19:35:08 -08:00
@( GO111MODULE = on CGO_ENABLED = 0 go build -trimpath --tags= kqueue --ldflags "-s -w" -o console ./cmd/console)
2020-07-02 21:33:55 -07:00
2020-05-18 21:55:54 -07:00
getdeps :
@mkdir -p ${ GOPATH } /bin
2022-08-05 08:07:38 -07:00
@echo "Installing golangci-lint" && curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $( GOPATH) /bin
2020-05-18 21:55:54 -07:00
verifiers : getdeps fmt lint
fmt :
@echo " Running $@ check "
2022-08-29 20:28:39 -04:00
@( env bash $( PWD) /verify-gofmt.sh)
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
2023-03-02 19:35:08 -08:00
swagger-gen : clean -swagger swagger -console apply -gofmt
2021-07-19 11:48:50 -07:00
@echo "Done Generating swagger server code from yaml"
2022-08-29 23:53:50 -04:00
apply-gofmt :
@echo "Applying gofmt to all generated an existing files"
@GO111MODULE= on gofmt -w .
2021-07-19 11:48:50 -07:00
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
swagger-console :
@echo "Generating swagger server code from yaml"
2023-03-02 19:35:08 -08:00
@swagger generate server -A console --main-package= management --server-package= restapi --exclude-main -P models.Principal -f ./swagger.yml -r NOTICE
2023-03-17 08:57:45 -07:00
@echo "Generating typescript api"
@npx swagger-typescript-api -p ./swagger.yml -o ./portal-ui/src/api -n consoleApi.ts
2021-07-19 11:48:50 -07:00
2020-04-01 18:18:57 -07:00
2020-04-09 11:29:49 -07:00
assets :
2022-08-05 17:54:47 -07:00
@( if [ -f " ${ NVM_DIR } /nvm.sh " ] ; then \. " ${ NVM_DIR } /nvm.sh " && nvm install && nvm use && npm install -g yarn ; fi && \
cd portal-ui; yarn install --prefer-offline; 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-03-05 15:20:00 -05:00
@( docker stop pgsqlcontainer || true )
@( docker stop minio || true )
2023-01-11 15:48:13 -08:00
@( docker stop minio2 || true )
2022-03-05 15:20:00 -05:00
@( docker network rm mynet123 || true )
2022-02-16 13:23:14 -05:00
@echo "create docker network to communicate containers MinIO & PostgreSQL"
@( docker network create --subnet= 173.18.0.0/29 mynet123)
2022-01-15 12:24:54 -05:00
@echo "docker run with MinIO Version below:"
@echo $( MINIO_VERSION)
2023-01-11 15:48:13 -08:00
@echo "MinIO 1"
@( docker run -v /data1 -v /data2 -v /data3 -v /data4 --net= mynet123 -d --name minio --rm -p 9000:9000 -p 9091:9091 -e MINIO_KMS_SECRET_KEY = my-minio-key:OSMM+vkKUTCvQs9YL/CVMIMt43HFhkUpqJxTmGl6rYw= $( MINIO_VERSION) server /data{ 1...4} --console-address ':9091' && sleep 5)
@echo "MinIO 2"
@( docker run -v /data1 -v /data2 -v /data3 -v /data4 --net= mynet123 -d --name minio2 --rm -p 9001:9001 -p 9092:9092 -e MINIO_KMS_SECRET_KEY = my-minio-key:OSMM+vkKUTCvQs9YL/CVMIMt43HFhkUpqJxTmGl6rYw= $( MINIO_VERSION) server /data{ 1...4} --address ':9001' --console-address ':9092' && sleep 5)
@echo "Postgres"
@( docker run --net= mynet123 --ip= 173.18.0.4 --name pgsqlcontainer --rm -p 5432:5432 -e POSTGRES_PASSWORD = password -d postgres && sleep 5)
2022-06-03 18:43:24 -04:00
@echo "execute test and get coverage for test-integration:"
2023-01-11 15:48:13 -08:00
@( cd integration && go test -coverpkg= ../restapi -c -tags testrunmain . && mkdir -p coverage && ./integration.test -test.v -test.run "^Test*" -test.coverprofile= coverage/system.out)
2022-03-02 23:26:32 -05:00
@( docker stop pgsqlcontainer)
2021-11-10 12:10:29 -08:00
@( docker stop minio)
2023-01-11 15:48:13 -08:00
@( docker stop minio2)
2022-03-02 23:26:32 -05:00
@( docker network rm mynet123)
2021-11-10 12:10:29 -08:00
2022-03-31 17:11:01 +00:00
test-replication :
@( docker stop minio || true )
@( docker stop minio1 || true )
@( docker stop minio2 || true )
@( docker network rm mynet123 || true )
@( docker network create mynet123)
@( docker run -v /data1 -v /data2 -v /data3 -v /data4 \
--net= mynet123 -d \
--name minio \
--rm \
-p 9000:9000 \
-p 6000:6000 \
-e MINIO_KMS_SECRET_KEY = my-minio-key:OSMM+vkKUTCvQs9YL/CVMIMt43HFhkUpqJxTmGl6rYw= \
-e MINIO_ROOT_USER = "minioadmin" \
-e MINIO_ROOT_PASSWORD = "minioadmin" \
$( MINIO_VERSION) server /data{ 1...4} \
--address :9000 \
--console-address :6000)
@( docker run -v /data1 -v /data2 -v /data3 -v /data4 \
--net= mynet123 -d \
--name minio1 \
--rm \
-p 9001:9001 \
-p 6001:6001 \
-e MINIO_KMS_SECRET_KEY = my-minio-key:OSMM+vkKUTCvQs9YL/CVMIMt43HFhkUpqJxTmGl6rYw= \
-e MINIO_ROOT_USER = "minioadmin" \
-e MINIO_ROOT_PASSWORD = "minioadmin" \
$( MINIO_VERSION) server /data{ 1...4} \
--address :9001 \
--console-address :6001)
@( docker run -v /data1 -v /data2 -v /data3 -v /data4 \
--net= mynet123 -d \
--name minio2 \
--rm \
-p 9002:9002 \
-p 6002:6002 \
-e MINIO_KMS_SECRET_KEY = my-minio-key:OSMM+vkKUTCvQs9YL/CVMIMt43HFhkUpqJxTmGl6rYw= \
-e MINIO_ROOT_USER = "minioadmin" \
-e MINIO_ROOT_PASSWORD = "minioadmin" \
$( MINIO_VERSION) server /data{ 1...4} \
--address :9002 \
--console-address :6002)
@( cd replication && go test -coverpkg= ../restapi -c -tags testrunmain . && mkdir -p coverage && ./replication.test -test.v -test.run "^Test*" -test.coverprofile= coverage/replication.out)
@( docker stop minio || true )
@( docker stop minio1 || true )
@( docker stop minio2 || true )
@( docker network rm mynet123 || true )
2022-03-24 23:11:42 -04:00
test-sso-integration :
@echo "create the network in bridge mode to communicate all containers"
@( docker network create my-net)
2022-05-05 13:29:41 -04:00
@echo "run openldap container using MinIO Image: quay.io/minio/openldap:latest"
2022-03-24 23:11:42 -04:00
@( docker run \
2022-05-05 13:29:41 -04:00
-e LDAP_ORGANIZATION = "MinIO Inc" \
-e LDAP_DOMAIN = "min.io" \
-e LDAP_ADMIN_PASSWORD = "admin" \
--network my-net \
-p 389:389 \
-p 636:636 \
--name openldap \
--detach quay.io/minio/openldap:latest)
@echo "Run Dex container using MinIO Image: quay.io/minio/dex:latest"
2022-03-24 23:11:42 -04:00
@( docker run \
2022-05-05 13:29:41 -04:00
-e DEX_ISSUER = http://dex:5556/dex \
2022-05-12 20:27:35 -04:00
-e DEX_CLIENT_REDIRECT_URI = http://127.0.0.1:9090/oauth_callback \
2022-05-05 13:29:41 -04:00
-e DEX_LDAP_SERVER = openldap:389 \
--network my-net \
-p 5556:5556 \
--name dex \
--detach quay.io/minio/dex:latest)
2022-03-24 23:11:42 -04:00
@echo "running minio server"
@( docker run \
-v /data1 -v /data2 -v /data3 -v /data4 \
--network my-net \
-d \
--name minio \
--rm \
-p 9000:9000 \
-p 9001:9001 \
2022-05-05 13:29:41 -04:00
-e MINIO_IDENTITY_OPENID_CLIENT_ID = "minio-client-app" \
-e MINIO_IDENTITY_OPENID_CLIENT_SECRET = "minio-client-app-secret" \
-e MINIO_IDENTITY_OPENID_CLAIM_NAME = name \
-e MINIO_IDENTITY_OPENID_CONFIG_URL = http://dex:5556/dex/.well-known/openid-configuration \
2022-05-12 20:27:35 -04:00
-e MINIO_IDENTITY_OPENID_REDIRECT_URI = http://127.0.0.1:9090/oauth_callback \
2022-03-24 23:11:42 -04:00
-e MINIO_ROOT_USER = minio \
-e MINIO_ROOT_PASSWORD = minio123 $( MINIO_VERSION) server /data{ 1...4} --address :9000 --console-address :9001)
2022-05-05 13:29:41 -04:00
@echo "run mc commands to set the policy"
@( docker run --name minio-client --network my-net -dit --entrypoint= /bin/sh minio/mc)
@( docker exec minio-client mc alias set myminio/ http://minio:9000 minio minio123)
@echo "adding policy to Dillon Harper to be able to login:"
2023-03-27 14:30:52 -07:00
@( cd sso-integration && docker cp allaccess.json minio-client:/ && docker exec minio-client mc admin policy create myminio "Dillon Harper" allaccess.json)
2022-03-24 23:11:42 -04:00
@echo "starting bash script"
@( env bash $( PWD) /sso-integration/set-sso.sh)
2022-05-05 13:29:41 -04:00
@echo "add python module"
@( pip3 install bs4)
2022-03-24 23:11:42 -04:00
@echo "Executing the test:"
@( cd sso-integration && go test -coverpkg= ../restapi -c -tags testrunmain . && mkdir -p coverage && ./sso-integration.test -test.v -test.run "^Test*" -test.coverprofile= coverage/sso-system.out)
2022-03-23 21:35:10 -04:00
test-permissions-1 :
2022-02-16 12:53:34 -05:00
@( docker run -v /data1 -v /data2 -v /data3 -v /data4 -d --name minio --rm -p 9000:9000 quay.io/minio/minio:latest server /data{ 1...4} )
2022-03-23 21:35:10 -04:00
@( env bash $( PWD) /portal-ui/tests/scripts/permissions.sh "portal-ui/tests/permissions-1/" )
@( docker stop minio)
test-permissions-2 :
@( docker run -v /data1 -v /data2 -v /data3 -v /data4 -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 "portal-ui/tests/permissions-2/" )
@( docker stop minio)
test-permissions-3 :
@( docker run -v /data1 -v /data2 -v /data3 -v /data4 -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 "portal-ui/tests/permissions-3/" )
2022-01-14 17:04:40 -08:00
@( docker stop minio)
2022-05-20 22:50:55 -04:00
test-permissions-4 :
@( docker run -v /data1 -v /data2 -v /data3 -v /data4 -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 "portal-ui/tests/permissions-4/" )
@( docker stop minio)
test-permissions-5 :
@( docker run -v /data1 -v /data2 -v /data3 -v /data4 -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 "portal-ui/tests/permissions-5/" )
@( docker stop minio)
test-permissions-6 :
@( docker run -v /data1 -v /data2 -v /data3 -v /data4 -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 "portal-ui/tests/permissions-6/" )
@( docker stop minio)
test-permissions-7 :
@( docker run -v /data1 -v /data2 -v /data3 -v /data4 -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 "portal-ui/tests/permissions-7/" )
@( 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 :
2022-02-16 12:53:34 -05:00
@( docker run -v /data1 -v /data2 -v /data3 -v /data4 -d --name minio --rm -p 9000:9000 quay.io/minio/minio:latest server /data{ 1...4} )
2022-01-20 16:50:52 -08:00
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 :
2022-03-02 23:26:32 -05:00
@echo "execute test and get coverage"
2022-03-17 12:15:06 -07:00
@( cd restapi && mkdir coverage && GO111MODULE = on go test -test.v -coverprofile= coverage/coverage.out)
2021-06-18 11:23:39 -07:00
2022-05-20 19:01:27 -05:00
2021-06-18 11:23:39 -07:00
test-pkg :
2022-03-02 23:26:32 -05:00
@echo "execute test and get coverage"
2022-03-17 12:15:06 -07:00
@( cd pkg && mkdir coverage && GO111MODULE = on go test -test.v -coverprofile= coverage/coverage-pkg.out)
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 :
2022-08-05 17:54:47 -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)' --build-arg NODE_VERSION = '$(NODE_VERSION)' .
2022-02-10 17:06:43 -08:00
release : swagger -gen
@echo " Generating Release: $( RELEASE) "
@make assets
@git add -u .
@git add portal-ui/build/