mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-21 19:34:52 +00:00
Merge pull request #351 from guriandoro/PT-1534
PT-1534 Support for --version
This commit is contained in:
@@ -10,7 +10,7 @@ GOPATH ?=${HOME}/go
|
|||||||
MAKE_TARS = ''
|
MAKE_TARS = ''
|
||||||
CUR_DIR=$(shell pwd)
|
CUR_DIR=$(shell pwd)
|
||||||
BIN_DIR=${CUR_DIR}/build
|
BIN_DIR=${CUR_DIR}/build
|
||||||
SOURCES=collect encryptor pt-secure-data
|
SOURCES=collect encryptor pt-secure-collect
|
||||||
LDFLAGS="-X main.Version=${VERSION} -X main.Build=${BUILD} -X main.Commit=${COMMIT} -X main.Branch=${BRANCH} -X main.GoVersion=${GOVERSION} -s -w"
|
LDFLAGS="-X main.Version=${VERSION} -X main.Build=${BUILD} -X main.Commit=${COMMIT} -X main.Branch=${BRANCH} -X main.GoVersion=${GOVERSION} -s -w"
|
||||||
|
|
||||||
ifeq (${GOPATH},)
|
ifeq (${GOPATH},)
|
||||||
@@ -22,7 +22,7 @@ $(error Invalid GOPATH. There is no src dir in the GOPATH)
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(findstring ${GOPATH},${CUR_DIR}), )
|
ifeq ($(findstring ${GOPATH},${CUR_DIR}), )
|
||||||
$(error Wrong directorry for the project. It must be in $GOPATH/github/Percona-Lab/pt-secure-data)
|
$(error Wrong directorry for the project. It must be in $GOPATH/github/Percona-Lab/pt-secure-collect)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
$(info )
|
$(info )
|
||||||
@@ -37,7 +37,7 @@ default: prepare
|
|||||||
@rm -f ${BIN_DIR}/collect_*.tar.gz
|
@rm -f ${BIN_DIR}/collect_*.tar.gz
|
||||||
@echo
|
@echo
|
||||||
@$(info Building in ${BIN_DIR})
|
@$(info Building in ${BIN_DIR})
|
||||||
@go build -ldflags ${LDFLAGS} -o ${BIN_DIR}/pt-secure-data *.go
|
@go build -ldflags ${LDFLAGS} -o ${BIN_DIR}/pt-secure-collect *.go
|
||||||
|
|
||||||
prepare:
|
prepare:
|
||||||
@$(info Checking if ${BIN_DIR} exists)
|
@$(info Checking if ${BIN_DIR} exists)
|
||||||
@@ -47,31 +47,31 @@ all: clean darwin-amd64-tar linux-amd64-tar windows-amd64-tar
|
|||||||
|
|
||||||
clean: prepare
|
clean: prepare
|
||||||
@$(info Cleaning binaries and tar.gz files in dir ${BIN_DIR})
|
@$(info Cleaning binaries and tar.gz files in dir ${BIN_DIR})
|
||||||
@rm -f ${BIN_DIR}/pt-secure-data
|
@rm -f ${BIN_DIR}/pt-secure-collect
|
||||||
@rm -f ${BIN_DIR}/pt-secure-data.exe
|
@rm -f ${BIN_DIR}/pt-secure-collect.exe
|
||||||
@rm -f ${BIN_DIR}/pt-secure-data_*.tar.gz
|
@rm -f ${BIN_DIR}/pt-secure-collect_*.tar.gz
|
||||||
|
|
||||||
linux-amd64: prepare
|
linux-amd64: prepare
|
||||||
@echo "Building linux/amd64 binaries in ${BIN_DIR}"
|
@echo "Building linux/amd64 binaries in ${BIN_DIR}"
|
||||||
@GOOS=linux GOARCH=amd64 go build -ldflags ${LDFLAGS} -o ${BIN_DIR}/pt-secure-data *.go
|
@GOOS=linux GOARCH=amd64 go build -ldflags ${LDFLAGS} -o ${BIN_DIR}/pt-secure-collect *.go
|
||||||
|
|
||||||
linux-amd64-tar: linux-amd64
|
linux-amd64-tar: linux-amd64
|
||||||
@tar cvzf ${BIN_DIR}/pt-secure-data_linux_amd64.tar.gz -C ${BIN_DIR} pt-secure-data
|
@tar cvzf ${BIN_DIR}/pt-secure-collect_linux_amd64.tar.gz -C ${BIN_DIR} pt-secure-collect
|
||||||
|
|
||||||
darwin-amd64:
|
darwin-amd64:
|
||||||
@echo "Building darwin/amd64 binaries in ${BIN_DIR}"
|
@echo "Building darwin/amd64 binaries in ${BIN_DIR}"
|
||||||
@mkdir -p ${BIN_DIR}
|
@mkdir -p ${BIN_DIR}
|
||||||
@GOOS=darwin GOARCH=amd64 go build -ldflags ${LDFLAGS} -o ${BIN_DIR}/pt-secure-data *.go
|
@GOOS=darwin GOARCH=amd64 go build -ldflags ${LDFLAGS} -o ${BIN_DIR}/pt-secure-collect *.go
|
||||||
|
|
||||||
darwin-amd64-tar: darwin-amd64
|
darwin-amd64-tar: darwin-amd64
|
||||||
@tar cvzf ${BIN_DIR}/pt-secure-data_darwin_amd64.tar.gz -C ${BIN_DIR} pt-secure-data
|
@tar cvzf ${BIN_DIR}/pt-secure-collect_darwin_amd64.tar.gz -C ${BIN_DIR} pt-secure-collect
|
||||||
|
|
||||||
windows-amd64: prepare
|
windows-amd64: prepare
|
||||||
@echo "Building windows/amd64 binaries in ${BIN_DIR}"
|
@echo "Building windows/amd64 binaries in ${BIN_DIR}"
|
||||||
@GOOS=windows GOARCH=amd64 go build -ldflags ${LDFLAGS} -o ${BIN_DIR}/pt-secure-data.exe *.go
|
@GOOS=windows GOARCH=amd64 go build -ldflags ${LDFLAGS} -o ${BIN_DIR}/pt-secure-collect.exe *.go
|
||||||
|
|
||||||
windows-amd64-tar: windows-amd64
|
windows-amd64-tar: windows-amd64
|
||||||
@tar cvzf ${BIN_DIR}/pt-secure-data_windows_amd64.tar.gz -C ${BIN_DIR} pt-secure-data.exe
|
@tar cvzf ${BIN_DIR}/pt-secure-collect_windows_amd64.tar.gz -C ${BIN_DIR} pt-secure-collect.exe
|
||||||
|
|
||||||
style:
|
style:
|
||||||
@echo ">> checking code style"
|
@echo ">> checking code style"
|
||||||
|
@@ -9,7 +9,7 @@ Internal variables placeholders will be replaced with the corresponding flag va
|
|||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
```
|
```
|
||||||
pt-secure-data [<flags>] <command> [<args> ...]
|
pt-secure-collect [<flags>] <command> [<args> ...]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
@@ -67,6 +67,8 @@ type myDefaults struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
TOOLNAME = "pt-secure-collect"
|
||||||
|
|
||||||
decryptCmd = "decrypt"
|
decryptCmd = "decrypt"
|
||||||
encryptCmd = "encrypt"
|
encryptCmd = "encrypt"
|
||||||
collectCmd = "collect"
|
collectCmd = "collect"
|
||||||
@@ -81,6 +83,10 @@ var (
|
|||||||
"pt-summary",
|
"pt-summary",
|
||||||
"pt-mysql-summary --host=$mysql-host --port=$mysql-port --user=$mysql-user --password=$mysql-pass",
|
"pt-mysql-summary --host=$mysql-host --port=$mysql-port --user=$mysql-user --password=$mysql-pass",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Build string = "01-01-1980"
|
||||||
|
GoVersion string = "1.8"
|
||||||
|
Version string = "3.0.1"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -164,12 +170,15 @@ func processCliParams(baseTempPath string, usageWriter io.Writer) (*cliOptions,
|
|||||||
}
|
}
|
||||||
msg += "\n "
|
msg += "\n "
|
||||||
|
|
||||||
app := kingpin.New("pt-secure-data", msg)
|
app := kingpin.New(TOOLNAME, msg)
|
||||||
if usageWriter != nil {
|
if usageWriter != nil {
|
||||||
app.UsageWriter(usageWriter)
|
app.UsageWriter(usageWriter)
|
||||||
app.Terminate(nil)
|
app.Terminate(nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add support for --version flag
|
||||||
|
app.Version(TOOLNAME + "\nVersion " + Version + "\nBuild: " + Build + " using " + GoVersion)
|
||||||
|
|
||||||
opts := &cliOptions{
|
opts := &cliOptions{
|
||||||
CollectCommand: app.Command(collectCmd, "Collect, sanitize, pack and encrypt data from pt-tools."),
|
CollectCommand: app.Command(collectCmd, "Collect, sanitize, pack and encrypt data from pt-tools."),
|
||||||
DecryptCommand: app.Command(decryptCmd, "Decrypt an encrypted file. The password will be requested from the terminal."),
|
DecryptCommand: app.Command(decryptCmd, "Decrypt an encrypted file. The password will be requested from the terminal."),
|
||||||
|
Reference in New Issue
Block a user