Skip to content

Commit

Permalink
Make read callbacks graceful for gitlab_project_share_group, gitlab_b…
Browse files Browse the repository at this point in the history
…ranch_protection and gitlab_label resources (#223)
  • Loading branch information
ymatsiuk authored and roidelapluie committed Nov 28, 2019
1 parent 5d0afe0 commit b173eeb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
4 changes: 3 additions & 1 deletion gitlab/resource_gitlab_branch_protection.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion gitlab/resource_gitlab_label.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 3 additions & 1 deletion gitlab/resource_gitlab_project_share_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit b173eeb

Please sign in to comment.