Skip to content

Flag/feature toggle service, written in aiohttp

License

Notifications You must be signed in to change notification settings

alex-averin/its_on

 
 

Repository files navigation

It's on

Build Status Test Coverage

Flag/feature toggle service, written in aiohttp.

API Reference

Basic

Method Endpoint Description
GET /api/docs Api documentation
GET /api/v1/switch List of flags for the group.
GET /api/v1/switches/{id}/svg-badge SVG badge with actual flag information
GET /api/v1/switches_full_info List of all active flags with full info.

Admin

Endpoint Description
/zbs/login Login form
/zbs/switches List of flags
/zbs/switches/{switch_id} Flag detail

Sample /api/v1/switch output

{
    "count": 2,
    "result": ["test_flag3", "test_flag4"]
}

SVG badges

SVG badges can be useful for showing actual feature flag states.

Open Flag detail page, find SVG badge section and copy badge.

Screenshot

admin-flag-editing-page

You will get an image with a link in Markdown format:

[![flag-name](link-to-svg-badge)](link-to-flag-editing-page)

Then paste text in a text editor with Markdown support (task tracker, Slack, Mattermost etc.). Actual flag state will be displayed as follows:

State Badge
Active flag active-flag-badge
Inactive flag inactive-flag-badge
Deleted flag deleted-flag-badge
Unknown flag unknown-flag-badge

See settings.yaml for additional settings.

Environment notice

Environment notice helps to visually distinguish environments (e.g. development, staging, production).

Screenshot

admin-environment-indicator

To add the environment notice to every page in the admin, add following settings:

export DYNACONF_ENVIRONMENT_NOTICE__show=true  # false by default
export DYNACONF_ENVIRONMENT_NOTICE__environment_name='<Environment>'
export DYNACONF_ENVIRONMENT_NOTICE__background_color='<HEX color>'

See settings.yaml for default settings for each specified environment.

Installation

Prerequisites

its_on requires an SQL database and a cache storage engine. Currently, only PostgreSQL and Redis are supported as respective backends.

Manual

Clone repo:

$ git clone git@gitlab.com:bestdoctor/public/its_on.git

Install python packages:

$ pip install -r requirements.txt

Specify database and cache settings:

export DYNACONF_REDIS_URL=redis://127.0.0.1:6379/1
export DYNACONF_CACHE_URL=redis://127.0.0.1:6379/1
export DYNACONF_DATABASE__dsn=postgresql://user:password@127.0.0.1:5432/its_on

Apply database migrations:

$ alembic upgrade head

Create admin user:

$ python scripts/create_user.py --login=admin --password=password --is_superuser

Run server:

$ python -m its_on

Navigate to http://127.0.0.1:8081/api/docs in your browser and you are good to go!

Docker

Example docker-compose.yml file:

version: '3'
services:
  cache:
    image: redis
    container_name: its-on-redis

  db:
    image: postgres
    container_name: its-on-postgres
    environment:
      POSTGRES_PASSWORD: strongpassword
      POSTGRES_USER: itson
      POSTGRES_DB: itson

  web:
    image: bestdoctor/its_on:latest-dev
    container_name: its-on
    environment:
      DYNACONF_HOST: '0.0.0.0'
      DYNACONF_DATABASE__dsn: postgresql://itson:strongpassword@db:5432/itson
      DYNACONF_REDIS_URL: redis://cache:6379/0
      DYNACONF_CACHE_URL: redis://cache:6379/1
    ports:
     - "127.0.0.1:8081:8081"
    depends_on:
      - cache
      - db

Don't forget to create a superuser:

docker exec -t its-on python scripts/create_user.py --login=admin \
                                                    --password=password \
                                                    --is_superuser

Navigate to http://127.0.0.1:8081/api/docs in your browser and you are good to go!

Testing

Run make test

Contributing

We would love you to contribute to our project. It's simple:

  • Create an issue with bug you found or proposal you have. Wait for approve from maintainer.
  • Create a pull request. Make sure all checks are green.
  • Fix review comments if any.
  • Be awesome.

Here are useful tips:

  • You can run all checks and tests with make check. Please do it before CI does.
  • We use BestDoctor python styleguide. Sorry, styleguide is available only in Russian for now.
  • We respect Django CoC. Make soft, not bullshit.

About

Flag/feature toggle service, written in aiohttp

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 84.4%
  • HTML 13.0%
  • Dockerfile 0.8%
  • CSS 0.6%
  • Shell 0.6%
  • Mako 0.4%
  • Other 0.2%