From c062358a649bf7fbab2429ad46cc58f839c290fe Mon Sep 17 00:00:00 2001 From: Dmytro Sydorov Date: Wed, 16 Jun 2021 15:26:14 +0200 Subject: [PATCH] fix: recreate missing replication policy 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. --- provider/resource_replication.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/provider/resource_replication.go b/provider/resource_replication.go index 5cd4248..0317e9b 100644 --- a/provider/resource_replication.go +++ b/provider/resource_replication.go @@ -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)