Skip to content

Commit

Permalink
chore: revert rm config
Browse files Browse the repository at this point in the history
  • Loading branch information
markphelps committed May 1, 2024
1 parent 1669d7d commit 7f59b05
Show file tree
Hide file tree
Showing 12 changed files with 109 additions and 34 deletions.
5 changes: 0 additions & 5 deletions config/flipt.schema.cue
Original file line number Diff line number Diff line change
Expand Up @@ -269,11 +269,6 @@ 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: 0 additions & 18 deletions config/flipt.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -928,24 +928,6 @@
"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
10 changes: 7 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ 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,12 +162,13 @@ 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/gobwas/ws v1.2.1 // indirect
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // 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 @@ -206,7 +208,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/gomega v1.30.0 // indirect
github.com/onsi/ginkgo/v2 v2.17.1 // 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 @@ -219,6 +221,8 @@ 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 @@ -246,7 +250,6 @@ require (
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
github.com/xtgo/uuid v0.0.0-20140804021211-a0b114877d4c // indirect
github.com/yusufpapurcu/wmi v1.2.3 // indirect
go.flipt.io/reverst v0.1.2 // indirect
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 // indirect
go.opentelemetry.io/contrib/propagators/aws v1.25.0 // indirect
Expand All @@ -255,6 +258,7 @@ 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
12 changes: 12 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,8 @@ 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 @@ -330,6 +332,8 @@ 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 @@ -557,6 +561,8 @@ 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 @@ -608,6 +614,10 @@ 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 @@ -786,6 +796,8 @@ 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
5 changes: 4 additions & 1 deletion go.work.sum
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,6 @@ github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2p
github.com/hashicorp/memberlist v0.5.0/go.mod h1:yvyXLpo0QaGE59Y7hDTsTzDD25JYBZ4mHgHUZ8lrOI0=
github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc=
github.com/hashicorp/serf v0.10.1/go.mod h1:yL2t6BqATOLGc5HF7qbFkTfXoPIY0WZdWHfEvMqbG+4=
github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho=
github.com/ianlancetaylor/demangle v0.0.0-20240312041847-bd984b5ce465/go.mod h1:gx7rwoVhcfuVKG5uya9Hs3Sxj7EIvldVofAWIUtGouw=
github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
github.com/imdario/mergo v0.3.8/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
Expand Down Expand Up @@ -903,6 +902,10 @@ github.com/prometheus/prometheus v0.50.1/go.mod h1:FvE8dtQ1Ww63IlyKBn1V4s+zMwF9k
github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU=
github.com/quasilyte/go-ruleguard/dsl v0.3.22/go.mod h1:KeCP03KrjuSO0H1kTuZQCWlQPulDV6YMIXmpQss17rU=
github.com/quasilyte/go-ruleguard/rules v0.0.0-20211022131956-028d6511ab71/go.mod h1:4cgAphtvu7Ftv7vOT2ZOYhC6CvBxZixcasr8qIOTA50=
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/rabbitmq/amqp091-go v1.8.1/go.mod h1:+jPrT9iY2eLjRaMSRHUhc3z14E/l85kv/f+6luSD3pc=
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 h1:N/ElC8H3+5XpJzTSTfLsJV/mx9Q9g7kxmchpfZyxgzM=
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
Expand Down
25 changes: 23 additions & 2 deletions internal/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -568,19 +568,40 @@ 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 = "https://flipt.cloud"
cfg.Server.Cloud.Address = "flipt.cloud"
cfg.Server.Cloud.Organization = "foo"
cfg.Server.Cloud.Instance = "bar"
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 = "https://flipt.cloud"
cfg.Server.Cloud.Address = "flipt.cloud"
cfg.Server.Cloud.Organization = "foo"
cfg.Server.Cloud.Instance = "bar"
return cfg
},
},
Expand Down
35 changes: 31 additions & 4 deletions internal/config/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,30 @@ var (
)

type CloudConfig struct {
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"`
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
}

func (c *CloudConfig) setDefaults(v *viper.Viper) error {
v.SetDefault("server.cloud", map[string]any{
"enabled": false,
"address": "https://flipt.cloud",
"address": "flipt.cloud",
"port": 8443,
})

Expand All @@ -121,6 +136,18 @@ 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: 4 additions & 0 deletions internal/config/testdata/server/cloud_missing_address.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
server:
cloud:
authentication:
api_key: foo
enabled: true
port: 8443
organization: foo
instance: bar
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
server:
cloud:
enabled: true
address: "https://flipt.cloud"
port: 8443
organization: foo
instance: bar
8 changes: 8 additions & 0 deletions internal/config/testdata/server/cloud_missing_instance.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
server:
cloud:
enabled: true
authentication:
api_key: foo
address: "https://flipt.cloud"
port: 8443
organization: foo
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
server:
cloud:
enabled: true
authentication:
api_key: foo
address: "https://flipt.cloud"
port: 8443
instance: bar
6 changes: 5 additions & 1 deletion internal/config/testdata/server/cloud_missing_port.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
server:
cloud:
authentication:
api_key: foo
enabled: true
address: "https://flipt.cloud"
address: "flipt.cloud"
organization: foo
instance: bar

0 comments on commit 7f59b05

Please sign in to comment.