Skip to content

Commit

Permalink
feat: flagd provider (open-feature#66)
Browse files Browse the repository at this point in the history
* initial commit

Signed-off-by: James-Milligan <james@omnant.co.uk>

* nx format:write

Signed-off-by: James-Milligan <james@omnant.co.uk>

* udpated nxignore to exclude generated files

Signed-off-by: James-Milligan <james@omnant.co.uk>

* fixed linting issues

Signed-off-by: James-Milligan <james@omnant.co.uk>

* typo

Signed-off-by: James-Milligan <james@omnant.co.uk>

* removed nested .vscode

Signed-off-by: James-Milligan <james@omnant.co.uk>

* added typing to axios response objects

Signed-off-by: James-Milligan <james@omnant.co.uk>

* removed proto files from version control

Signed-off-by: James-Milligan <james@omnant.co.uk>

* required commit for nx run-command

Signed-off-by: James-Milligan <james@omnant.co.uk>

* actions

Signed-off-by: James-Milligan <james@omnant.co.uk>

* dependency updates + removal of cantextTransformer method

Signed-off-by: James-Milligan <james@omnant.co.uk>

* removed forked submodule

Signed-off-by: James-Milligan <james@omnant.co.uk>

* switched to open-feature/schemas

Signed-off-by: James-Milligan <james@omnant.co.uk>

* dependency sync

Signed-off-by: James-Milligan <james@omnant.co.uk>

* merge fixes

Signed-off-by: James-Milligan <james@omnant.co.uk>

* workspace fixes

Signed-off-by: James-Milligan <james@omnant.co.uk>

* merge fixes

Signed-off-by: James-Milligan <james@omnant.co.uk>

* merge fixes

Signed-off-by: James-Milligan <james@omnant.co.uk>

* merge fixes - added go to ci

Signed-off-by: James-Milligan <james@omnant.co.uk>

* merge fixes

Signed-off-by: James-Milligan <james@omnant.co.uk>

* updated go version in github action setup

Signed-off-by: James-Milligan <james@omnant.co.uk>

* squashed commits

Signed-off-by: James-Milligan <james@omnant.co.uk>

* buf setup test => avoid using go install buf

Signed-off-by: James-Milligan <james@omnant.co.uk>

* removed go setup + removed submodule issue => error

Signed-off-by: James-Milligan <james@omnant.co.uk>

* removed go setup + removed submodule issue => error

Signed-off-by: James-Milligan <james@omnant.co.uk>

* happy path unit tests

Signed-off-by: James-Milligan <james@omnant.co.uk>

* more unit tests + fixes

Signed-off-by: James-Milligan <james@omnant.co.uk>

* set noImplicitOverride to false

Signed-off-by: James-Milligan <james@omnant.co.uk>

* errorCode consolidation

Signed-off-by: James-Milligan <james@omnant.co.uk>

* removed tslint ignores and .vscode files

Signed-off-by: James-Milligan <james@omnant.co.uk>

* package.json cleanup

Signed-off-by: James-Milligan <james@omnant.co.uk>

* Update project.json

Signed-off-by: James Milligan <75740990+james-milligan@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: Michael Beemer <beeme1mr@users.noreply.github.com>
Signed-off-by: James Milligan <75740990+james-milligan@users.noreply.github.com>

* PR updates

Signed-off-by: James-Milligan <james@omnant.co.uk>

* removed makefile

Signed-off-by: James-Milligan <james@omnant.co.uk>

* replaced hardcoded errorCode and reason values with imported values from nodesdk

Signed-off-by: James-Milligan <james@omnant.co.uk>

* style updates, simplification of provider construction, README updates

Signed-off-by: James-Milligan <james@omnant.co.uk>

* removed variant value "default_value" on error/default, simplified checkResponse function

Signed-off-by: James-Milligan <james@omnant.co.uk>

* Update README.md

Signed-off-by: James Milligan <75740990+james-milligan@users.noreply.github.com>

* Update libs/providers/flagd/package.json

Co-authored-by: Thomas Poignant <thomas.poignant@gmail.com>
Signed-off-by: James Milligan <75740990+james-milligan@users.noreply.github.com>

* added encodeURI to urls in http service

Signed-off-by: James-Milligan <james@omnant.co.uk>

* Update pushlish script

Signed-off-by: Todd Baert <toddbaert@gmail.com>

* encodeURIComponent(flagKey) in http service

Signed-off-by: James-Milligan <james@omnant.co.uk>

* added protocol option

Signed-off-by: James-Milligan <james@omnant.co.uk>

* update README

Signed-off-by: James-Milligan <james@omnant.co.uk>

Co-authored-by: Michael Beemer <beeme1mr@users.noreply.github.com>
Co-authored-by: Thomas Poignant <thomas.poignant@gmail.com>
Co-authored-by: Todd Baert <toddbaert@gmail.com>
  • Loading branch information
4 people authored Jul 27, 2022
1 parent 7db7d31 commit 9d6cb86
Show file tree
Hide file tree
Showing 28 changed files with 1,720 additions and 59 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ jobs:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: bufbuild/buf-setup-action@v0.5.0
with:
version: '1.1.1'
- uses: nrwl/nx-set-shas@v2
- run: npm ci

Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,6 @@ testem.log
# System Files
.DS_Store
Thumbs.db

# generated files
proto
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "libs/providers/flagd/schemas"]
path = libs/providers/flagd/schemas
url = https://github.com/open-feature/schemas
5 changes: 3 additions & 2 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"libs/hooks/open-telemetry": "1.2.3-alpha",
"libs/providers/go-feature-flag": "0.1.3"
}
"libs/providers/go-feature-flag": "0.1.3",
"libs/providers/flagd": "0.1.0"
}
8 changes: 0 additions & 8 deletions .vscode/extensions.json

This file was deleted.

10 changes: 10 additions & 0 deletions libs/providers/flagd/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"presets": [
[
"@nrwl/web/babel",
{
"useBuiltIns": "usage"
}
]
]
}
18 changes: 18 additions & 0 deletions libs/providers/flagd/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"extends": ["../../../.eslintrc.json"],
"ignorePatterns": ["!**/*", "node_modules", "src/proto/**"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
}
]
}
35 changes: 35 additions & 0 deletions libs/providers/flagd/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# NodeJS flagd Provider for OpenFeature

![Experimental](https://img.shields.io/badge/experimental-breaking%20changes%20allowed-yellow)

Flagd is a simple command line tool for fetching and presenting feature flags to services. It is designed to conform to OpenFeature schema for flag definitions. This repository and package provides the client side code for interacting with it via the Open-Feature Node SDK.

## Installation

```
$ npm install @openfeature/flagd-provider
```

## Building

Run `nx package providers-flagd` to build the library.

## Running unit tests

Run `nx test providers-flagd` to execute the unit tests via [Jest](https://jestjs.io).


## Usage

The `FlagdProvider` client constructor takes a single optional argument with 3 fields, their default values correspond to the default arguments supplied to the flagd server:
```
OpenFeature.setProvider(new FlagdProvider({
service: 'grpc',
host: 'localhost',
port: 8080,
}))
```
**service**: "http" | "grpc" *(defaults to http)*
**host**: string *(defaults to "localhost")*
**port**: number *(defaults to 8080)*
**protocol**: "http" | "https" *(defaults to http - only active for http service)*
3 changes: 3 additions & 0 deletions libs/providers/flagd/babel.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["minify"]
}
15 changes: 15 additions & 0 deletions libs/providers/flagd/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/* eslint-disable */
export default {
displayName: 'providers-flagd',
preset: '../../../jest.preset.js',
globals: {
'ts-jest': {
tsconfig: '<rootDir>/tsconfig.spec.json',
},
},
transform: {
'^.+\\.[tj]s$': 'ts-jest',
},
moduleFileExtensions: ['ts', 'js', 'html'],
coverageDirectory: '../../../coverage/libs/providers/flagd',
};
Loading

0 comments on commit 9d6cb86

Please sign in to comment.