Skip to content

Commit

Permalink
Fix lint/test issue (#561)
Browse files Browse the repository at this point in the history
  • Loading branch information
thomaspoignant authored Mar 17, 2023
1 parent 2979e2f commit 4ed0154
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 60 deletions.
13 changes: 7 additions & 6 deletions cmd/relayproxy/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var DefaultRetriever = struct {
HTTPMethod string
GithubBranch string
}{
Timeout: time.Duration(10 * time.Second),
Timeout: 10 * time.Second,
HTTPMethod: http.MethodGet,
GithubBranch: "main",
}
Expand All @@ -28,11 +28,12 @@ var DefaultExporter = struct {
FlushInterval time.Duration
MaxEventInMemory int64
}{
Format: "JSON",
LogFormat: "[{{ .FormattedDate}}] user=\"{{ .UserKey}}\", flag=\"{{ .Key}}\", value=\"{{ .Value}}\"",
FileName: "flag-variation-{{ .Hostname}}-{{ .Timestamp}}.{{ .Format}}",
CsvFormat: "{ .Kind}};{{ .ContextKind}};{{ .UserKey}};{{ .CreationDate}};{{ .Key}};{{ .Variation}};{{ .Value}};{{ .Default}}\\n",
FlushInterval: time.Duration(60000 * time.Millisecond),
Format: "JSON",
LogFormat: "[{{ .FormattedDate}}] user=\"{{ .UserKey}}\", flag=\"{{ .Key}}\", value=\"{{ .Value}}\"",
FileName: "flag-variation-{{ .Hostname}}-{{ .Timestamp}}.{{ .Format}}",
CsvFormat: "{ .Kind}};{{ .ContextKind}};{{ .UserKey}};{{ .CreationDate}};{{ .Key}};{{ .Variation}};" +
"{{ .Value}};{{ .Default}}\\n",
FlushInterval: 60000 * time.Millisecond,
MaxEventInMemory: 100000,
}

Expand Down
68 changes: 14 additions & 54 deletions cmd/relayproxy/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,11 @@ func TestParseConfig_fileFromPflag(t *testing.T) {
FileFormat: "yaml",
Host: "localhost",
Retriever: &config.RetrieverConf{
Kind: "http",
URL: "https://raw.githubusercontent.com/thomaspoignant/go-feature-flag/main/examples/retriever_file/flags.yaml",
HTTPMethod: "GET",
Timeout: 10000,
Kind: "http",
URL: "https://raw.githubusercontent.com/thomaspoignant/go-feature-flag/main/examples/retriever_file/flags.yaml",
},
Exporter: &config.ExporterConf{
Kind: "log",
Filename: "flag-variation-{{ .Hostname}}-{{ .Timestamp}}.{{ .Format}}",
CsvTemplate: `{ .Kind}};{{ .ContextKind}};{{ .UserKey}};{{ .CreationDate}};{{ .Key}};{{ .Variation}};{{ .Value}};{{ .Default}}\n`,
Format: "JSON",
LogFormat: `[{{ .FormattedDate}}] user="{{ .UserKey}}", flag="{{ .Key}}", value="{{ .Value}}"`,
FlushInterval: 60000,
MaxEventInMemory: 100000,
Kind: "log",
},
StartWithRetrieverError: false,
RestAPITimeout: 5000,
Expand All @@ -52,22 +44,10 @@ func TestParseConfig_fileFromPflag(t *testing.T) {
name: "All default",
fileLocation: "../testdata/config/all-default.yaml",
want: &config.Config{
ListenPort: 1031,
PollingInterval: 60000,
FileFormat: "yaml",
Host: "localhost",
Retriever: &config.RetrieverConf{
HTTPMethod: "GET",
Timeout: 10000,
},
Exporter: &config.ExporterConf{
Filename: "flag-variation-{{ .Hostname}}-{{ .Timestamp}}.{{ .Format}}",
CsvTemplate: `{ .Kind}};{{ .ContextKind}};{{ .UserKey}};{{ .CreationDate}};{{ .Key}};{{ .Variation}};{{ .Value}};{{ .Default}}\n`,
Format: "JSON",
LogFormat: `[{{ .FormattedDate}}] user="{{ .UserKey}}", flag="{{ .Key}}", value="{{ .Value}}"`,
FlushInterval: 60000,
MaxEventInMemory: 100000,
},
ListenPort: 1031,
PollingInterval: 60000,
FileFormat: "yaml",
Host: "localhost",
StartWithRetrieverError: false,
RestAPITimeout: 5000,
Version: "1.X.X",
Expand Down Expand Up @@ -114,19 +94,11 @@ func TestParseConfig_fileFromFolder(t *testing.T) {
FileFormat: "yaml",
Host: "localhost",
Retriever: &config.RetrieverConf{
Kind: "http",
URL: "https://raw.githubusercontent.com/thomaspoignant/go-feature-flag/main/examples/retriever_file/flags.yaml",
HTTPMethod: "GET",
Timeout: 10000,
Kind: "http",
URL: "https://raw.githubusercontent.com/thomaspoignant/go-feature-flag/main/examples/retriever_file/flags.yaml",
},
Exporter: &config.ExporterConf{
Kind: "log",
Filename: "flag-variation-{{ .Hostname}}-{{ .Timestamp}}.{{ .Format}}",
CsvTemplate: `{ .Kind}};{{ .ContextKind}};{{ .UserKey}};{{ .CreationDate}};{{ .Key}};{{ .Variation}};{{ .Value}};{{ .Default}}\n`,
Format: "JSON",
LogFormat: `[{{ .FormattedDate}}] user="{{ .UserKey}}", flag="{{ .Key}}", value="{{ .Value}}"`,
FlushInterval: 60000,
MaxEventInMemory: 100000,
Kind: "log",
},
StartWithRetrieverError: false,
RestAPITimeout: 5000,
Expand All @@ -139,22 +111,10 @@ func TestParseConfig_fileFromFolder(t *testing.T) {
name: "All default",
fileLocation: "../testdata/config/all-default.yaml",
want: &config.Config{
ListenPort: 1031,
PollingInterval: 60000,
FileFormat: "yaml",
Host: "localhost",
Retriever: &config.RetrieverConf{
HTTPMethod: "GET",
Timeout: 10000,
},
Exporter: &config.ExporterConf{
Filename: "flag-variation-{{ .Hostname}}-{{ .Timestamp}}.{{ .Format}}",
CsvTemplate: `{ .Kind}};{{ .ContextKind}};{{ .UserKey}};{{ .CreationDate}};{{ .Key}};{{ .Variation}};{{ .Value}};{{ .Default}}\n`,
Format: "JSON",
LogFormat: `[{{ .FormattedDate}}] user="{{ .UserKey}}", flag="{{ .Key}}", value="{{ .Value}}"`,
FlushInterval: 60000,
MaxEventInMemory: 100000,
},
ListenPort: 1031,
PollingInterval: 60000,
FileFormat: "yaml",
Host: "localhost",
StartWithRetrieverError: false,
RestAPITimeout: 5000,
Version: "1.X.X",
Expand Down
1 change: 1 addition & 0 deletions cmd/relayproxy/service/gofeatureflag.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ func NewGoFeatureFlagClient(proxyConf *config.Config, logger *zap.Logger) (*ffcl
retrievers := make([]retriever.Retriever, 0)
if proxyConf.Retrievers != nil {
for _, r := range *proxyConf.Retrievers {
r := r
currentRetriever, err := initRetriever(&r)
if err != nil {
return nil, err
Expand Down

0 comments on commit 4ed0154

Please sign in to comment.