Skip to content

Conversation

@DeamonDev
Copy link
Contributor

@DeamonDev DeamonDev commented Oct 6, 2025

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-mode flag which when present would only dump the configuration of retriever being used to perform evaluate call. It also served me while testing some multi-flags (like http's --header) because there is some kind of parsing logic at evaluate_cmd layer.

The redis retriever is not supported because of #4023. We may of course hack it and provide empty output when -kind=redis but I think the refactor of RetrieverConf struct would benefit more.

Closes issue(s)

Resolve #3876

Checklist

  • I have tested this code
  • I have added unit test to cover this code
  • I have updated the documentation (README.md and /website/docs)
  • I have followed the contributing guide

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]>
@netlify
Copy link

netlify bot commented Oct 6, 2025

Deploy Preview for go-feature-flag-doc-preview canceled.

Name Link
🔨 Latest commit f650bcc
🔍 Latest deploy log https://app.netlify.com/projects/go-feature-flag-doc-preview/deploys/68fe18d0b2503f000881223b

@DeamonDev DeamonDev changed the title Feature add support for all retrievers in cli feature: add support for all retrievers in cli Oct 6, 2025
@codecov
Copy link

codecov bot commented Oct 6, 2025

Codecov Report

❌ Patch coverage is 90.53254% with 16 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.06%. Comparing base (a28007f) to head (f650bcc).

Files with missing lines Patch % Lines
cmd/cli/evaluate/evaluate_cmd.go 92.68% 6 Missing and 6 partials ⚠️
retriever/gcstorageretriever/retriever.go 0.00% 2 Missing ⚠️
retriever/s3retrieverv2/retriever.go 0.00% 2 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@DeamonDev DeamonDev changed the title feature: add support for all retrievers in cli feat: add support for all retrievers in cli Oct 6, 2025
Comment on lines +100 to +103

func (s *Retriever) SetDownloader(downloader DownloaderAPI) {
s.downloader = downloader
}
Copy link
Owner

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?

Copy link
Contributor Author

@DeamonDev DeamonDev Oct 17, 2025

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)

@thomaspoignant
Copy link
Owner

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a 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.

@DeamonDev DeamonDev force-pushed the feature-add-support-for-all-retrievers-in-cli branch from 72150d2 to 51a412b Compare October 17, 2025 13:12
@sonarqubecloud
Copy link

Copy link
Owner

@thomaspoignant thomaspoignant left a 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.
Copy link
Owner

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 | "" |
Copy link
Owner

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?

Comment on lines +169 to +179
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>'
Copy link
Owner

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.

Comment on lines +23 to +41
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"`
Copy link
Owner

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
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

(feature) Allow cli tool to use retriever other than fileretriever

2 participants