From b47043f07f96d7b45e9f0ed2aa25ba9ef314f7b4 Mon Sep 17 00:00:00 2001 From: Saswata Mukherjee Date: Thu, 10 Jun 2021 19:53:45 +0530 Subject: [PATCH] Add env substitution to pathorcontent Signed-off-by: Saswata Mukherjee --- CHANGELOG.md | 1 + cmd/thanos/compact.go | 2 +- cmd/thanos/config.go | 8 ++-- cmd/thanos/downsample.go | 2 +- cmd/thanos/query_frontend.go | 6 +-- cmd/thanos/receive.go | 2 +- cmd/thanos/rule.go | 2 +- cmd/thanos/sidecar.go | 2 +- cmd/thanos/store.go | 11 ++++-- cmd/thanos/tools_bucket.go | 6 +-- go.mod | 1 + go.sum | 2 + pkg/extflag/hidden.go | 4 ++ pkg/extflag/pathorcontent.go | 75 ------------------------------------ pkg/extkingpin/flags.go | 15 +++++--- pkg/logging/options.go | 2 +- pkg/queryfrontend/config.go | 2 +- pkg/replicate/replicator.go | 2 +- 18 files changed, 42 insertions(+), 103 deletions(-) delete mode 100644 pkg/extflag/pathorcontent.go diff --git a/CHANGELOG.md b/CHANGELOG.md index ef6f147a89c..ab63f0b49bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ We use _breaking :warning:_ to mark changes that are not backward compatible (re ### Added - [#4299](https://github.com/thanos-io/thanos/pull/4299) Tracing: Add tracing to exemplar APIs. +- [#4327](https://github.com/thanos-io/thanos/pull/4327) Add env substitution to PathOrContent flag. ### Fixed diff --git a/cmd/thanos/compact.go b/cmd/thanos/compact.go index 5d69b412422..b7655996044 100644 --- a/cmd/thanos/compact.go +++ b/cmd/thanos/compact.go @@ -14,6 +14,7 @@ import ( "time" "github.com/alecthomas/units" + extflag "github.com/efficientgo/tools/extkingpin" "github.com/go-kit/kit/log" "github.com/go-kit/kit/log/level" "github.com/oklog/run" @@ -30,7 +31,6 @@ import ( "github.com/thanos-io/thanos/pkg/compact" "github.com/thanos-io/thanos/pkg/compact/downsample" "github.com/thanos-io/thanos/pkg/component" - "github.com/thanos-io/thanos/pkg/extflag" "github.com/thanos-io/thanos/pkg/extkingpin" "github.com/thanos-io/thanos/pkg/extprom" extpromhttp "github.com/thanos-io/thanos/pkg/extprom/http" diff --git a/cmd/thanos/config.go b/cmd/thanos/config.go index bcc06faecda..3770389a681 100644 --- a/cmd/thanos/config.go +++ b/cmd/thanos/config.go @@ -9,7 +9,7 @@ import ( "net/url" "time" - "github.com/thanos-io/thanos/pkg/extflag" + extflag "github.com/efficientgo/tools/extkingpin" "github.com/prometheus/common/model" "github.com/thanos-io/thanos/pkg/extkingpin" @@ -186,7 +186,7 @@ type queryConfig struct { func (qc *queryConfig) registerFlag(cmd extkingpin.FlagClause) *queryConfig { cmd.Flag("query", "Addresses of statically configured query API servers (repeatable). The scheme may be prefixed with 'dns+' or 'dnssrv+' to detect query API servers through respective DNS lookups."). PlaceHolder("").StringsVar(&qc.addrs) - qc.configPath = extflag.RegisterPathOrContent(cmd, "query.config", "YAML file that contains query API servers configuration. See format details: https://thanos.io/tip/components/rule.md/#configuration. If defined, it takes precedence over the '--query' and '--query.sd-files' flags.", false) + qc.configPath = extflag.RegisterPathOrContent(cmd, "query.config", "YAML file that contains query API servers configuration. See format details: https://thanos.io/tip/components/rule.md/#configuration. If defined, it takes precedence over the '--query' and '--query.sd-files' flags.", extflag.WithEnvSubstitution()) cmd.Flag("query.sd-files", "Path to file that contains addresses of query API servers. The path can be a glob pattern (repeatable)."). PlaceHolder("").StringsVar(&qc.sdFiles) cmd.Flag("query.sd-interval", "Refresh interval to re-read file SD files. (used as a fallback)"). @@ -211,7 +211,7 @@ type alertMgrConfig struct { } func (ac *alertMgrConfig) registerFlag(cmd extflag.FlagClause) *alertMgrConfig { - ac.configPath = extflag.RegisterPathOrContent(cmd, "alertmanagers.config", "YAML file that contains alerting configuration. See format details: https://thanos.io/tip/components/rule.md/#configuration. If defined, it takes precedence over the '--alertmanagers.url' and '--alertmanagers.send-timeout' flags.", false) + ac.configPath = extflag.RegisterPathOrContent(cmd, "alertmanagers.config", "YAML file that contains alerting configuration. See format details: https://thanos.io/tip/components/rule.md/#configuration. If defined, it takes precedence over the '--alertmanagers.url' and '--alertmanagers.send-timeout' flags.", extflag.WithEnvSubstitution()) cmd.Flag("alertmanagers.url", "Alertmanager replica URLs to push firing alerts. Ruler claims success if push to at least one alertmanager from discovered succeeds. The scheme should not be empty e.g `http` might be used. The scheme may be prefixed with 'dns+' or 'dnssrv+' to detect Alertmanager IPs through respective DNS lookups. The port defaults to 9093 or the SRV record's value. The URL path is used as a prefix for the regular Alertmanager API path."). StringsVar(&ac.alertmgrURLs) cmd.Flag("alertmanagers.send-timeout", "Timeout for sending alerts to Alertmanager").Default("10s"). @@ -221,6 +221,6 @@ func (ac *alertMgrConfig) registerFlag(cmd extflag.FlagClause) *alertMgrConfig { ac.alertQueryURL = cmd.Flag("alert.query-url", "The external Thanos Query URL that would be set in all alerts 'Source' field").String() cmd.Flag("alert.label-drop", "Labels by name to drop before sending to alertmanager. This allows alert to be deduplicated on replica label (repeated). Similar Prometheus alert relabelling"). StringsVar(&ac.alertExcludeLabels) - ac.alertRelabelConfigPath = extflag.RegisterPathOrContent(cmd, "alert.relabel-config", "YAML file that contains alert relabelling configuration.", false) + ac.alertRelabelConfigPath = extflag.RegisterPathOrContent(cmd, "alert.relabel-config", "YAML file that contains alert relabelling configuration.", extflag.WithEnvSubstitution()) return ac } diff --git a/cmd/thanos/downsample.go b/cmd/thanos/downsample.go index aa280ef826d..15bbe23fcbf 100644 --- a/cmd/thanos/downsample.go +++ b/cmd/thanos/downsample.go @@ -10,6 +10,7 @@ import ( "sort" "time" + extflag "github.com/efficientgo/tools/extkingpin" "github.com/go-kit/kit/log" "github.com/go-kit/kit/log/level" "github.com/oklog/run" @@ -24,7 +25,6 @@ import ( "github.com/thanos-io/thanos/pkg/compact" "github.com/thanos-io/thanos/pkg/compact/downsample" "github.com/thanos-io/thanos/pkg/component" - "github.com/thanos-io/thanos/pkg/extflag" "github.com/thanos-io/thanos/pkg/extprom" "github.com/thanos-io/thanos/pkg/objstore" "github.com/thanos-io/thanos/pkg/objstore/client" diff --git a/cmd/thanos/query_frontend.go b/cmd/thanos/query_frontend.go index 02b70700d20..2026931b76e 100644 --- a/cmd/thanos/query_frontend.go +++ b/cmd/thanos/query_frontend.go @@ -20,9 +20,9 @@ import ( "github.com/prometheus/client_golang/prometheus" "github.com/weaveworks/common/user" + extflag "github.com/efficientgo/tools/extkingpin" "github.com/thanos-io/thanos/pkg/api" "github.com/thanos-io/thanos/pkg/component" - "github.com/thanos-io/thanos/pkg/extflag" "github.com/thanos-io/thanos/pkg/extkingpin" "github.com/thanos-io/thanos/pkg/extprom" extpromhttp "github.com/thanos-io/thanos/pkg/extprom/http" @@ -89,7 +89,7 @@ func registerQueryFrontend(app *extkingpin.App) { cmd.Flag("query-range.partial-response", "Enable partial response for query range requests if no partial_response param is specified. --no-query-range.partial-response for disabling."). Default("true").BoolVar(&cfg.QueryRangeConfig.PartialResponseStrategy) - cfg.QueryRangeConfig.CachePathOrContent = *extflag.RegisterPathOrContent(cmd, "query-range.response-cache-config", "YAML file that contains response cache configuration.", false) + cfg.QueryRangeConfig.CachePathOrContent = *extflag.RegisterPathOrContent(cmd, "query-range.response-cache-config", "YAML file that contains response cache configuration.", extflag.WithEnvSubstitution()) // Labels tripperware flags. cmd.Flag("labels.split-interval", "Split labels requests by an interval and execute in parallel, it should be greater than 0 when labels.response-cache-config is configured."). @@ -110,7 +110,7 @@ func registerQueryFrontend(app *extkingpin.App) { cmd.Flag("labels.default-time-range", "The default metadata time range duration for retrieving labels through Labels and Series API when the range parameters are not specified."). Default("24h").DurationVar(&cfg.DefaultTimeRange) - cfg.LabelsConfig.CachePathOrContent = *extflag.RegisterPathOrContent(cmd, "labels.response-cache-config", "YAML file that contains response cache configuration.", false) + cfg.LabelsConfig.CachePathOrContent = *extflag.RegisterPathOrContent(cmd, "labels.response-cache-config", "YAML file that contains response cache configuration.", extflag.WithEnvSubstitution()) cmd.Flag("cache-compression-type", "Use compression in results cache. Supported values are: 'snappy' and '' (disable compression)."). Default("").StringVar(&cfg.CacheCompression) diff --git a/cmd/thanos/receive.go b/cmd/thanos/receive.go index 982f477a36c..c28660043dc 100644 --- a/cmd/thanos/receive.go +++ b/cmd/thanos/receive.go @@ -27,8 +27,8 @@ import ( "github.com/thanos-io/thanos/pkg/extkingpin" "github.com/thanos-io/thanos/pkg/logging" + extflag "github.com/efficientgo/tools/extkingpin" "github.com/thanos-io/thanos/pkg/component" - "github.com/thanos-io/thanos/pkg/extflag" "github.com/thanos-io/thanos/pkg/extgrpc" "github.com/thanos-io/thanos/pkg/extprom" "github.com/thanos-io/thanos/pkg/objstore" diff --git a/cmd/thanos/rule.go b/cmd/thanos/rule.go index 0b4e6bf5e57..87285c3ff17 100644 --- a/cmd/thanos/rule.go +++ b/cmd/thanos/rule.go @@ -35,12 +35,12 @@ import ( "github.com/thanos-io/thanos/pkg/errutil" "github.com/thanos-io/thanos/pkg/extkingpin" + extflag "github.com/efficientgo/tools/extkingpin" "github.com/thanos-io/thanos/pkg/alert" v1 "github.com/thanos-io/thanos/pkg/api/rule" "github.com/thanos-io/thanos/pkg/block/metadata" "github.com/thanos-io/thanos/pkg/component" "github.com/thanos-io/thanos/pkg/discovery/dns" - "github.com/thanos-io/thanos/pkg/extflag" "github.com/thanos-io/thanos/pkg/extprom" extpromhttp "github.com/thanos-io/thanos/pkg/extprom/http" http_util "github.com/thanos-io/thanos/pkg/http" diff --git a/cmd/thanos/sidecar.go b/cmd/thanos/sidecar.go index f84e66ba472..c748b0df136 100644 --- a/cmd/thanos/sidecar.go +++ b/cmd/thanos/sidecar.go @@ -11,6 +11,7 @@ import ( "sync" "time" + extflag "github.com/efficientgo/tools/extkingpin" "github.com/go-kit/kit/log" "github.com/go-kit/kit/log/level" grpc_logging "github.com/grpc-ecosystem/go-grpc-middleware/v2/interceptors/logging" @@ -25,7 +26,6 @@ import ( "github.com/thanos-io/thanos/pkg/block/metadata" "github.com/thanos-io/thanos/pkg/component" "github.com/thanos-io/thanos/pkg/exemplars" - "github.com/thanos-io/thanos/pkg/extflag" "github.com/thanos-io/thanos/pkg/exthttp" "github.com/thanos-io/thanos/pkg/extkingpin" "github.com/thanos-io/thanos/pkg/extprom" diff --git a/cmd/thanos/store.go b/cmd/thanos/store.go index 371310c622f..19b6dbf8370 100644 --- a/cmd/thanos/store.go +++ b/cmd/thanos/store.go @@ -21,11 +21,12 @@ import ( commonmodel "github.com/prometheus/common/model" + extflag "github.com/efficientgo/tools/extkingpin" blocksAPI "github.com/thanos-io/thanos/pkg/api/blocks" "github.com/thanos-io/thanos/pkg/block" "github.com/thanos-io/thanos/pkg/block/metadata" "github.com/thanos-io/thanos/pkg/component" - "github.com/thanos-io/thanos/pkg/extflag" + hidden "github.com/thanos-io/thanos/pkg/extflag" "github.com/thanos-io/thanos/pkg/extkingpin" "github.com/thanos-io/thanos/pkg/extprom" extpromhttp "github.com/thanos-io/thanos/pkg/extprom/http" @@ -84,11 +85,13 @@ func (sc *storeConfig) registerFlag(cmd extkingpin.FlagClause) { sc.indexCacheConfigs = *extflag.RegisterPathOrContent(cmd, "index-cache.config", "YAML file that contains index cache configuration. See format details: https://thanos.io/tip/components/store.md/#index-cache", - false) + extflag.WithEnvSubstitution(), + ) - sc.cachingBucketConfig = *extflag.RegisterPathOrContent(extflag.HiddenCmdClause(cmd), "store.caching-bucket.config", + sc.cachingBucketConfig = *extflag.RegisterPathOrContent(hidden.HiddenCmdClause(cmd), "store.caching-bucket.config", "YAML that contains configuration for caching bucket. Experimental feature, with high risk of changes. See format details: https://thanos.io/tip/components/store.md/#caching-bucket", - false) + extflag.WithEnvSubstitution(), + ) cmd.Flag("chunk-pool-size", "Maximum size of concurrently allocatable bytes reserved strictly to reuse for chunks in memory."). Default("2GB").BytesVar(&sc.chunkPoolSize) diff --git a/cmd/thanos/tools_bucket.go b/cmd/thanos/tools_bucket.go index d9b312dede4..64185dab358 100644 --- a/cmd/thanos/tools_bucket.go +++ b/cmd/thanos/tools_bucket.go @@ -33,6 +33,7 @@ import ( "github.com/prometheus/prometheus/tsdb" "github.com/prometheus/prometheus/tsdb/chunkenc" + extflag "github.com/efficientgo/tools/extkingpin" v1 "github.com/thanos-io/thanos/pkg/api/blocks" "github.com/thanos-io/thanos/pkg/block" "github.com/thanos-io/thanos/pkg/block/metadata" @@ -40,7 +41,6 @@ import ( "github.com/thanos-io/thanos/pkg/compact/downsample" "github.com/thanos-io/thanos/pkg/compactv2" "github.com/thanos-io/thanos/pkg/component" - "github.com/thanos-io/thanos/pkg/extflag" "github.com/thanos-io/thanos/pkg/extkingpin" "github.com/thanos-io/thanos/pkg/extprom" extpromhttp "github.com/thanos-io/thanos/pkg/extprom/http" @@ -821,8 +821,8 @@ func registerBucketRewrite(app extkingpin.AppClause, objStoreConfig *extflag.Pat hashFunc := cmd.Flag("hash-func", "Specify which hash function to use when calculating the hashes of produced files. If no function has been specified, it does not happen. This permits avoiding downloading some files twice albeit at some performance cost. Possible values are: \"\", \"SHA256\"."). Default("").Enum("SHA256", "") dryRun := cmd.Flag("dry-run", "Prints the series changes instead of doing them. Defaults to true, for user to double check. (: Pass --no-dry-run to skip this.").Default("true").Bool() - toDelete := extflag.RegisterPathOrContent(cmd, "rewrite.to-delete-config", "YAML file that contains []metadata.DeletionRequest that will be applied to blocks", false) - toRelabel := extflag.RegisterPathOrContent(cmd, "rewrite.to-relabel-config", "YAML file that contains relabel configs that will be applied to blocks", false) + toDelete := extflag.RegisterPathOrContent(cmd, "rewrite.to-delete-config", "YAML file that contains []metadata.DeletionRequest that will be applied to blocks", extflag.WithEnvSubstitution()) + toRelabel := extflag.RegisterPathOrContent(cmd, "rewrite.to-relabel-config", "YAML file that contains relabel configs that will be applied to blocks", extflag.WithEnvSubstitution()) provideChangeLog := cmd.Flag("rewrite.add-change-log", "If specified, all modifications are written to new block directory. Disable if latency is to high.").Default("true").Bool() promBlocks := cmd.Flag("prom-blocks", "If specified, we assume the blocks to be uploaded are only used with Prometheus so we don't check external labels in this case.").Default("false").Bool() cmd.Setup(func(g *run.Group, logger log.Logger, reg *prometheus.Registry, _ opentracing.Tracer, _ <-chan struct{}, _ bool) error { diff --git a/go.mod b/go.mod index bf64c422458..b4535568815 100644 --- a/go.mod +++ b/go.mod @@ -16,6 +16,7 @@ require ( github.com/chromedp/chromedp v0.5.3 github.com/cortexproject/cortex v1.8.1-0.20210422151339-cf1c444e0905 github.com/davecgh/go-spew v1.1.1 + github.com/efficientgo/tools/extkingpin v0.0.0-20210609125236-d73259166f20 github.com/facette/natsort v0.0.0-20181210072756-2cd4dd1e2dcb github.com/fatih/structtag v1.1.0 github.com/felixge/fgprof v0.9.1 diff --git a/go.sum b/go.sum index f9a59068760..24fec065f0f 100644 --- a/go.sum +++ b/go.sum @@ -321,6 +321,8 @@ github.com/eclipse/paho.mqtt.golang v1.2.0/go.mod h1:H9keYFcgq3Qr5OUJm/JZI/i6U7j github.com/edsrzf/mmap-go v0.0.0-20170320065105-0bce6a688712/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= github.com/edsrzf/mmap-go v1.0.0 h1:CEBF7HpRnUCSJgGUb5h1Gm7e3VkmVDrR8lvWVLtrOFw= github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= +github.com/efficientgo/tools/extkingpin v0.0.0-20210609125236-d73259166f20 h1:kM/ALyvAnTrwSB+nlKqoKaDnZbInp1YImZvW+gtHwc8= +github.com/efficientgo/tools/extkingpin v0.0.0-20210609125236-d73259166f20/go.mod h1:ZV0utlglOczUWv3ih2AbqPSoLoFzdplUYxwV62eZi6Q= github.com/elastic/go-sysinfo v1.1.1 h1:ZVlaLDyhVkDfjwPGU55CQRCRolNpc7P0BbyhhQZQmMI= github.com/elastic/go-sysinfo v1.1.1/go.mod h1:i1ZYdU10oLNfRzq4vq62BEwD2fH8KaWh6eh0ikPT9F0= github.com/elastic/go-windows v1.0.0/go.mod h1:TsU0Nrp7/y3+VwE82FoZF8gC/XFg/Elz6CcloAxnPgU= diff --git a/pkg/extflag/hidden.go b/pkg/extflag/hidden.go index 7f812285651..61be4d58cd0 100644 --- a/pkg/extflag/hidden.go +++ b/pkg/extflag/hidden.go @@ -7,6 +7,10 @@ import ( "gopkg.in/alecthomas/kingpin.v2" ) +type FlagClause interface { + Flag(name, help string) *kingpin.FlagClause +} + // HiddenCmdClause returns FlagClause that hides created flags. func HiddenCmdClause(c FlagClause) FlagClause { return hidden{c: c} diff --git a/pkg/extflag/pathorcontent.go b/pkg/extflag/pathorcontent.go deleted file mode 100644 index 81469e0bd0b..00000000000 --- a/pkg/extflag/pathorcontent.go +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright (c) The Thanos Authors. -// Licensed under the Apache License 2.0. - -package extflag - -import ( - "fmt" - "io/ioutil" - - "github.com/pkg/errors" - "gopkg.in/alecthomas/kingpin.v2" -) - -// PathOrContent is a flag type that defines two flags to fetch bytes. Either from file (*-file flag) or content (* flag). -type PathOrContent struct { - flagName string - - required bool - - path *string - content *string -} - -type FlagClause interface { - Flag(name, help string) *kingpin.FlagClause -} - -// RegisterPathOrContent registers PathOrContent flag in kingpinCmdClause. -func RegisterPathOrContent(cmd FlagClause, flagName string, help string, required bool) *PathOrContent { - fileFlagName := fmt.Sprintf("%s-file", flagName) - contentFlagName := flagName - - fileHelp := fmt.Sprintf("Path to %s", help) - fileFlag := cmd.Flag(fileFlagName, fileHelp).PlaceHolder("").String() - - contentHelp := fmt.Sprintf("Alternative to '%s' flag (mutually exclusive). Content of %s", fileFlagName, help) - contentFlag := cmd.Flag(contentFlagName, contentHelp).PlaceHolder("").String() - - return &PathOrContent{ - flagName: flagName, - required: required, - path: fileFlag, - content: contentFlag, - } -} - -// Content returns the content of the file when given or directly the content that has been passed to the flag. -// It returns an error when: -// * The file and content flags are both not empty. -// * The file flag is not empty but the file can't be read. -// * The content is empty and the flag has been defined as required. -func (p *PathOrContent) Content() ([]byte, error) { - fileFlagName := fmt.Sprintf("%s-file", p.flagName) - - if len(*p.path) > 0 && len(*p.content) > 0 { - return nil, errors.Errorf("both %s and %s flags set.", fileFlagName, p.flagName) - } - - var content []byte - if len(*p.path) > 0 { - c, err := ioutil.ReadFile(*p.path) - if err != nil { - return nil, errors.Wrapf(err, "loading file %s for %s", *p.path, fileFlagName) - } - content = c - } else { - content = []byte(*p.content) - } - - if len(content) == 0 && p.required { - return nil, errors.Errorf("flag %s or %s is required for running this command and content cannot be empty.", fileFlagName, p.flagName) - } - - return content, nil -} diff --git a/pkg/extkingpin/flags.go b/pkg/extkingpin/flags.go index 0a5bd1a8ba1..44e301536fe 100644 --- a/pkg/extkingpin/flags.go +++ b/pkg/extkingpin/flags.go @@ -7,8 +7,8 @@ import ( "fmt" "strings" + extflag "github.com/efficientgo/tools/extkingpin" "github.com/prometheus/common/model" - "github.com/thanos-io/thanos/pkg/extflag" "gopkg.in/alecthomas/kingpin.v2" ) @@ -57,8 +57,11 @@ func RegisterHTTPFlags(cmd FlagClause) (httpBindAddr *string, httpGracePeriod *m func RegisterCommonObjStoreFlags(cmd FlagClause, suffix string, required bool, extraDesc ...string) *extflag.PathOrContent { help := fmt.Sprintf("YAML file that contains object store%s configuration. See format details: https://thanos.io/tip/thanos/storage.md/#configuration ", suffix) help = strings.Join(append([]string{help}, extraDesc...), " ") - - return extflag.RegisterPathOrContent(cmd, fmt.Sprintf("objstore%s.config", suffix), help, required) + opts := []extflag.Option{extflag.WithEnvSubstitution()} + if required { + opts = append(opts, extflag.WithRequired()) + } + return extflag.RegisterPathOrContent(cmd, fmt.Sprintf("objstore%s.config", suffix), help, opts...) } // RegisterCommonTracingFlags registers flags to pass a tracing configuration to be used with OpenTracing. @@ -67,7 +70,7 @@ func RegisterCommonTracingFlags(app FlagClause) *extflag.PathOrContent { app, "tracing.config", "YAML file with tracing configuration. See format details: https://thanos.io/tip/thanos/tracing.md/#configuration ", - false, + extflag.WithEnvSubstitution(), ) } @@ -78,7 +81,7 @@ func RegisterRequestLoggingFlags(app FlagClause) *extflag.PathOrContent { "request.logging-config", // TODO @yashrsharma44: Change the link with the documented link for yaml configuration. "YAML file with request logging configuration. See format details: https://gist.github.com/yashrsharma44/02f5765c5710dd09ce5d14e854f22825", - false, + extflag.WithEnvSubstitution(), ) } @@ -88,6 +91,6 @@ func RegisterSelectorRelabelFlags(cmd FlagClause) *extflag.PathOrContent { cmd, "selector.relabel-config", "YAML file that contains relabeling configuration that allows selecting blocks. It follows native Prometheus relabel-config syntax. See format details: https://prometheus.io/docs/prometheus/latest/configuration/configuration/#relabel_config ", - false, + extflag.WithEnvSubstitution(), ) } diff --git a/pkg/logging/options.go b/pkg/logging/options.go index 463ca1f68eb..a5270ff6569 100644 --- a/pkg/logging/options.go +++ b/pkg/logging/options.go @@ -8,12 +8,12 @@ import ( "math/rand" "time" + extflag "github.com/efficientgo/tools/extkingpin" "github.com/go-kit/kit/log" "github.com/go-kit/kit/log/level" grpc_logging "github.com/grpc-ecosystem/go-grpc-middleware/v2/interceptors/logging" "github.com/grpc-ecosystem/go-grpc-middleware/v2/interceptors/tags" "github.com/oklog/ulid" - "github.com/thanos-io/thanos/pkg/extflag" "google.golang.org/grpc/codes" ) diff --git a/pkg/queryfrontend/config.go b/pkg/queryfrontend/config.go index b21b5aee3eb..c398ef5c779 100644 --- a/pkg/queryfrontend/config.go +++ b/pkg/queryfrontend/config.go @@ -16,8 +16,8 @@ import ( "github.com/pkg/errors" "gopkg.in/yaml.v2" + extflag "github.com/efficientgo/tools/extkingpin" "github.com/thanos-io/thanos/pkg/cacheutil" - "github.com/thanos-io/thanos/pkg/extflag" "github.com/thanos-io/thanos/pkg/model" ) diff --git a/pkg/replicate/replicator.go b/pkg/replicate/replicator.go index 76e9d65437f..3611cb1dc6b 100644 --- a/pkg/replicate/replicator.go +++ b/pkg/replicate/replicator.go @@ -12,6 +12,7 @@ import ( thanosmodel "github.com/thanos-io/thanos/pkg/model" + extflag "github.com/efficientgo/tools/extkingpin" "github.com/go-kit/kit/log" "github.com/go-kit/kit/log/level" "github.com/oklog/run" @@ -25,7 +26,6 @@ import ( thanosblock "github.com/thanos-io/thanos/pkg/block" "github.com/thanos-io/thanos/pkg/compact" "github.com/thanos-io/thanos/pkg/component" - "github.com/thanos-io/thanos/pkg/extflag" "github.com/thanos-io/thanos/pkg/extprom" "github.com/thanos-io/thanos/pkg/objstore/client" "github.com/thanos-io/thanos/pkg/prober"