Skip to content

feat: openfeature pull command #79

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

jsalaber
Copy link

@jsalaber jsalaber commented Mar 17, 2025

Summary

  • init command creates a .openfeature.yaml to store flagSourceUrl using the --flag-source-url
  • adds a new pull command that fetches a flag configuration from a flagSourceUrl configured in the init command
  • pull command prompts the user for default values if the source configuration doesn't define default values
  • overwrites the manifest with the source url flags
  • supports using local file uri or http: file:// or https://

Related Issues

#3

Notes

  • refactored out the Load function from flagset due to circular dependency when trying to use flagset type in the manifest package
  • new LoadFromSourceFlags takes the type from a source configuration and compares it to different types that could match, e.g. Boolean, bool, boolean

Todo

  • Support different auth types other than auth token as a header, and figure out a way to store it securely without needing to pass it in as a flag in the pull command

@jsalaber jsalaber force-pushed the feat/openfeature-pull-command branch 3 times, most recently from 7583c17 to 7bd1a4f Compare March 17, 2025 15:32
@beeme1mr beeme1mr requested review from beeme1mr and anghelflorinm and removed request for beeme1mr March 17, 2025 16:41
@jsalaber jsalaber force-pushed the feat/openfeature-pull-command branch from 7bd1a4f to d113d0f Compare March 17, 2025 17:47
@dominikhaska
Copy link
Contributor

I think it would be good to add some tests - there is an in memory filesystem in generate_test.go so it could be used and probably faking network should not be that hard.

@jsalaber jsalaber force-pushed the feat/openfeature-pull-command branch 4 times, most recently from 4492e4a to 18e5f24 Compare March 18, 2025 16:20
@jsalaber
Copy link
Author

@dominikhaska added a couple of tests for the pull command!

@jsalaber jsalaber requested a review from beeme1mr March 18, 2025 16:21
@jsalaber jsalaber marked this pull request as ready for review March 18, 2025 17:54
@jsalaber jsalaber force-pushed the feat/openfeature-pull-command branch from 18e5f24 to c713693 Compare March 19, 2025 14:43
@kriscoleman
Copy link
Collaborator

kriscoleman commented Mar 20, 2025

this is looking great, thanks!
I think this is a great first step to push/pull/diff.

I was also ideating on a pull command too, and had wondered what kind of sources we might pull from.
Just food for thought, I imagined we might have a concept of Sources, a source might be as simple as a public URL to a manifest file, or an authed endpoint like here, a file stored in git, or from an instance of openfeature itself. We might be able to contribute different source provider types (GitSource, OpenFeatureApiSource, URLSource, etc.), to make this extensible and able to encapsulate domain specifics for different sources.

@beeme1mr
Copy link
Member

I was also ideating on a pull command too, and had wondered what kind of sources we might pull from.
Just food for thought, I imagined we might have a concept of Sources, a source might be as simple as a public URL to a manifest file, or an authed endpoint like here, a file stored in git, or from an instance of openfeature itself. We might be able to contribute different source provider types (GitSource, OpenFeatureApiSource, URLSource, etc.), to make this extensible and able to encapsulate domain specifics for different sources.

I was thinking about that too. Perhaps we could do something similar to flagd where we accept a --uri flag and use the protocol identifier to determine how to pull from the source. We could start by supporting only http, but we could easily add support for git, ssh, s3, and more.

}

var sourceFlags []SourceFlag
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the flag source object should look like this:

{
  "flags": [
     {
        "key" "test",
        "type": "boolean",
        "defaultValue": false
     }
  ]
}

This will allow us to add additional top-level properties without requiring a breaking change.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean the source should return with a top level flags property or when we unmarshal the data to pass around a data object that has the flags property?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The source is what I had in mind.

@jsalaber jsalaber force-pushed the feat/openfeature-pull-command branch from c713693 to 7ba5c1c Compare April 8, 2025 15:16
@jsalaber jsalaber requested a review from beeme1mr April 8, 2025 15:18
@jsalaber jsalaber force-pushed the feat/openfeature-pull-command branch from d55ec78 to 82da5e3 Compare April 8, 2025 15:47
@jsalaber jsalaber force-pushed the feat/openfeature-pull-command branch from 82da5e3 to d048ffa Compare April 10, 2025 13:42
…pull command

Signed-off-by: Jason Salaber <jcsalaber@hotmail.com>
Signed-off-by: Jason Salaber <jcsalaber@hotmail.com>
Signed-off-by: Jason Salaber <jcsalaber@hotmail.com>
Signed-off-by: Jason Salaber <jcsalaber@hotmail.com>
Signed-off-by: Jason Salaber <jcsalaber@hotmail.com>
@jsalaber jsalaber force-pushed the feat/openfeature-pull-command branch from d048ffa to e4adc07 Compare April 22, 2025 15:14
@beeme1mr beeme1mr linked an issue Apr 25, 2025 that may be closed by this pull request
@beeme1mr beeme1mr requested a review from dominikhaska April 25, 2025 18:07
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.

Support fetching remote flag manifests
4 participants