Skip to content

Commit ffc4f5c

Browse files
committed
docs: Update docs about refactoring the repo_mapping variable
1 parent 5ac9725 commit ffc4f5c

File tree

4 files changed

+56
-41
lines changed

4 files changed

+56
-41
lines changed

README.md

+17-6
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,28 @@ spec:
4242
name: my-ecr-repo-ir
4343
```
4444
The webhook created by the `Receiver` resource has to be configured in the module, for example:
45+
> **Note**: Let's assume that our ECR repository is called `my-ecr-repo`.
46+
4547
```hcl
4648
module "flux2-ecr-webhook" {
47-
source = "github.com/fabidick22/flux2-ecr-webhook?ref=v1.0.2"
49+
source = "github.com/fabidick22/flux2-ecr-webhook?ref=v1.2.0"
50+
51+
app_name = "flux-ecr-webhook"
4852
49-
...
5053
repo_mapping = {
51-
my-ecr-repo = {
52-
webhook = ["https://custom.domain.com/hook/11111111", "https://custom.domain.com/hook/2222222"]
54+
my-ecr-repo = { # ECR resource name
55+
prod = {
56+
webhook = ["https://domain.com/hook/1111111"] # URL created by the Receiver
57+
regex = "prod-(?P<version>.*)" # Regex for ECR image tag
58+
}
59+
stg = {
60+
webhook = ["https://domain.com/hook/2222222"] # URL created by the Receiver
61+
regex = "stg-(?P<version>.*)" # Regex for ECR image tag
62+
}
5363
}
5464
}
55-
...
65+
66+
webhook_token = "var.webhook_token"
5667
}
5768
```
5869
## Example
@@ -101,7 +112,7 @@ module "flux2-ecr-webhook" {
101112
|------|-------------|------|---------|:--------:|
102113
| <a name="input_app_name"></a> [app\_name](#input\_app\_name) | Name used for resources to create. | `string` | `"flux2-ecr-webhook"` | no |
103114
| <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 |
104-
| <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 |
115+
| <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 |
105116
| <a name="input_repo_mapping_file"></a> [repo\_mapping\_file](#input\_repo\_mapping\_file) | YAML file path with repository mapping. | `string` | `""` | no |
106117
| <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 |
107118

docs/tf-docs/header.md

+16-5
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,28 @@ spec:
4242
name: my-ecr-repo-ir
4343
```
4444
The webhook created by the `Receiver` resource has to be configured in the module, for example:
45+
> **Note**: Let's assume that our ECR repository is called `my-ecr-repo`.
46+
4547
```hcl
4648
module "flux2-ecr-webhook" {
47-
source = "github.com/fabidick22/flux2-ecr-webhook?ref=v1.0.2"
49+
source = "github.com/fabidick22/flux2-ecr-webhook?ref=v1.2.0"
50+
51+
app_name = "flux-ecr-webhook"
4852
49-
...
5053
repo_mapping = {
51-
my-ecr-repo = {
52-
webhook = ["https://custom.domain.com/hook/11111111", "https://custom.domain.com/hook/2222222"]
54+
my-ecr-repo = { # ECR resource name
55+
prod = {
56+
webhook = ["https://domain.com/hook/1111111"] # URL created by the Receiver
57+
regex = "prod-(?P<version>.*)" # Regex for ECR image tag
58+
}
59+
stg = {
60+
webhook = ["https://domain.com/hook/2222222"] # URL created by the Receiver
61+
regex = "stg-(?P<version>.*)" # Regex for ECR image tag
62+
}
5363
}
5464
}
55-
...
65+
66+
webhook_token = "var.webhook_token"
5667
}
5768
```
5869
## Example

examples/complete/main.tf

+17-17
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,13 @@
11

2-
module "flux2-ecr-webhook" {
3-
source = "../../"
4-
5-
app_name = "flux2-ecr-webhook"
6-
repo_mapping_file = "repos.yml" # Deprecated
7-
webhook_token = "WEBHOOK-TOKEN" # Keep this token safe, you can use sops (mozilla/sops).
8-
cw_logs_retention = 7
9-
}
10-
112
module "flux2-ecr-webhook2" {
123
source = "../../"
134

145
app_name = "flux2-ecr-webhook2"
156
repo_mapping = {
16-
test/my-ecr-repo = {
17-
webhook = "https://gitops.domain.com/hook/11111111111"
7+
"test/my-ecr-repo" = {
8+
production = {
9+
webhook = ["https://gitops.domain.com/hook/11111111111"]
10+
}
1811
}
1912
}
2013
webhook_token = "WEBHOOK-TOKEN" # Keep this token safe, you can use sops (mozilla/sops).
@@ -26,15 +19,22 @@ module "flux2-ecr-webhook3" {
2619
app_name = "flux2-ecr-webhook3"
2720
repo_mapping = {
2821
my-ecr-repo = {
29-
webhook = "https://gitops.domain.com/hook/11111111111"
30-
token = "WEBHOOK-TOKEN" # Keep this token safe, you can use sops (mozilla/sops).
22+
prod = {
23+
webhook = ["https://gitops.domain.com/hook/11111111111"]
24+
}
3125
}
3226
my-ecr-repo2 = {
33-
webhook = "https://gitops.domain.com/hook/11111111111"
27+
prod = {
28+
webhook = ["https://gitops.domain.com/hook/11111111111"]
29+
regex = "prod-(?P<version>.*)" # Regex for ECR image tag
30+
}
3431
}
3532
my-ecr-repo3 = {
36-
webhook = "https://gitops.domain.com/hook/11111111111"
33+
prod = {
34+
webhook = ["https://gitops.domain.com/hook/11111111111"]
35+
token = "WEBHOOK-TOKEN" # Custom token (you can use mozilla/sops).
36+
}
3737
}
3838
}
39-
webhook_token = "WEBHOOK-TOKEN" # Keep this token safe, you can use sops (mozilla/sops).
40-
}
39+
webhook_token = "WEBHOOK-TOKEN" # Webhook token (you can use mozilla/sops).
40+
}

variables.tf

+6-13
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,15 @@ variable "repo_mapping" {
1414
type = any
1515
default = null
1616
sensitive = true
17-
#description = "Object with repository mapping, if this variable is set `repo_mapping_file` will be ignored."
1817
description = <<EOT
1918
Object with repository mapping, if this variable is set `repo_mapping_file` will be ignored.
20-
**Example:**
2119
22-
```
23-
{
24-
ecr-repo-name = {
25-
webhook = ["https://gitops.domain.com/hook/111111" ]
26-
}
27-
test/ecr-repo-name = {
28-
webhook = ["https://gitops.domain.com/hook/111111", "https://gitops.domain.com/hook/222222" ]
29-
token = "webhook-token "
30-
}
31-
}
32-
```
20+
**Available Attributes:**
21+
- `<ECR>`: ECR resource name.
22+
- `<ECR>.<ID>`: Unique name for webhooks.
23+
- `<ECR>.<ID>.webhook`: Webhook list.
24+
- `<ECR>.<ID>.token` (Optional): Token used for webhooks, if set, then "webhook_token" will be ignored.
25+
- `<ECR>.<ID>.regex` (Optional): Regular expression that is applied to the image tag
3326
3427
EOT
3528
}

0 commit comments

Comments
 (0)