Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix importing users or groups with profiles #20

Merged
merged 3 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
13 changes: 6 additions & 7 deletions pkg/connector/sso_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
entitlementSdk "github.com/conductorone/baton-sdk/pkg/types/entitlement"
grantSdk "github.com/conductorone/baton-sdk/pkg/types/grant"
resourceSdk "github.com/conductorone/baton-sdk/pkg/types/resource"
"google.golang.org/protobuf/types/known/structpb"
)

type ssoGroupResourceType struct {
Expand Down Expand Up @@ -244,17 +243,17 @@
profile["aws_group_id"] = awsSdk.ToString(group.GroupId)

if len(group.ExternalIds) >= 1 {
lv := &structpb.ListValue{}
lv := []interface{}{}
for _, ext := range group.ExternalIds {
attr, _ := structpb.NewStruct(map[string]interface{}{
attr := map[string]interface{}{
"id": awsSdk.ToString(ext.Id),
"issuer": awsSdk.ToString(ext.Issuer),
})
if attr != nil {
lv.Values = append(lv.Values, structpb.NewStructValue(attr))
}

lv = append(lv, attr)

Check failure on line 254 in pkg/connector/sso_group.go

View workflow job for this annotation

GitHub Actions / go-lint

unnecessary trailing newline (whitespace)
}
profile["external_ids"] = structpb.NewListValue(lv)
profile["external_ids"] = lv
}

return profile
Expand Down
11 changes: 5 additions & 6 deletions pkg/connector/sso_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
"github.com/conductorone/baton-sdk/pkg/annotations"
"github.com/conductorone/baton-sdk/pkg/pagination"
resourceSdk "github.com/conductorone/baton-sdk/pkg/types/resource"
"google.golang.org/protobuf/types/known/structpb"
)

type ssoUserResourceType struct {
Expand Down Expand Up @@ -126,17 +125,17 @@
profile["aws_user_id"] = awsSdk.ToString(user.UserId)

if len(user.ExternalIds) >= 1 {
lv := &structpb.ListValue{}
lv := []interface{}{}
for _, ext := range user.ExternalIds {
attr, _ := structpb.NewStruct(map[string]interface{}{
attr := map[string]interface{}{

Check failure on line 130 in pkg/connector/sso_user.go

View workflow job for this annotation

GitHub Actions / go-lint

SA4031(related information): this is the value of attr (staticcheck)
"id": awsSdk.ToString(ext.Id),
"issuer": awsSdk.ToString(ext.Issuer),
})
}
if attr != nil {

Check failure on line 134 in pkg/connector/sso_user.go

View workflow job for this annotation

GitHub Actions / go-lint

nilness: tautological condition: non-nil != nil (govet)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like the linter says, you can remove this check because attr is never nil.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep

lv.Values = append(lv.Values, structpb.NewStructValue(attr))
lv = append(lv, attr)
}
}
profile["external_ids"] = structpb.NewListValue(lv)
profile["external_ids"] = lv
}
return profile
}
Loading