From 866a77ca1856055014193bcbc7915ea55759f400 Mon Sep 17 00:00:00 2001 From: Mark Phelps <209477+markphelps@users.noreply.github.com> Date: Tue, 30 Apr 2024 14:37:22 -0400 Subject: [PATCH] chore: remove unused config options for now --- cmd/flipt/main.go | 31 ++++++++-------- config/flipt.schema.cue | 5 +++ config/flipt.schema.json | 18 ++++++++++ go.mod | 9 ++--- go.sum | 14 -------- internal/config/config_test.go | 25 ++----------- internal/config/server.go | 35 +++---------------- .../testdata/server/cloud_missing_address.yml | 4 --- .../server/cloud_missing_authentication.yml | 7 ---- .../server/cloud_missing_instance.yml | 8 ----- .../server/cloud_missing_organization.yml | 8 ----- .../testdata/server/cloud_missing_port.yml | 6 +--- 12 files changed, 48 insertions(+), 122 deletions(-) delete mode 100644 internal/config/testdata/server/cloud_missing_authentication.yml delete mode 100644 internal/config/testdata/server/cloud_missing_instance.yml delete mode 100644 internal/config/testdata/server/cloud_missing_organization.yml diff --git a/cmd/flipt/main.go b/cmd/flipt/main.go index b32c02ee08..65af452e42 100644 --- a/cmd/flipt/main.go +++ b/cmd/flipt/main.go @@ -6,7 +6,6 @@ import ( "errors" "fmt" "io/fs" - "net/http" "os" "os/signal" "path/filepath" @@ -23,7 +22,6 @@ import ( "go.flipt.io/flipt/internal/info" "go.flipt.io/flipt/internal/release" "go.flipt.io/flipt/internal/telemetry" - "go.flipt.io/reverst/client" "go.uber.org/zap" "go.uber.org/zap/zapcore" "golang.org/x/sync/errgroup" @@ -372,23 +370,26 @@ func run(ctx context.Context, logger *zap.Logger, cfg *config.Config) error { if cfg.Server.Cloud.Enabled { // starts QUIC tunnel server to connect to Cloud - g.Go(func() error { - tunnelServer := &client.Server{ - TunnelGroup: fmt.Sprintf("%s.%s", cfg.Server.Cloud.Organization, cfg.Server.Cloud.Address), - Handler: httpServer.Handler, - Authenticator: client.BearerAuthenticator(cfg.Server.Cloud.Authentication.ApiKey), - } - tunnel := fmt.Sprintf("%s-%s.%s", cfg.Server.Cloud.Instance, cfg.Server.Cloud.Organization, cfg.Server.Cloud.Address) + // TODO: get organization, instance, and authentication from config - logger.Info("cloud tunnel available", zap.String("address", tunnel), zap.Int("port", cfg.Server.Cloud.Port)) + // g.Go(func() error { + // tunnelServer := &client.Server{ + // TunnelGroup: fmt.Sprintf("%s.%s", cfg.Server.Cloud.Organization, cfg.Server.Cloud.Address), + // Handler: httpServer.Handler, + // Authenticator: client.BearerAuthenticator(cfg.Server.Cloud.Authentication.ApiKey), + // } - if err := tunnelServer.DialAndServe(ctx, fmt.Sprintf("%s:%d", tunnel, cfg.Server.Cloud.Port)); !errors.Is(err, http.ErrServerClosed) { - return fmt.Errorf("cloud tunnel server: %w", err) - } + // tunnel := fmt.Sprintf("%s-%s.%s", cfg.Server.Cloud.Instance, cfg.Server.Cloud.Organization, cfg.Server.Cloud.Address) - return nil - }) + // logger.Info("cloud tunnel available", zap.String("address", tunnel), zap.Int("port", cfg.Server.Cloud.Port)) + + // if err := tunnelServer.DialAndServe(ctx, fmt.Sprintf("%s:%d", tunnel, cfg.Server.Cloud.Port)); !errors.Is(err, http.ErrServerClosed) { + // return fmt.Errorf("cloud tunnel server: %w", err) + // } + + // return nil + // }) } // block until root context is cancelled diff --git a/config/flipt.schema.cue b/config/flipt.schema.cue index 6ece3a1d55..7e6df2c3ec 100644 --- a/config/flipt.schema.cue +++ b/config/flipt.schema.cue @@ -269,6 +269,11 @@ import "strings" grpc_conn_max_idle_time?: =~#duration grpc_conn_max_age?: =~#duration grpc_conn_max_age_grace?: =~#duration + cloud?: { + enabled?: bool | *false + address?: string | *"https://flipt.cloud" + port?: int | *8443 + } } #metrics: { diff --git a/config/flipt.schema.json b/config/flipt.schema.json index 15e3a6bdad..daddf37bdd 100644 --- a/config/flipt.schema.json +++ b/config/flipt.schema.json @@ -928,6 +928,24 @@ "grpc_conn_max_age_grace": { "type": "string", "pattern": "^([0-9]+(ns|us|µs|ms|s|m|h))+$" + }, + "cloud": { + "type": "object", + "additionalProperties": false, + "properties": { + "enabled": { + "type": "boolean", + "default": false + }, + "address": { + "type": "string", + "default": "https://flipt.cloud" + }, + "port": { + "type": "integer", + "default": 8443 + } + } } }, "required": [], diff --git a/go.mod b/go.mod index de239e76aa..3015811f3c 100644 --- a/go.mod +++ b/go.mod @@ -65,7 +65,6 @@ require ( go.flipt.io/flipt/errors v1.19.3 go.flipt.io/flipt/rpc/flipt v1.38.0 go.flipt.io/flipt/sdk/go v0.11.0 - go.flipt.io/reverst v0.1.2 go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.51.0 go.opentelemetry.io/contrib/propagators/autoprop v0.50.0 go.opentelemetry.io/otel v1.26.0 @@ -161,13 +160,12 @@ require ( github.com/go-logr/logr v1.4.1 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/go-ole/go-ole v1.2.6 // indirect - github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect + github.com/gobwas/ws v1.2.1 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang-jwt/jwt/v5 v5.2.1 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/protobuf v1.5.4 // indirect github.com/google/go-querystring v1.1.0 // indirect - github.com/google/pprof v0.0.0-20240416155748-26353dc0451f // indirect github.com/google/s2a-go v0.1.7 // indirect github.com/google/wire v0.6.0 // indirect github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect @@ -207,7 +205,7 @@ require ( github.com/moby/sys/user v0.1.0 // indirect github.com/moby/term v0.5.0 // indirect github.com/morikuni/aec v1.0.0 // indirect - github.com/onsi/ginkgo/v2 v2.17.1 // indirect + github.com/onsi/gomega v1.30.0 // indirect github.com/openzipkin/zipkin-go v0.4.2 // indirect github.com/paulmach/orb v0.11.1 // indirect github.com/pelletier/go-toml/v2 v2.1.0 // indirect @@ -220,8 +218,6 @@ require ( github.com/prometheus/client_model v0.6.1 // indirect github.com/prometheus/common v0.48.0 // indirect github.com/prometheus/procfs v0.12.0 // indirect - github.com/quic-go/qpack v0.4.0 // indirect - github.com/quic-go/quic-go v0.42.0 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/sagikazarmark/locafero v0.4.0 // indirect github.com/sagikazarmark/slog-shim v0.1.0 // indirect @@ -257,7 +253,6 @@ require ( go.opentelemetry.io/contrib/propagators/ot v1.25.0 // indirect go.opentelemetry.io/proto/otlp v1.2.0 // indirect go.uber.org/atomic v1.11.0 // indirect - go.uber.org/mock v0.4.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/mod v0.17.0 // indirect golang.org/x/sys v0.19.0 // indirect diff --git a/go.sum b/go.sum index a0ab047a61..18d6e64774 100644 --- a/go.sum +++ b/go.sum @@ -260,8 +260,6 @@ github.com/go-sql-driver/mysql v1.8.1 h1:LedoTUt/eveggdHS9qUFC1EFSa8bU2+1pZjSRpv github.com/go-sql-driver/mysql v1.8.1/go.mod h1:wEBSXgmK//2ZFJyE+qWnIsVGmvmEKlqwuVSjsCm7DZg= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= -github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= -github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls= github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y= github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8= github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee/go.mod h1:L0fX3K22YWvt/FAX9NnzrNzcI4wNYi9Yku4O0LKYflo= @@ -332,8 +330,6 @@ github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/ github.com/google/martian/v3 v3.3.2 h1:IqNFLAmvJOgVlpdEBiQbDc2EwKW77amAycfTuWKdfvw= github.com/google/martian/v3 v3.3.2/go.mod h1:oBOf6HBosgwRXnUGWUB05QECsc6uvmMiJ3+6W4l/CUk= github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20240416155748-26353dc0451f h1:WpZiq8iqvGjJ3m3wzAVKL6+0vz7VkE79iSy9GII00II= -github.com/google/pprof v0.0.0-20240416155748-26353dc0451f/go.mod h1:kf6iHlnVGwgKolg33glAes7Yg/8iWP8ukqeldJSO7jw= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/s2a-go v0.1.7 h1:60BLSyTrOV4/haCDW4zb1guZItoSq8foHCXrAnjBo/o= github.com/google/s2a-go v0.1.7/go.mod h1:50CgR4k1jNlWBu4UfS4AcfhVe1r6pdZPygJ3R8F0Qdw= @@ -559,8 +555,6 @@ github.com/onsi/ginkgo/v2 v2.3.0/go.mod h1:Eew0uilEqZmIEZr8JrvYlvOM7Rr6xzTmMV8Ay github.com/onsi/ginkgo/v2 v2.4.0/go.mod h1:iHkDK1fKGcBoEHT5W7YBq4RFWaQulw+caOMkAt4OrFo= github.com/onsi/ginkgo/v2 v2.5.0/go.mod h1:Luc4sArBICYCS8THh8v3i3i5CuSZO+RaQRaJoeNwomw= github.com/onsi/ginkgo/v2 v2.7.0/go.mod h1:yjiuMwPokqY1XauOgju45q3sJt6VzQ/Fict1LFVcsAo= -github.com/onsi/ginkgo/v2 v2.17.1 h1:V++EzdbhI4ZV4ev0UTIj0PzhzOcReJFyJaLjtSF55M8= -github.com/onsi/ginkgo/v2 v2.17.1/go.mod h1:llBI3WDLL9Z6taip6f33H76YcWtJv+7R3HigUjbIBOs= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY= @@ -612,10 +606,6 @@ github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo= github.com/protocolbuffers/txtpbfmt v0.0.0-20230328191034-3462fbc510c0 h1:sadMIsgmHpEOGbUs6VtHBXRR1OHevnj7hLx9ZcdNGW4= github.com/protocolbuffers/txtpbfmt v0.0.0-20230328191034-3462fbc510c0/go.mod h1:jgxiZysxFPM+iWKwQwPR+y+Jvo54ARd4EisXxKYpB5c= -github.com/quic-go/qpack v0.4.0 h1:Cr9BXA1sQS2SmDUWjSofMPNKmvF6IiIfDRmgU0w1ZCo= -github.com/quic-go/qpack v0.4.0/go.mod h1:UZVnYIfi5GRk+zI9UMaCPsmZ2xKJP7XBUvVyT1Knj9A= -github.com/quic-go/quic-go v0.42.0 h1:uSfdap0eveIl8KXnipv9K7nlwZ5IqLlYOpJ58u5utpM= -github.com/quic-go/quic-go v0.42.0/go.mod h1:132kz4kL3F9vxhW3CtQJLDVwcFe5wdWeJXXijhsO57M= github.com/redis/go-redis/v9 v9.0.0-rc.4/go.mod h1:Vo3EsyWnicKnSKCA7HhgnvnyA74wOA69Cd2Meli5mmA= github.com/redis/go-redis/v9 v9.5.1 h1:H1X4D3yHPaYrkL5X06Wh6xNVM/pX0Ft4RV0vMGvLBh8= github.com/redis/go-redis/v9 v9.5.1/go.mod h1:hdY0cQFCN4fnSYT6TkisLufl/4W5UIXyv0b/CLO2V2M= @@ -738,8 +728,6 @@ github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5t github.com/yusufpapurcu/wmi v1.2.3 h1:E1ctvB7uKFMOJw3fdOW32DwGE9I7t++CRUEMKvFoFiw= github.com/yusufpapurcu/wmi v1.2.3/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= github.com/zenazn/goji v0.9.0/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxtB1Q= -go.flipt.io/reverst v0.1.2 h1:L43Jx5oWAQwOCK6J/bCN9fXgIIGymnJx1yyp2UCbb14= -go.flipt.io/reverst v0.1.2/go.mod h1:0kDf22udIDgZAruOu6/9/dZIHRpWJhDcZ3fqoP33jc0= go.mongodb.org/mongo-driver v1.11.4/go.mod h1:PTSz5yu21bkT/wXpkS7WR5f0ddqw5quethTUn9WM+2g= go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0= go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= @@ -794,8 +782,6 @@ go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0 go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= -go.uber.org/mock v0.4.0 h1:VcM4ZOtdbR4f6VXfiOpwpVJDL6lCReaZ6mw31wqh7KU= -go.uber.org/mock v0.4.0/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU= go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= diff --git a/internal/config/config_test.go b/internal/config/config_test.go index c718659e82..343cb3f596 100644 --- a/internal/config/config_test.go +++ b/internal/config/config_test.go @@ -567,40 +567,19 @@ func TestLoad(t *testing.T) { expected: func() *Config { cfg := Default() cfg.Server.Cloud.Enabled = true - cfg.Server.Cloud.Authentication.ApiKey = "foo" cfg.Server.Cloud.Port = 8443 - cfg.Server.Cloud.Address = "flipt.cloud" - cfg.Server.Cloud.Organization = "foo" - cfg.Server.Cloud.Instance = "bar" + cfg.Server.Cloud.Address = "https://flipt.cloud" return cfg }, }, - { - name: "cloud missing organization", - path: "./testdata/server/cloud_missing_organization.yml", - wantErr: errors.New("field \"server.cloud.organization\": non-empty value is required"), - }, - { - name: "cloud missing instance", - path: "./testdata/server/cloud_missing_instance.yml", - wantErr: errors.New("field \"server.cloud.instance\": non-empty value is required"), - }, - { - name: "cloud missing authentication", - path: "./testdata/server/cloud_missing_authentication.yml", - wantErr: errors.New("field \"server.cloud.authentication.api_key\": non-empty value is required"), - }, { name: "cloud missing port", path: "./testdata/server/cloud_missing_port.yml", expected: func() *Config { cfg := Default() cfg.Server.Cloud.Enabled = true - cfg.Server.Cloud.Authentication.ApiKey = "foo" cfg.Server.Cloud.Port = 8443 - cfg.Server.Cloud.Address = "flipt.cloud" - cfg.Server.Cloud.Organization = "foo" - cfg.Server.Cloud.Instance = "bar" + cfg.Server.Cloud.Address = "https://flipt.cloud" return cfg }, }, diff --git a/internal/config/server.go b/internal/config/server.go index ef995d497f..f74ef72298 100644 --- a/internal/config/server.go +++ b/internal/config/server.go @@ -96,30 +96,15 @@ var ( ) type CloudConfig struct { - Enabled bool `json:"enabled,omitempty" mapstructure:"enabled" yaml:"enabled"` - Authentication CloudAuthenticationConfig `json:"authentication,omitempty" mapstructure:"authentication" yaml:"authentication,omitempty"` - Address string `json:"address,omitempty" mapstructure:"address" yaml:"address,omitempty"` - Port int `json:"port,omitempty" mapstructure:"port" yaml:"port,omitempty"` - Organization string `json:"organization,omitempty" mapstructure:"organization" yaml:"organization,omitempty"` - Instance string `json:"instance,omitempty" mapstructure:"instance" yaml:"instance,omitempty"` -} - -type CloudAuthenticationConfig struct { - ApiKey string `json:"-" mapstructure:"api_key" yaml:"api_key,omitempty"` -} - -func (c *CloudAuthenticationConfig) validate() error { - if c.ApiKey == "" { - return errFieldRequired("server.cloud.authentication.api_key") - } - - return nil + Enabled bool `json:"enabled,omitempty" mapstructure:"enabled" yaml:"enabled"` + Address string `json:"address,omitempty" mapstructure:"address" yaml:"address,omitempty"` + Port int `json:"port,omitempty" mapstructure:"port" yaml:"port,omitempty"` } func (c *CloudConfig) setDefaults(v *viper.Viper) error { v.SetDefault("server.cloud", map[string]any{ "enabled": false, - "address": "flipt.cloud", + "address": "https://flipt.cloud", "port": 8443, }) @@ -136,18 +121,6 @@ func (c *CloudConfig) validate() error { if c.Port == 0 { return errFieldRequired("server.cloud.port") } - - if c.Organization == "" { - return errFieldRequired("server.cloud.organization") - } - - if c.Instance == "" { - return errFieldRequired("server.cloud.instance") - } - - if c.Authentication.ApiKey == "" { - return errFieldRequired("server.cloud.authentication.api_key") - } } return nil diff --git a/internal/config/testdata/server/cloud_missing_address.yml b/internal/config/testdata/server/cloud_missing_address.yml index 61b713b3be..9e1acb7bd8 100644 --- a/internal/config/testdata/server/cloud_missing_address.yml +++ b/internal/config/testdata/server/cloud_missing_address.yml @@ -1,8 +1,4 @@ server: cloud: - authentication: - api_key: foo enabled: true port: 8443 - organization: foo - instance: bar diff --git a/internal/config/testdata/server/cloud_missing_authentication.yml b/internal/config/testdata/server/cloud_missing_authentication.yml deleted file mode 100644 index 557664fc83..0000000000 --- a/internal/config/testdata/server/cloud_missing_authentication.yml +++ /dev/null @@ -1,7 +0,0 @@ -server: - cloud: - enabled: true - address: "https://flipt.cloud" - port: 8443 - organization: foo - instance: bar diff --git a/internal/config/testdata/server/cloud_missing_instance.yml b/internal/config/testdata/server/cloud_missing_instance.yml deleted file mode 100644 index 37cefe41e0..0000000000 --- a/internal/config/testdata/server/cloud_missing_instance.yml +++ /dev/null @@ -1,8 +0,0 @@ -server: - cloud: - enabled: true - authentication: - api_key: foo - address: "https://flipt.cloud" - port: 8443 - organization: foo diff --git a/internal/config/testdata/server/cloud_missing_organization.yml b/internal/config/testdata/server/cloud_missing_organization.yml deleted file mode 100644 index 3adaaf7868..0000000000 --- a/internal/config/testdata/server/cloud_missing_organization.yml +++ /dev/null @@ -1,8 +0,0 @@ -server: - cloud: - enabled: true - authentication: - api_key: foo - address: "https://flipt.cloud" - port: 8443 - instance: bar diff --git a/internal/config/testdata/server/cloud_missing_port.yml b/internal/config/testdata/server/cloud_missing_port.yml index c855f1eed2..b75a2721bd 100644 --- a/internal/config/testdata/server/cloud_missing_port.yml +++ b/internal/config/testdata/server/cloud_missing_port.yml @@ -1,8 +1,4 @@ server: cloud: - authentication: - api_key: foo enabled: true - address: "flipt.cloud" - organization: foo - instance: bar + address: "https://flipt.cloud"