Skip to content

Commit

Permalink
fix: update shield client
Browse files Browse the repository at this point in the history
  • Loading branch information
ravisuhag committed Jul 26, 2023
1 parent f8c81b5 commit 371d683
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 17 deletions.
3 changes: 1 addition & 2 deletions plugins/extractors/populate.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ import (
_ "github.com/raystack/meteor/plugins/extractors/presto"
_ "github.com/raystack/meteor/plugins/extractors/redash"
_ "github.com/raystack/meteor/plugins/extractors/redshift"

// _ "github.com/raystack/meteor/plugins/extractors/shield"
_ "github.com/raystack/meteor/plugins/extractors/shield"
_ "github.com/raystack/meteor/plugins/extractors/snowflake"
_ "github.com/raystack/meteor/plugins/extractors/superset"
_ "github.com/raystack/meteor/plugins/extractors/tableau"
Expand Down
21 changes: 6 additions & 15 deletions plugins/extractors/shield/shield.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,12 @@ func (e *Extractor) Init(ctx context.Context, config plugins.Config) (err error)
func (e *Extractor) Extract(ctx context.Context, emit plugins.Emit) error {
defer e.client.Close()

listUsers, err := e.client.ListUsers(ctx, &sh.ListUsersRequest{
Fields: nil,
})
listUsers, err := e.client.ListUsers(ctx, &sh.ListUsersRequest{})
if err != nil {
return fmt.Errorf("error fetching users: %w", err)
}

for _, user := range listUsers.Users {
role, roleErr := e.client.GetRole(ctx, &sh.GetRoleRequest{Id: user.GetId()})
if roleErr != nil {
return fmt.Errorf("error fetching user roles: %w", err)
}

grp, grpErr := e.client.GetGroup(ctx, &sh.GetGroupRequest{Id: user.GetId()})
if grpErr != nil {
return fmt.Errorf("error fetching user groups: %w", err)
Expand All @@ -91,7 +84,6 @@ func (e *Extractor) Extract(ctx context.Context, emit plugins.Emit) error {
Memberships: []*v1beta2.Membership{
{
GroupUrn: fmt.Sprintf("%s:%s", grp.Group.GetName(), grp.Group.GetId()),
Role: []string{role.Role.GetName()},
},
},
CreateTime: user.GetCreatedAt(),
Expand All @@ -102,12 +94,11 @@ func (e *Extractor) Extract(ctx context.Context, emit plugins.Emit) error {
return err
}
emit(models.NewRecord(&v1beta2.Asset{
Urn: models.NewURN(service, e.UrnScope, "user", user.GetId()),
Name: user.GetName(),
Service: service,
Type: "user",
Description: user.GetSlug(),
Data: data,
Urn: models.NewURN(service, e.UrnScope, "user", user.GetId()),
Name: user.GetName(),
Service: service,
Type: "user",
Data: data,
}))
}

Expand Down

0 comments on commit 371d683

Please sign in to comment.