-
-
Notifications
You must be signed in to change notification settings - Fork 178
feat: add support for all retrievers in cli #4025
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat: add support for all retrievers in cli #4025
Conversation
Signed-off-by: deamondev <[email protected]>
Signed-off-by: deamondev <[email protected]>
Signed-off-by: deamondev <[email protected]>
Signed-off-by: deamondev <[email protected]>
Signed-off-by: deamondev <[email protected]>
Signed-off-by: deamondev <[email protected]>
Signed-off-by: deamondev <[email protected]>
Signed-off-by: deamondev <[email protected]>
Signed-off-by: deamondev <[email protected]>
Signed-off-by: deamondev <[email protected]>
Signed-off-by: deamondev <[email protected]>
Signed-off-by: deamondev <[email protected]>
Signed-off-by: deamondev <[email protected]>
Signed-off-by: deamondev <[email protected]>
Signed-off-by: deamondev <[email protected]>
Signed-off-by: deamondev <[email protected]>
Signed-off-by: deamondev <[email protected]>
Signed-off-by: deamondev <[email protected]>
Signed-off-by: deamondev <[email protected]>
Signed-off-by: deamondev <[email protected]>
Signed-off-by: deamondev <[email protected]>
✅ Deploy Preview for go-feature-flag-doc-preview canceled.
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #4025 +/- ##
==========================================
+ Coverage 84.93% 85.06% +0.13%
==========================================
Files 138 138
Lines 5643 5806 +163
==========================================
+ Hits 4793 4939 +146
- Misses 644 654 +10
- Partials 206 213 +7 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
|
||
| func (s *Retriever) SetDownloader(downloader DownloaderAPI) { | ||
| s.downloader = downloader | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to be sure, why do you need this function?
You can probably set the downloader directly in the struct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is used indeed in test
r, err := retrieverInit.InitRetriever(
&retrieverconf.RetrieverConf{
Kind: "s3",
Bucket: "Bucket",
Item: "valid",
})
if err != nil {
return evaluate{}, err
}
s3Retriever, _ := r.(*s3retrieverv2.Retriever)
s3Retriever.SetDownloader(downloader)And downloader is not (and should not be) a member of RetrieverConf (here I used, of course mocked downloader)
|
/gemini review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request significantly enhances the CLI by adding support for all retrievers, which is a great feature. The implementation introduces a --check-mode for inspecting retriever configurations, which is very useful for debugging.
My review focuses on improving documentation clarity, fixing a parsing bug, and some minor code cleanup. I've identified a few issues in the README.md that could confuse users, a bug in the HTTP header parsing logic, and some opportunities for code refinement in the tests and command implementation.
Overall, this is a solid contribution. Addressing the feedback will make the new CLI features more robust and easier to use.
Signed-off-by: deamondev <[email protected]>
Signed-off-by: deamondev <[email protected]>
Signed-off-by: deamondev <[email protected]>
72150d2 to
51a412b
Compare
Signed-off-by: deamondev <[email protected]>
Signed-off-by: deamondev <[email protected]>
Signed-off-by: deamondev <[email protected]>
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @DeamonDev sorry if I am a bit late to review.
I've tested the changes and we are close to be good.
Can you address the last changes if you don't mind?
| - `postgresql` | ||
|
|
||
| **Caution**: We do not support `redis` retriever as for now due | ||
| to: https://github.com/thomaspoignant/go-feature-flag/issues/4023. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you want to add the serializable layer on this PR or do you prefer to open another pull request for this?
|
|
||
| | Flag | Description | Default | | ||
| |----------|-------------------------------------------|---------| | ||
| | `--path` | Path to the local flag configuration file | "" | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we have a default value to file to be similar to the old behavior as much as possible?
| As mentioned above the `--config` flag is deprecated and we encourage you to use the `--path` flag instead. For example | ||
| the following command: | ||
|
|
||
| ```shell | ||
| go-feature-flag-cli evaluate --config="<location_of_your_flag_configuration_file>" --flag="<name_of_your_flag_to_evaluate>" --ctx='<evaluation_ctx_as_json_string>' | ||
| ``` | ||
|
|
||
| may be replaced by: | ||
|
|
||
| ```shell | ||
| go-feature-flag-cli evaluate --kind="file" --path="<location_of_your_flag_configuration_file>" --flag="<name_of_your_flag_to_evaluate>" --ctx='<evaluation_ctx_as_json_string>' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👏 praise: This is great to have an example here.
| Kind RetrieverKind `mapstructure:"kind" koanf:"kind" json:"Kind"` | ||
| RepositorySlug string `mapstructure:"repositorySlug" koanf:"repositoryslug" json:"RepositorySlug"` | ||
| Branch string `mapstructure:"branch" koanf:"branch" json:"Branch"` | ||
| Path string `mapstructure:"path" koanf:"path" json:"Path"` | ||
| // Deprecated: Please use AuthToken instead | ||
| GithubToken string `mapstructure:"githubToken" koanf:"githubtoken"` | ||
| URL string `mapstructure:"url" koanf:"url"` | ||
| Timeout int64 `mapstructure:"timeout" koanf:"timeout"` | ||
| HTTPMethod string `mapstructure:"method" koanf:"method"` | ||
| HTTPBody string `mapstructure:"body" koanf:"body"` | ||
| HTTPHeaders map[string][]string `mapstructure:"headers" koanf:"headers"` | ||
| Bucket string `mapstructure:"bucket" koanf:"bucket"` | ||
| Object string `mapstructure:"object" koanf:"object"` | ||
| Item string `mapstructure:"item" koanf:"item"` | ||
| Namespace string `mapstructure:"namespace" koanf:"namespace"` | ||
| ConfigMap string `mapstructure:"configmap" koanf:"configmap"` | ||
| Key string `mapstructure:"key" koanf:"key"` | ||
| BaseURL string `mapstructure:"baseUrl" koanf:"baseurl"` | ||
| AuthToken string `mapstructure:"token" koanf:"token"` | ||
| GithubToken string `mapstructure:"githubToken" koanf:"githubtoken" json:"GithubToken"` | ||
| URL string `mapstructure:"url" koanf:"url" json:"URL"` | ||
| Timeout int64 `mapstructure:"timeout" koanf:"timeout" json:"Timeout"` | ||
| HTTPMethod string `mapstructure:"method" koanf:"method" json:"HTTPMethod"` | ||
| HTTPBody string `mapstructure:"body" koanf:"body" json:"HTTPBody"` | ||
| HTTPHeaders map[string][]string `mapstructure:"headers" koanf:"headers" json:"HTTPHeaders"` | ||
| Bucket string `mapstructure:"bucket" koanf:"bucket" json:"Bucket"` | ||
| Object string `mapstructure:"object" koanf:"object" json:"Object"` | ||
| Item string `mapstructure:"item" koanf:"item" json:"Item"` | ||
| Namespace string `mapstructure:"namespace" koanf:"namespace" json:"Namespace"` | ||
| ConfigMap string `mapstructure:"configmap" koanf:"configmap" json:"ConfigMap"` | ||
| Key string `mapstructure:"key" koanf:"key" json:"Key"` | ||
| BaseURL string `mapstructure:"baseUrl" koanf:"baseurl" json:"BaseURL"` | ||
| AuthToken string `mapstructure:"token" koanf:"token" json:"AuthToken"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you really need to add the json tag in the struct?
What is the reason do you need it?
|
|
||
| err := retrieverConf.IsValid() | ||
| if err != nil { | ||
| return err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔨 issue: With the current cli flags names there is an issue when the cli is in error, the error message is not consistent.
For example if I run
cli evaluate --kind=github --ctx='{"targetingKey": "123"}'I will have the following error:
ERROR error executing command: invalid retriever: no "repositorySlug" property found for kind "github"
But your cli flags are waiting for repository-slug and not repositorySlug.



Description
I added new flags related to other kind of retrievers. Based on them the new retriever is being spawned (but see #4024).
There is also new
--check-modeflag which when present would only dump the configuration of retriever being used to performevaluatecall. It also served me while testing some multi-flags (like http's--header) because there is some kind of parsing logic atevaluate_cmdlayer.The
redisretriever is not supported because of #4023. We may of course hack it and provide empty output when-kind=redisbut I think the refactor ofRetrieverConfstruct would benefit more.Closes issue(s)
Resolve #3876
Checklist
README.mdand/website/docs)