Merge branch '3.x' into PT-2281_provide_container_name_for_copying_files_in_the_dump

This commit is contained in:
Sveta Smirnova
2023-11-30 19:37:36 +03:00
9 changed files with 56 additions and 26 deletions

View File

@@ -25,7 +25,7 @@ jobs:
run: cd src/go; make linux-amd64; cd ../../
- name: Build the Docker image
run: echo "FROM oraclelinux:9-slim" > Dockerfile; echo "COPY bin/* /usr/bin/" >> Dockerfile; docker build . --file Dockerfile --tag percona-toolkit:${{ github.sha }}
run: echo "FROM oraclelinux:9-slim" > Dockerfile; echo "RUN microdnf -y update" >> Dockerfile; echo "COPY bin/* /usr/bin/" >> Dockerfile; docker build . --file Dockerfile --tag percona-toolkit:${{ github.sha }}
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@0.14.0
with:

View File

@@ -1,20 +1,38 @@
use ExtUtils::MakeMaker;
use ExtUtils::MY;
sub MY::postamble {
return <<'MAKE_GOTOOLS';
gotools:
cd src/go && $(MAKE) build
MAKE_GOTOOLS
}
WriteMakefile(
NAME => 'Percona::Toolkit',
VERSION => '3.5.5',
EXE_FILES => [ <bin/*> ],
EXE_FILES => [
map {
(my $name = $_) =~ s/^bin.//;
my $file_name = $_;
if ( ( $file_name !~ m/mongo/ ) || ( $file_name !~ m/pg/ ) || ( $file_name !~ m/pt-stalk/ ) || ( $file_name !~ m/pt-k8s/ ) ) {
$_;
}
} <bin/*>
],
MAN1PODS => {
'docs/percona-toolkit.pod' => 'blib/man1/percona-toolkit.1p',
map {
(my $name = $_) =~ s/^bin.//;
my $file_name = $_;
if ( ( $file_name !~ m/mongo/ ) || ( $file_name !~ m/pg/ ) || ( $file_name !~ m/pt-stalk/ ) ) {
if ( ( $file_name !~ m/mongo/ ) || ( $file_name !~ m/pg/ ) || ( $file_name !~ m/pt-stalk/ ) || ( $file_name !~ m/pt-k8s/ ) ) {
$_ => "blib/man1/$name.1p";
}
} <bin/*>
},
MAN3PODS => {}, # man(3) pages are for C libs
depend => {manifypods => gotools},
PREREQ_PM => {
DBI => 1.46,
DBD::mysql => 3.0000_0,

4
go.mod
View File

@@ -25,7 +25,7 @@ require (
golang.org/x/crypto v0.15.0
golang.org/x/exp v0.0.0-20230321023759-10a507213a29
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22
k8s.io/api v0.28.3
k8s.io/api v0.28.4
)
require (
@@ -57,7 +57,7 @@ require (
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/apimachinery v0.28.3 // indirect
k8s.io/apimachinery v0.28.4 // indirect
k8s.io/klog/v2 v2.100.1 // indirect
k8s.io/utils v0.0.0-20230406110748-d93618cff8a2 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect

8
go.sum
View File

@@ -193,10 +193,10 @@ gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
k8s.io/api v0.28.3 h1:Gj1HtbSdB4P08C8rs9AR94MfSGpRhJgsS+GF9V26xMM=
k8s.io/api v0.28.3/go.mod h1:MRCV/jr1dW87/qJnZ57U5Pak65LGmQVkKTzf3AtKFHc=
k8s.io/apimachinery v0.28.3 h1:B1wYx8txOaCQG0HmYF6nbpU8dg6HvA06x5tEffvOe7A=
k8s.io/apimachinery v0.28.3/go.mod h1:uQTKmIqs+rAYaq+DFaoD2X7pcjLOqbQX2AOiO0nIpb8=
k8s.io/api v0.28.4 h1:8ZBrLjwosLl/NYgv1P7EQLqoO8MGQApnbgH8tu3BMzY=
k8s.io/api v0.28.4/go.mod h1:axWTGrY88s/5YE+JSt4uUi6NMM+gur1en2REMR7IRj0=
k8s.io/apimachinery v0.28.4 h1:zOSJe1mc+GxuMnFzD4Z/U1wst50X28ZNsn5bhgIIao8=
k8s.io/apimachinery v0.28.4/go.mod h1:wI37ncBvfAoswfq626yPTe6Bz1c22L7uaJ8dho83mgg=
k8s.io/klog/v2 v2.100.1 h1:7WCHKK6K8fNhTqfBhISHQ97KrnJNFZMcQvKp7gP/tmg=
k8s.io/klog/v2 v2.100.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0=
k8s.io/utils v0.0.0-20230406110748-d93618cff8a2 h1:qY1Ad8PODbnymg2pRbkyMT/ylpTrCM8P2RJ0yroCyIk=

View File

@@ -22,7 +22,7 @@ pkgs = $(shell find . -type d -name "pt-*" -exec basename {} \;)
# VERSION ?=$(shell git describe --abbrev=0) doesn't always work here, need to use git log
VERSION ?=$(shell git log --no-walk --tags --pretty="%H %d" --decorate=short | head -n1 | awk -F'[, $(CP)]' '{ print $$4; }')
BUILD=$(BUILD_DATE)
GOVERSION=$(shell go version | cut --delimiter=" " -f3)
GOVERSION=$(shell go version | cut -d " " -f3)
GOUTILSDIR ?= $(GOPATH)/bin
FILES = $(shell find . -type f -name '*.go' -not -path "./vendor/*")
PREFIX=$(shell pwd)
@@ -127,24 +127,36 @@ env-down: env ## Clean-up MongoDB docker containers cluster
docker-compose down -v
rm .env
linux-amd64: ## Build Mongo tools for linux-amd64.
linux-amd64: ## Build Go tools for linux-amd64.
@echo "Building linux/amd64 binaries in ${BIN_DIR} as version ${VERSION}"
@cd ${TOP_DIR} && go get ./...
@$(foreach pkg,$(pkgs),rm -f ${BIN_DIR}/$(pkg) 2> /dev/null;)
@$(foreach pkg,$(pkgs),GOOS=linux GOARCH=amd64 go build -ldflags ${LDFLAGS} -o ${BIN_DIR}/$(pkg) ./$(pkg);)
linux-386: ## Build Mongo tools for linux-386
linux-386: ## Build Go tools for linux-386
@echo "Building linux/386 binaries in ${BIN_DIR} as version ${VERSION}"
@cd ${TOP_DIR} && go get ./...
@$(foreach pkg,$(pkgs),rm -f ${BIN_DIR}/$(pkg) 2> /dev/null;)
@$(foreach pkg,$(pkgs),GOOS=linux GOARCH=386 go build -ldflags ${LDFLAGS} -o ${BIN_DIR}/$(pkg) ./$(pkg);)
darwin-amd64: ## Build Mongo tools for darwin-amd64 (MacOS)
darwin-amd64: ## Build Go tools for darwin-amd64 (MacOS)
@echo "Building darwin/amd64 binaries in ${BIN_DIR} as version ${VERSION}"
@cd ${TOP_DIR} && go get ./...
@$(foreach pkg,$(pkgs),rm -f ${BIN_DIR}/$(pkg) 2> /dev/null;)
@$(foreach pkg,$(pkgs),GOOS=darwin GOARCH=amd64 go build -ldflags ${LDFLAGS} -o ${BIN_DIR}/$(pkg) ./$(pkg);)
darwin-arm64: ## Build Go tools for darwin-arm64 (MacOS)
@echo "Building darwin/arm64 binaries in ${BIN_DIR} as version ${VERSION}"
@cd ${TOP_DIR} && go get ./...
@$(foreach pkg,$(pkgs),rm -f ${BIN_DIR}/$(pkg) 2> /dev/null;)
@$(foreach pkg,$(pkgs),GOOS=darwin GOARCH=arm64 go build -ldflags ${LDFLAGS} -o ${BIN_DIR}/$(pkg) ./$(pkg);)
build:
@echo "Building binaries in ${BIN_DIR} as version ${VERSION}"
@cd ${TOP_DIR} && go get ./...
@$(foreach pkg,$(pkgs),rm -f ${BIN_DIR}/$(pkg) 2> /dev/null;)
@$(foreach pkg,$(pkgs),go build -ldflags ${LDFLAGS} -o ${BIN_DIR}/$(pkg) ./$(pkg);)
style: ## Check code style
@echo ">> checking code style"
@! gofmt -d $(shell find . -path ./vendor -prune -o -name '*.go' -print) | grep '^'

View File

@@ -129,14 +129,14 @@ func TestOverrideConfig(t *testing.T) {
}
func TestDefaultFiles(t *testing.T) {
user, _ := user.Current()
current, _ := user.Current()
toolname := "pt-testing"
want := []string{
"/etc/percona-toolkit/percona-toolkit.conf",
fmt.Sprintf("/etc/percona-toolkit/%s.conf", toolname),
fmt.Sprintf("%s/.percona-toolkit.conf", user.HomeDir),
fmt.Sprintf("%s/.%s.conf", user.HomeDir, toolname),
fmt.Sprintf("%s/.percona-toolkit.conf", current.HomeDir),
fmt.Sprintf("%s/.%s.conf", current.HomeDir, toolname),
}
got, err := DefaultConfigFiles(toolname)

View File

@@ -37,7 +37,7 @@ type Security struct {
KeyFile string `bson:"keyFile"`
ClusterAuthMode string `bson:"clusterAuthMode"`
Authorization string `bson:"authorization"`
JavascriptEnabled bool `bson:javascriptEnabled"`
JavascriptEnabled bool `bson:"javascriptEnabled"`
Sasl struct {
HostName string `bson:"hostName"`
ServiceName string `bson:"serverName"`

View File

@@ -31,7 +31,7 @@ type ServerStatus struct {
type StorageEngine struct {
Name string `bson:"name"`
SupportCommittedREads bool `bson:supportsCommittedReads"`
SupportsCommittedReads bool `bson:"supportsCommittedReads"`
ReadOnly bool `bson:"readOnly"`
Persistent bool `bson:"persistent"`
}

View File

@@ -412,15 +412,15 @@ type multiSorter struct {
less []lessFunc
}
// Sort sorts the argument slice according to the less functions passed to OrderedBy.
// Sort sorts the argument slice according to the less functions passed to orderedBy.
func (ms *multiSorter) Sort(queries []stats.QueryStats) {
ms.queries = queries
sort.Sort(ms)
}
// OrderedBy returns a Sorter that sorts using the less functions, in order.
// orderedBy returns a Sorter that sorts using the less functions, in order.
// Call its Sort method to sort the data.
func OrderedBy(less ...lessFunc) *multiSorter {
func orderedBy(less ...lessFunc) *multiSorter {
return &multiSorter{
less: less,
}
@@ -520,7 +520,7 @@ func sortQueries(queries []stats.QueryStats, orderby []string) []stats.QueryStat
sortFuncs = append(sortFuncs, f)
}
OrderedBy(sortFuncs...).Sort(queries)
orderedBy(sortFuncs...).Sort(queries)
return queries
}