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

feat(cloud): add environment configuration guide #277

Merged
merged 3 commits into from
Sep 30, 2024
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
3 changes: 2 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
cloud/overview.mdx
cloud/overview.mdx
cloud/guides/configuring-environments.mdx
3 changes: 2 additions & 1 deletion .vale.ini
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ Openly.A11Y = warning
Openly.Punctuation = warning
Openly.Spelling = disabled
Openly.So = warning
Openly.ThereIs = warning
Openly.ThereIs = warning
Openly.Titles = disabled
3 changes: 2 additions & 1 deletion cloud/features/approval-workflows.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ Once the pull request is merged, the changes will be deployed to the protected e
You can leverage GitHub's existing [Code
Owners](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners)
feature to automatically request reviews from specific teams or individuals
when a proposal is created. This is a great way to automate requesting the relevant teams and individuals for their approval input.
when a proposal is created. This is a great way to automate requesting the
relevant teams and individuals for their approval input.
</Tip>

## Evaluation
Expand Down
148 changes: 148 additions & 0 deletions cloud/guides/configuring-environments.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
---

Check warning on line 1 in cloud/guides/configuring-environments.mdx

View workflow job for this annotation

GitHub Actions / Vale

[vale] reported by reviewdog 🐶 [Openly.Readability] Grade level (10.43) too high! Raw Output: {"message": "[Openly.Readability] Grade level (10.43) too high!", "location": {"path": "cloud/guides/configuring-environments.mdx", "range": {"start": {"line": 1, "column": 1}}}, "severity": "WARNING"}
title: Configuring Environments
description: Learn how to configure different aspects of your Flipt environments
---

## Commit Messages, Pull-Request Titles and Bodies

Flipt Cloud dynamically generates commit messages and pull-requests based on parameters of the changes being made.
It passes these parameters through Go templates to produce the resulting messages.
While cloud is configured some sensible defaults, these can be overridden on a per Flipt environment basis.

To override these templates you must provide a `flipt.yaml` file at the root of your environment tree.

```console
.
└─ production
   └─ flipt.yaml
```

<Info>
An environment is a combination of a Git `repository`, a `branch`
name and `directory` path. These are selected when you create your environment
in Flipt Cloud. The `flipt.yaml` must exist in this directory and branch in
order to configure the relevant environment.
</Info>

When this file isn't provided, a default one is implicitly generated. The default is effectively the following:

Check warning on line 27 in cloud/guides/configuring-environments.mdx

View workflow job for this annotation

GitHub Actions / Vale

[vale] reported by reviewdog 🐶 [Microsoft.Adverbs] Remove 'effectively' if it's not important to the meaning of the statement. Raw Output: {"message": "[Microsoft.Adverbs] Remove 'effectively' if it's not important to the meaning of the statement.", "location": {"path": "cloud/guides/configuring-environments.mdx", "range": {"start": {"line": 27, "column": 86}}}, "severity": "WARNING"}

```yaml
version: "1.0"
templates:
commit_message: |-
{{- if eq (len .Changes) 1 }}
{{- (index .Changes 0) }}
{{- else -}}
updated multiple resources
{{ range $change := .Changes }}
{{ $change }}
{{- end }}
{{- end }}
proposal_title: "Flipt: Update features in {{ .Base.Name }}"
proposal_body: |-
Update Flipt resources in [{{ .Base.Name }}]({{ .Base.HostURL }})
The branched environment can be viewed at [{{ .Branch.Name }}]({{ .Branch.HostURL }})
```

### Commit Message

Commit message templates are supplied with a list of changes.
Currently, Flipt only provides a single change, however, this may change in the future. As such, the template provides a list of changes.
A change is a combination of a `verb` and `resource`.
A resource is a combination of `type`, `namespace` (when relevant) and `key`.

The following is a pseudo-schema for the context passed to this template:

```go Context
{
Changes: []Change{
{
Verb: string // e.g. create, update or delete
Resource: {
Type: {
Package: string // e.g. flipt.core
Name: string // e.g. Flag
}
Namespace: string // e.g. default
Key: string // e.g. my-flag-key
}
}
}
}
```

Simply printing out a change in the template (for example,`{{ (index .Changes 0) }}`) results in the following format:

```
<verb> <type> [<namespace>/]<key>
```

<Accordion title="Example: semantic commit messages">
The following gives an example of how to change the above template to produce semantic commits:

```yaml
version: "1.0"
templates:
commit_message: |-
{{- if eq (len .Changes) 1 }}
{{- printf "feat(flipt/%s): %s" .Environment.Name (index .Changes 0) }}
{{- else -}}
updated multiple resources
{{ range $change := .Changes }}
{{- printf "feat(flipt/%s): %s" .Environment.Name $change }}
{{- end }}
{{- end }}
```

</Accordion>

### Proposal (Pull-Request) Title and Body

Proposals (generated Pull-Requests) have a configurable title and body templates.
Both templates are provided with the `base` environment and the `branch` environment configuration.

The following is a pseudo-schema for the context passed to these templates:

```go Context
{
Base: {
Name: string // e.g. production
Organization: string // e.g. myorg
Host: string // e.g. production-myorg.flipt.cloud
Branch: string // e.g. main
Directory: string // e.g. production
}
Branch: {
Name: string // e.g. interestingcohen
Organization: string // e.g. myorg
Host: string // e.g. interestingcohen-production-myorg.flipt.cloud
Branch: string // e.g. flipt/production/interestingcohen
Directory: string // e.g. production
}
}
```

<AccordionGroup>
<Accordion title="Example: Title in semantic commit message style">
The following gives an example of how to change the above template to produce semantic commits:

```yaml
version: "1.0"
templates:
proposal_title: "feat: update feature flags in {{ .Base.Name }}"
```

</Accordion>
<Accordion title="Example: Body with organization">
The following gives an example of how to change the above template to produce semantic commits:

```yaml
version: "1.0"
templates:
proposal_body: |-
Update Flipt resources for the {{ .Base.Organization }} in [{{ .Base.Name }}]({{ .Base.HostURL }}).
The branched environment can be viewed at [{{ .Branch.Name }}]({{ .Branch.HostURL }}).
```

</Accordion>
</AccordionGroup>
3 changes: 2 additions & 1 deletion mint.json
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,8 @@
"group": "Guides",
"pages": [
"cloud/guides/getting-started",
"cloud/guides/production"
"cloud/guides/production",
"cloud/guides/configuring-environments"
]
},
{
Expand Down
Loading