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

Fix creation of replications with dest_namespace_replace = 0 #314

Merged
merged 4 commits into from
Jun 5, 2023
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
2 changes: 1 addition & 1 deletion docs/resources/replication.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ The following arguments are supported:
* **enabled** - (Optional) Specify whether the replication is enabled. Can be set to `true` or `false` (Default: `true`)
* **description** - (Optional) Description of the replication policy.
* **dest_namespace** - (Optional) Specify the destination namespace. if empty, the resource will be put under the same namespace as the source.
* **dest_namespace_replace** - (Optional) Specify the destination namespace flattening policy. Integers from `-1` to `3` are valid values in the harbor API. A value of `-1` will 'Flatten All Levels', `0` means 'No Flattening', `1` 'Flatten 1 Level', `2` 'Flatten 2 Levels', `3` 'Flatten 3 Levels' (Default: `0`, see [Replication Rules](https://goharbor.io/docs/latest/administration/configuring-replication/create-replication-rules/) for more details)
* **dest_namespace_replace** - (Optional) Specify the destination namespace flattening policy. Integers from `-1` to `3` are valid values in the harbor API. A value of `-1` will 'Flatten All Levels', `0` means 'No Flattening', `1` 'Flatten 1 Level', `2` 'Flatten 2 Levels', `3` 'Flatten 3 Levels' (Default: `-1`, see [Replication Rules](https://goharbor.io/docs/latest/administration/configuring-replication/create-replication-rules/) for more details)
* **deletion** - (Optional) Specify whether to delete the remote resources when locally deleted. Can be set to `true` or `false` (Default: `false`)

* **filters** - (Optional) A collection of `filters` block as documented below.
Expand Down
2 changes: 1 addition & 1 deletion models/replications.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type ReplicationBody struct {
ID int `json:"id,omitempty"`
} `json:"dest_registry,omitempty"`
DestNamespace string `json:"dest_namespace,omitempty"`
DestNamespaceReplace int `json:"dest_namespace_replace_count,omitempty"`
DestNamespaceReplace int `json:"dest_namespace_replace_count"`
Trigger struct {
Type string `json:"type,omitempty"`
TriggerSettings struct {
Expand Down
4 changes: 3 additions & 1 deletion provider/resource_replication.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func resourceReplication() *schema.Resource {
"speed": {
Type: schema.TypeInt,
Optional: true,
Default: -1,
Default: -1,
},
},
Create: resourceReplicationCreate,
Expand Down Expand Up @@ -173,6 +173,8 @@ func resourceReplicationRead(d *schema.ResourceData, m interface{}) error {
d.Set("name", jsonDataReplication.Name)
d.Set("deletion", jsonDataReplication.Deletion)
d.Set("override", jsonDataReplication.Override)
d.Set("dest_namespace", jsonDataReplication.DestNamespace)
d.Set("dest_namespace_replace", jsonDataReplication.DestNamespaceReplace)

return nil
}
Expand Down