toguru-panel-cli
v1.0.5
Published
Queries toggles for cultures and includes helper methods
Downloads
2
Readme
toguru-panel-cli
Filter exsting toguru toggles by property values
Setup up
- Run
npm install toguru-panel-cli --save
in your project
Configure & Use Toguru.js
- Include
toguru-panel-cli
in your project withconst Toguru = require('toguru-panel-cli')
- Create a Toguru object with
const toguru = Toguru(toguruToken)
- Where
toguruToken
is your decrypted toguru token string.
- Where
- Call
toguru.toggles()
to receive anObservable
of all toggles, and chain any filter predicates you want - Chain
.subscribe(toguru.sink)
to your last observable filter operation to pretty print the resulting JSON
Examples
Run the included example with node example.js -t <your-toguru-token>
.
Analagous to an SQL
query, it:
"selects" toggles where
- the toggle's team is
gecloud
- the toggle is fully rolled out
- the toggle is defined for the
classified-detail
service.
toguru.toggles() // SELECT * FROM TOGGLES
.filter(toguru.teamToggles("gecloud")) // WHERE (TOGGLES.TEAM = "gecloud"
.filter(toguru.fullRollout) // AND TOGGLES.ROLLOUT_PERCENTAGE = 100
.filter(toguru.toggleServices("classified-detail")) // AND TOGGLES.SERVICES = "classified-detail)"
.subscribe(toguru.sink); // pretty prints result(s) to STDOUT
Running tests
npm run test
Extend or write your own filters
To do this, write a predicate function that accepts a toggle object and returns true or false, and filter the toggles based on your predicate.
- E.g.
toguru.toggles().filter((toggle) => toggle.id === "my-toggle-id")
Contributing to the existing library
- Make a pull request with your changes describing what it does and why it is applicable to the general user base
- All library functionality should live in
/lib/toguru.js
, and extend the existing API - Include tests for your new changes and make sure all old and new tests run with
npm run test
Toggle JSON structure
Warning: some toggles are missing fields since they are user defined. Be sure to be aware of this when writing your own filters
{
"id": "<toggle-id>",
"tags": {
"team": "<team-name>",
"stack": "<stack-name>",
"services": "<service-name(s)>"
},
"rolloutPercentage": <[0 - 100]>
}