Skip to content

Commit

Permalink
Update documentation
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Poignant <[email protected]>
  • Loading branch information
thomaspoignant committed Nov 22, 2024
1 parent 71c7f0b commit 6484b9f
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 32 deletions.
6 changes: 6 additions & 0 deletions cmd/lint/DOCKERHUB.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# GO Feature Flag Lint cli

![Status](https://img.shields.io/badge/status-deprecated-red)

> [!WARNING]
> The linter command has been deprecated in favor of the GO Feature Flag Command Line.
> Check the documentation for the [GO Feature Flag Command Line](http://gofeatureflag.org/docs/tooling/linter) for more information.
The lint command lint tool validates that a flags file can be parsed by GO Feature Flag.

## How to use this image
Expand Down
6 changes: 6 additions & 0 deletions cmd/lint/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# GO Feature Flag Lint cli

![Status](https://img.shields.io/badge/status-deprecated-red)

> [!WARNING]
> The linter command has been deprecated in favor of the GO Feature Flag Command Line.
> Check the documentation for the [GO Feature Flag Command Line](http://gofeatureflag.org/docs/tooling/linter) for more information.
The lint command line tool validates that a flags file can be parsed by GO Feature Flag.

## How to install the cli
Expand Down
32 changes: 32 additions & 0 deletions website/docs/tooling/cli.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
sidebar_position: 1
title: Command Line
description: The GO Feature Flag Command Line is a CLI tool to interact with GO Feature Flag in your terminal.
---

# Command Line Tool

The GO Feature Flag Command Line is a CLI tool to interact with GO Feature Flag in your terminal.

It offers a variety of commands to interact with GO Feature Flag, for now the supported commands are:
- [`evaluate`](./evaluate) to evaluate feature flags directly in your terminal
- [`lint`](./linter) to validate a configuration file format.

## Install the GO Feature Flag Command Line

### Install using Homebrew (mac and linux)
```shell
brew tap thomaspoignant/homebrew-tap
brew install go-feature-flag-cli
```

### Install using Scoop (windows)
```shell
scoop bucket add org https://github.com/go-feature-flag/scoop.git
scoop install go-feature-flag-cli
```

### Install using Docker
```shell
docker pull thomaspoignant/go-feature-flag-cli:latest
```
36 changes: 36 additions & 0 deletions website/docs/tooling/evaluate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
sidebar_position: 11
title: Evaluate command line
description: Evaluate feature flags directly in your terminal
---

# Evaluate feature flags directly in your terminal

Sometimes for debug or testing purposes, you may want to be able to know what will be the variant used during the evaluation of your feature flag.
With the GO Feature Flag Command Line, you can evaluate a feature flag directly in your terminal.

:::tip
You can also use the `evaluate` command to use feature flags in your CI/CD pipelines.
:::

## Install the Command Line

Check the [installation guide](./cli) to install the `go-feature-flag-cli`.

## Use the evaluate command in your terminal

```shell
./go-feature-flag-cli evaluate \
--config="<location_of_your_flag_configuration_file>" \
--format="yaml" \
--flag="<name_of_your_flag_to_evaluate>" \
--ctx='<evaluation_ctx_as_json_string>'
```

| param | description |
|------------|------------------------------------------------------------------------------------------------------------------------|
| `--config` | **(mandatory)** The location of your configuration file. |
| `--ctx` | **(mandatory)** The evaluation context used to evaluate the flag in json format (ex: `{"targetingKey":"123"}`). |
| `--format` | The format of your configuration flag _(acceptable values:`yaml`, `json`, `toml`)_.<br/>Default: **`yaml`** |
| `--flag` | The name of the flag you want to evaluate, if omitted all flags will be evaluated |

42 changes: 10 additions & 32 deletions website/docs/tooling/linter.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,49 +11,27 @@ import TabItem from '@theme/TabItem';
# Lint your configuration file

Ensuring the accuracy of your configuration is vital for the **GO Feature Flag** to function as expected.
This is why we have introduced the `go-feature-flag-lint`, a command line tool that validates whether a flag file can be parsed by **GO Feature Flag**.
This is why you can lint your configuration file using the [`go-feature-flag-cli`](./cli), a command line tool that allow to interact with GO Feature Flag in your terminal. The `lint` command validates whether a flag file can be parsed by **GO Feature Flag**.

:::tip
We recommend you to use this command line in your CI/CD pipelines to avoid any unforeseen issues.
:::

## Install the linter
## Install the Command Line

### Install using Homebrew (mac and linux)
```shell
brew tap thomaspoignant/homebrew-tap
brew install go-feature-flag-lint
```

### Install using Scoop (windows)
```shell
scoop bucket add org https://github.com/go-feature-flag/scoop.git
scoop install go-feature-flag-lint
```

### Install using Docker
```shell
docker pull thomaspoignant/go-feature-flag-lint:latest
```
Check the [installation guide](./cli) to install the `go-feature-flag-cli`.

## Use the linter

```shell
./go-feature-flag-lint \
--input-format=yaml \
--input-file=/input/my-go-feature-flag-config.goff.yaml
./go-feature-flag-cli lint /input/my-go-feature-flag-config.goff.yaml --format=yaml
```

The command line has 2 arguments you should specify.

| param | description |
|------------------|-------------------------------------------------------------------------------------------------------------------|
| `--input-file` | **(mandatory)** The location of your configuration file. |
| `--input-format` | **(mandatory)** The format of your current configuration file. <br/>Available formats are `yaml`, `json`, `toml`. |
You have to pass the location of your configuration file and the format of your current configuration file _(available formats are `yaml`, `json`, `toml`)_.

## Use the linter in your CI (continuous integration)

You can run `go-feature-flag-lint` directly in your CI:
You can run `go-feature-flag-cli` directly in your CI:

<Tabs groupId="code">
<TabItem value="githubaction" label="Github Action">
Expand Down Expand Up @@ -92,8 +70,8 @@ jobs:

steps:
- checkout
- run: curl -L $(curl -s https://api.github.com/repos/thomaspoignant/go-feature-flag/releases/latest | jq -r '.assets[] | select(.name|match("Linux_x86_64.tar.gz$")) | .browser_download_url' | grep 'go-feature-flag-lint') --output release.tar.gz && tar -zxvf release.tar.gz
- run: ./go-feature-flag-lint --input-format=yaml --input-file=flag-config.goff.yaml # please put the right file name
- run: curl -L $(curl -s https://api.github.com/repos/thomaspoignant/go-feature-flag/releases/latest | jq -r '.assets[] | select(.name|match("Linux_x86_64.tar.gz$")) | .browser_download_url' | grep 'go-feature-flag-cli') --output release.tar.gz && tar -zxvf release.tar.gz
- run: ./go-feature-flag-cli lint flag-config.goff.yaml --format=yaml # please put the right file name
```
</TabItem>
Expand All @@ -109,8 +87,8 @@ lint-job:
- apt-get install -y jq curl

script:
- curl -L $(curl -s https://api.github.com/repos/thomaspoignant/go-feature-flag/releases/latest | jq -r '.assets[] | select(.name|match("Linux_x86_64.tar.gz$")) | .browser_download_url' | grep 'go-feature-flag-lint') --output release.tar.gz && tar -zxvf release.tar.gz
- ./go-feature-flag-lint --input-format=yaml --input-file=flag-config.goff.yaml # please put the right file name
- curl -L $(curl -s https://api.github.com/repos/thomaspoignant/go-feature-flag/releases/latest | jq -r '.assets[] | select(.name|match("Linux_x86_64.tar.gz$")) | .browser_download_url' | grep 'go-feature-flag-cli') --output release.tar.gz && tar -zxvf release.tar.gz
- ./go-feature-flag-cli lint flag-config.goff.yaml --format=yaml # please put the right file name
```
</TabItem>
Expand Down

0 comments on commit 6484b9f

Please sign in to comment.