Skip to content

Commit

Permalink
docs: Update docs about refactoring the repo_mapping variable
Browse files Browse the repository at this point in the history
  • Loading branch information
fabidick22 committed Jul 12, 2023
1 parent 5ac9725 commit ffc4f5c
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 41 deletions.
23 changes: 17 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,28 @@ spec:
name: my-ecr-repo-ir
```
The webhook created by the `Receiver` resource has to be configured in the module, for example:
> **Note**: Let's assume that our ECR repository is called `my-ecr-repo`.

```hcl
module "flux2-ecr-webhook" {
source = "github.com/fabidick22/flux2-ecr-webhook?ref=v1.0.2"
source = "github.com/fabidick22/flux2-ecr-webhook?ref=v1.2.0"
app_name = "flux-ecr-webhook"
...
repo_mapping = {
my-ecr-repo = {
webhook = ["https://custom.domain.com/hook/11111111", "https://custom.domain.com/hook/2222222"]
my-ecr-repo = { # ECR resource name
prod = {
webhook = ["https://domain.com/hook/1111111"] # URL created by the Receiver
regex = "prod-(?P<version>.*)" # Regex for ECR image tag
}
stg = {
webhook = ["https://domain.com/hook/2222222"] # URL created by the Receiver
regex = "stg-(?P<version>.*)" # Regex for ECR image tag
}
}
}
...
webhook_token = "var.webhook_token"
}
```
## Example
Expand Down Expand Up @@ -101,7 +112,7 @@ module "flux2-ecr-webhook" {
|------|-------------|------|---------|:--------:|
| <a name="input_app_name"></a> [app\_name](#input\_app\_name) | Name used for resources to create. | `string` | `"flux2-ecr-webhook"` | no |
| <a name="input_cw_logs_retention"></a> [cw\_logs\_retention](#input\_cw\_logs\_retention) | Specifies the number of days you want to retain log events in the specified log group. | `number` | `14` | no |
| <a name="input_repo_mapping"></a> [repo\_mapping](#input\_repo\_mapping) | Object with repository mapping, if this variable is set `repo_mapping_file` will be ignored.<br>**Example:**<pre>{<br> ecr-repo-name = {<br> webhook = ["https://gitops.domain.com/hook/111111" ]<br> }<br> test/ecr-repo-name = {<br> webhook = ["https://gitops.domain.com/hook/111111", "https://gitops.domain.com/hook/222222" ]<br> token = "webhook-token "<br> }<br>}</pre> | `any` | `null` | no |
| <a name="input_repo_mapping"></a> [repo\_mapping](#input\_repo\_mapping) | Object with repository mapping, if this variable is set `repo_mapping_file` will be ignored.<br><br>**Available Attributes:**<br>- `<ECR>`: ECR resource name.<br>- `<ECR>.<ID>`: Unique name for webhooks.<br>- `<ECR>.<ID>.webhook`: Webhook list.<br>- `<ECR>.<ID>.token` (Optional): Token used for webhooks, if set, then "webhook\_token" will be ignored.<br>- `<ECR>.<ID>.regex` (Optional): Regular expression that is applied to the image tag | `any` | `null` | no |
| <a name="input_repo_mapping_file"></a> [repo\_mapping\_file](#input\_repo\_mapping\_file) | YAML file path with repository mapping. | `string` | `""` | no |
| <a name="input_webhook_token"></a> [webhook\_token](#input\_webhook\_token) | Webhook default token used to call the Flux receiver. If it doesn't find a `token` attribute in the repository mapping use this token for the webhooks | `string` | `null` | no |

Expand Down
21 changes: 16 additions & 5 deletions docs/tf-docs/header.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,28 @@ spec:
name: my-ecr-repo-ir
```
The webhook created by the `Receiver` resource has to be configured in the module, for example:
> **Note**: Let's assume that our ECR repository is called `my-ecr-repo`.

```hcl
module "flux2-ecr-webhook" {
source = "github.com/fabidick22/flux2-ecr-webhook?ref=v1.0.2"
source = "github.com/fabidick22/flux2-ecr-webhook?ref=v1.2.0"
app_name = "flux-ecr-webhook"
...
repo_mapping = {
my-ecr-repo = {
webhook = ["https://custom.domain.com/hook/11111111", "https://custom.domain.com/hook/2222222"]
my-ecr-repo = { # ECR resource name
prod = {
webhook = ["https://domain.com/hook/1111111"] # URL created by the Receiver
regex = "prod-(?P<version>.*)" # Regex for ECR image tag
}
stg = {
webhook = ["https://domain.com/hook/2222222"] # URL created by the Receiver
regex = "stg-(?P<version>.*)" # Regex for ECR image tag
}
}
}
...
webhook_token = "var.webhook_token"
}
```
## Example
Expand Down
34 changes: 17 additions & 17 deletions examples/complete/main.tf
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@

module "flux2-ecr-webhook" {
source = "../../"

app_name = "flux2-ecr-webhook"
repo_mapping_file = "repos.yml" # Deprecated
webhook_token = "WEBHOOK-TOKEN" # Keep this token safe, you can use sops (mozilla/sops).
cw_logs_retention = 7
}

module "flux2-ecr-webhook2" {
source = "../../"

app_name = "flux2-ecr-webhook2"
repo_mapping = {
test/my-ecr-repo = {
webhook = "https://gitops.domain.com/hook/11111111111"
"test/my-ecr-repo" = {
production = {
webhook = ["https://gitops.domain.com/hook/11111111111"]
}
}
}
webhook_token = "WEBHOOK-TOKEN" # Keep this token safe, you can use sops (mozilla/sops).
Expand All @@ -26,15 +19,22 @@ module "flux2-ecr-webhook3" {
app_name = "flux2-ecr-webhook3"
repo_mapping = {
my-ecr-repo = {
webhook = "https://gitops.domain.com/hook/11111111111"
token = "WEBHOOK-TOKEN" # Keep this token safe, you can use sops (mozilla/sops).
prod = {
webhook = ["https://gitops.domain.com/hook/11111111111"]
}
}
my-ecr-repo2 = {
webhook = "https://gitops.domain.com/hook/11111111111"
prod = {
webhook = ["https://gitops.domain.com/hook/11111111111"]
regex = "prod-(?P<version>.*)" # Regex for ECR image tag
}
}
my-ecr-repo3 = {
webhook = "https://gitops.domain.com/hook/11111111111"
prod = {
webhook = ["https://gitops.domain.com/hook/11111111111"]
token = "WEBHOOK-TOKEN" # Custom token (you can use mozilla/sops).
}
}
}
webhook_token = "WEBHOOK-TOKEN" # Keep this token safe, you can use sops (mozilla/sops).
}
webhook_token = "WEBHOOK-TOKEN" # Webhook token (you can use mozilla/sops).
}
19 changes: 6 additions & 13 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,15 @@ variable "repo_mapping" {
type = any
default = null
sensitive = true
#description = "Object with repository mapping, if this variable is set `repo_mapping_file` will be ignored."
description = <<EOT
Object with repository mapping, if this variable is set `repo_mapping_file` will be ignored.
**Example:**
```
{
ecr-repo-name = {
webhook = ["https://gitops.domain.com/hook/111111" ]
}
test/ecr-repo-name = {
webhook = ["https://gitops.domain.com/hook/111111", "https://gitops.domain.com/hook/222222" ]
token = "webhook-token "
}
}
```
**Available Attributes:**
- `<ECR>`: ECR resource name.
- `<ECR>.<ID>`: Unique name for webhooks.
- `<ECR>.<ID>.webhook`: Webhook list.
- `<ECR>.<ID>.token` (Optional): Token used for webhooks, if set, then "webhook_token" will be ignored.
- `<ECR>.<ID>.regex` (Optional): Regular expression that is applied to the image tag
EOT
}
Expand Down

0 comments on commit ffc4f5c

Please sign in to comment.