Skip to content

Commit

Permalink
Lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
loganintech committed Nov 20, 2023
1 parent 17d0411 commit 91d30b2
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 38 deletions.
14 changes: 10 additions & 4 deletions pkg/connector/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import (
"context"
"errors"
"fmt"
entitlementSdk "github.com/conductorone/baton-sdk/pkg/types/entitlement"
resourceSdk "github.com/conductorone/baton-sdk/pkg/types/resource"
"strings"
"sync"

Expand All @@ -19,6 +17,8 @@ import (
v2 "github.com/conductorone/baton-sdk/pb/c1/connector/v2"
"github.com/conductorone/baton-sdk/pkg/annotations"
"github.com/conductorone/baton-sdk/pkg/pagination"
entitlementSdk "github.com/conductorone/baton-sdk/pkg/types/entitlement"
resourceSdk "github.com/conductorone/baton-sdk/pkg/types/resource"
)

const (
Expand Down Expand Up @@ -73,7 +73,13 @@ func (o *accountResourceType) List(ctx context.Context, _ *v2.ResourceId, pt *pa
Id: awsSdk.ToString(account.Id),
}
profile := accountProfile(ctx, account)
userResource, err := resourceSdk.NewAppResource(awsSdk.ToString(account.Name), resourceTypeAccount, awsSdk.ToString(account.Id), []resourceSdk.AppTraitOption{resourceSdk.WithAppProfile(profile)}, resourceSdk.WithAnnotation(annos))
userResource, err := resourceSdk.NewAppResource(
awsSdk.ToString(account.Name),
resourceTypeAccount,
awsSdk.ToString(account.Id),
[]resourceSdk.AppTraitOption{resourceSdk.WithAppProfile(profile)},
resourceSdk.WithAnnotation(annos),
)
if err != nil {
return nil, "", nil, err
}
Expand All @@ -100,7 +106,7 @@ func (o *accountResourceType) List(ctx context.Context, _ *v2.ResourceId, pt *pa

func (o *accountResourceType) Entitlements(ctx context.Context, resource *v2.Resource, _ *pagination.Token) ([]*v2.Entitlement, string, annotations.Annotations, error) {
// we fetch all permission sets, so that even on accounts that aren't associated with a permission set
// you could od a Grant Request for it -- and we'll just have an entitlement with zero entries in it in ListGrants.
// you could do a Grant Request for it -- and we'll just have an entitlement with zero entries in it in ListGrants.
allPS, err := o.getPermissionSets(ctx)
if err != nil {
return nil, "", nil, fmt.Errorf("aws-connector: getPermissionSets failed: %w", err)
Expand Down
29 changes: 0 additions & 29 deletions pkg/connector/iam_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,35 +156,6 @@ func (o *iamGroupResourceType) Grants(ctx context.Context, resource *v2.Resource
return rv, nextPage, nil, nil
}

//func (g *iamGroupResourceType) Grant(ctx context.Context, principal *v2.Resource, entitlement *v2.Entitlement) (annotations.Annotations, error) {
// if principal.Id.ResourceType != resourceTypeIAMUser.Id {
// return nil, errors.New("baton-aws: only iam users can be added to an iam group")
// }
//
// if _, err := g.iamClient.AddUserToGroup(ctx, &iam.AddUserToGroupInput{
// GroupName: awsSdk.String(entitlement.Resource.Id.Resource),
// UserName: awsSdk.String(principal.Id.Resource),
// }); err != nil {
// return nil, fmt.Errorf("baton-aws: error adding iam user to iam group: %w", err)
// }
//
// return nil, nil
//}
//func (g *iamGroupResourceType) Revoke(ctx context.Context, grant *v2.Grant) (annotations.Annotations, error) {
// if grant.Principal.Id.ResourceType != resourceTypeIAMUser.Id {
// return nil, errors.New("baton-aws: only iam users can be added to an iam group")
// }
//
// if _, err := g.iamClient.RemoveUserFromGroup(ctx, &iam.RemoveUserFromGroupInput{
// GroupName: awsSdk.String(grant.Entitlement.Resource.Id.Resource),
// UserName: awsSdk.String(grant.Principal.Id.Resource),
// }); err != nil {
// return nil, fmt.Errorf("baton-aws: error removing iam user from iam group: %w", err)
// }
//
// return nil, nil
//}

func iamGroupBuilder(iamClient *iam.Client) *iamGroupResourceType {
return &iamGroupResourceType{
resourceType: resourceTypeIAMGroup,
Expand Down
2 changes: 1 addition & 1 deletion pkg/connector/iam_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package connector
import (
"context"
"fmt"
resourceSdk "github.com/conductorone/baton-sdk/pkg/types/resource"
"strings"

awsSdk "github.com/aws/aws-sdk-go-v2/aws"
Expand All @@ -12,6 +11,7 @@ import (
v2 "github.com/conductorone/baton-sdk/pb/c1/connector/v2"
"github.com/conductorone/baton-sdk/pkg/annotations"
"github.com/conductorone/baton-sdk/pkg/pagination"
resourceSdk "github.com/conductorone/baton-sdk/pkg/types/resource"
)

type iamUserResourceType struct {
Expand Down
12 changes: 9 additions & 3 deletions pkg/connector/role.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ package connector
import (
"context"
"fmt"
entitlementSdk "github.com/conductorone/baton-sdk/pkg/types/entitlement"
resourceSdk "github.com/conductorone/baton-sdk/pkg/types/resource"

awsSdk "github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/service/iam"
iamTypes "github.com/aws/aws-sdk-go-v2/service/iam/types"
v2 "github.com/conductorone/baton-sdk/pb/c1/connector/v2"
"github.com/conductorone/baton-sdk/pkg/annotations"
"github.com/conductorone/baton-sdk/pkg/pagination"
entitlementSdk "github.com/conductorone/baton-sdk/pkg/types/entitlement"
resourceSdk "github.com/conductorone/baton-sdk/pkg/types/resource"
)

const (
Expand Down Expand Up @@ -56,7 +56,13 @@ func (o *roleResourceType) List(ctx context.Context, _ *v2.ResourceId, pt *pagin
Id: awsSdk.ToString(role.Arn),
}
profile := roleProfile(ctx, role)
roleResource, err := resourceSdk.NewRoleResource(awsSdk.ToString(role.RoleName), resourceTypeRole, awsSdk.ToString(role.Arn), []resourceSdk.RoleTraitOption{resourceSdk.WithRoleProfile(profile)}, resourceSdk.WithAnnotation(annos))
roleResource, err := resourceSdk.NewRoleResource(
awsSdk.ToString(role.RoleName),
resourceTypeRole,
awsSdk.ToString(role.Arn),
[]resourceSdk.RoleTraitOption{resourceSdk.WithRoleProfile(profile)},
resourceSdk.WithAnnotation(annos),
)
if err != nil {
return nil, "", nil, err
}
Expand Down
1 change: 1 addition & 0 deletions pkg/connector/sso_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"

awsSdk "github.com/aws/aws-sdk-go-v2/aws"
awsIdentityStore "github.com/aws/aws-sdk-go-v2/service/identitystore"
awsIdentityStoreTypes "github.com/aws/aws-sdk-go-v2/service/identitystore/types"
Expand Down
2 changes: 1 addition & 1 deletion pkg/connector/sso_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package connector
import (
"context"
"fmt"
resourceSdk "github.com/conductorone/baton-sdk/pkg/types/resource"
"strings"

awsSdk "github.com/aws/aws-sdk-go-v2/aws"
Expand All @@ -14,6 +13,7 @@ import (
v2 "github.com/conductorone/baton-sdk/pb/c1/connector/v2"
"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"
)

Expand Down

0 comments on commit 91d30b2

Please sign in to comment.