From b173eeb43856248f5ce5cf92217b0ab65d788c84 Mon Sep 17 00:00:00 2001 From: Yurii Matsiuk <24990891+ymatsiuk@users.noreply.github.com> Date: Thu, 28 Nov 2019 01:00:12 +0100 Subject: [PATCH] Make read callbacks graceful for gitlab_project_share_group, gitlab_branch_protection and gitlab_label resources (#223) --- gitlab/resource_gitlab_branch_protection.go | 4 +++- gitlab/resource_gitlab_label.go | 4 +++- gitlab/resource_gitlab_project_share_group.go | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/gitlab/resource_gitlab_branch_protection.go b/gitlab/resource_gitlab_branch_protection.go index 66cda5e50..09bb8288e 100644 --- a/gitlab/resource_gitlab_branch_protection.go +++ b/gitlab/resource_gitlab_branch_protection.go @@ -89,7 +89,9 @@ func resourceGitlabBranchProtectionRead(d *schema.ResourceData, meta interface{} pb, _, err := client.ProtectedBranches.GetProtectedBranch(project, branch) if err != nil { - return err + log.Printf("[DEBUG] failed to read gitlab branch protection for project %s, branch %s: %s", project, branch, err) + d.SetId("") + return nil } d.Set("project", project) diff --git a/gitlab/resource_gitlab_label.go b/gitlab/resource_gitlab_label.go index 31ac40fdd..675ab4e97 100644 --- a/gitlab/resource_gitlab_label.go +++ b/gitlab/resource_gitlab_label.go @@ -70,7 +70,9 @@ func resourceGitlabLabelRead(d *schema.ResourceData, meta interface{}) error { labels, _, err := client.Labels.ListLabels(project, nil) if err != nil { - return err + log.Printf("[DEBUG] failed to read gitlab label %s/%s: %s", project, labelName, err) + d.SetId("") + return nil } found := false for _, label := range labels { diff --git a/gitlab/resource_gitlab_project_share_group.go b/gitlab/resource_gitlab_project_share_group.go index 1eb0aa034..ec8af0ee8 100644 --- a/gitlab/resource_gitlab_project_share_group.go +++ b/gitlab/resource_gitlab_project_share_group.go @@ -76,7 +76,9 @@ func resourceGitlabProjectShareGroupRead(d *schema.ResourceData, meta interface{ projectInformation, _, err := client.Projects.GetProject(projectId, nil) if err != nil { - return err + log.Printf("[DEBUG] failed to read gitlab project %s: %s", id, err) + d.SetId("") + return nil } for _, v := range projectInformation.SharedWithGroups {