Skip to content

Commit

Permalink
chore: fix formatting of gitops guide
Browse files Browse the repository at this point in the history
Signed-off-by: Mark Phelps <209477+markphelps@users.noreply.github.com>
  • Loading branch information
markphelps committed May 29, 2024
1 parent c685769 commit 8adc9b1
Showing 1 changed file with 86 additions and 89 deletions.
175 changes: 86 additions & 89 deletions guides/user/get-going-with-gitops.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -94,28 +94,26 @@ We provide this evaluation call with a request containing the flags key, an enti
}

- bubbleSort(words)

* flag, err := s.flipt.Evaluation().Boolean(r.Context(), &evaluation.EvaluationRequest{
* FlagKey: "use-quicksort-algorithm",
* EntityId: getUser(r.Context()),
* Context: map[string]string{
* "organization": getOrganization(r.Context()),
* },
* })
*
* if flag.Enabled {
* quicksort(words)
* } else {
* bubblesort(words)
* }

if err := json.NewEncoder(w).Encode(words); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
}

````
+ flag, err := s.flipt.Evaluation().Boolean(r.Context(), &evaluation.EvaluationRequest{

Check failure on line 97 in guides/user/get-going-with-gitops.mdx

View workflow job for this annotation

GitHub Actions / lint

Replace `+` with `⏎*`
+ FlagKey: "use-quicksort-algorithm",

Check failure on line 98 in guides/user/get-going-with-gitops.mdx

View workflow job for this annotation

GitHub Actions / lint

Replace `+··` with `*`
+ EntityId: getUser(r.Context()),

Check failure on line 99 in guides/user/get-going-with-gitops.mdx

View workflow job for this annotation

GitHub Actions / lint

Replace `+··` with `*`
+ Context: map[string]string{

Check failure on line 100 in guides/user/get-going-with-gitops.mdx

View workflow job for this annotation

GitHub Actions / lint

Replace `+··` with `*`
+ "organization": getOrganization(r.Context()),

Check failure on line 101 in guides/user/get-going-with-gitops.mdx

View workflow job for this annotation

GitHub Actions / lint

Replace `+` with `*`
+ },

Check failure on line 102 in guides/user/get-going-with-gitops.mdx

View workflow job for this annotation

GitHub Actions / lint

Replace `+··` with `*`
+ })

Check failure on line 103 in guides/user/get-going-with-gitops.mdx

View workflow job for this annotation

GitHub Actions / lint

Replace `+` with `*`
+

Check failure on line 104 in guides/user/get-going-with-gitops.mdx

View workflow job for this annotation

GitHub Actions / lint

Replace `+` with `*`
+ if flag.Enabled {

Check failure on line 105 in guides/user/get-going-with-gitops.mdx

View workflow job for this annotation

GitHub Actions / lint

Replace `+` with `*`
+ quicksort(words)

Check failure on line 106 in guides/user/get-going-with-gitops.mdx

View workflow job for this annotation

GitHub Actions / lint

Replace `+··` with `*`
+ } else {
+ bubblesort(words)
+ }

if err := json.NewEncoder(w).Encode(words); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
}
```

```go pkg/server/words.go
func (s *Server) ListWords(w http.ResponseWriter, r *http.Request) {
Expand Down Expand Up @@ -144,8 +142,7 @@ func (s *Server) ListWords(w http.ResponseWriter, r *http.Request) {
return
}
}
````

```
</CodeGroup>

The entity ID used here is going to be an identifier for the requests authenticated user. This is returned by the call to `getUser(r.Context())`.
Expand Down Expand Up @@ -198,10 +195,10 @@ This flag will be a _boolean_ type flag and be in a disabled (`enabled = false`)
version: "1.2"
namespace: default
flags:
- key: use-quicksort-algorithm
name: Use Quicksort Algorithm
type: BOOLEAN_FLAG_TYPE
enabled: false
- key: use-quicksort-algorithm
name: Use Quicksort Algorithm
type: BOOLEAN_FLAG_TYPE
enabled: false
```
### Running Flipt Locally
Expand Down Expand Up @@ -327,23 +324,23 @@ We open the `features.yml` file and update the definition with a new segment and
version: "1.2"
namespace: default
flags:
- key: use-quicksort-algorithm
name: Use Quicksort Algorithm
type: BOOLEAN_FLAG_TYPE
enabled: false
rollouts:
- segment:
key: internal-users
value: true
- key: use-quicksort-algorithm
name: Use Quicksort Algorithm
type: BOOLEAN_FLAG_TYPE
enabled: false
rollouts:
- segment:
key: internal-users
value: true
segments:
- key: internal-users
name: Internal Users
match_type: ANY_MATCH_TYPE
constraints:
- property: organization
operator: eq
value: internal
type: STRING_COMPARISON_TYPE
- key: internal-users
name: Internal Users
match_type: ANY_MATCH_TYPE
constraints:
- property: organization
operator: eq
value: internal
type: STRING_COMPARISON_TYPE
```
</CodeGroup>
Expand All @@ -355,14 +352,14 @@ Breaking this change down we've got:
```yaml features.yml
# ...
segments:
- key: internal-users
name: Internal Users
match_type: ANY_MATCH_TYPE
constraints:
- property: organization
operator: eq
value: internal
type: STRING_COMPARISON_TYPE
- key: internal-users
name: Internal Users
match_type: ANY_MATCH_TYPE
constraints:
- property: organization
operator: eq
value: internal
type: STRING_COMPARISON_TYPE
```

This [segment](/concepts#segments) definition matches any evaluation request where there exists a key `organization` on the context, with a value `internal`.
Expand All @@ -375,12 +372,12 @@ Now, when the user happens to be associated with the `internal` organization, it

```yaml features.yml
flags:
- key: use-quicksort-algorithm
# ...
rollouts:
- segment:
key: internal-users
value: true
- key: use-quicksort-algorithm
# ...
rollouts:
- segment:
key: internal-users
value: true
```

Finally, we add a [rollout rule](/concepts#rollouts) to our boolean flag.
Expand Down Expand Up @@ -477,26 +474,26 @@ Then we're going to edit `features.yml` and add a threshold percentage rule.
version: "1.2"
namespace: default
flags:
- key: use-quicksort-algorithm
name: Use Quicksort Algorithm
type: BOOLEAN_FLAG_TYPE
enabled: false
rollouts:
- segment:
key: internal-users
value: true
- threshold:
percentage: 20
value: true
- key: use-quicksort-algorithm
name: Use Quicksort Algorithm
type: BOOLEAN_FLAG_TYPE
enabled: false
rollouts:
- segment:
key: internal-users
value: true
- threshold:
percentage: 20
value: true
segments:
- key: internal-users
name: Internal Users
match_type: ANY_MATCH_TYPE
constraints:
- property: organization
operator: eq
value: internal
type: STRING_COMPARISON_TYPE
- key: internal-users
name: Internal Users
match_type: ANY_MATCH_TYPE
constraints:
- property: organization
operator: eq
value: internal
type: STRING_COMPARISON_TYPE
```

</CodeGroup>
Expand All @@ -515,14 +512,14 @@ If no rules match, then the flags top-level `enabled` property is used as the fi

```yaml features.yml
flags:
- key: use-quicksort-algorithm
# ...
- segment:
key: internal-users
value: true
- threshold:
percentage: 20
value: true
- key: use-quicksort-algorithm
# ...
- segment:
key: internal-users
value: true
- threshold:
percentage: 20
value: true
```

This threshold percentage is set to `20`, meaning roughly `20%` of entity IDs will match and cause the flag to return `enabled = true`.
Expand Down Expand Up @@ -556,10 +553,10 @@ Once we get to the stage of enabling the flag for 100% of users, we can either s
version: "1.2"
namespace: default
flags:
- key: use-quicksort-algorithm
name: Use Quicksort Algorithm
type: BOOLEAN_FLAG_TYPE
enabled: true
- key: use-quicksort-algorithm
name: Use Quicksort Algorithm
type: BOOLEAN_FLAG_TYPE
enabled: true
```

Beyond this, we can further close the loop by removing the feature flag call from our application code and simply use the new `quicksort` function.
Expand Down

0 comments on commit 8adc9b1

Please sign in to comment.