Skip to content

Commit cd3014a

Browse files
mhodgsontimofurrer
authored andcommitted
Update SAML link read to use new Get endpoint
1 parent a74f767 commit cd3014a

File tree

1 file changed

+7
-18
lines changed

1 file changed

+7
-18
lines changed

internal/provider/resource_gitlab_group_saml_link.go

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -88,31 +88,20 @@ func resourceGitlabGroupSamlLinkRead(ctx context.Context, d *schema.ResourceData
8888

8989
// Try to fetch all group links from GitLab
9090
log.Printf("[DEBUG] Read GitLab group SamlLinks %s", group)
91-
samlLinks, _, err := client.Groups.ListGroupSAMLLinks(group, nil, gitlab.WithContext(ctx))
91+
samlLink, _, err := client.Groups.GetGroupSAMLLink(group, samlGroupName, nil, gitlab.WithContext(ctx))
9292
if err != nil {
93-
return diag.FromErr(err)
94-
}
95-
96-
if samlLinks != nil {
97-
// Check if the SAML link exists in the returned list of links
98-
found := false
99-
for _, samlLink := range samlLinks {
100-
if samlLink.Name == samlGroupName {
101-
d.Set("group", group)
102-
d.Set("access_level", samlLink.AccessLevel)
103-
d.Set("saml_group_name", samlLink.Name)
104-
found = true
105-
break
106-
}
107-
}
108-
109-
if !found {
93+
if is404(err) {
11094
log.Printf("[DEBUG] GitLab SAML Group Link %d, group ID %s not found, removing from state", samlGroupName, group)
11195
d.SetId("")
11296
return nil
11397
}
98+
return diag.FromErr(err)
11499
}
115100

101+
d.Set("group", group)
102+
d.Set("access_level", samlLink.AccessLevel)
103+
d.Set("saml_group_name", samlLink.Name)
104+
116105
return nil
117106
}
118107

0 commit comments

Comments
 (0)