Skip to content
This repository has been archived by the owner on Mar 11, 2021. It is now read-only.

fabric8-services/fabric8-toggles-service

Repository files navigation

Fabric8 toggles service

Overview

The fabric8-toggles-service is the client service to run with the fabric8-toggles server. The server is heavily based on Unleash server, a feature toggle system, that gives you a great overview over all feature toggles across all your applications and services. It comes with official client implementations for Java, Node.js and Go.

fabric8-server defines 4 level of toggle configuration: internal, experimental, beta or released. The activation strategy is per userGroupId.

Using the admin console deployed with fabric8-toggle, you can easily move a feature from experimental to beta. This client makes use of the unleash Go SDK to connect to fabric8-toggles server.

You can see usage of the service in fabric8-ui.

Development

Build

The following guide is mainly targeted towards a Linux or macOS development machine.

Pre-requisites

Have the following installed on your machine:

go Install GoLang from 1.8+, set the environment variable GOPATH.

Get the code

$ git clone https://github.com/fabric8-services/fabric8-toggles-services $GOPATH/src/github.com/fabric8-services/fabric8-toggles-service

Build

To fetch the Go dependencies, generate code (GOA framework) and finally build the project you can type:

$ cd $GOPATH/src/github.com/fabric8-services/fabric8-toggles-service
$ make clean build

Run test

To run unit tests:

make build test

Docker build

  • build image from centos

make image
  • run your docker image in minishift

make deploy-minishift
  • Deploy locally:

F8_TOGGLES_URL=http://toggles-fabric8.192.168.64.4.xip.io/api F8_AUTH_URL=https://auth.prod-preview.openshift.io make run

where F8_TOGGLES_URL points to the exposed route on minishift and F8_AUTH_URL target prod-preview.

Configure

Configure unleash database

  • Go to fabric8-toggles-server admin console (ie: the unleash admin console) http://fabric8-toggles-fabric8.MINISHIFT_IP.nip.io

  • In strategy tab:

    • add a strategy with name enableByLevel with a parameter level, choose string for parameter type.

    • add a strategy with name enableByEmails with a parameter emails, choose list for parameter type.

  • Go to features list:

    • add a feature with name "Planner", give a description and add the newly created enableByLevel strategy, enter released.

    • add a feature with name Analyze, give a description and add the newly created enableByEmails strategy, enter your prod-preview and prod emails. for level. Enable the feature.

📎
This is a temporary settings, the fabric8-server should bootstrap those values.

Test your service locally with a curl

  • For anonymous user

$ curl http://localhost:8080/api/features?names\=Planner
{
  "data": [
    {
      "attributes": {
        "description": "Planner's description",
        "enabled": true,
        "enablement-level": "released",
        "user-enabled": true
      },
      "id": "Planner",
      "type": "features"
    }
  ]
}
  • For logged-in user

$ export TOKEN=YOUT_TOKEN
$ curl http://localhost:8080/api/features\?group\=Analyze -H "Authorization: Bearer $TOKEN"