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

Create a new documentation version v1.5.1 #585

Merged
merged 1 commit into from
Mar 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions website/versioned_docs/version-v1.5.1/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"position": 0,
"collapsible": true,
"collapsed": false
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"position": 20,
"collapsible": true,
"collapsed": true,
"label": "Configure your feature flags",
"link": {
"type": "generated-index",
"title": "Configure your feature flags"
}
}
266 changes: 266 additions & 0 deletions website/versioned_docs/version-v1.5.1/configure_flag/flag_format.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,266 @@
---
sidebar_position: 20
description: What is a flag and how you can create them.
---
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';


# How to configure a flag

**GO Feature Flag** core feature is to centralize all your feature flags in a source file, and to avoid hosting and maintaining a backend server to manage them.

Your file must be a valid `YAML`, `JSON` or `TOML` file with a list of flags
*(examples: [`YAML`](https://github.com/thomaspoignant/go-feature-flag/tree/main/testdata/flag-config.yaml),
[`JSON`](https://github.com/thomaspoignant/go-feature-flag/tree/main/testdata/flag-config.json),
[`TOML`](https://github.com/thomaspoignant/go-feature-flag/tree/main/testdata/flag-config.toml))*.

:::tip
The easiest way to create your configuration file is to used
[**GO Feature Flag Editor** available at [https://editor.gofeatureflag.org](https://editor.gofeatureflag.org).

If you prefer to do it manually please follow instruction bellow.
:::

## Editor

Creating the first version of the flag is not always pleasant, that's why we have created
[**GO Feature Flag Editor**](https://editor.gofeatureflag.org) a simple editor to create your files.

## Example

A flag configuration looks like:


<Tabs groupId="code">
<TabItem value="yaml" label="YAML">

```yaml
# This is your configuration for your first flag
first-flag:
variations: # All possible return value for your feature flag
A: false
B: true
targeting: # If you want to target a subset of your users in particular
- query: key eq "random-key"
percentage:
A: 0
B: 100
defaultRule: # When no targeting match we use the defaultRule
variation: A

# A second example of a flag configuration
second-flag:
variations:
A: "valueA"
B: "valueB"
defaultValue: "a default value"
targeting:
- name: legacyRuleV0
query: key eq "not-a-key"
percentage:
A: 10
B: 90
defaultRule:
name: legacyDefaultRule
variation: defaultValue
version: "12"
experimentation:
start: 2021-03-20T00:00:00.1-05:00
end: 2021-03-21T00:00:00.1-05:00
```

</TabItem>
<TabItem value="json" label="JSON">

```json
{
"first-flag": {
"variations": {
"A": false,
"B": true
},
"targeting": [
{
"query": "key eq \"random-key\"",
"percentage": {
"A": 0,
"B": 100
}
}
],
"defaultRule": {
"variation": "A"
}
},

"second-flag": {
"variations": {
"A": "valueA",
"B": "valueB",
"defaultValue": "a default value"
},
"targeting": [
{
"name": "legacyRuleV0",
"query": "key eq \"not-a-key\"",
"percentage": {
"A": 10,
"B": 90
}
}
],
"defaultRule": {
"name": "legacyDefaultRule",
"variation": "defaultValue"
},
"version": "12",
"experimentation": {
"start": "2021-03-20T05:00:00.100Z",
"end": "2021-03-21T05:00:00.100Z"
}
}
}
```

</TabItem>
<TabItem value="toml" label="TOML">

```toml
[first-flag.variations]
A = false
B = true

[[first-flag.targeting]]
query = 'key eq "random-key"'

[first-flag.targeting.percentage]
A = 0
B = 100

[first-flag.defaultRule]
variation = "A"

[second-flag]
version = "12"

[second-flag.variations]
A = "valueA"
B = "valueB"
defaultValue = "a default value"

[[second-flag.targeting]]
name = "legacyRuleV0"
query = 'key eq "not-a-key"'

[second-flag.targeting.percentage]
A = 10
B = 90

[second-flag.defaultRule]
name = "legacyDefaultRule"
variation = "defaultValue"

[second-flag.experimentation]
start = 2021-03-20T05:00:00.100Z
end = 2021-03-21T05:00:00.100Z
```

</TabItem>
</Tabs>

## Format details

<table>
<thead>
<tr>
<th>Field</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td width="20%"><strong>flag-key</strong></td>
<td>Name of your flag.<br/><i>It must be unique.<br/>On the example the flag keys are <code>test-flag</code> and <code>test-flag2</code>.</i></td>
</tr>
<tr>
<td><code>variations</code></td>
<td>
<p>Variations are all the variations available for this flag.</p>
<p>It is represented as a key/value element. The key is the name of the variation and the value could be any types available (<code>string</code>, <code>float</code>, <code>int</code>, <code>map</code>, <code>array</code>, <code>bool</code>).</p>
<p>You can have as many variation as needed.</p>
<pre># Some examples<br/>
variationString: test<br/>
variationBool: true<br/>
variationInt: 1000<br/>
variationFloat: 1000.23<br/>
variationArray: <br/> - item1<br/> - item2<br/>
variationObj:<br/> item1: 123<br/> item2: this is a string<br/> item3: false<br/>
</pre>
</td>
</tr>
<tr>
<td><code>targeting</code><br/><i>(optional)</i></td>
<td>
<p>
Targeting contains the list of rules you have to target a subset of your users.
<br/>You can have as many target as needed.
</p>
<p>This field is an <code>array</code> and contains a list of rules.</p>
<p><i>See <a href="./rule_format">rules format</a> to have more info on how to write a rule.</i></p>
</td>
</tr>
<tr>
<td><code>defaultRule</code></td>
<td>
<p>DefaultRule is the rule that is applied if the user does not match in any targeting.</p>
<p><i>See <a href="./rule_format">rules format</a> to have more info on how to write a rule.</i></p>
</td>
</tr>
<tr>
<td><code>trackEvents</code><br/><i>(optional)</i></td>
<td>
<p><code>false</code> if you don't want to export the data in your data exporter.</p>
<p><b>Default:</b> <code>true</code></p>
</td>
</tr>
<tr>
<td><code>disable</code><br/><i>(optional)</i></td>
<td>
<p><code>true</code> if the flag is disabled.</p>
<p><b>Default:</b> <code>false</code></p>
</td>
</tr>
<tr>
<td><code>version</code><br/><i>(optional)</i></td>
<td>
<p>The version is the version of your flag.<br/>This string is used to display the information in the notifiers and data collection, you have to update it your self.</p>
<p><b>Default:</b> <code>""</code></p>
</td>
</tr>
<tr>
<td><code>scheduledRollout</code><br/><i>(optional)</i></td>
<td>
<p>Scheduled allow to patch your flag over time.</p>
<p>You can add several steps that updates the flag, this is typically used if you want to gradually add more user in your flag.</p>
<p><i>See <a href="./rollout/scheduled/">Scheduled rollout</a> to have more info on how to use it.</i></p>
</td>
</tr>
<tr>
<td><code>experimentation</code><br/><i>(optional)</i></td>
<td>
<p>Experimentation allow you to configure a start date and an end date for your flag. When the experimentation is not running, the flag will serve the default value.</p>
<p><i>See <a href="./rollout/experimentation/">Experimentation rollout</a> to have more info on how to use it.</i></p>
</td>
</tr>
</tbody>
</table>




## Advanced configurations

You can have advanced configurations for your flag to have specific behavior for them, such as:
- [Specific rollout strategies](../category/rollout-strategies/)
- [Don't track a flag](../go_module/data_collection/index.md#dont-track-a-flag)
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"position": 30,
"collapsible": true,
"collapsed": true,
"label": "Rollout strategies",
"link": {
"type": "generated-index",
"title": "Rollout strategies",
"description": "A critical part of every new feature release is orchestrating the actual launch schedule between Product, Engineering, and Marketing teams. Delivering powerful user experiences typically requires software teams to manage complex releases and make manual updates at inconvenient times. But it does’t have to, having a complex rollout strategy allows you to have lifecycle for your flags."
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

# Canary Release

**Canary release** is a technique to reduce the risk of introducing a new software version in production by slowly rolling out the change to a small subset of users before rolling it out to the entire infrastructure and making it available to everybody.

This is the easiest rollout strategy available.
You just have to select a percentage of your users in your flag, and the `True` behavior will apply to them.

## Example

<Tabs groupId="code">
<TabItem value="yaml" label="YAML">

```yaml
canary-flag:
variations:
oldBehavior: false
canary: true
defaultRule:
# highlight-start
percentage:
oldBehavior: 99
canary: 1
# highlight-end
```

</TabItem>
<TabItem value="json" label="JSON">

```json
{
"canary-flag": {
"variations": {
"oldBehavior": false,
"canary": true
},
"defaultRule": {
# highlight-start
"percentage": {
"oldBehavior": 99,
"canary": 1
}
# highlight-end
}
}
}
```

</TabItem>
<TabItem value="toml" label="TOML">


```toml
[canary-flag.variations]
oldBehavior = false
canary = true

# highlight-start
[canary-flag.defaultRule.percentage]
oldBehavior = 99
canary = 1
# highlight-end
```

</TabItem>
</Tabs>
Loading