diff --git a/argocd/resource_argocd_application.go b/argocd/resource_argocd_application.go index 5760bc84..bfa927c6 100644 --- a/argocd/resource_argocd_application.go +++ b/argocd/resource_argocd_application.go @@ -150,7 +150,7 @@ func resourceArgoCDApplicationDelete(d *schema.ResourceData, meta interface{}) e c := *server.ApplicationClient appName := d.Id() _, err := c.Delete(context.Background(), &applicationClient.ApplicationDeleteRequest{Name: &appName}) - if err != nil { + if err != nil && !strings.Contains(err.Error(), "NotFound") { return err } d.SetId("") diff --git a/argocd/resource_argocd_project.go b/argocd/resource_argocd_project.go index 9f6b7f3d..d99ccfc4 100644 --- a/argocd/resource_argocd_project.go +++ b/argocd/resource_argocd_project.go @@ -174,7 +174,7 @@ func resourceArgoCDProjectDelete(d *schema.ResourceData, meta interface{}) error _, err := c.Delete(context.Background(), &projectClient.ProjectQuery{Name: projectName}) tokenMutexProjectMap[projectName].Unlock() - if err != nil { + if err != nil && !strings.Contains(err.Error(), "NotFound") { return err } d.SetId("") diff --git a/argocd/resource_argocd_repository.go b/argocd/resource_argocd_repository.go index 604f5de3..9f01f858 100644 --- a/argocd/resource_argocd_repository.go +++ b/argocd/resource_argocd_repository.go @@ -71,7 +71,7 @@ func resourceArgoCDRepositoryRead(d *schema.ResourceData, meta interface{}) erro tokenMutexConfiguration.RLock() r, err = c.Get(context.Background(), &repository.RepoQuery{ Repo: d.Id(), - ForceRefresh: false, + ForceRefresh: true, }) tokenMutexConfiguration.RUnlock() @@ -89,7 +89,7 @@ func resourceArgoCDRepositoryRead(d *schema.ResourceData, meta interface{}) erro tokenMutexConfiguration.RLock() rl, err := c.ListRepositories(context.Background(), &repository.RepoQuery{ Repo: d.Id(), - ForceRefresh: false, + ForceRefresh: true, }) tokenMutexConfiguration.RUnlock() @@ -165,7 +165,14 @@ func resourceArgoCDRepositoryDelete(d *schema.ResourceData, meta interface{}) er tokenMutexConfiguration.Unlock() if err != nil { - return err + switch strings.Contains(err.Error(), "NotFound") { + // Repository has already been deleted in an out-of-band fashion + case true: + d.SetId("") + return nil + default: + return err + } } d.SetId("") return nil diff --git a/argocd/resource_argocd_repository_credentials.go b/argocd/resource_argocd_repository_credentials.go index 5b15d3f9..7f5841c5 100644 --- a/argocd/resource_argocd_repository_credentials.go +++ b/argocd/resource_argocd_repository_credentials.go @@ -117,7 +117,14 @@ func resourceArgoCDRepositoryCredentialsDelete(d *schema.ResourceData, meta inte tokenMutexConfiguration.Unlock() if err != nil { - return err + switch strings.Contains(err.Error(), "NotFound") { + // Repository credentials have already been deleted in an out-of-band fashion + case true: + d.SetId("") + return nil + default: + return err + } } d.SetId("") return nil