From 6156ba7476897f9473841bbf832fb33b65c423a5 Mon Sep 17 00:00:00 2001 From: Logan Saso Date: Mon, 4 Dec 2023 16:42:03 -0800 Subject: [PATCH 1/3] Don't pre-emptively pack things into Struct or List values --- pkg/connector/sso_user.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/pkg/connector/sso_user.go b/pkg/connector/sso_user.go index 5bc4aedb..b91a05bc 100644 --- a/pkg/connector/sso_user.go +++ b/pkg/connector/sso_user.go @@ -14,7 +14,6 @@ import ( "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 { @@ -126,17 +125,17 @@ func ssoUserProfile(ctx context.Context, user awsIdentityStoreTypes.User) map[st 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{}{ "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) } } - profile["external_ids"] = structpb.NewListValue(lv) + profile["external_ids"] = lv } return profile } From 97349c293e0ea11ed5bf6564090e3b0b4c07e4a5 Mon Sep 17 00:00:00 2001 From: Logan Saso Date: Mon, 4 Dec 2023 16:43:00 -0800 Subject: [PATCH 2/3] Also fix sso groups --- pkg/connector/sso_group.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/pkg/connector/sso_group.go b/pkg/connector/sso_group.go index 57b0af2a..b2d4b7a8 100644 --- a/pkg/connector/sso_group.go +++ b/pkg/connector/sso_group.go @@ -16,7 +16,6 @@ import ( 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 { @@ -244,17 +243,17 @@ func ssoGroupProfile(ctx context.Context, group awsIdentityStoreTypes.Group) map 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) + } - profile["external_ids"] = structpb.NewListValue(lv) + profile["external_ids"] = lv } return profile From 42b01fba3e118b97d82b6d4c0a2e798d280a50cc Mon Sep 17 00:00:00 2001 From: Logan Saso Date: Mon, 4 Dec 2023 16:45:22 -0800 Subject: [PATCH 3/3] Fix lint --- pkg/connector/sso_group.go | 2 -- pkg/connector/sso_user.go | 4 +--- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/pkg/connector/sso_group.go b/pkg/connector/sso_group.go index b2d4b7a8..779eb971 100644 --- a/pkg/connector/sso_group.go +++ b/pkg/connector/sso_group.go @@ -249,9 +249,7 @@ func ssoGroupProfile(ctx context.Context, group awsIdentityStoreTypes.Group) map "id": awsSdk.ToString(ext.Id), "issuer": awsSdk.ToString(ext.Issuer), } - lv = append(lv, attr) - } profile["external_ids"] = lv } diff --git a/pkg/connector/sso_user.go b/pkg/connector/sso_user.go index b91a05bc..98bdb8b9 100644 --- a/pkg/connector/sso_user.go +++ b/pkg/connector/sso_user.go @@ -131,9 +131,7 @@ func ssoUserProfile(ctx context.Context, user awsIdentityStoreTypes.User) map[st "id": awsSdk.ToString(ext.Id), "issuer": awsSdk.ToString(ext.Issuer), } - if attr != nil { - lv = append(lv, attr) - } + lv = append(lv, attr) } profile["external_ids"] = lv }