From 7aad745a4d51a865fb0598cae7c34f2271dd3226 Mon Sep 17 00:00:00 2001 From: Arve Knudsen Date: Fri, 7 Jan 2022 10:20:29 +0100 Subject: [PATCH] Revert "Use flagext module from grafana/dskit (#4443)" This reverts commit a9a96cb246f293fabe722fa797dfa0a6f516ca57. Signed-off-by: Arve Knudsen --- cmd/cortex/main.go | 2 +- cmd/test-exporter/main.go | 2 +- integration/e2ecortex/storage.go | 2 +- integration/s3_storage_client_test.go | 2 +- pkg/alertmanager/alertmanager.go | 2 +- pkg/alertmanager/alertmanager_ring.go | 2 +- pkg/alertmanager/api_test.go | 2 +- pkg/alertmanager/distributor_test.go | 2 +- pkg/alertmanager/multitenant.go | 2 +- pkg/alertmanager/multitenant_test.go | 2 +- pkg/chunk/aws/dynamodb_storage_client.go | 2 +- pkg/chunk/aws/s3_storage_client.go | 2 +- pkg/chunk/azure/blob_storage_client.go | 2 +- pkg/chunk/cache/fifo_cache.go | 2 +- pkg/chunk/cache/redis_client.go | 3 +- pkg/chunk/cassandra/fixtures.go | 3 +- pkg/chunk/cassandra/storage_client.go | 2 +- pkg/chunk/cassandra/storage_client_test.go | 3 +- pkg/chunk/chunk_store_test.go | 2 +- pkg/chunk/purger/purger_test.go | 2 +- pkg/chunk/storage/caching_fixtures.go | 8 +- pkg/chunk/storage/factory_test.go | 2 +- pkg/chunk/testutils/testutils.go | 2 +- pkg/compactor/compactor.go | 2 +- pkg/compactor/compactor_ring.go | 2 +- pkg/compactor/compactor_ring_test.go | 2 +- pkg/compactor/compactor_test.go | 2 +- pkg/configs/client/client.go | 2 +- pkg/cortex/cortex.go | 2 +- pkg/cortex/cortex_test.go | 2 +- pkg/distributor/distributor_ring.go | 2 +- pkg/distributor/distributor_ring_test.go | 2 +- pkg/distributor/distributor_test.go | 2 +- pkg/distributor/ha_tracker_test.go | 2 +- pkg/frontend/frontend_test.go | 2 +- pkg/frontend/v1/frontend_test.go | 2 +- pkg/frontend/v1/queue_test.go | 2 +- pkg/frontend/v2/frontend.go | 2 +- pkg/frontend/v2/frontend_test.go | 2 +- pkg/ingester/lifecycle_test.go | 2 +- .../blocks_store_replicated_set_test.go | 2 +- pkg/querier/querier.go | 2 +- pkg/querier/querier_test.go | 2 +- pkg/querier/queryrange/results_cache.go | 2 +- pkg/querier/queryrange/results_cache_test.go | 2 +- pkg/querier/queryrange/roundtrip.go | 2 +- pkg/querier/store_gateway_client_test.go | 2 +- pkg/querier/testutils.go | 2 +- pkg/ring/bench/ring_memberlist_test.go | 2 +- pkg/ring/kv/etcd/etcd.go | 2 +- pkg/ring/kv/etcd/mock.go | 2 +- .../kv/memberlist/kv_init_service_test.go | 2 +- pkg/ring/kv/memberlist/memberlist_client.go | 2 +- .../kv/memberlist/memberlist_client_test.go | 2 +- pkg/ring/kv/memberlist/tcp_transport.go | 2 +- pkg/ring/kv/memberlist/tcp_transport_test.go | 2 +- pkg/ring/lifecycler.go | 2 +- pkg/ring/lifecycler_test.go | 2 +- pkg/ring/ring.go | 2 +- pkg/ring/ring_test.go | 2 +- pkg/ruler/client_pool_test.go | 2 +- pkg/ruler/ruler.go | 2 +- pkg/ruler/ruler_ring.go | 2 +- pkg/ruler/ruler_test.go | 2 +- pkg/ruler/rulestore/config.go | 3 +- pkg/ruler/rulestore/config_test.go | 3 +- pkg/scheduler/scheduler_test.go | 2 +- pkg/storage/bucket/azure/config.go | 3 +- pkg/storage/bucket/azure/config_test.go | 2 +- pkg/storage/bucket/client_test.go | 2 +- pkg/storage/bucket/gcs/config.go | 2 +- pkg/storage/bucket/http/config_test.go | 3 +- pkg/storage/bucket/s3/config.go | 2 +- pkg/storage/bucket/s3/config_test.go | 2 +- pkg/storage/bucket/sse_bucket_client_test.go | 2 +- pkg/storage/tsdb/config_test.go | 2 +- pkg/storage/tsdb/index_cache_test.go | 3 +- pkg/storegateway/bucket_stores_test.go | 2 +- pkg/storegateway/gateway_ring.go | 2 +- pkg/storegateway/gateway_test.go | 2 +- .../dskit => pkg/util}/flagext/cidr.go | 0 pkg/util/flagext/cidr_test.go | 51 +++++++++++ .../grafana/dskit => pkg/util}/flagext/day.go | 0 pkg/util/flagext/day_test.go | 52 +++++++++++ .../dskit => pkg/util}/flagext/deprecated.go | 0 .../dskit => pkg/util}/flagext/ignored.go | 0 pkg/util/flagext/register.go | 24 +++++ .../dskit => pkg/util}/flagext/secret.go | 0 pkg/util/flagext/secret_test.go | 77 ++++++++++++++++ .../dskit => pkg/util}/flagext/stringslice.go | 0 .../util}/flagext/stringslicecsv.go | 0 pkg/util/flagext/stringslicecsv_test.go | 34 +++++++ .../dskit => pkg/util}/flagext/time.go | 0 pkg/util/flagext/time_test.go | 80 +++++++++++++++++ .../grafana/dskit => pkg/util}/flagext/url.go | 0 pkg/util/flagext/url_test.go | 90 +++++++++++++++++++ pkg/util/net/firewall_dialer.go | 3 +- pkg/util/net/firewall_dialer_test.go | 3 +- pkg/util/validation/limits.go | 3 +- pkg/util/validation/limits_test.go | 3 +- tools/blocksconvert/scanner/scanner.go | 2 +- tools/doc-generator/parser.go | 3 +- .../grafana/dskit/flagext/register.go | 55 ------------ vendor/modules.txt | 1 - 104 files changed, 506 insertions(+), 149 deletions(-) rename {vendor/github.com/grafana/dskit => pkg/util}/flagext/cidr.go (100%) create mode 100644 pkg/util/flagext/cidr_test.go rename {vendor/github.com/grafana/dskit => pkg/util}/flagext/day.go (100%) create mode 100644 pkg/util/flagext/day_test.go rename {vendor/github.com/grafana/dskit => pkg/util}/flagext/deprecated.go (100%) rename {vendor/github.com/grafana/dskit => pkg/util}/flagext/ignored.go (100%) create mode 100644 pkg/util/flagext/register.go rename {vendor/github.com/grafana/dskit => pkg/util}/flagext/secret.go (100%) create mode 100644 pkg/util/flagext/secret_test.go rename {vendor/github.com/grafana/dskit => pkg/util}/flagext/stringslice.go (100%) rename {vendor/github.com/grafana/dskit => pkg/util}/flagext/stringslicecsv.go (100%) create mode 100644 pkg/util/flagext/stringslicecsv_test.go rename {vendor/github.com/grafana/dskit => pkg/util}/flagext/time.go (100%) create mode 100644 pkg/util/flagext/time_test.go rename {vendor/github.com/grafana/dskit => pkg/util}/flagext/url.go (100%) create mode 100644 pkg/util/flagext/url_test.go delete mode 100644 vendor/github.com/grafana/dskit/flagext/register.go diff --git a/cmd/cortex/main.go b/cmd/cortex/main.go index 15ec60f2c0e..fe4e89fab3f 100644 --- a/cmd/cortex/main.go +++ b/cmd/cortex/main.go @@ -13,7 +13,6 @@ import ( "time" "github.com/go-kit/log/level" - "github.com/grafana/dskit/flagext" "github.com/pkg/errors" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/common/version" @@ -22,6 +21,7 @@ import ( "github.com/cortexproject/cortex/pkg/cortex" "github.com/cortexproject/cortex/pkg/util" + "github.com/cortexproject/cortex/pkg/util/flagext" util_log "github.com/cortexproject/cortex/pkg/util/log" ) diff --git a/cmd/test-exporter/main.go b/cmd/test-exporter/main.go index 0094e0f9b1c..a7ad04b6d32 100644 --- a/cmd/test-exporter/main.go +++ b/cmd/test-exporter/main.go @@ -6,12 +6,12 @@ import ( "time" "github.com/go-kit/log/level" - "github.com/grafana/dskit/flagext" "github.com/prometheus/client_golang/prometheus" "github.com/weaveworks/common/server" "github.com/weaveworks/common/tracing" "github.com/cortexproject/cortex/pkg/testexporter/correctness" + "github.com/cortexproject/cortex/pkg/util/flagext" "github.com/cortexproject/cortex/pkg/util/log" ) diff --git a/integration/e2ecortex/storage.go b/integration/e2ecortex/storage.go index f35a084000d..f31179dfd75 100644 --- a/integration/e2ecortex/storage.go +++ b/integration/e2ecortex/storage.go @@ -6,13 +6,13 @@ import ( "strings" "github.com/go-kit/log" - "github.com/grafana/dskit/flagext" "github.com/oklog/ulid" "github.com/thanos-io/thanos/pkg/objstore" "github.com/cortexproject/cortex/integration/e2e" e2edb "github.com/cortexproject/cortex/integration/e2e/db" "github.com/cortexproject/cortex/pkg/storage/bucket/s3" + "github.com/cortexproject/cortex/pkg/util/flagext" ) type S3Client struct { diff --git a/integration/s3_storage_client_test.go b/integration/s3_storage_client_test.go index 26a259370a5..770dadb4eee 100644 --- a/integration/s3_storage_client_test.go +++ b/integration/s3_storage_client_test.go @@ -10,13 +10,13 @@ import ( "net/url" "testing" - "github.com/grafana/dskit/flagext" "github.com/stretchr/testify/require" "github.com/cortexproject/cortex/integration/e2e" e2edb "github.com/cortexproject/cortex/integration/e2e/db" s3 "github.com/cortexproject/cortex/pkg/chunk/aws" cortex_s3 "github.com/cortexproject/cortex/pkg/storage/bucket/s3" + "github.com/cortexproject/cortex/pkg/util/flagext" ) func TestS3Client(t *testing.T) { diff --git a/pkg/alertmanager/alertmanager.go b/pkg/alertmanager/alertmanager.go index 43fe9e3e319..087fbc896c4 100644 --- a/pkg/alertmanager/alertmanager.go +++ b/pkg/alertmanager/alertmanager.go @@ -15,7 +15,6 @@ import ( "github.com/go-kit/log" "github.com/go-kit/log/level" - "github.com/grafana/dskit/flagext" "github.com/grafana/dskit/services" "github.com/pkg/errors" "github.com/prometheus/alertmanager/api" @@ -49,6 +48,7 @@ import ( "golang.org/x/time/rate" "github.com/cortexproject/cortex/pkg/alertmanager/alertstore" + "github.com/cortexproject/cortex/pkg/util/flagext" util_net "github.com/cortexproject/cortex/pkg/util/net" ) diff --git a/pkg/alertmanager/alertmanager_ring.go b/pkg/alertmanager/alertmanager_ring.go index 7e033d7dba0..66532a37445 100644 --- a/pkg/alertmanager/alertmanager_ring.go +++ b/pkg/alertmanager/alertmanager_ring.go @@ -8,10 +8,10 @@ import ( "github.com/go-kit/log" "github.com/go-kit/log/level" - "github.com/grafana/dskit/flagext" "github.com/cortexproject/cortex/pkg/ring" "github.com/cortexproject/cortex/pkg/ring/kv" + "github.com/cortexproject/cortex/pkg/util/flagext" util_log "github.com/cortexproject/cortex/pkg/util/log" ) diff --git a/pkg/alertmanager/api_test.go b/pkg/alertmanager/api_test.go index 494120dc3d7..8208f5665d3 100644 --- a/pkg/alertmanager/api_test.go +++ b/pkg/alertmanager/api_test.go @@ -11,7 +11,6 @@ import ( "github.com/go-kit/log" "github.com/gorilla/mux" - "github.com/grafana/dskit/flagext" "github.com/grafana/dskit/services" "github.com/pkg/errors" "github.com/prometheus/alertmanager/config" @@ -25,6 +24,7 @@ import ( "github.com/cortexproject/cortex/pkg/alertmanager/alertspb" "github.com/cortexproject/cortex/pkg/alertmanager/alertstore/bucketclient" + "github.com/cortexproject/cortex/pkg/util/flagext" util_log "github.com/cortexproject/cortex/pkg/util/log" ) diff --git a/pkg/alertmanager/distributor_test.go b/pkg/alertmanager/distributor_test.go index 421d4fc9d05..aeedccb7d8c 100644 --- a/pkg/alertmanager/distributor_test.go +++ b/pkg/alertmanager/distributor_test.go @@ -14,7 +14,6 @@ import ( "time" "github.com/go-kit/log" - "github.com/grafana/dskit/flagext" "github.com/grafana/dskit/services" "github.com/prometheus/client_golang/prometheus" "github.com/stretchr/testify/assert" @@ -28,6 +27,7 @@ import ( "github.com/cortexproject/cortex/pkg/ring" "github.com/cortexproject/cortex/pkg/ring/kv" "github.com/cortexproject/cortex/pkg/ring/kv/consul" + "github.com/cortexproject/cortex/pkg/util/flagext" util_log "github.com/cortexproject/cortex/pkg/util/log" "github.com/cortexproject/cortex/pkg/util/test" ) diff --git a/pkg/alertmanager/multitenant.go b/pkg/alertmanager/multitenant.go index 8fcd0acc39f..6f1b999facc 100644 --- a/pkg/alertmanager/multitenant.go +++ b/pkg/alertmanager/multitenant.go @@ -15,7 +15,6 @@ import ( "github.com/go-kit/log" "github.com/go-kit/log/level" - "github.com/grafana/dskit/flagext" "github.com/grafana/dskit/services" "github.com/pkg/errors" "github.com/prometheus/alertmanager/cluster" @@ -38,6 +37,7 @@ import ( "github.com/cortexproject/cortex/pkg/tenant" "github.com/cortexproject/cortex/pkg/util" "github.com/cortexproject/cortex/pkg/util/concurrency" + "github.com/cortexproject/cortex/pkg/util/flagext" util_log "github.com/cortexproject/cortex/pkg/util/log" ) diff --git a/pkg/alertmanager/multitenant_test.go b/pkg/alertmanager/multitenant_test.go index 0ff63f35568..2bc807d0b69 100644 --- a/pkg/alertmanager/multitenant_test.go +++ b/pkg/alertmanager/multitenant_test.go @@ -20,7 +20,6 @@ import ( "time" "github.com/go-kit/log" - "github.com/grafana/dskit/flagext" "github.com/grafana/dskit/services" "github.com/prometheus/alertmanager/cluster/clusterpb" "github.com/prometheus/alertmanager/notify" @@ -47,6 +46,7 @@ import ( "github.com/cortexproject/cortex/pkg/storage/bucket" "github.com/cortexproject/cortex/pkg/util" "github.com/cortexproject/cortex/pkg/util/concurrency" + "github.com/cortexproject/cortex/pkg/util/flagext" "github.com/cortexproject/cortex/pkg/util/test" "github.com/cortexproject/cortex/pkg/util/validation" ) diff --git a/pkg/chunk/aws/dynamodb_storage_client.go b/pkg/chunk/aws/dynamodb_storage_client.go index 90d8390ac4d..4cd495c9902 100644 --- a/pkg/chunk/aws/dynamodb_storage_client.go +++ b/pkg/chunk/aws/dynamodb_storage_client.go @@ -18,7 +18,6 @@ import ( "github.com/aws/aws-sdk-go/service/dynamodb" "github.com/aws/aws-sdk-go/service/dynamodb/dynamodbiface" "github.com/go-kit/log/level" - "github.com/grafana/dskit/flagext" ot "github.com/opentracing/opentracing-go" otlog "github.com/opentracing/opentracing-go/log" "github.com/pkg/errors" @@ -31,6 +30,7 @@ import ( chunk_util "github.com/cortexproject/cortex/pkg/chunk/util" "github.com/cortexproject/cortex/pkg/util" "github.com/cortexproject/cortex/pkg/util/backoff" + "github.com/cortexproject/cortex/pkg/util/flagext" "github.com/cortexproject/cortex/pkg/util/log" "github.com/cortexproject/cortex/pkg/util/math" "github.com/cortexproject/cortex/pkg/util/spanlogger" diff --git a/pkg/chunk/aws/s3_storage_client.go b/pkg/chunk/aws/s3_storage_client.go index 73a5d93f073..e13f9842bbb 100644 --- a/pkg/chunk/aws/s3_storage_client.go +++ b/pkg/chunk/aws/s3_storage_client.go @@ -20,7 +20,6 @@ import ( v4 "github.com/aws/aws-sdk-go/aws/signer/v4" "github.com/aws/aws-sdk-go/service/s3" "github.com/aws/aws-sdk-go/service/s3/s3iface" - "github.com/grafana/dskit/flagext" "github.com/minio/minio-go/v7/pkg/signer" "github.com/pkg/errors" "github.com/prometheus/client_golang/prometheus" @@ -30,6 +29,7 @@ import ( "github.com/cortexproject/cortex/pkg/chunk" cortex_s3 "github.com/cortexproject/cortex/pkg/storage/bucket/s3" "github.com/cortexproject/cortex/pkg/util" + "github.com/cortexproject/cortex/pkg/util/flagext" ) const ( diff --git a/pkg/chunk/azure/blob_storage_client.go b/pkg/chunk/azure/blob_storage_client.go index 13e2c3d7677..ddcd0ce2ead 100644 --- a/pkg/chunk/azure/blob_storage_client.go +++ b/pkg/chunk/azure/blob_storage_client.go @@ -12,11 +12,11 @@ import ( "github.com/Azure/azure-pipeline-go/pipeline" "github.com/Azure/azure-storage-blob-go/azblob" - "github.com/grafana/dskit/flagext" "github.com/cortexproject/cortex/pkg/chunk" chunk_util "github.com/cortexproject/cortex/pkg/chunk/util" "github.com/cortexproject/cortex/pkg/util" + "github.com/cortexproject/cortex/pkg/util/flagext" "github.com/cortexproject/cortex/pkg/util/log" ) diff --git a/pkg/chunk/cache/fifo_cache.go b/pkg/chunk/cache/fifo_cache.go index 906c6ae13f5..15e135e4a4e 100644 --- a/pkg/chunk/cache/fifo_cache.go +++ b/pkg/chunk/cache/fifo_cache.go @@ -11,11 +11,11 @@ import ( "github.com/dustin/go-humanize" "github.com/go-kit/log" "github.com/go-kit/log/level" - "github.com/grafana/dskit/flagext" "github.com/pkg/errors" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promauto" + "github.com/cortexproject/cortex/pkg/util/flagext" util_log "github.com/cortexproject/cortex/pkg/util/log" ) diff --git a/pkg/chunk/cache/redis_client.go b/pkg/chunk/cache/redis_client.go index 62162cc1214..dfe74bf256d 100644 --- a/pkg/chunk/cache/redis_client.go +++ b/pkg/chunk/cache/redis_client.go @@ -10,7 +10,8 @@ import ( "unsafe" "github.com/go-redis/redis/v8" - "github.com/grafana/dskit/flagext" + + "github.com/cortexproject/cortex/pkg/util/flagext" ) // RedisConfig defines how a RedisCache should be constructed. diff --git a/pkg/chunk/cassandra/fixtures.go b/pkg/chunk/cassandra/fixtures.go index 68543bf5a12..b55cb16af5f 100644 --- a/pkg/chunk/cassandra/fixtures.go +++ b/pkg/chunk/cassandra/fixtures.go @@ -5,10 +5,9 @@ import ( "io" "os" - "github.com/grafana/dskit/flagext" - "github.com/cortexproject/cortex/pkg/chunk" "github.com/cortexproject/cortex/pkg/chunk/testutils" + "github.com/cortexproject/cortex/pkg/util/flagext" ) // GOCQL doesn't provide nice mocks, so we use a real Cassandra instance. diff --git a/pkg/chunk/cassandra/storage_client.go b/pkg/chunk/cassandra/storage_client.go index 46009ffa442..5283242e8bb 100644 --- a/pkg/chunk/cassandra/storage_client.go +++ b/pkg/chunk/cassandra/storage_client.go @@ -13,13 +13,13 @@ import ( "github.com/go-kit/log" "github.com/go-kit/log/level" "github.com/gocql/gocql" - "github.com/grafana/dskit/flagext" "github.com/pkg/errors" "github.com/prometheus/client_golang/prometheus" "golang.org/x/sync/semaphore" "github.com/cortexproject/cortex/pkg/chunk" "github.com/cortexproject/cortex/pkg/chunk/util" + "github.com/cortexproject/cortex/pkg/util/flagext" util_log "github.com/cortexproject/cortex/pkg/util/log" ) diff --git a/pkg/chunk/cassandra/storage_client_test.go b/pkg/chunk/cassandra/storage_client_test.go index 317604f56f8..7fd6867fe27 100644 --- a/pkg/chunk/cassandra/storage_client_test.go +++ b/pkg/chunk/cassandra/storage_client_test.go @@ -4,9 +4,10 @@ import ( "testing" "github.com/gocql/gocql" - "github.com/grafana/dskit/flagext" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + "github.com/cortexproject/cortex/pkg/util/flagext" ) func TestConfig_setClusterConfig_noAuth(t *testing.T) { diff --git a/pkg/chunk/chunk_store_test.go b/pkg/chunk/chunk_store_test.go index 2fb587c474a..2a6c8d865c0 100644 --- a/pkg/chunk/chunk_store_test.go +++ b/pkg/chunk/chunk_store_test.go @@ -9,7 +9,6 @@ import ( "time" "github.com/go-kit/log" - "github.com/grafana/dskit/flagext" "github.com/pkg/errors" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/common/model" @@ -21,6 +20,7 @@ import ( "github.com/cortexproject/cortex/pkg/chunk/cache" "github.com/cortexproject/cortex/pkg/chunk/encoding" + "github.com/cortexproject/cortex/pkg/util/flagext" "github.com/cortexproject/cortex/pkg/util/validation" ) diff --git a/pkg/chunk/purger/purger_test.go b/pkg/chunk/purger/purger_test.go index 5141bb508de..b9affb1a6f9 100644 --- a/pkg/chunk/purger/purger_test.go +++ b/pkg/chunk/purger/purger_test.go @@ -8,7 +8,6 @@ import ( "testing" "time" - "github.com/grafana/dskit/flagext" "github.com/grafana/dskit/services" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/testutil" @@ -18,6 +17,7 @@ import ( "github.com/cortexproject/cortex/pkg/chunk" "github.com/cortexproject/cortex/pkg/chunk/testutils" + "github.com/cortexproject/cortex/pkg/util/flagext" util_log "github.com/cortexproject/cortex/pkg/util/log" "github.com/cortexproject/cortex/pkg/util/test" ) diff --git a/pkg/chunk/storage/caching_fixtures.go b/pkg/chunk/storage/caching_fixtures.go index 1805f875b9a..98f88301354 100644 --- a/pkg/chunk/storage/caching_fixtures.go +++ b/pkg/chunk/storage/caching_fixtures.go @@ -5,16 +5,14 @@ import ( "time" "github.com/go-kit/log" - "github.com/grafana/dskit/flagext" "github.com/prometheus/client_golang/prometheus" - "github.com/cortexproject/cortex/pkg/util/validation" - + "github.com/cortexproject/cortex/pkg/chunk" "github.com/cortexproject/cortex/pkg/chunk/cache" "github.com/cortexproject/cortex/pkg/chunk/gcp" - - "github.com/cortexproject/cortex/pkg/chunk" "github.com/cortexproject/cortex/pkg/chunk/testutils" + "github.com/cortexproject/cortex/pkg/util/flagext" + "github.com/cortexproject/cortex/pkg/util/validation" ) type fixture struct { diff --git a/pkg/chunk/storage/factory_test.go b/pkg/chunk/storage/factory_test.go index 3a13810e5c1..54c1ad6147e 100644 --- a/pkg/chunk/storage/factory_test.go +++ b/pkg/chunk/storage/factory_test.go @@ -8,13 +8,13 @@ import ( "time" "github.com/go-kit/log" - "github.com/grafana/dskit/flagext" "github.com/prometheus/common/model" "github.com/stretchr/testify/require" "github.com/cortexproject/cortex/pkg/chunk" "github.com/cortexproject/cortex/pkg/chunk/cassandra" "github.com/cortexproject/cortex/pkg/chunk/local" + "github.com/cortexproject/cortex/pkg/util/flagext" "github.com/cortexproject/cortex/pkg/util/validation" ) diff --git a/pkg/chunk/testutils/testutils.go b/pkg/chunk/testutils/testutils.go index b1e0b043fad..2208ca5d7f9 100644 --- a/pkg/chunk/testutils/testutils.go +++ b/pkg/chunk/testutils/testutils.go @@ -6,7 +6,6 @@ import ( "strconv" "time" - "github.com/grafana/dskit/flagext" "github.com/prometheus/common/model" "github.com/prometheus/prometheus/model/labels" @@ -14,6 +13,7 @@ import ( "github.com/cortexproject/cortex/pkg/chunk/cache" promchunk "github.com/cortexproject/cortex/pkg/chunk/encoding" "github.com/cortexproject/cortex/pkg/ingester/client" + "github.com/cortexproject/cortex/pkg/util/flagext" "github.com/cortexproject/cortex/pkg/util/validation" ) diff --git a/pkg/compactor/compactor.go b/pkg/compactor/compactor.go index 810ea06be04..347c6e3c94c 100644 --- a/pkg/compactor/compactor.go +++ b/pkg/compactor/compactor.go @@ -15,7 +15,6 @@ import ( "github.com/go-kit/log" "github.com/go-kit/log/level" - "github.com/grafana/dskit/flagext" "github.com/grafana/dskit/services" "github.com/pkg/errors" "github.com/prometheus/client_golang/prometheus" @@ -33,6 +32,7 @@ import ( "github.com/cortexproject/cortex/pkg/storage/tsdb/bucketindex" "github.com/cortexproject/cortex/pkg/util" "github.com/cortexproject/cortex/pkg/util/backoff" + "github.com/cortexproject/cortex/pkg/util/flagext" util_log "github.com/cortexproject/cortex/pkg/util/log" ) diff --git a/pkg/compactor/compactor_ring.go b/pkg/compactor/compactor_ring.go index 7b14b1a5b68..c6ba61b29fa 100644 --- a/pkg/compactor/compactor_ring.go +++ b/pkg/compactor/compactor_ring.go @@ -6,10 +6,10 @@ import ( "time" "github.com/go-kit/log/level" - "github.com/grafana/dskit/flagext" "github.com/cortexproject/cortex/pkg/ring" "github.com/cortexproject/cortex/pkg/ring/kv" + "github.com/cortexproject/cortex/pkg/util/flagext" util_log "github.com/cortexproject/cortex/pkg/util/log" ) diff --git a/pkg/compactor/compactor_ring_test.go b/pkg/compactor/compactor_ring_test.go index 3a70ccde2b9..0519367c04a 100644 --- a/pkg/compactor/compactor_ring_test.go +++ b/pkg/compactor/compactor_ring_test.go @@ -4,10 +4,10 @@ import ( "testing" "time" - "github.com/grafana/dskit/flagext" "github.com/stretchr/testify/assert" "github.com/cortexproject/cortex/pkg/ring" + "github.com/cortexproject/cortex/pkg/util/flagext" ) func TestRingConfig_DefaultConfigToLifecyclerConfig(t *testing.T) { diff --git a/pkg/compactor/compactor_test.go b/pkg/compactor/compactor_test.go index ad74f8f1ec3..2c6227f0a33 100644 --- a/pkg/compactor/compactor_test.go +++ b/pkg/compactor/compactor_test.go @@ -18,7 +18,6 @@ import ( "time" "github.com/go-kit/log" - "github.com/grafana/dskit/flagext" "github.com/grafana/dskit/services" "github.com/oklog/ulid" "github.com/pkg/errors" @@ -39,6 +38,7 @@ import ( "github.com/cortexproject/cortex/pkg/storage/bucket" cortex_tsdb "github.com/cortexproject/cortex/pkg/storage/tsdb" "github.com/cortexproject/cortex/pkg/util/concurrency" + "github.com/cortexproject/cortex/pkg/util/flagext" cortex_testutil "github.com/cortexproject/cortex/pkg/util/test" "github.com/cortexproject/cortex/pkg/util/validation" ) diff --git a/pkg/configs/client/client.go b/pkg/configs/client/client.go index 4aaebc37d55..1903098d6b9 100644 --- a/pkg/configs/client/client.go +++ b/pkg/configs/client/client.go @@ -12,13 +12,13 @@ import ( "time" "github.com/go-kit/log/level" - "github.com/grafana/dskit/flagext" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promauto" "github.com/prometheus/common/version" "github.com/weaveworks/common/instrument" "github.com/cortexproject/cortex/pkg/configs/userconfig" + "github.com/cortexproject/cortex/pkg/util/flagext" util_log "github.com/cortexproject/cortex/pkg/util/log" tls_cfg "github.com/cortexproject/cortex/pkg/util/tls" ) diff --git a/pkg/cortex/cortex.go b/pkg/cortex/cortex.go index 06256f33198..14b9fcce86e 100644 --- a/pkg/cortex/cortex.go +++ b/pkg/cortex/cortex.go @@ -12,7 +12,6 @@ import ( "github.com/go-kit/log" "github.com/go-kit/log/level" - "github.com/grafana/dskit/flagext" "github.com/grafana/dskit/services" "github.com/pkg/errors" "github.com/prometheus/client_golang/prometheus" @@ -56,6 +55,7 @@ import ( "github.com/cortexproject/cortex/pkg/tenant" "github.com/cortexproject/cortex/pkg/util" "github.com/cortexproject/cortex/pkg/util/fakeauth" + "github.com/cortexproject/cortex/pkg/util/flagext" "github.com/cortexproject/cortex/pkg/util/grpcutil" util_log "github.com/cortexproject/cortex/pkg/util/log" "github.com/cortexproject/cortex/pkg/util/modules" diff --git a/pkg/cortex/cortex_test.go b/pkg/cortex/cortex_test.go index e19e9e91e3d..5a186bee712 100644 --- a/pkg/cortex/cortex_test.go +++ b/pkg/cortex/cortex_test.go @@ -12,7 +12,6 @@ import ( "testing" "time" - "github.com/grafana/dskit/flagext" "github.com/grafana/dskit/services" "github.com/prometheus/client_golang/prometheus" "github.com/stretchr/testify/assert" @@ -32,6 +31,7 @@ import ( "github.com/cortexproject/cortex/pkg/storage/bucket" "github.com/cortexproject/cortex/pkg/storage/bucket/s3" "github.com/cortexproject/cortex/pkg/storage/tsdb" + "github.com/cortexproject/cortex/pkg/util/flagext" ) func TestCortex(t *testing.T) { diff --git a/pkg/distributor/distributor_ring.go b/pkg/distributor/distributor_ring.go index 1e7ff840c88..f1b0fa2fb3d 100644 --- a/pkg/distributor/distributor_ring.go +++ b/pkg/distributor/distributor_ring.go @@ -6,10 +6,10 @@ import ( "time" "github.com/go-kit/log/level" - "github.com/grafana/dskit/flagext" "github.com/cortexproject/cortex/pkg/ring" "github.com/cortexproject/cortex/pkg/ring/kv" + "github.com/cortexproject/cortex/pkg/util/flagext" util_log "github.com/cortexproject/cortex/pkg/util/log" ) diff --git a/pkg/distributor/distributor_ring_test.go b/pkg/distributor/distributor_ring_test.go index b34a8326c82..24811aae903 100644 --- a/pkg/distributor/distributor_ring_test.go +++ b/pkg/distributor/distributor_ring_test.go @@ -4,10 +4,10 @@ import ( "testing" "time" - "github.com/grafana/dskit/flagext" "github.com/stretchr/testify/assert" "github.com/cortexproject/cortex/pkg/ring" + "github.com/cortexproject/cortex/pkg/util/flagext" ) func TestRingConfig_DefaultConfigToLifecyclerConfig(t *testing.T) { diff --git a/pkg/distributor/distributor_test.go b/pkg/distributor/distributor_test.go index d97caa42edc..ae0b34e50a1 100644 --- a/pkg/distributor/distributor_test.go +++ b/pkg/distributor/distributor_test.go @@ -15,7 +15,6 @@ import ( "time" "github.com/go-kit/log" - "github.com/grafana/dskit/flagext" "github.com/grafana/dskit/services" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/testutil" @@ -42,6 +41,7 @@ import ( "github.com/cortexproject/cortex/pkg/tenant" "github.com/cortexproject/cortex/pkg/util" "github.com/cortexproject/cortex/pkg/util/chunkcompat" + "github.com/cortexproject/cortex/pkg/util/flagext" "github.com/cortexproject/cortex/pkg/util/limiter" util_math "github.com/cortexproject/cortex/pkg/util/math" "github.com/cortexproject/cortex/pkg/util/test" diff --git a/pkg/distributor/ha_tracker_test.go b/pkg/distributor/ha_tracker_test.go index cc60d1cf295..a1d4e252646 100644 --- a/pkg/distributor/ha_tracker_test.go +++ b/pkg/distributor/ha_tracker_test.go @@ -8,7 +8,6 @@ import ( "time" "github.com/go-kit/log" - "github.com/grafana/dskit/flagext" "github.com/grafana/dskit/services" "github.com/pkg/errors" "github.com/prometheus/client_golang/prometheus" @@ -24,6 +23,7 @@ import ( "github.com/cortexproject/cortex/pkg/ring/kv" "github.com/cortexproject/cortex/pkg/ring/kv/consul" "github.com/cortexproject/cortex/pkg/util" + "github.com/cortexproject/cortex/pkg/util/flagext" util_log "github.com/cortexproject/cortex/pkg/util/log" "github.com/cortexproject/cortex/pkg/util/test" ) diff --git a/pkg/frontend/frontend_test.go b/pkg/frontend/frontend_test.go index eca87fea099..bdfc2a4477c 100644 --- a/pkg/frontend/frontend_test.go +++ b/pkg/frontend/frontend_test.go @@ -14,7 +14,6 @@ import ( "github.com/go-kit/log" "github.com/gorilla/mux" - "github.com/grafana/dskit/flagext" "github.com/grafana/dskit/services" otgrpc "github.com/opentracing-contrib/go-grpc" "github.com/opentracing-contrib/go-stdlib/nethttp" @@ -30,6 +29,7 @@ import ( "github.com/cortexproject/cortex/pkg/frontend/v1/frontendv1pb" querier_worker "github.com/cortexproject/cortex/pkg/querier/worker" "github.com/cortexproject/cortex/pkg/util/concurrency" + "github.com/cortexproject/cortex/pkg/util/flagext" ) const ( diff --git a/pkg/frontend/v1/frontend_test.go b/pkg/frontend/v1/frontend_test.go index 2b898565a6d..1e1a2d3af41 100644 --- a/pkg/frontend/v1/frontend_test.go +++ b/pkg/frontend/v1/frontend_test.go @@ -12,7 +12,6 @@ import ( "github.com/go-kit/log" "github.com/gorilla/mux" - "github.com/grafana/dskit/flagext" "github.com/grafana/dskit/services" otgrpc "github.com/opentracing-contrib/go-grpc" "github.com/opentracing-contrib/go-stdlib/nethttp" @@ -33,6 +32,7 @@ import ( "github.com/cortexproject/cortex/pkg/frontend/v1/frontendv1pb" querier_worker "github.com/cortexproject/cortex/pkg/querier/worker" "github.com/cortexproject/cortex/pkg/scheduler/queue" + "github.com/cortexproject/cortex/pkg/util/flagext" ) const ( diff --git a/pkg/frontend/v1/queue_test.go b/pkg/frontend/v1/queue_test.go index 26fd45608b4..4faf0b92f87 100644 --- a/pkg/frontend/v1/queue_test.go +++ b/pkg/frontend/v1/queue_test.go @@ -9,7 +9,6 @@ import ( "time" "github.com/go-kit/log" - "github.com/grafana/dskit/flagext" "github.com/grafana/dskit/services" "github.com/pkg/errors" "github.com/stretchr/testify/require" @@ -18,6 +17,7 @@ import ( "google.golang.org/grpc/metadata" "github.com/cortexproject/cortex/pkg/frontend/v1/frontendv1pb" + "github.com/cortexproject/cortex/pkg/util/flagext" ) func setupFrontend(t *testing.T, config Config) (*Frontend, error) { diff --git a/pkg/frontend/v2/frontend.go b/pkg/frontend/v2/frontend.go index 2a1512e0c0f..81b89e09101 100644 --- a/pkg/frontend/v2/frontend.go +++ b/pkg/frontend/v2/frontend.go @@ -11,7 +11,6 @@ import ( "github.com/go-kit/log" "github.com/go-kit/log/level" - "github.com/grafana/dskit/flagext" "github.com/grafana/dskit/services" "github.com/opentracing/opentracing-go" "github.com/pkg/errors" @@ -23,6 +22,7 @@ import ( "github.com/cortexproject/cortex/pkg/frontend/v2/frontendv2pb" "github.com/cortexproject/cortex/pkg/querier/stats" "github.com/cortexproject/cortex/pkg/tenant" + "github.com/cortexproject/cortex/pkg/util/flagext" "github.com/cortexproject/cortex/pkg/util/grpcclient" "github.com/cortexproject/cortex/pkg/util/httpgrpcutil" ) diff --git a/pkg/frontend/v2/frontend_test.go b/pkg/frontend/v2/frontend_test.go index 199eb2c24eb..a2846b3320c 100644 --- a/pkg/frontend/v2/frontend_test.go +++ b/pkg/frontend/v2/frontend_test.go @@ -10,7 +10,6 @@ import ( "time" "github.com/go-kit/log" - "github.com/grafana/dskit/flagext" "github.com/grafana/dskit/services" "github.com/stretchr/testify/require" "github.com/weaveworks/common/httpgrpc" @@ -21,6 +20,7 @@ import ( "github.com/cortexproject/cortex/pkg/frontend/v2/frontendv2pb" "github.com/cortexproject/cortex/pkg/querier/stats" "github.com/cortexproject/cortex/pkg/scheduler/schedulerpb" + "github.com/cortexproject/cortex/pkg/util/flagext" "github.com/cortexproject/cortex/pkg/util/test" ) diff --git a/pkg/ingester/lifecycle_test.go b/pkg/ingester/lifecycle_test.go index b34cd6a03b7..1f6b10aa059 100644 --- a/pkg/ingester/lifecycle_test.go +++ b/pkg/ingester/lifecycle_test.go @@ -11,7 +11,6 @@ import ( "time" "github.com/go-kit/log" - "github.com/grafana/dskit/flagext" "github.com/grafana/dskit/services" "github.com/prometheus/common/model" "github.com/prometheus/prometheus/model/labels" @@ -27,6 +26,7 @@ import ( "github.com/cortexproject/cortex/pkg/ring" "github.com/cortexproject/cortex/pkg/ring/kv" "github.com/cortexproject/cortex/pkg/ring/kv/consul" + "github.com/cortexproject/cortex/pkg/util/flagext" "github.com/cortexproject/cortex/pkg/util/test" "github.com/cortexproject/cortex/pkg/util/validation" ) diff --git a/pkg/querier/blocks_store_replicated_set_test.go b/pkg/querier/blocks_store_replicated_set_test.go index 9d78ff6873e..fe8288ed052 100644 --- a/pkg/querier/blocks_store_replicated_set_test.go +++ b/pkg/querier/blocks_store_replicated_set_test.go @@ -8,7 +8,6 @@ import ( "time" "github.com/go-kit/log" - "github.com/grafana/dskit/flagext" "github.com/grafana/dskit/services" "github.com/oklog/ulid" "github.com/prometheus/client_golang/prometheus" @@ -20,6 +19,7 @@ import ( "github.com/cortexproject/cortex/pkg/ring/kv/consul" cortex_tsdb "github.com/cortexproject/cortex/pkg/storage/tsdb" "github.com/cortexproject/cortex/pkg/util" + "github.com/cortexproject/cortex/pkg/util/flagext" "github.com/cortexproject/cortex/pkg/util/test" ) diff --git a/pkg/querier/querier.go b/pkg/querier/querier.go index 73e449b4ee4..f497b86d658 100644 --- a/pkg/querier/querier.go +++ b/pkg/querier/querier.go @@ -11,7 +11,6 @@ import ( "github.com/go-kit/log" "github.com/go-kit/log/level" - "github.com/grafana/dskit/flagext" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/common/model" "github.com/prometheus/prometheus/model/labels" @@ -29,6 +28,7 @@ import ( "github.com/cortexproject/cortex/pkg/querier/series" "github.com/cortexproject/cortex/pkg/tenant" "github.com/cortexproject/cortex/pkg/util" + "github.com/cortexproject/cortex/pkg/util/flagext" "github.com/cortexproject/cortex/pkg/util/limiter" "github.com/cortexproject/cortex/pkg/util/spanlogger" "github.com/cortexproject/cortex/pkg/util/validation" diff --git a/pkg/querier/querier_test.go b/pkg/querier/querier_test.go index 7ac4de207e2..e6bf0861788 100644 --- a/pkg/querier/querier_test.go +++ b/pkg/querier/querier_test.go @@ -19,7 +19,6 @@ import ( "github.com/cortexproject/cortex/pkg/cortexpb" "github.com/cortexproject/cortex/pkg/util/validation" - "github.com/grafana/dskit/flagext" "github.com/prometheus/common/model" "github.com/prometheus/prometheus/model/labels" "github.com/prometheus/prometheus/promql" @@ -37,6 +36,7 @@ import ( "github.com/cortexproject/cortex/pkg/querier/iterators" "github.com/cortexproject/cortex/pkg/util" "github.com/cortexproject/cortex/pkg/util/chunkcompat" + "github.com/cortexproject/cortex/pkg/util/flagext" ) const ( diff --git a/pkg/querier/queryrange/results_cache.go b/pkg/querier/queryrange/results_cache.go index 68a89af5b54..e00339428e6 100644 --- a/pkg/querier/queryrange/results_cache.go +++ b/pkg/querier/queryrange/results_cache.go @@ -13,7 +13,6 @@ import ( "github.com/go-kit/log/level" "github.com/gogo/protobuf/proto" "github.com/gogo/protobuf/types" - "github.com/grafana/dskit/flagext" "github.com/opentracing/opentracing-go" otlog "github.com/opentracing/opentracing-go/log" "github.com/pkg/errors" @@ -28,6 +27,7 @@ import ( "github.com/cortexproject/cortex/pkg/chunk/cache" "github.com/cortexproject/cortex/pkg/cortexpb" "github.com/cortexproject/cortex/pkg/tenant" + "github.com/cortexproject/cortex/pkg/util/flagext" util_log "github.com/cortexproject/cortex/pkg/util/log" "github.com/cortexproject/cortex/pkg/util/spanlogger" "github.com/cortexproject/cortex/pkg/util/validation" diff --git a/pkg/querier/queryrange/results_cache_test.go b/pkg/querier/queryrange/results_cache_test.go index e76b532ec64..4ab4b84571d 100644 --- a/pkg/querier/queryrange/results_cache_test.go +++ b/pkg/querier/queryrange/results_cache_test.go @@ -9,7 +9,6 @@ import ( "github.com/go-kit/log" "github.com/gogo/protobuf/types" - "github.com/grafana/dskit/flagext" "github.com/prometheus/common/model" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -17,6 +16,7 @@ import ( "github.com/cortexproject/cortex/pkg/chunk/cache" "github.com/cortexproject/cortex/pkg/cortexpb" + "github.com/cortexproject/cortex/pkg/util/flagext" ) const ( diff --git a/pkg/querier/queryrange/roundtrip.go b/pkg/querier/queryrange/roundtrip.go index 4620ff4e458..5dd9c47a30d 100644 --- a/pkg/querier/queryrange/roundtrip.go +++ b/pkg/querier/queryrange/roundtrip.go @@ -26,7 +26,6 @@ import ( "github.com/go-kit/log" "github.com/go-kit/log/level" - "github.com/grafana/dskit/flagext" "github.com/opentracing/opentracing-go" "github.com/pkg/errors" "github.com/prometheus/client_golang/prometheus" @@ -39,6 +38,7 @@ import ( "github.com/cortexproject/cortex/pkg/chunk/cache" "github.com/cortexproject/cortex/pkg/tenant" "github.com/cortexproject/cortex/pkg/util" + "github.com/cortexproject/cortex/pkg/util/flagext" ) const day = 24 * time.Hour diff --git a/pkg/querier/store_gateway_client_test.go b/pkg/querier/store_gateway_client_test.go index 3583bee7e23..bf2b3f8880e 100644 --- a/pkg/querier/store_gateway_client_test.go +++ b/pkg/querier/store_gateway_client_test.go @@ -5,7 +5,6 @@ import ( "net" "testing" - "github.com/grafana/dskit/flagext" "github.com/prometheus/client_golang/prometheus" dto "github.com/prometheus/client_model/go" "github.com/stretchr/testify/assert" @@ -15,6 +14,7 @@ import ( "google.golang.org/grpc" "github.com/cortexproject/cortex/pkg/storegateway/storegatewaypb" + "github.com/cortexproject/cortex/pkg/util/flagext" "github.com/cortexproject/cortex/pkg/util/grpcclient" ) diff --git a/pkg/querier/testutils.go b/pkg/querier/testutils.go index 7b6932a9092..022da7e7016 100644 --- a/pkg/querier/testutils.go +++ b/pkg/querier/testutils.go @@ -3,7 +3,6 @@ package querier import ( "context" - "github.com/grafana/dskit/flagext" "github.com/prometheus/common/model" "github.com/prometheus/prometheus/model/labels" "github.com/prometheus/prometheus/scrape" @@ -11,6 +10,7 @@ import ( "github.com/cortexproject/cortex/pkg/ingester/client" "github.com/cortexproject/cortex/pkg/prom1/storage/metric" + "github.com/cortexproject/cortex/pkg/util/flagext" "github.com/cortexproject/cortex/pkg/util/validation" ) diff --git a/pkg/ring/bench/ring_memberlist_test.go b/pkg/ring/bench/ring_memberlist_test.go index 69bf4363489..da35c100614 100644 --- a/pkg/ring/bench/ring_memberlist_test.go +++ b/pkg/ring/bench/ring_memberlist_test.go @@ -7,7 +7,6 @@ import ( "time" "github.com/go-kit/log" - "github.com/grafana/dskit/flagext" "github.com/grafana/dskit/services" "github.com/prometheus/client_golang/prometheus" "github.com/stretchr/testify/require" @@ -15,6 +14,7 @@ import ( "github.com/cortexproject/cortex/pkg/ring" "github.com/cortexproject/cortex/pkg/ring/kv/codec" "github.com/cortexproject/cortex/pkg/ring/kv/memberlist" + "github.com/cortexproject/cortex/pkg/util/flagext" ) type dnsProviderMock struct { diff --git a/pkg/ring/kv/etcd/etcd.go b/pkg/ring/kv/etcd/etcd.go index b898fe381ce..a748d8ec6ca 100644 --- a/pkg/ring/kv/etcd/etcd.go +++ b/pkg/ring/kv/etcd/etcd.go @@ -9,13 +9,13 @@ import ( "github.com/go-kit/log" "github.com/go-kit/log/level" - "github.com/grafana/dskit/flagext" "github.com/pkg/errors" clientv3 "go.etcd.io/etcd/client/v3" "go.etcd.io/etcd/pkg/transport" "github.com/cortexproject/cortex/pkg/ring/kv/codec" "github.com/cortexproject/cortex/pkg/util/backoff" + "github.com/cortexproject/cortex/pkg/util/flagext" cortextls "github.com/cortexproject/cortex/pkg/util/tls" ) diff --git a/pkg/ring/kv/etcd/mock.go b/pkg/ring/kv/etcd/mock.go index 53142e1c19b..823dcb4b43b 100644 --- a/pkg/ring/kv/etcd/mock.go +++ b/pkg/ring/kv/etcd/mock.go @@ -8,12 +8,12 @@ import ( "sync" "github.com/go-kit/log" - "github.com/grafana/dskit/flagext" "go.etcd.io/etcd/api/v3/etcdserverpb" "go.etcd.io/etcd/api/v3/mvccpb" clientv3 "go.etcd.io/etcd/client/v3" "github.com/cortexproject/cortex/pkg/ring/kv/codec" + "github.com/cortexproject/cortex/pkg/util/flagext" ) // channelBufferSize is the size of the channels used to send events from Put, Delete, diff --git a/pkg/ring/kv/memberlist/kv_init_service_test.go b/pkg/ring/kv/memberlist/kv_init_service_test.go index 35c668433fa..7f3c34f2efc 100644 --- a/pkg/ring/kv/memberlist/kv_init_service_test.go +++ b/pkg/ring/kv/memberlist/kv_init_service_test.go @@ -9,7 +9,7 @@ import ( "github.com/prometheus/client_golang/prometheus" "github.com/stretchr/testify/require" - "github.com/grafana/dskit/flagext" + "github.com/cortexproject/cortex/pkg/util/flagext" ) func TestPage(t *testing.T) { diff --git a/pkg/ring/kv/memberlist/memberlist_client.go b/pkg/ring/kv/memberlist/memberlist_client.go index 5d2d38e4acb..ec7558d1994 100644 --- a/pkg/ring/kv/memberlist/memberlist_client.go +++ b/pkg/ring/kv/memberlist/memberlist_client.go @@ -15,13 +15,13 @@ import ( "github.com/go-kit/log" "github.com/go-kit/log/level" - "github.com/grafana/dskit/flagext" "github.com/grafana/dskit/services" "github.com/hashicorp/memberlist" "github.com/prometheus/client_golang/prometheus" "github.com/cortexproject/cortex/pkg/ring/kv/codec" "github.com/cortexproject/cortex/pkg/util/backoff" + "github.com/cortexproject/cortex/pkg/util/flagext" ) const ( diff --git a/pkg/ring/kv/memberlist/memberlist_client_test.go b/pkg/ring/kv/memberlist/memberlist_client_test.go index aa33df53443..e1ea96df500 100644 --- a/pkg/ring/kv/memberlist/memberlist_client_test.go +++ b/pkg/ring/kv/memberlist/memberlist_client_test.go @@ -16,13 +16,13 @@ import ( "time" "github.com/go-kit/log" - "github.com/grafana/dskit/flagext" "github.com/grafana/dskit/services" "github.com/prometheus/client_golang/prometheus" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/cortexproject/cortex/pkg/ring/kv/codec" + "github.com/cortexproject/cortex/pkg/util/flagext" ) const ACTIVE = 1 diff --git a/pkg/ring/kv/memberlist/tcp_transport.go b/pkg/ring/kv/memberlist/tcp_transport.go index 9fb8608c6f2..47887c30e75 100644 --- a/pkg/ring/kv/memberlist/tcp_transport.go +++ b/pkg/ring/kv/memberlist/tcp_transport.go @@ -14,7 +14,6 @@ import ( "github.com/go-kit/log" "github.com/go-kit/log/level" - "github.com/grafana/dskit/flagext" "github.com/hashicorp/go-sockaddr" "github.com/hashicorp/memberlist" "github.com/pkg/errors" @@ -22,6 +21,7 @@ import ( "github.com/prometheus/client_golang/prometheus/promauto" "go.uber.org/atomic" + "github.com/cortexproject/cortex/pkg/util/flagext" cortextls "github.com/cortexproject/cortex/pkg/util/tls" ) diff --git a/pkg/ring/kv/memberlist/tcp_transport_test.go b/pkg/ring/kv/memberlist/tcp_transport_test.go index e4e1fbd2f12..e8e1ab44b40 100644 --- a/pkg/ring/kv/memberlist/tcp_transport_test.go +++ b/pkg/ring/kv/memberlist/tcp_transport_test.go @@ -4,11 +4,11 @@ import ( "testing" "github.com/go-kit/log" - "github.com/grafana/dskit/flagext" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/cortexproject/cortex/pkg/util/concurrency" + "github.com/cortexproject/cortex/pkg/util/flagext" ) func TestTCPTransport_WriteTo_ShouldNotLogAsWarningExpectedFailures(t *testing.T) { diff --git a/pkg/ring/lifecycler.go b/pkg/ring/lifecycler.go index 3cf48dba5b5..e24960b99c9 100644 --- a/pkg/ring/lifecycler.go +++ b/pkg/ring/lifecycler.go @@ -11,7 +11,6 @@ import ( "github.com/go-kit/log" "github.com/go-kit/log/level" - "github.com/grafana/dskit/flagext" "github.com/grafana/dskit/services" "github.com/pkg/errors" perrors "github.com/pkg/errors" @@ -19,6 +18,7 @@ import ( "go.uber.org/atomic" "github.com/cortexproject/cortex/pkg/ring/kv" + "github.com/cortexproject/cortex/pkg/util/flagext" ) // LifecyclerConfig is the config to build a Lifecycler. diff --git a/pkg/ring/lifecycler_test.go b/pkg/ring/lifecycler_test.go index 5ad0d347759..de53e5b4220 100644 --- a/pkg/ring/lifecycler_test.go +++ b/pkg/ring/lifecycler_test.go @@ -8,13 +8,13 @@ import ( "time" "github.com/go-kit/log" - "github.com/grafana/dskit/flagext" "github.com/grafana/dskit/services" "github.com/pkg/errors" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/cortexproject/cortex/pkg/ring/kv/consul" + "github.com/cortexproject/cortex/pkg/util/flagext" "github.com/cortexproject/cortex/pkg/util/test" ) diff --git a/pkg/ring/ring.go b/pkg/ring/ring.go index c0e29248f2e..713c805c4ad 100644 --- a/pkg/ring/ring.go +++ b/pkg/ring/ring.go @@ -13,7 +13,6 @@ import ( "github.com/go-kit/log" "github.com/go-kit/log/level" - "github.com/grafana/dskit/flagext" "github.com/grafana/dskit/services" "github.com/pkg/errors" "github.com/prometheus/client_golang/prometheus" @@ -22,6 +21,7 @@ import ( "github.com/cortexproject/cortex/pkg/ring/kv" shardUtil "github.com/cortexproject/cortex/pkg/ring/shard" "github.com/cortexproject/cortex/pkg/ring/util" + "github.com/cortexproject/cortex/pkg/util/flagext" utilmath "github.com/cortexproject/cortex/pkg/util/math" ) diff --git a/pkg/ring/ring_test.go b/pkg/ring/ring_test.go index cea95e3ab4d..6c484df1fc3 100644 --- a/pkg/ring/ring_test.go +++ b/pkg/ring/ring_test.go @@ -13,7 +13,6 @@ import ( "time" "github.com/go-kit/log" - "github.com/grafana/dskit/flagext" "github.com/grafana/dskit/services" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/testutil" @@ -24,6 +23,7 @@ import ( "github.com/cortexproject/cortex/pkg/ring/kv/consul" "github.com/cortexproject/cortex/pkg/ring/shard" "github.com/cortexproject/cortex/pkg/ring/util" + "github.com/cortexproject/cortex/pkg/util/flagext" "github.com/cortexproject/cortex/pkg/util/test" ) diff --git a/pkg/ruler/client_pool_test.go b/pkg/ruler/client_pool_test.go index 14d7cfb8e71..11c2ce4c2bb 100644 --- a/pkg/ruler/client_pool_test.go +++ b/pkg/ruler/client_pool_test.go @@ -5,7 +5,6 @@ import ( "net" "testing" - "github.com/grafana/dskit/flagext" "github.com/prometheus/client_golang/prometheus" dto "github.com/prometheus/client_model/go" "github.com/stretchr/testify/assert" @@ -13,6 +12,7 @@ import ( "github.com/weaveworks/common/user" "google.golang.org/grpc" + "github.com/cortexproject/cortex/pkg/util/flagext" "github.com/cortexproject/cortex/pkg/util/grpcclient" ) diff --git a/pkg/ruler/ruler.go b/pkg/ruler/ruler.go index 51e1b4d8048..46f77eacf56 100644 --- a/pkg/ruler/ruler.go +++ b/pkg/ruler/ruler.go @@ -14,7 +14,6 @@ import ( "github.com/go-kit/log" "github.com/go-kit/log/level" - "github.com/grafana/dskit/flagext" "github.com/grafana/dskit/services" "github.com/pkg/errors" "github.com/prometheus/client_golang/prometheus" @@ -34,6 +33,7 @@ import ( "github.com/cortexproject/cortex/pkg/tenant" "github.com/cortexproject/cortex/pkg/util" "github.com/cortexproject/cortex/pkg/util/concurrency" + "github.com/cortexproject/cortex/pkg/util/flagext" "github.com/cortexproject/cortex/pkg/util/grpcclient" util_log "github.com/cortexproject/cortex/pkg/util/log" "github.com/cortexproject/cortex/pkg/util/validation" diff --git a/pkg/ruler/ruler_ring.go b/pkg/ruler/ruler_ring.go index 676a1c31501..9017a8429b1 100644 --- a/pkg/ruler/ruler_ring.go +++ b/pkg/ruler/ruler_ring.go @@ -7,10 +7,10 @@ import ( "time" "github.com/go-kit/log" - "github.com/grafana/dskit/flagext" "github.com/cortexproject/cortex/pkg/ring" "github.com/cortexproject/cortex/pkg/ring/kv" + "github.com/cortexproject/cortex/pkg/util/flagext" ) const ( diff --git a/pkg/ruler/ruler_test.go b/pkg/ruler/ruler_test.go index a870eddc50d..6e8f75fe29b 100644 --- a/pkg/ruler/ruler_test.go +++ b/pkg/ruler/ruler_test.go @@ -20,7 +20,6 @@ import ( "github.com/go-kit/log" "github.com/go-kit/log/level" "github.com/gorilla/mux" - "github.com/grafana/dskit/flagext" "github.com/grafana/dskit/services" "github.com/prometheus/client_golang/prometheus" prom_testutil "github.com/prometheus/client_golang/prometheus/testutil" @@ -51,6 +50,7 @@ import ( "github.com/cortexproject/cortex/pkg/ruler/rulestore/objectclient" "github.com/cortexproject/cortex/pkg/tenant" "github.com/cortexproject/cortex/pkg/util" + "github.com/cortexproject/cortex/pkg/util/flagext" "github.com/cortexproject/cortex/pkg/util/validation" ) diff --git a/pkg/ruler/rulestore/config.go b/pkg/ruler/rulestore/config.go index b4f92f94ae3..ef5c855eede 100644 --- a/pkg/ruler/rulestore/config.go +++ b/pkg/ruler/rulestore/config.go @@ -4,12 +4,11 @@ import ( "flag" "reflect" - "github.com/grafana/dskit/flagext" - "github.com/cortexproject/cortex/pkg/configs/client" "github.com/cortexproject/cortex/pkg/ruler/rulestore/configdb" "github.com/cortexproject/cortex/pkg/ruler/rulestore/local" "github.com/cortexproject/cortex/pkg/storage/bucket" + "github.com/cortexproject/cortex/pkg/util/flagext" ) // Config configures a rule store. diff --git a/pkg/ruler/rulestore/config_test.go b/pkg/ruler/rulestore/config_test.go index bde42e48c07..9f836a9d8ad 100644 --- a/pkg/ruler/rulestore/config_test.go +++ b/pkg/ruler/rulestore/config_test.go @@ -3,8 +3,9 @@ package rulestore import ( "testing" - "github.com/grafana/dskit/flagext" "github.com/stretchr/testify/assert" + + "github.com/cortexproject/cortex/pkg/util/flagext" ) func TestIsDefaults(t *testing.T) { diff --git a/pkg/scheduler/scheduler_test.go b/pkg/scheduler/scheduler_test.go index c131ffaf717..c6431c5f34a 100644 --- a/pkg/scheduler/scheduler_test.go +++ b/pkg/scheduler/scheduler_test.go @@ -11,7 +11,6 @@ import ( "time" "github.com/go-kit/log" - "github.com/grafana/dskit/flagext" "github.com/grafana/dskit/services" "github.com/opentracing/opentracing-go" "github.com/prometheus/client_golang/prometheus" @@ -23,6 +22,7 @@ import ( "github.com/cortexproject/cortex/pkg/frontend/v2/frontendv2pb" "github.com/cortexproject/cortex/pkg/scheduler/schedulerpb" + "github.com/cortexproject/cortex/pkg/util/flagext" "github.com/cortexproject/cortex/pkg/util/httpgrpcutil" "github.com/cortexproject/cortex/pkg/util/test" ) diff --git a/pkg/storage/bucket/azure/config.go b/pkg/storage/bucket/azure/config.go index eb41b5f4f08..4f256ce223d 100644 --- a/pkg/storage/bucket/azure/config.go +++ b/pkg/storage/bucket/azure/config.go @@ -3,9 +3,8 @@ package azure import ( "flag" - "github.com/grafana/dskit/flagext" - "github.com/cortexproject/cortex/pkg/storage/bucket/http" + "github.com/cortexproject/cortex/pkg/util/flagext" ) // Config holds the config options for an Azure backend diff --git a/pkg/storage/bucket/azure/config_test.go b/pkg/storage/bucket/azure/config_test.go index 3c6bb147e23..a335612a55e 100644 --- a/pkg/storage/bucket/azure/config_test.go +++ b/pkg/storage/bucket/azure/config_test.go @@ -4,11 +4,11 @@ import ( "testing" "time" - "github.com/grafana/dskit/flagext" "github.com/stretchr/testify/require" yaml "gopkg.in/yaml.v2" "github.com/cortexproject/cortex/pkg/storage/bucket/http" + "github.com/cortexproject/cortex/pkg/util/flagext" ) // defaultConfig should match the default flag values defined in RegisterFlagsWithPrefix. diff --git a/pkg/storage/bucket/client_test.go b/pkg/storage/bucket/client_test.go index b1b7de6c30c..7a3022dd7f3 100644 --- a/pkg/storage/bucket/client_test.go +++ b/pkg/storage/bucket/client_test.go @@ -4,11 +4,11 @@ import ( "context" "testing" - "github.com/grafana/dskit/flagext" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" yaml "gopkg.in/yaml.v2" + "github.com/cortexproject/cortex/pkg/util/flagext" util_log "github.com/cortexproject/cortex/pkg/util/log" ) diff --git a/pkg/storage/bucket/gcs/config.go b/pkg/storage/bucket/gcs/config.go index 1e212352281..3e646a757c4 100644 --- a/pkg/storage/bucket/gcs/config.go +++ b/pkg/storage/bucket/gcs/config.go @@ -3,7 +3,7 @@ package gcs import ( "flag" - "github.com/grafana/dskit/flagext" + "github.com/cortexproject/cortex/pkg/util/flagext" ) // Config holds the config options for GCS backend diff --git a/pkg/storage/bucket/http/config_test.go b/pkg/storage/bucket/http/config_test.go index d7da35e581a..2203a52acb3 100644 --- a/pkg/storage/bucket/http/config_test.go +++ b/pkg/storage/bucket/http/config_test.go @@ -4,9 +4,10 @@ import ( "testing" "time" - "github.com/grafana/dskit/flagext" "github.com/stretchr/testify/require" yaml "gopkg.in/yaml.v2" + + "github.com/cortexproject/cortex/pkg/util/flagext" ) // defaultConfig should match the default flag values defined in RegisterFlagsWithPrefix. diff --git a/pkg/storage/bucket/s3/config.go b/pkg/storage/bucket/s3/config.go index 4bbd7051f9f..07e7906b870 100644 --- a/pkg/storage/bucket/s3/config.go +++ b/pkg/storage/bucket/s3/config.go @@ -7,13 +7,13 @@ import ( "net/http" "strings" - "github.com/grafana/dskit/flagext" "github.com/minio/minio-go/v7/pkg/encrypt" "github.com/pkg/errors" "github.com/thanos-io/thanos/pkg/objstore/s3" bucket_http "github.com/cortexproject/cortex/pkg/storage/bucket/http" "github.com/cortexproject/cortex/pkg/util" + "github.com/cortexproject/cortex/pkg/util/flagext" ) const ( diff --git a/pkg/storage/bucket/s3/config_test.go b/pkg/storage/bucket/s3/config_test.go index 4e02ee5006f..08e1cd27b75 100644 --- a/pkg/storage/bucket/s3/config_test.go +++ b/pkg/storage/bucket/s3/config_test.go @@ -6,12 +6,12 @@ import ( "testing" "time" - "github.com/grafana/dskit/flagext" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "gopkg.in/yaml.v2" bucket_http "github.com/cortexproject/cortex/pkg/storage/bucket/http" + "github.com/cortexproject/cortex/pkg/util/flagext" ) // defaultConfig should match the default flag values defined in RegisterFlagsWithPrefix. diff --git a/pkg/storage/bucket/sse_bucket_client_test.go b/pkg/storage/bucket/sse_bucket_client_test.go index 870ec1a3ece..c6af17c6aae 100644 --- a/pkg/storage/bucket/sse_bucket_client_test.go +++ b/pkg/storage/bucket/sse_bucket_client_test.go @@ -9,12 +9,12 @@ import ( "testing" "github.com/go-kit/log" - "github.com/grafana/dskit/flagext" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/thanos-io/thanos/pkg/objstore" "github.com/cortexproject/cortex/pkg/storage/bucket/s3" + "github.com/cortexproject/cortex/pkg/util/flagext" ) func TestSSEBucketClient_Upload_ShouldInjectCustomSSEConfig(t *testing.T) { diff --git a/pkg/storage/tsdb/config_test.go b/pkg/storage/tsdb/config_test.go index 857a47a460b..6946f51c6e8 100644 --- a/pkg/storage/tsdb/config_test.go +++ b/pkg/storage/tsdb/config_test.go @@ -5,10 +5,10 @@ import ( "testing" "time" - "github.com/grafana/dskit/flagext" "github.com/stretchr/testify/assert" "github.com/cortexproject/cortex/pkg/storage/bucket" + "github.com/cortexproject/cortex/pkg/util/flagext" ) func TestConfig_Validate(t *testing.T) { diff --git a/pkg/storage/tsdb/index_cache_test.go b/pkg/storage/tsdb/index_cache_test.go index eaaf8520e47..c5617f04d9d 100644 --- a/pkg/storage/tsdb/index_cache_test.go +++ b/pkg/storage/tsdb/index_cache_test.go @@ -3,8 +3,9 @@ package tsdb import ( "testing" - "github.com/grafana/dskit/flagext" "github.com/stretchr/testify/assert" + + "github.com/cortexproject/cortex/pkg/util/flagext" ) func TestIndexCacheConfig_Validate(t *testing.T) { diff --git a/pkg/storegateway/bucket_stores_test.go b/pkg/storegateway/bucket_stores_test.go index 482b052bebe..4a1d1c0fcce 100644 --- a/pkg/storegateway/bucket_stores_test.go +++ b/pkg/storegateway/bucket_stores_test.go @@ -15,7 +15,6 @@ import ( "time" "github.com/go-kit/log" - "github.com/grafana/dskit/flagext" "github.com/oklog/ulid" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/testutil" @@ -39,6 +38,7 @@ import ( "github.com/cortexproject/cortex/pkg/storage/bucket/filesystem" cortex_tsdb "github.com/cortexproject/cortex/pkg/storage/tsdb" "github.com/cortexproject/cortex/pkg/util" + "github.com/cortexproject/cortex/pkg/util/flagext" ) func TestBucketStores_InitialSync(t *testing.T) { diff --git a/pkg/storegateway/gateway_ring.go b/pkg/storegateway/gateway_ring.go index 0a8ded19eae..f73065b7715 100644 --- a/pkg/storegateway/gateway_ring.go +++ b/pkg/storegateway/gateway_ring.go @@ -8,10 +8,10 @@ import ( "github.com/go-kit/log" "github.com/go-kit/log/level" - "github.com/grafana/dskit/flagext" "github.com/cortexproject/cortex/pkg/ring" "github.com/cortexproject/cortex/pkg/ring/kv" + "github.com/cortexproject/cortex/pkg/util/flagext" util_log "github.com/cortexproject/cortex/pkg/util/log" ) diff --git a/pkg/storegateway/gateway_test.go b/pkg/storegateway/gateway_test.go index 9f47af3b94a..9bf26863509 100644 --- a/pkg/storegateway/gateway_test.go +++ b/pkg/storegateway/gateway_test.go @@ -17,7 +17,6 @@ import ( "time" "github.com/go-kit/log" - "github.com/grafana/dskit/flagext" "github.com/grafana/dskit/services" "github.com/oklog/ulid" "github.com/pkg/errors" @@ -44,6 +43,7 @@ import ( "github.com/cortexproject/cortex/pkg/storage/tsdb/bucketindex" cortex_testutil "github.com/cortexproject/cortex/pkg/storage/tsdb/testutil" "github.com/cortexproject/cortex/pkg/util" + "github.com/cortexproject/cortex/pkg/util/flagext" "github.com/cortexproject/cortex/pkg/util/test" "github.com/cortexproject/cortex/pkg/util/validation" ) diff --git a/vendor/github.com/grafana/dskit/flagext/cidr.go b/pkg/util/flagext/cidr.go similarity index 100% rename from vendor/github.com/grafana/dskit/flagext/cidr.go rename to pkg/util/flagext/cidr.go diff --git a/pkg/util/flagext/cidr_test.go b/pkg/util/flagext/cidr_test.go new file mode 100644 index 00000000000..1e1209adfc4 --- /dev/null +++ b/pkg/util/flagext/cidr_test.go @@ -0,0 +1,51 @@ +package flagext + +import ( + "testing" + + "github.com/stretchr/testify/assert" + "gopkg.in/yaml.v2" +) + +func Test_CIDRSliceCSV_YamlMarshalling(t *testing.T) { + type TestStruct struct { + CIDRs CIDRSliceCSV `yaml:"cidrs"` + } + + tests := map[string]struct { + input string + expected []string + }{ + "should marshal empty config": { + input: "cidrs: \"\"\n", + expected: nil, + }, + "should marshal single value": { + input: "cidrs: 127.0.0.1/32\n", + expected: []string{"127.0.0.1/32"}, + }, + "should marshal multiple comma-separated values": { + input: "cidrs: 127.0.0.1/32,10.0.10.0/28,fdf8:f53b:82e4::/100,192.168.0.0/20\n", + expected: []string{"127.0.0.1/32", "10.0.10.0/28", "fdf8:f53b:82e4::/100", "192.168.0.0/20"}, + }, + } + + for name, tc := range tests { + t.Run(name, func(t *testing.T) { + // Unmarshal. + actual := TestStruct{} + err := yaml.Unmarshal([]byte(tc.input), &actual) + assert.NoError(t, err) + + assert.Len(t, actual.CIDRs, len(tc.expected)) + for idx, cidr := range actual.CIDRs { + assert.Equal(t, tc.expected[idx], cidr.String()) + } + + // Marshal. + out, err := yaml.Marshal(actual) + assert.NoError(t, err) + assert.Equal(t, tc.input, string(out)) + }) + } +} diff --git a/vendor/github.com/grafana/dskit/flagext/day.go b/pkg/util/flagext/day.go similarity index 100% rename from vendor/github.com/grafana/dskit/flagext/day.go rename to pkg/util/flagext/day.go diff --git a/pkg/util/flagext/day_test.go b/pkg/util/flagext/day_test.go new file mode 100644 index 00000000000..fae59523cf1 --- /dev/null +++ b/pkg/util/flagext/day_test.go @@ -0,0 +1,52 @@ +package flagext + +import ( + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "gopkg.in/yaml.v2" +) + +func TestDayValueYAML(t *testing.T) { + t.Run("embedding DayValue", func(t *testing.T) { + type TestStruct struct { + Day DayValue `yaml:"day"` + } + + var testStruct TestStruct + require.NoError(t, testStruct.Day.Set("1985-06-02")) + expected := []byte(`day: "1985-06-02" +`) + + actual, err := yaml.Marshal(testStruct) + require.NoError(t, err) + assert.Equal(t, expected, actual) + + var actualStruct TestStruct + err = yaml.Unmarshal(expected, &actualStruct) + require.NoError(t, err) + assert.Equal(t, testStruct, actualStruct) + }) + + t.Run("pointer of DayValue", func(t *testing.T) { + type TestStruct struct { + Day *DayValue `yaml:"day"` + } + + var testStruct TestStruct + testStruct.Day = &DayValue{} + require.NoError(t, testStruct.Day.Set("1985-06-02")) + expected := []byte(`day: "1985-06-02" +`) + + actual, err := yaml.Marshal(testStruct) + require.NoError(t, err) + assert.Equal(t, expected, actual) + + var actualStruct TestStruct + err = yaml.Unmarshal(expected, &actualStruct) + require.NoError(t, err) + assert.Equal(t, testStruct, actualStruct) + }) +} diff --git a/vendor/github.com/grafana/dskit/flagext/deprecated.go b/pkg/util/flagext/deprecated.go similarity index 100% rename from vendor/github.com/grafana/dskit/flagext/deprecated.go rename to pkg/util/flagext/deprecated.go diff --git a/vendor/github.com/grafana/dskit/flagext/ignored.go b/pkg/util/flagext/ignored.go similarity index 100% rename from vendor/github.com/grafana/dskit/flagext/ignored.go rename to pkg/util/flagext/ignored.go diff --git a/pkg/util/flagext/register.go b/pkg/util/flagext/register.go new file mode 100644 index 00000000000..1140843e047 --- /dev/null +++ b/pkg/util/flagext/register.go @@ -0,0 +1,24 @@ +package flagext + +import "flag" + +// Registerer is a thing that can RegisterFlags +type Registerer interface { + RegisterFlags(*flag.FlagSet) +} + +// RegisterFlags registers flags with the provided Registerers +func RegisterFlags(rs ...Registerer) { + for _, r := range rs { + r.RegisterFlags(flag.CommandLine) + } +} + +// DefaultValues initiates a set of configs (Registerers) with their defaults. +func DefaultValues(rs ...Registerer) { + fs := flag.NewFlagSet("", flag.PanicOnError) + for _, r := range rs { + r.RegisterFlags(fs) + } + _ = fs.Parse([]string{}) +} diff --git a/vendor/github.com/grafana/dskit/flagext/secret.go b/pkg/util/flagext/secret.go similarity index 100% rename from vendor/github.com/grafana/dskit/flagext/secret.go rename to pkg/util/flagext/secret.go diff --git a/pkg/util/flagext/secret_test.go b/pkg/util/flagext/secret_test.go new file mode 100644 index 00000000000..3288d7922a3 --- /dev/null +++ b/pkg/util/flagext/secret_test.go @@ -0,0 +1,77 @@ +package flagext + +import ( + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "gopkg.in/yaml.v2" +) + +func TestSecretdYAML(t *testing.T) { + // Test embedding of Secret. + { + type TestStruct struct { + Secret Secret `yaml:"secret"` + } + + var testStruct TestStruct + require.NoError(t, testStruct.Secret.Set("pa55w0rd")) + expected := []byte(`secret: '********' +`) + + actual, err := yaml.Marshal(testStruct) + require.NoError(t, err) + assert.Equal(t, expected, actual) + + var actualStruct TestStruct + yamlSecret := []byte(`secret: pa55w0rd +`) + err = yaml.Unmarshal(yamlSecret, &actualStruct) + require.NoError(t, err) + assert.Equal(t, testStruct, actualStruct) + } + + // Test pointers of Secret. + { + type TestStruct struct { + Secret *Secret `yaml:"secret"` + } + + var testStruct TestStruct + testStruct.Secret = &Secret{} + require.NoError(t, testStruct.Secret.Set("pa55w0rd")) + expected := []byte(`secret: '********' +`) + + actual, err := yaml.Marshal(testStruct) + require.NoError(t, err) + assert.Equal(t, expected, actual) + + var actualStruct TestStruct + yamlSecret := []byte(`secret: pa55w0rd +`) + err = yaml.Unmarshal(yamlSecret, &actualStruct) + require.NoError(t, err) + assert.Equal(t, testStruct, actualStruct) + } + + // Test no value set in Secret. + { + type TestStruct struct { + Secret Secret `yaml:"secret"` + } + var testStruct TestStruct + expected := []byte(`secret: "" +`) + + actual, err := yaml.Marshal(testStruct) + require.NoError(t, err) + assert.Equal(t, expected, actual) + + var actualStruct TestStruct + err = yaml.Unmarshal(expected, &actualStruct) + require.NoError(t, err) + assert.Equal(t, testStruct, actualStruct) + } +} diff --git a/vendor/github.com/grafana/dskit/flagext/stringslice.go b/pkg/util/flagext/stringslice.go similarity index 100% rename from vendor/github.com/grafana/dskit/flagext/stringslice.go rename to pkg/util/flagext/stringslice.go diff --git a/vendor/github.com/grafana/dskit/flagext/stringslicecsv.go b/pkg/util/flagext/stringslicecsv.go similarity index 100% rename from vendor/github.com/grafana/dskit/flagext/stringslicecsv.go rename to pkg/util/flagext/stringslicecsv.go diff --git a/pkg/util/flagext/stringslicecsv_test.go b/pkg/util/flagext/stringslicecsv_test.go new file mode 100644 index 00000000000..67e50ba1df4 --- /dev/null +++ b/pkg/util/flagext/stringslicecsv_test.go @@ -0,0 +1,34 @@ +package flagext + +import ( + "testing" + + "github.com/stretchr/testify/assert" + "gopkg.in/yaml.v2" +) + +func Test_StringSliceCSV(t *testing.T) { + type TestStruct struct { + CSV StringSliceCSV `yaml:"csv"` + } + + var testStruct TestStruct + s := "a,b,c,d" + assert.Nil(t, testStruct.CSV.Set(s)) + + assert.Equal(t, []string{"a", "b", "c", "d"}, []string(testStruct.CSV)) + assert.Equal(t, s, testStruct.CSV.String()) + + expected := []byte(`csv: a,b,c,d +`) + + actual, err := yaml.Marshal(testStruct) + assert.Nil(t, err) + assert.Equal(t, expected, actual) + + var testStruct2 TestStruct + + err = yaml.Unmarshal(expected, &testStruct2) + assert.Nil(t, err) + assert.Equal(t, testStruct, testStruct2) +} diff --git a/vendor/github.com/grafana/dskit/flagext/time.go b/pkg/util/flagext/time.go similarity index 100% rename from vendor/github.com/grafana/dskit/flagext/time.go rename to pkg/util/flagext/time.go diff --git a/pkg/util/flagext/time_test.go b/pkg/util/flagext/time_test.go new file mode 100644 index 00000000000..b34942b6eda --- /dev/null +++ b/pkg/util/flagext/time_test.go @@ -0,0 +1,80 @@ +package flagext + +import ( + "testing" + "time" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "gopkg.in/yaml.v2" +) + +func TestTimeYAML(t *testing.T) { + { + type TestStruct struct { + T Time `yaml:"time"` + } + + var testStruct TestStruct + require.NoError(t, testStruct.T.Set("2020-10-20")) + + marshaled, err := yaml.Marshal(testStruct) + require.NoError(t, err) + + expected := `time: "2020-10-20T00:00:00Z"` + "\n" + assert.Equal(t, expected, string(marshaled)) + + var actualStruct TestStruct + err = yaml.Unmarshal([]byte(expected), &actualStruct) + require.NoError(t, err) + assert.Equal(t, testStruct, actualStruct) + } + + { + type TestStruct struct { + T *Time `yaml:"time"` + } + + var testStruct TestStruct + testStruct.T = &Time{} + require.NoError(t, testStruct.T.Set("2020-10-20")) + + marshaled, err := yaml.Marshal(testStruct) + require.NoError(t, err) + + expected := `time: "2020-10-20T00:00:00Z"` + "\n" + assert.Equal(t, expected, string(marshaled)) + + var actualStruct TestStruct + err = yaml.Unmarshal([]byte(expected), &actualStruct) + require.NoError(t, err) + assert.Equal(t, testStruct, actualStruct) + } +} + +func TestTimeFormats(t *testing.T) { + ts := &Time{} + require.NoError(t, ts.Set("0")) + require.True(t, time.Time(*ts).IsZero()) + require.Equal(t, "0", ts.String()) + + require.NoError(t, ts.Set("2020-10-05")) + require.Equal(t, mustParseTime(t, "2006-01-02", "2020-10-05").Format(time.RFC3339), ts.String()) + + require.NoError(t, ts.Set("2020-10-05T13:27")) + require.Equal(t, mustParseTime(t, "2006-01-02T15:04", "2020-10-05T13:27").Format(time.RFC3339), ts.String()) + + require.NoError(t, ts.Set("2020-10-05T13:27:00Z")) + require.Equal(t, mustParseTime(t, "2006-01-02T15:04:05Z", "2020-10-05T13:27:00Z").Format(time.RFC3339), ts.String()) + + require.NoError(t, ts.Set("2020-10-05T13:27:00+02:00")) + require.Equal(t, mustParseTime(t, "2006-01-02T15:04:05Z07:00", "2020-10-05T13:27:00+02:00").Format(time.RFC3339), ts.String()) +} + +func mustParseTime(t *testing.T, f, s string) time.Time { + ts, err := time.Parse(f, s) + if err != nil { + t.Fatalf("failed to parse %q: %v", s, err) + } + return ts +} diff --git a/vendor/github.com/grafana/dskit/flagext/url.go b/pkg/util/flagext/url.go similarity index 100% rename from vendor/github.com/grafana/dskit/flagext/url.go rename to pkg/util/flagext/url.go diff --git a/pkg/util/flagext/url_test.go b/pkg/util/flagext/url_test.go new file mode 100644 index 00000000000..3f18d29fa54 --- /dev/null +++ b/pkg/util/flagext/url_test.go @@ -0,0 +1,90 @@ +package flagext + +import ( + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "gopkg.in/yaml.v2" +) + +func TestURLValueYAML(t *testing.T) { + // Test embedding of URLValue. + { + type TestStruct struct { + URL URLValue `yaml:"url"` + } + + var testStruct TestStruct + require.NoError(t, testStruct.URL.Set("http://google.com")) + expected := []byte(`url: http://google.com +`) + + actual, err := yaml.Marshal(testStruct) + require.NoError(t, err) + assert.Equal(t, expected, actual) + + var actualStruct TestStruct + err = yaml.Unmarshal(expected, &actualStruct) + require.NoError(t, err) + assert.Equal(t, testStruct, actualStruct) + } + + // Test pointers of URLValue. + { + type TestStruct struct { + URL *URLValue `yaml:"url"` + } + + var testStruct TestStruct + testStruct.URL = &URLValue{} + require.NoError(t, testStruct.URL.Set("http://google.com")) + expected := []byte(`url: http://google.com +`) + + actual, err := yaml.Marshal(testStruct) + require.NoError(t, err) + assert.Equal(t, expected, actual) + + var actualStruct TestStruct + err = yaml.Unmarshal(expected, &actualStruct) + require.NoError(t, err) + assert.Equal(t, testStruct, actualStruct) + } + + // Test no url set in URLValue. + { + type TestStruct struct { + URL URLValue `yaml:"url"` + } + + var testStruct TestStruct + expected := []byte(`url: "" +`) + + actual, err := yaml.Marshal(testStruct) + require.NoError(t, err) + assert.Equal(t, expected, actual) + + var actualStruct TestStruct + err = yaml.Unmarshal(expected, &actualStruct) + require.NoError(t, err) + assert.Equal(t, testStruct, actualStruct) + } + + // Test passwords are masked. + { + type TestStruct struct { + URL URLValue `yaml:"url"` + } + + var testStruct TestStruct + require.NoError(t, testStruct.URL.Set("http://username:password@google.com")) + expected := []byte(`url: http://username:%2A%2A%2A%2A%2A%2A%2A%2A@google.com +`) + + actual, err := yaml.Marshal(testStruct) + require.NoError(t, err) + assert.Equal(t, expected, actual) + } +} diff --git a/pkg/util/net/firewall_dialer.go b/pkg/util/net/firewall_dialer.go index b62bb95cf5f..6ab34441adf 100644 --- a/pkg/util/net/firewall_dialer.go +++ b/pkg/util/net/firewall_dialer.go @@ -5,8 +5,9 @@ import ( "net" "syscall" - "github.com/grafana/dskit/flagext" "github.com/pkg/errors" + + "github.com/cortexproject/cortex/pkg/util/flagext" ) var errBlockedAddress = errors.New("blocked address") diff --git a/pkg/util/net/firewall_dialer_test.go b/pkg/util/net/firewall_dialer_test.go index c75ca61c9b7..ab5bdad89ee 100644 --- a/pkg/util/net/firewall_dialer_test.go +++ b/pkg/util/net/firewall_dialer_test.go @@ -8,9 +8,10 @@ import ( "testing" "time" - "github.com/grafana/dskit/flagext" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + "github.com/cortexproject/cortex/pkg/util/flagext" ) func TestFirewallDialer(t *testing.T) { diff --git a/pkg/util/validation/limits.go b/pkg/util/validation/limits.go index f7fbc00a28a..9f2474c47db 100644 --- a/pkg/util/validation/limits.go +++ b/pkg/util/validation/limits.go @@ -9,10 +9,11 @@ import ( "strings" "time" - "github.com/grafana/dskit/flagext" "github.com/prometheus/common/model" "github.com/prometheus/prometheus/model/relabel" "golang.org/x/time/rate" + + "github.com/cortexproject/cortex/pkg/util/flagext" ) var errMaxGlobalSeriesPerUserValidation = errors.New("The ingester.max-global-series-per-user limit is unsupported if distributor.shard-by-all-labels is disabled") diff --git a/pkg/util/validation/limits_test.go b/pkg/util/validation/limits_test.go index 9b37ef9c959..6e6cc9a304d 100644 --- a/pkg/util/validation/limits_test.go +++ b/pkg/util/validation/limits_test.go @@ -7,13 +7,14 @@ import ( "testing" "time" - "github.com/grafana/dskit/flagext" "github.com/prometheus/common/model" "github.com/prometheus/prometheus/model/relabel" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "golang.org/x/time/rate" "gopkg.in/yaml.v2" + + "github.com/cortexproject/cortex/pkg/util/flagext" ) // mockTenantLimits exposes per-tenant limits based on a provided map diff --git a/tools/blocksconvert/scanner/scanner.go b/tools/blocksconvert/scanner/scanner.go index 668eb438a60..53b37c3951d 100644 --- a/tools/blocksconvert/scanner/scanner.go +++ b/tools/blocksconvert/scanner/scanner.go @@ -17,7 +17,6 @@ import ( "github.com/go-kit/log" "github.com/go-kit/log/level" - "github.com/grafana/dskit/flagext" "github.com/grafana/dskit/services" "github.com/pkg/errors" "github.com/prometheus/client_golang/prometheus" @@ -29,6 +28,7 @@ import ( "github.com/cortexproject/cortex/pkg/chunk/aws" "github.com/cortexproject/cortex/pkg/chunk/storage" "github.com/cortexproject/cortex/pkg/util/backoff" + "github.com/cortexproject/cortex/pkg/util/flagext" "github.com/cortexproject/cortex/tools/blocksconvert" ) diff --git a/tools/doc-generator/parser.go b/tools/doc-generator/parser.go index b9cc045b923..07e1bdcfff9 100644 --- a/tools/doc-generator/parser.go +++ b/tools/doc-generator/parser.go @@ -8,10 +8,11 @@ import ( "strings" "unicode" - "github.com/grafana/dskit/flagext" "github.com/pkg/errors" "github.com/prometheus/common/model" "github.com/weaveworks/common/logging" + + "github.com/cortexproject/cortex/pkg/util/flagext" ) var ( diff --git a/vendor/github.com/grafana/dskit/flagext/register.go b/vendor/github.com/grafana/dskit/flagext/register.go deleted file mode 100644 index 1004e1ba454..00000000000 --- a/vendor/github.com/grafana/dskit/flagext/register.go +++ /dev/null @@ -1,55 +0,0 @@ -package flagext - -import ( - "flag" - - "github.com/go-kit/log" -) - -// Registerer is a thing that can RegisterFlags -type Registerer interface { - RegisterFlags(*flag.FlagSet) -} - -// RegistererWithLogger is a thing that can RegisterFlags with a Logger -type RegistererWithLogger interface { - RegisterFlags(*flag.FlagSet, log.Logger) -} - -// RegisterFlags registers flags with the provided Registerers -func RegisterFlags(rs ...Registerer) { - for _, r := range rs { - r.RegisterFlags(flag.CommandLine) - } -} - -// RegisterFlagsWithLogger registers flags with the provided Registerers -func RegisterFlagsWithLogger(logger log.Logger, rs ...interface{}) { - for _, v := range rs { - switch r := v.(type) { - case Registerer: - r.RegisterFlags(flag.CommandLine) - case RegistererWithLogger: - r.RegisterFlags(flag.CommandLine, logger) - default: - panic("RegisterFlagsWithLogger must be passed a Registerer or RegistererWithLogger") - } - } -} - -// DefaultValues initiates a set of configs (Registerers) with their defaults. -func DefaultValues(rs ...interface{}) { - fs := flag.NewFlagSet("", flag.PanicOnError) - logger := log.NewNopLogger() - for _, v := range rs { - switch r := v.(type) { - case Registerer: - r.RegisterFlags(fs) - case RegistererWithLogger: - r.RegisterFlags(fs, logger) - default: - panic("RegisterFlagsWithLogger must be passed a Registerer") - } - } - _ = fs.Parse([]string{}) -} diff --git a/vendor/modules.txt b/vendor/modules.txt index fcb61ca9815..ed448e7ec9a 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -359,7 +359,6 @@ github.com/googleapis/gax-go/v2/apierror/internal/proto github.com/gorilla/mux # github.com/grafana/dskit v0.0.0-20220105080720-01ce9286d7d5 ## explicit -github.com/grafana/dskit/flagext github.com/grafana/dskit/multierror github.com/grafana/dskit/runutil github.com/grafana/dskit/services