diff --git a/client/replication.go b/client/replication.go index 7502a2a..b07b318 100755 --- a/client/replication.go +++ b/client/replication.go @@ -22,6 +22,7 @@ func GetReplicationBody(d *schema.ResourceData) models.ReplicationBody { Deletion: d.Get("deletion").(bool), DestNamespace: d.Get("dest_namespace").(string), DestNamespaceReplace: d.Get("dest_namespace_replace").(int), + CopyByChunk: d.Get("copy_by_chunk").(bool), Speed: d.Get("speed").(int), } diff --git a/docs/resources/replication.md b/docs/resources/replication.md index bf80b55..bf62cea 100644 --- a/docs/resources/replication.md +++ b/docs/resources/replication.md @@ -73,6 +73,7 @@ resource "harbor_replication" "alpine" { - `description` (String) Description of the replication policy. - `dest_namespace` (String) Specify the destination namespace. if empty, the resource will be put under the same namespace as the source. - `dest_namespace_replace` (Number) 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) +- `copy_by_chunk` (Boolean) Specify whether to enable the artifact blobs copied by chunks. (Default: `false`) - `enabled` (Boolean) Specify whether the replication is enabled. (Default: `true`) - `execute_on_changed` (Boolean) Specify whether to execute the replication rule if new or modified. (Default: `false`) - `filters` (Block Set) (see [below for nested schema](#nestedblock--filters)) diff --git a/models/replications.go b/models/replications.go index 53c81d8..3c95efe 100644 --- a/models/replications.go +++ b/models/replications.go @@ -21,11 +21,12 @@ type ReplicationBody struct { Cron string `json:"cron,omitempty"` } `json:"trigger_settings,omitempty"` } `json:"trigger,omitempty"` - Enabled bool `json:"enabled"` - Deletion bool `json:"deletion,omitempty"` - Override bool `json:"override,omitempty"` - Filters []ReplicationFilters `json:"filters,omitempty"` - Speed int `json:"speed,omitempty"` + Enabled bool `json:"enabled"` + Deletion bool `json:"deletion,omitempty"` + Override bool `json:"override,omitempty"` + CopyByChunk bool `json:"copy_by_chunk,omitempty"` + Filters []ReplicationFilters `json:"filters,omitempty"` + Speed int `json:"speed,omitempty"` } type ReplicationFilters struct { diff --git a/provider/resource_replication.go b/provider/resource_replication.go index 25fea2e..874e057 100644 --- a/provider/resource_replication.go +++ b/provider/resource_replication.go @@ -65,6 +65,11 @@ func resourceReplication() *schema.Resource { Optional: true, Default: true, }, + "copy_by_chunk": { + Type: schema.TypeBool, + Optional: true, + Default: false, + }, "filters": { Type: schema.TypeSet, Optional: true, @@ -201,6 +206,7 @@ func resourceReplicationRead(d *schema.ResourceData, m interface{}) error { d.Set("override", jsonDataReplication.Override) d.Set("dest_namespace", jsonDataReplication.DestNamespace) d.Set("dest_namespace_replace", jsonDataReplication.DestNamespaceReplace) + d.Set("copy_by_chunk", jsonDataReplication.CopyByChunk) return nil } diff --git a/provider/resource_replication_test.go b/provider/resource_replication_test.go index 4793b6a..413ecae 100644 --- a/provider/resource_replication_test.go +++ b/provider/resource_replication_test.go @@ -187,3 +187,24 @@ func testReplicationPolicyDestinationNamespaceWithReplaceCount(scheduleType stri } `, endpoint, scheduleType, destNamepace) } +func testReplicationPolicyWithCopyByChunk(scheduleType string, destNamepace int) string { + // endpoint := os.Getenv("HARBOR_REPLICATION_ENDPOINT") + endpoint := "https://hub.docker.com" + return fmt.Sprintf(` + resource "harbor_registry" "main" { + provider_name = "docker-hub" + name = "docker-hub-test-rep-pol" + endpoint_url = "%s" + } + + resource "harbor_replication" "pull" { + name = "test_pull" + action = "pull" + registry_id = harbor_registry.main.registry_id + schedule = "%s" + dest_namespace = "nobody_cares" + dest_namespace_replace = "%d" + copy_by_chunk = "true" + } + `, endpoint, scheduleType, destNamepace) +} diff --git a/templates/resources/replication.md.tmpl b/templates/resources/replication.md.tmpl index 888912d..1c91cc7 100644 --- a/templates/resources/replication.md.tmpl +++ b/templates/resources/replication.md.tmpl @@ -32,6 +32,7 @@ For example, the {{ .SchemaMarkdown }} template can be used to replace manual sc - `description` (String) Description of the replication policy. - `dest_namespace` (String) Specify the destination namespace. if empty, the resource will be put under the same namespace as the source. - `dest_namespace_replace` (Number) 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) +- `copy_by_chunk` (Boolean) Specify whether to enable the artifact blobs copied by chunks. (Default: `false`) - `enabled` (Boolean) Specify whether the replication is enabled. (Default: `true`) - `execute_on_changed` (Boolean) Specify whether to execute the replication rule if new or modified. (Default: `false`) - `filters` (Block Set) (see [below for nested schema](#nestedblock--filters))