Skip to content

Commit 4ebebe4

Browse files
authored
New Resource for handle Harbor Replication Policies (#15)
Add Replica Policy Ressource
1 parent dca2ba0 commit 4ebebe4

File tree

8 files changed

+521
-3
lines changed

8 files changed

+521
-3
lines changed

docs/guides/knowingProblems.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Swagger MissMatches
2+
3+
Page for Colleting Swagger ApiClient Issues.
4+
5+
## `#/definitions/ReplicationPolicy`
6+
7+
```json
8+
"filters": [
9+
{
10+
"type": "name",
11+
"value": "test"
12+
},
13+
...
14+
{
15+
"type": "label",
16+
"value": [
17+
"testlabel-acc-classic"
18+
]
19+
}
20+
...
21+
]
22+
...
23+
```
24+
25+
```swagger
26+
"filters": [
27+
{
28+
"type": "string",
29+
"value": "string"
30+
}
31+
],
32+
````

docs/resources/harbor_registry.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ resource "harbor_registry" "helmhub" {
1919

2020
The following arguments are supported:
2121

22-
* `name` - (Required) The of the project that will be created in harbor.
22+
* `name` - (Required) of the project that will be created in harbor.
2323

2424
* `url` - (Required) The registry remote endpoint, like `https://hub.docker.com`.
2525

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# Resource: harbor_replication
2+
3+
Harbor Doc: [configuring-replication](https://goharbor.io/docs/2.0.0/administration/configuring-replication/)
4+
5+
6+
## Example Usage
7+
8+
```hcl
9+
data "harbor_project" "project_replica" {
10+
name = "main"
11+
}
12+
13+
data "harbor_registry" "registry_helm_hub" {
14+
name = "helmhub"
15+
}
16+
17+
data "harbor_registry" "registry_docker_hub" {
18+
name = "dockerhub"
19+
}
20+
21+
resource "harbor_replication" "pull_based_helm" {
22+
name = "acc-helm-prometheus-operator-test"
23+
description = "Prometheus Operator Replica"
24+
source_registry_id = data.harbor_registry.registry_replica_helm_hub.id
25+
source_registry_filter_name = "stable/prometheus-operator"
26+
source_registry_filter_tag = "**"
27+
destination_namespace = data.harbor_project.project_replica.name
28+
}
29+
30+
resource "harbor_replication_pull" "push_based_docker" {
31+
name = "docker-push"
32+
description = "Push Docker"
33+
destination_registry_id = data.harbor_registry.registry_docker_hub.id
34+
destination_namespace = "notexisting"
35+
source_registry_filter_name = "${data.harbor_project.project_replica.name}/vscode-devcontainers/k8s-operator"
36+
source_registry_filter_tag = "**"
37+
}
38+
39+
```
40+
41+
## Argument Reference
42+
43+
The following arguments are supported:
44+
45+
* `name` - (Required) of the replication that will be created in harbor.
46+
47+
* `description` - (Optional) of replication that will be displayed in harbor.
48+
49+
* `source_registry_id` - (Optional) Used for pull the resources from the remote registry to the local Harbor.
50+
51+
* `source_registry_filter_name` - (Optional) Filter the name of the resource. Leave empty or use '\*\*' to match all. 'library/\*\*' only matches resources under 'library'.
52+
53+
* `source_registry_filter_tag` - (Optional) Filter the tag/version part of the resources. Leave empty or use '\*\*' to match all. '1.0*' only matches the tags that starts with '1.0'.
54+
55+
* `destination_namespace` - (Optional) Destination namespace Specify the destination namespace. If empty, the resources will be put under the same namespace as the source.
56+
57+
* `destination_registry_id` - (Optional) The target Registry ID, used only for `push-based` replications.
58+
59+
* `trigger_mode` - (Optional) Can be `manual`,`scheduled` and for push-based addition `event_based`, Default: `manual`
60+
61+
* `trigger_cron` - (Optional) Used cron for `scheduled` trigger mode, like `* * 5 * * *`
62+
63+
* `override` - (Optional) Specify whether to override the resources at the destination if a resource with the same name exists. Default: `false`
64+
65+
* `enabled` - (Optional)
66+
67+
68+
## Attributes Reference
69+
70+
In addition to all argument, the following attributes are exported:
71+
72+
* `id` - The id of the registry policy with harbor.
73+
74+
## Import
75+
76+
Harbor Projects can be imported using the `harbor_replication`, e.g.
77+
78+
```sh
79+
terraform import harbor_replication.helmhub_prometheus 1
80+
```

harbor/provider.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ func Provider() terraform.ResourceProvider {
5454
"harbor_robot_account": resourceRobotAccount(),
5555
"harbor_tasks": resourceTasks(),
5656
"harbor_label": resourceLabel(),
57+
"harbor_replication": resourceReplication(),
5758
},
5859
DataSourcesMap: map[string]*schema.Resource{
5960
"harbor_project": dataSourceProject(),

0 commit comments

Comments
 (0)