Skip to content

Commit

Permalink
chore: remove unused config options for now
Browse files Browse the repository at this point in the history
  • Loading branch information
markphelps committed Apr 30, 2024
1 parent 73178c7 commit 866a77c
Show file tree
Hide file tree
Showing 12 changed files with 48 additions and 122 deletions.
31 changes: 16 additions & 15 deletions cmd/flipt/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"errors"
"fmt"
"io/fs"
"net/http"
"os"
"os/signal"
"path/filepath"
Expand All @@ -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"
Expand Down Expand Up @@ -372,23 +370,26 @@ func run(ctx context.Context, logger *zap.Logger, cfg *config.Config) error {

if cfg.Server.Cloud.Enabled {

Check failure on line 371 in cmd/flipt/main.go

View workflow job for this annotation

GitHub Actions / Lint Go

SA9003: empty branch (staticcheck)
// 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
Expand Down
5 changes: 5 additions & 0 deletions config/flipt.schema.cue
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
18 changes: 18 additions & 0 deletions config/flipt.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [],
Expand Down
9 changes: 2 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
14 changes: 0 additions & 14 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down Expand Up @@ -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=
Expand Down Expand Up @@ -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=
Expand Down Expand Up @@ -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=
Expand Down Expand Up @@ -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=
Expand Down Expand Up @@ -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=
Expand Down
25 changes: 2 additions & 23 deletions internal/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
},
Expand Down
35 changes: 4 additions & 31 deletions internal/config/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})

Expand All @@ -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
Expand Down
4 changes: 0 additions & 4 deletions internal/config/testdata/server/cloud_missing_address.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
server:
cloud:
authentication:
api_key: foo
enabled: true
port: 8443
organization: foo
instance: bar

This file was deleted.

8 changes: 0 additions & 8 deletions internal/config/testdata/server/cloud_missing_instance.yml

This file was deleted.

This file was deleted.

6 changes: 1 addition & 5 deletions internal/config/testdata/server/cloud_missing_port.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
server:
cloud:
authentication:
api_key: foo
enabled: true
address: "flipt.cloud"
organization: foo
instance: bar
address: "https://flipt.cloud"

0 comments on commit 866a77c

Please sign in to comment.