Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@ jobs:
cache: true

- name: golangci-lint
uses: golangci/golangci-lint-action@v6
uses: golangci/golangci-lint-action@v9
with:
version: latest
26 changes: 13 additions & 13 deletions internal/client/group_membership.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func (c *Client) GetGroup(groupID string) (*GetGroupData, error) {
if err != nil {
return nil, fmt.Errorf("request: %w", err)
}
defer resp.Body.Close()
defer func() { _ = resp.Body.Close() }()

if resp.StatusCode != http.StatusOK {
body, _ := io.ReadAll(resp.Body)
Expand Down Expand Up @@ -143,7 +143,7 @@ func (c *Client) CreateGroupMembership(groupID, userID, roleID string) (membersh
if err != nil {
return "", fmt.Errorf("request: %w", err)
}
defer resp.Body.Close()
defer func() { _ = resp.Body.Close() }()

respBody, _ := io.ReadAll(resp.Body)
if resp.StatusCode == http.StatusConflict {
Expand Down Expand Up @@ -190,16 +190,16 @@ func (c *Client) ListGroupMemberships(groupID string) ([]ListGroupMembershipItem

if resp.StatusCode != http.StatusOK {
body, _ := io.ReadAll(resp.Body)
resp.Body.Close()
_ = resp.Body.Close()
return nil, fmt.Errorf("list group memberships: status %d: %s", resp.StatusCode, string(body))
}

var out ListGroupMembershipsResponse
if err := json.NewDecoder(resp.Body).Decode(&out); err != nil {
resp.Body.Close()
_ = resp.Body.Close()
return nil, fmt.Errorf("decode response: %w", err)
}
resp.Body.Close()
_ = resp.Body.Close()

all = append(all, out.Data...)
if out.Links == nil || out.Links.Next == "" {
Expand Down Expand Up @@ -227,16 +227,16 @@ func (c *Client) GetGroupMembershipByID(groupID, membershipID string) (*ListGrou

if resp.StatusCode != http.StatusOK {
body, _ := io.ReadAll(resp.Body)
resp.Body.Close()
_ = resp.Body.Close()
return nil, fmt.Errorf("list group memberships: status %d: %s", resp.StatusCode, string(body))
}

var out ListGroupMembershipsResponse
if err := json.NewDecoder(resp.Body).Decode(&out); err != nil {
resp.Body.Close()
_ = resp.Body.Close()
return nil, fmt.Errorf("decode response: %w", err)
}
resp.Body.Close()
_ = resp.Body.Close()

for i := range out.Data {
if out.Data[i].ID == membershipID {
Expand Down Expand Up @@ -273,16 +273,16 @@ func (c *Client) getGroupMembershipIDOfUser(groupID, userID string) (string, err

if resp.StatusCode != http.StatusOK {
body, _ := io.ReadAll(resp.Body)
resp.Body.Close()
_ = resp.Body.Close()
return "", fmt.Errorf("list group memberships: status %d: %s", resp.StatusCode, string(body))
}

var out ListGroupMembershipsResponse
if err := json.NewDecoder(resp.Body).Decode(&out); err != nil {
resp.Body.Close()
_ = resp.Body.Close()
return "", fmt.Errorf("decode response: %w", err)
}
resp.Body.Close()
_ = resp.Body.Close()

if len(out.Data) > 0 {
return out.Data[0].ID, nil
Expand Down Expand Up @@ -323,7 +323,7 @@ func (c *Client) UpdateGroupMembership(groupID, membershipID, roleID string) err
if err != nil {
return fmt.Errorf("request: %w", err)
}
defer resp.Body.Close()
defer func() { _ = resp.Body.Close() }()

respBody, _ := io.ReadAll(resp.Body)
if resp.StatusCode != http.StatusOK && resp.StatusCode != http.StatusNoContent {
Expand Down Expand Up @@ -351,7 +351,7 @@ func (c *Client) DeleteGroupMembership(groupID, membershipID string, cascade boo
if err != nil {
return fmt.Errorf("request: %w", err)
}
defer resp.Body.Close()
defer func() { _ = resp.Body.Close() }()

if resp.StatusCode != http.StatusNoContent && resp.StatusCode != http.StatusOK {
body, _ := io.ReadAll(resp.Body)
Expand Down
6 changes: 3 additions & 3 deletions internal/client/group_orgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,16 @@ func (c *Client) ListGroupOrgs(groupID string) ([]OrgItem, error) {

if resp.StatusCode != http.StatusOK {
body, _ := io.ReadAll(resp.Body)
resp.Body.Close()
_ = resp.Body.Close()
return nil, fmt.Errorf("list group orgs: status %d: %s", resp.StatusCode, string(body))
}

var out ListGroupOrgsResponse
if err := json.NewDecoder(resp.Body).Decode(&out); err != nil {
resp.Body.Close()
_ = resp.Body.Close()
return nil, fmt.Errorf("decode response: %w", err)
}
resp.Body.Close()
_ = resp.Body.Close()

all = append(all, out.Data...)
if out.Links == nil || out.Links.Next == "" {
Expand Down
2 changes: 1 addition & 1 deletion internal/client/group_roles.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func (c *Client) ListGroupRolesV1(groupID string) ([]RoleItem, error) {
if err != nil {
return nil, fmt.Errorf("request: %w", err)
}
defer resp.Body.Close()
defer func() { _ = resp.Body.Close() }()

if resp.StatusCode != http.StatusOK {
body, _ := io.ReadAll(resp.Body)
Expand Down
18 changes: 9 additions & 9 deletions internal/client/org_membership.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func (c *Client) CreateOrgMembership(orgID, userID, roleID string) (membershipID
if err != nil {
return "", fmt.Errorf("request: %w", err)
}
defer resp.Body.Close()
defer func() { _ = resp.Body.Close() }()

respBody, _ := io.ReadAll(resp.Body)
if resp.StatusCode != http.StatusCreated {
Expand Down Expand Up @@ -129,16 +129,16 @@ func (c *Client) ListOrgMemberships(orgID string) ([]ListOrgMembershipItem, erro

if resp.StatusCode != http.StatusOK {
body, _ := io.ReadAll(resp.Body)
resp.Body.Close()
_ = resp.Body.Close()
return nil, fmt.Errorf("list org memberships: status %d: %s", resp.StatusCode, string(body))
}

var out ListOrgMembershipsResponse
if err := json.NewDecoder(resp.Body).Decode(&out); err != nil {
resp.Body.Close()
_ = resp.Body.Close()
return nil, fmt.Errorf("decode response: %w", err)
}
resp.Body.Close()
_ = resp.Body.Close()

all = append(all, out.Data...)
if out.Links == nil || out.Links.Next == "" {
Expand Down Expand Up @@ -166,16 +166,16 @@ func (c *Client) GetOrgMembershipByID(orgID, membershipID string) (*ListOrgMembe

if resp.StatusCode != http.StatusOK {
body, _ := io.ReadAll(resp.Body)
resp.Body.Close()
_ = resp.Body.Close()
return nil, fmt.Errorf("list org memberships: status %d: %s", resp.StatusCode, string(body))
}

var out ListOrgMembershipsResponse
if err := json.NewDecoder(resp.Body).Decode(&out); err != nil {
resp.Body.Close()
_ = resp.Body.Close()
return nil, fmt.Errorf("decode response: %w", err)
}
resp.Body.Close()
_ = resp.Body.Close()

for i := range out.Data {
if out.Data[i].ID == membershipID {
Expand Down Expand Up @@ -204,7 +204,7 @@ func (c *Client) DeleteOrgMembership(orgID, membershipID string) error {
if err != nil {
return fmt.Errorf("request: %w", err)
}
defer resp.Body.Close()
defer func() { _ = resp.Body.Close() }()

if resp.StatusCode != http.StatusNoContent && resp.StatusCode != http.StatusOK {
body, _ := io.ReadAll(resp.Body)
Expand Down Expand Up @@ -242,7 +242,7 @@ func (c *Client) UpdateOrgMembership(orgID, membershipID, roleID string) error {
if err != nil {
return fmt.Errorf("request: %w", err)
}
defer resp.Body.Close()
defer func() { _ = resp.Body.Close() }()

respBody, _ := io.ReadAll(resp.Body)
if resp.StatusCode != http.StatusOK && resp.StatusCode != http.StatusNoContent {
Expand Down
8 changes: 4 additions & 4 deletions internal/client/sso.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func (c *Client) ListGroupSSOConnections(groupID string) ([]SSOConnectionItem, e
if err != nil {
return nil, fmt.Errorf("request: %w", err)
}
defer resp.Body.Close()
defer func() { _ = resp.Body.Close() }()

if resp.StatusCode != http.StatusOK {
body, _ := io.ReadAll(resp.Body)
Expand Down Expand Up @@ -81,16 +81,16 @@ func (c *Client) ListGroupSSOConnectionUsers(groupID, ssoID string) ([]SSOConnec

if resp.StatusCode != http.StatusOK {
body, _ := io.ReadAll(resp.Body)
resp.Body.Close()
_ = resp.Body.Close()
return nil, fmt.Errorf("list group SSO connection users: status %d: %s", resp.StatusCode, string(body))
}

var out ListGroupSSOConnectionUsersResponse
if err := json.NewDecoder(resp.Body).Decode(&out); err != nil {
resp.Body.Close()
_ = resp.Body.Close()
return nil, fmt.Errorf("decode response: %w", err)
}
resp.Body.Close()
_ = resp.Body.Close()

all = append(all, out.Data...)
if out.Links == nil || out.Links.Next == "" {
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func TestNew(t *testing.T) {
if p == nil {
t.Fatal("nil provider")
}
var _ tfprovider.Provider = p
var _ = p
}

func TestSnykIdentityProvider_Metadata(t *testing.T) {
Expand Down
Loading