Skip to content
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

Feat/rest api and file provider #28

Merged

Conversation

toddbaert
Copy link
Member

@toddbaert toddbaert commented Jun 8, 2022

This PR adds:

  • generation of an OpenFeature-compliant REST API from a OpenAPI spec including models, validation, and parsing.
  • a "evaluator" concept and package, with an IEvaluator interface. This is the "brain" doing flag evaluation. It knows hot to take a string from the ISync's Fetch method, and convert it to a particular schema, and then perform flag evaluations. The only implementation so far is the JsonEvaluator, which uses the schema here (included as a submodule)

The Chi framework was used since it has no dependencies, and is compatible with native go net/http handlers.

To test:

  • pull in the schema submodule with git submodule update --init --recursive
  • go mod download
  • run make build (which is now includes of make generate). The generated code is .gitignored.

Then, you can perform flag evaluations after running ./flagd start --uri ./examples/provider_flags.json

curl -X POST localhost:8080/flags/myBoolTest/resolve/boolean?default-value=true
// {"reason":"DEFAULT","value":true}

curl -X POST localhost:8080/flags/myStringTest/resolve/string?default-value=hi
// {"reason":"DEFAULT","value":"red"}

curl -X POST localhost:8080/flags/myNumericTest/resolve/number?default-value=123
// {"reason":"DEFAULT","value":1}

curl -X POST localhost:8080/flags/myObjectTest/resolve/object?default-value=foo,bar
// {"reason":"DEFAULT","value":{"color":"blue"}}

Closes: #23
Closes: #27

@toddbaert toddbaert force-pushed the feat/rest-api-and-file-provider branch 5 times, most recently from 88e6d92 to 014188e Compare June 8, 2022 03:51
@AlexsJones
Copy link
Member

Hey great stuff, Can we talk this one through on a zoom call @toddbaert ?

@toddbaert toddbaert force-pushed the feat/rest-api-and-file-provider branch 5 times, most recently from a5baf96 to 15ef2b6 Compare June 10, 2022 15:34
Makefile Show resolved Hide resolved
@toddbaert toddbaert force-pushed the feat/rest-api-and-file-provider branch 2 times, most recently from b334cdc to 7fa8378 Compare June 10, 2022 15:42
pkg/runtime/runtime.go Outdated Show resolved Hide resolved
@toddbaert toddbaert force-pushed the feat/rest-api-and-file-provider branch from 7fa8378 to 6c940a9 Compare June 10, 2022 15:58
cmd/start.go Outdated Show resolved Hide resolved
@toddbaert toddbaert force-pushed the feat/rest-api-and-file-provider branch from 6c940a9 to 2b9339c Compare June 10, 2022 16:13
pkg/runtime/runtime.go Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
cmd/start.go Outdated Show resolved Hide resolved
toddbaert and others added 2 commits June 10, 2022 13:30
Co-authored-by: Alex Jones <alex.jones@canonical.com>
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.

REST API compliant with the OpenAPI schema OpenAPI schema
2 participants