Skip to content

Commit

Permalink
fix: recreate missing replication policy
Browse files Browse the repository at this point in the history
Fixes an issue when the replication policy can not be recreated if it was deleted outside of the Terraform code.
To reproduce an issue you need to create a replication policy as it's described in the documentation https://registry.terraform.io/providers/BESTSELLER/harbor/latest/docs/resources/replication
After the creation go to the Harbor web interface, delete the replication policy, and try to execute `terraform plan` or `terraform apply` again.
It will fail with the error: `Error: Resource not found /replication/policies/1`

The same fix was applied in PR #125 for other resources.
  • Loading branch information
sydorovdmytro committed Jun 16, 2021
1 parent 34bf1cf commit c062358
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions provider/resource_replication.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ func resourceReplicationRead(d *schema.ResourceData, m interface{}) error {
apiClient := m.(*client.Client)

resp, _, err := apiClient.SendRequest("GET", d.Id(), nil, 200)
if err != nil {
d.SetId("")
return nil
}

var jsonData models.RegistryBody
err = json.Unmarshal([]byte(resp), &jsonData)
Expand Down

0 comments on commit c062358

Please sign in to comment.