From bd3954768037fb63dd7210540182de50793339d3 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Thu, 9 Apr 2020 10:30:34 -0700 Subject: [PATCH] add support for mcs build to trim gopaths also remove `version` sub-command as we don't use this anymore, just use `mcs --version` --- Makefile | 20 +++++++++++++++----- cmd/mcs/main.go | 3 +-- cmd/mcs/version.go | 37 ------------------------------------- 3 files changed, 16 insertions(+), 44 deletions(-) delete mode 100644 cmd/mcs/version.go diff --git a/Makefile b/Makefile index cf90da1012..7829597a66 100644 --- a/Makefile +++ b/Makefile @@ -1,23 +1,33 @@ +PWD := $(shell pwd) +GOPATH := $(shell go env GOPATH) + default: mcs .PHONY: mcs mcs: @echo "Building mcs binary to './mcs'" - @(CGO_ENABLED=0 go build --tags=kqueue --ldflags "-s -w" -o mcs ./cmd/mcs) + @(CGO_ENABLED=0 go build -trimpath --tags=kqueue --ldflags "-s -w" -o mcs ./cmd/mcs) + +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\"." swagger-gen: @echo "Generating swagger server code from yaml" @swagger generate server -A mcs --main-package=mcs --exclude-main -P models.Principal -f ./swagger.yml -r NOTICE -build: +assets: @(cd portal-ui; yarn install; make build-static; cd ..) - @(CGO_ENABLED=0 go build --tags kqueue --ldflags "-s -w" -o mcs ./cmd/mcs) test: - @(go test ./restapi -v) + @(go test -race -v github.com/minio/mcs/restapi/...) coverage: - @(go test ./restapi -v -coverprofile=coverage.out && go tool cover -html=coverage.out && open coverage.html) + @(go test -v -coverprofile=coverage.out github.com/minio/mcs/restapi/... && go tool cover -html=coverage.out && open coverage.html) clean: + @echo "Cleaning up all the generated files" + @find . -name '*.test' | xargs rm -fv + @find . -name '*~' | xargs rm -fv @rm -vf mcs diff --git a/cmd/mcs/main.go b/cmd/mcs/main.go index deac98b9b5..1382614c63 100644 --- a/cmd/mcs/main.go +++ b/cmd/mcs/main.go @@ -53,7 +53,6 @@ VERSION: var appCmds = []cli.Command{ serverCmd, - versionCmd, } func newApp(name string) *cli.App { @@ -106,7 +105,7 @@ func newApp(name string) *cli.App { app.Name = name app.Version = pkg.Version app.Author = "MinIO, Inc." - app.Usage = "mcs COMMAND" + app.Usage = "mcs" app.Description = `MinIO Console Server` app.Commands = commands app.HideHelpCommand = true // Hide `help, h` command, we already have `minio --help`. diff --git a/cmd/mcs/version.go b/cmd/mcs/version.go deleted file mode 100644 index 55e4b58480..0000000000 --- a/cmd/mcs/version.go +++ /dev/null @@ -1,37 +0,0 @@ -// This file is part of MinIO Console Server -// Copyright (c) 2020 MinIO, Inc. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package main - -import ( - "fmt" - - "github.com/minio/cli" - "github.com/minio/mcs/pkg" -) - -// starts the server -var versionCmd = cli.Command{ - Name: "version", - Usage: "shows mcs version", - Action: version, -} - -// starts the controller -func version(ctx *cli.Context) error { - fmt.Printf("MCS version %s (%s - %s. Commit %s)", pkg.Version, pkg.ReleaseTag, pkg.ReleaseTime, pkg.CommitID) - return nil -}