Skip to content

Commit f94cd16

Browse files
authored
Merge branch 'master' into get-vlogs-tenants
2 parents b89670f + 82aca88 commit f94cd16

File tree

446 files changed

+3221
-25143
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

446 files changed

+3221
-25143
lines changed

.github/workflows/docs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ jobs:
5151
git config --global user.email "${{ steps.import-gpg.outputs.email }}"
5252
if [[ -n $(git status --porcelain) ]]; then
5353
git add .
54-
git commit -S -m "sync docs with VictoriaMetrics/VictoriaMetrics commit: ${{ steps.update.outputs.SHORT_SHA }}"
54+
git commit -S -m "sync docs with VictoriaMetrics/VictoriaLogs commit: ${{ steps.update.outputs.SHORT_SHA }}"
5555
git push
5656
fi
5757
working-directory: __vm-docs

.golangci.yml

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,29 @@
1-
run:
2-
timeout: 2m
3-
1+
version: "2"
42
linters:
5-
enable:
6-
- revive
7-
8-
issues:
9-
exclude-rules:
10-
- linters:
11-
- staticcheck
12-
text: "SA(4003|1019|5011):"
13-
include:
14-
- EXC0012
15-
- EXC0014
16-
17-
linters-settings:
18-
errcheck:
19-
exclude-functions:
20-
- "fmt.Fprintf"
21-
- "fmt.Fprint"
22-
- "(net/http.ResponseWriter).Write"
3+
settings:
4+
errcheck:
5+
exclude-functions:
6+
- fmt.Fprintf
7+
- fmt.Fprint
8+
- (net/http.ResponseWriter).Write
9+
exclusions:
10+
generated: lax
11+
presets:
12+
- common-false-positives
13+
- legacy
14+
- std-error-handling
15+
rules:
16+
- linters:
17+
- staticcheck
18+
text: '(SA(4003|1019|5011)|QF1001):'
19+
paths:
20+
- third_party$
21+
- builtin$
22+
- examples$
23+
formatters:
24+
exclusions:
25+
generated: lax
26+
paths:
27+
- third_party$
28+
- builtin$
29+
- examples$

Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ ifeq ($(PKG_TAG),)
1111
PKG_TAG := $(BUILDINFO_TAG)
1212
endif
1313

14-
GO_BUILDINFO = -X '$(PKG_PREFIX)/lib/buildinfo.Version=$(APP_NAME)-$(DATEINFO_TAG)-$(BUILDINFO_TAG)'
14+
GO_BUILDINFO = -X 'github.com/VictoriaMetrics/VictoriaMetrics/lib/buildinfo.Version=$(APP_NAME)-$(DATEINFO_TAG)-$(BUILDINFO_TAG)'
1515
TAR_OWNERSHIP ?= --owner=1000 --group=1000
1616

17+
GOLANGCI_LINT_VERSION := 2.2.1
18+
1719
.PHONY: $(MAKECMDGOALS)
1820

1921
include app/*/Makefile
@@ -330,7 +332,7 @@ golangci-lint: install-golangci-lint
330332
GOEXPERIMENT=synctest golangci-lint run
331333

332334
install-golangci-lint:
333-
which golangci-lint || curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell go env GOPATH)/bin v1.64.7
335+
which golangci-lint && (golangci-lint --version | grep -q $(GOLANGCI_LINT_VERSION)) || curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell go env GOPATH)/bin v$(GOLANGCI_LINT_VERSION)
334336

335337
remove-golangci-lint:
336338
rm -rf `which golangci-lint`

app/vlagent/remotewrite/client_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ func TestCalculateRetryDuration(t *testing.T) {
2222
expectMaxDuration := helper(expectMinDuration)
2323
expectMinDuration = expectMinDuration - (1000 * time.Millisecond) // Avoid edge case when calculating time.Until(now)
2424

25-
if !(retryDuration >= expectMinDuration && retryDuration <= expectMaxDuration) {
25+
if retryDuration < expectMinDuration || retryDuration > expectMaxDuration {
2626
t.Fatalf(
2727
"incorrect retry duration, want (ms): [%d, %d], got (ms): %d",
2828
expectMinDuration.Milliseconds(), expectMaxDuration.Milliseconds(),

app/vlinsert/elasticsearch/elasticsearch_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@ package elasticsearch
33
import (
44
"bytes"
55
"fmt"
6+
"io"
7+
"testing"
8+
69
"github.com/golang/snappy"
710
"github.com/klauspost/compress/gzip"
811
"github.com/klauspost/compress/zlib"
912
"github.com/klauspost/compress/zstd"
10-
"io"
11-
"testing"
1213

1314
"github.com/VictoriaMetrics/VictoriaLogs/app/vlinsert/insertutil"
1415
)

app/vlogscli/main.go

Lines changed: 61 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ import (
1919
"github.com/VictoriaMetrics/VictoriaMetrics/lib/buildinfo"
2020
"github.com/VictoriaMetrics/VictoriaMetrics/lib/envflag"
2121
"github.com/VictoriaMetrics/VictoriaMetrics/lib/flagutil"
22+
"github.com/VictoriaMetrics/VictoriaMetrics/lib/httputil"
2223
"github.com/VictoriaMetrics/VictoriaMetrics/lib/logger"
24+
"github.com/VictoriaMetrics/VictoriaMetrics/lib/promauth"
2325
"github.com/ergochat/readline"
2426

2527
"github.com/VictoriaMetrics/VictoriaLogs/lib/logstorage"
@@ -31,9 +33,21 @@ var (
3133
tailURL = flag.String("tail.url", "", "URL for live tailing queries to VictoriaLogs; see https://docs.victoriametrics.com/victorialogs/querying/#live-tailing ."+
3234
"The url is automatically detected from -datasource.url by replacing /query with /tail at the end if -tail.url is empty")
3335
historyFile = flag.String("historyFile", "vlogscli-history", "Path to file with command history")
34-
header = flagutil.NewArrayString("header", "Optional header to pass in request -datasource.url in the form 'HeaderName: value'")
35-
accountID = flag.Int("accountID", 0, "Account ID to query; see https://docs.victoriametrics.com/victorialogs/#multitenancy")
36-
projectID = flag.Int("projectID", 0, "Project ID to query; see https://docs.victoriametrics.com/victorialogs/#multitenancy")
36+
37+
header = flagutil.NewArrayString("header", "Optional header to pass in request -datasource.url in the form 'HeaderName: value'")
38+
accountID = flag.Int("accountID", 0, "Account ID to query; see https://docs.victoriametrics.com/victorialogs/#multitenancy")
39+
projectID = flag.Int("projectID", 0, "Project ID to query; see https://docs.victoriametrics.com/victorialogs/#multitenancy")
40+
41+
username = flag.String("username", "", "Optional basic auth username to use for the -datasource.url")
42+
password = flagutil.NewPassword("password", "Optional basic auth password to use for the -datsource.url")
43+
bearerToken = flagutil.NewPassword("bearerToken", "Optional bearer auth token to use for the -datasource.url")
44+
45+
tlsCAFile = flag.String("tlsCAFile", "", "Optional path to TLS CA file to use for verifying connections to the -datasource.url. By default, system CA is used")
46+
tlsCertFile = flag.String("tlsCertFile", "", "Optional path to client-side TLS certificate file to use when connecting to the -datasource.url")
47+
tlsKeyFile = flag.String("tlsKeyFile", "", "Optional path to client-side TLS certificate key to use when connecting to the -datasource.url")
48+
tlsServerName = flag.String("tlsServerName", "", "Optional TLS server name to use for connections to the -datasource.url. "+
49+
"By default, the server name from -datasource.url is used")
50+
tlsInsecureSkipVerify = flag.Bool("tlsInsecureSkipVerify", false, "Whether to skip tls verification when connecting to the -datasource.url")
3751
)
3852

3953
const (
@@ -55,6 +69,8 @@ func main() {
5569
}
5670
headers = hes
5771

72+
httpClient = newHTTPClient()
73+
5874
incompleteLine := ""
5975
cfg := &readline.Config{
6076
Prompt: firstLinePrompt,
@@ -418,7 +434,48 @@ func getQueryResponse(ctx context.Context, output io.Writer, qStr string, output
418434
return jp
419435
}
420436

421-
var httpClient = &http.Client{}
437+
func newHTTPClient() *http.Client {
438+
ac := newAuthConfig()
439+
tr := httputil.NewTransport(true, "vlogscli")
440+
c := &http.Client{
441+
Transport: ac.NewRoundTripper(tr),
442+
}
443+
return c
444+
}
445+
446+
func newAuthConfig() *promauth.Config {
447+
username := *username
448+
password := password.Get()
449+
var basicAuthCfg *promauth.BasicAuthConfig
450+
if username != "" || password != "" {
451+
basicAuthCfg = &promauth.BasicAuthConfig{
452+
Username: username,
453+
Password: promauth.NewSecret(password),
454+
}
455+
}
456+
457+
tlsCfg := &promauth.TLSConfig{
458+
CAFile: *tlsCAFile,
459+
CertFile: *tlsCertFile,
460+
KeyFile: *tlsKeyFile,
461+
ServerName: *tlsServerName,
462+
InsecureSkipVerify: *tlsInsecureSkipVerify,
463+
}
464+
465+
opts := &promauth.Options{
466+
BasicAuth: basicAuthCfg,
467+
BearerToken: bearerToken.Get(),
468+
TLSConfig: tlsCfg,
469+
}
470+
ac, err := opts.NewConfig()
471+
if err != nil {
472+
logger.Panicf("FATAL: cannot populate auth config: %s", err)
473+
}
474+
475+
return ac
476+
}
477+
478+
var httpClient *http.Client
422479

423480
var headers []headerEntry
424481

0 commit comments

Comments
 (0)