Skip to content

Commit

Permalink
fix!: migrate to uuid (#115)
Browse files Browse the repository at this point in the history
* fix!: migrate to uuid

* fix(appeal): remove fatal logging in revoke expired access job handler
  • Loading branch information
rahmatrhd authored Jan 19, 2022
1 parent 051547f commit f400eef
Show file tree
Hide file tree
Showing 53 changed files with 561 additions and 493 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ NAME="github.com/odpf/guardian"
LAST_COMMIT := $(shell git rev-parse --short HEAD)
LAST_TAG := "$(shell git rev-list --tags --max-count=1)"
APP_VERSION := "$(shell git describe --tags ${LAST_TAG})-next"
PROTON_COMMIT := "ef83b9e9248e064a1c366da4fe07b3068266fe59"
PROTON_COMMIT := "60f4fe9e5fc95660b56cf76b434d9557d9f483d7"

.PHONY: all build test clean dist vet proto install

Expand Down
30 changes: 15 additions & 15 deletions api/handler/v1beta1/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func (a *adapter) FromProviderProto(p *guardianv1beta1.Provider) (*domain.Provid
}

return &domain.Provider{
ID: uint(p.GetId()),
ID: p.GetId(),
Type: p.GetType(),
URN: p.GetUrn(),
Config: providerConfig,
Expand Down Expand Up @@ -87,7 +87,7 @@ func (a *adapter) ToProviderProto(p *domain.Provider) (*guardianv1beta1.Provider
}

return &guardianv1beta1.Provider{
Id: uint32(p.ID),
Id: p.ID,
Type: p.Type,
Urn: p.URN,
Config: config,
Expand Down Expand Up @@ -210,7 +210,7 @@ func (a *adapter) FromPolicyProto(p *guardianv1beta1.Policy) (*domain.Policy, er
ProviderURN: aa.GetResource().GetProviderUrn(),
Type: aa.GetResource().GetType(),
URN: aa.GetResource().GetUrn(),
ID: uint(aa.GetResource().GetId()),
ID: aa.GetResource().GetId(),
}
}

Expand Down Expand Up @@ -304,7 +304,7 @@ func (a *adapter) ToPolicyProto(p *domain.Policy) (*guardianv1beta1.Policy, erro
ProviderUrn: aa.Resource.ProviderURN,
Type: aa.Resource.Type,
Urn: aa.Resource.URN,
Id: uint32(aa.Resource.ID),
Id: aa.Resource.ID,
}
}

Expand Down Expand Up @@ -357,7 +357,7 @@ func (a *adapter) FromResourceProto(r *guardianv1beta1.Resource) *domain.Resourc
details = r.GetDetails().AsMap()
}
return &domain.Resource{
ID: uint(r.GetId()),
ID: r.GetId(),
ProviderType: r.GetProviderType(),
ProviderURN: r.GetProviderUrn(),
Type: r.GetType(),
Expand All @@ -382,7 +382,7 @@ func (a *adapter) ToResourceProto(r *domain.Resource) (*guardianv1beta1.Resource
}

return &guardianv1beta1.Resource{
Id: uint32(r.ID),
Id: r.ID,
ProviderType: r.ProviderType,
ProviderUrn: r.ProviderURN,
Type: r.Type,
Expand All @@ -408,9 +408,9 @@ func (a *adapter) FromAppealProto(appeal *guardianv1beta1.Appeal) (*domain.Appea
}

approvals = append(approvals, &domain.Approval{
ID: uint(a.GetId()),
ID: a.GetId(),
Name: a.GetName(),
AppealID: uint(a.GetId()),
AppealID: a.GetId(),
Status: a.GetStatus(),
Actor: actor,
Reason: a.GetReason(),
Expand All @@ -428,8 +428,8 @@ func (a *adapter) FromAppealProto(appeal *guardianv1beta1.Appeal) (*domain.Appea
}

return &domain.Appeal{
ID: uint(appeal.GetId()),
ResourceID: uint(appeal.GetResourceId()),
ID: appeal.GetId(),
ResourceID: appeal.GetResourceId(),
PolicyID: appeal.GetPolicyId(),
PolicyVersion: uint(appeal.GetPolicyVersion()),
Status: appeal.GetStatus(),
Expand Down Expand Up @@ -486,8 +486,8 @@ func (a *adapter) ToAppealProto(appeal *domain.Appeal) (*guardianv1beta1.Appeal,
}

return &guardianv1beta1.Appeal{
Id: uint32(appeal.ID),
ResourceId: uint32(appeal.ResourceID),
Id: appeal.ID,
ResourceId: appeal.ResourceID,
PolicyId: appeal.PolicyID,
PolicyVersion: uint32(appeal.PolicyVersion),
Status: appeal.Status,
Expand Down Expand Up @@ -524,7 +524,7 @@ func (a *adapter) FromCreateAppealProto(ca *guardianv1beta1.CreateAppealRequest,
AccountID: ca.GetAccountId(),
AccountType: ca.GetAccountType(),
CreatedBy: authenticatedUser,
ResourceID: uint(r.GetId()),
ResourceID: r.GetId(),
Role: r.GetRole(),
Options: options,
Details: r.GetDetails().AsMap(),
Expand All @@ -550,9 +550,9 @@ func (a *adapter) ToApprovalProto(approval *domain.Approval) (*guardianv1beta1.A
}

return &guardianv1beta1.Approval{
Id: uint32(approval.ID),
Id: approval.ID,
Name: approval.Name,
AppealId: uint32(approval.AppealID),
AppealId: approval.AppealID,
Appeal: appealProto,
Status: approval.Status,
Actor: actor,
Expand Down
18 changes: 9 additions & 9 deletions api/handler/v1beta1/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func (s *GRPCServer) ListProviders(ctx context.Context, req *guardianv1beta1.Lis
}

func (s *GRPCServer) GetProvider(ctx context.Context, req *guardianv1beta1.GetProviderRequest) (*guardianv1beta1.GetProviderResponse, error) {
p, err := s.providerService.GetByID(uint(req.GetId()))
p, err := s.providerService.GetByID(req.GetId())
if err != nil {
switch err {
case provider.ErrRecordNotFound:
Expand Down Expand Up @@ -145,7 +145,7 @@ func (s *GRPCServer) UpdateProvider(ctx context.Context, req *guardianv1beta1.Up
}

p := &domain.Provider{
ID: uint(id),
ID: id,
Type: providerConfig.Type,
URN: providerConfig.URN,
Config: providerConfig,
Expand All @@ -165,7 +165,7 @@ func (s *GRPCServer) UpdateProvider(ctx context.Context, req *guardianv1beta1.Up
}

func (s *GRPCServer) ListRoles(ctx context.Context, req *guardianv1beta1.ListRolesRequest) (*guardianv1beta1.ListRolesResponse, error) {
roles, err := s.providerService.GetRoles(uint(req.GetId()), req.GetResourceType())
roles, err := s.providerService.GetRoles(req.GetId(), req.GetResourceType())
if err != nil {
return nil, status.Errorf(codes.Internal, "failed to list roles: %v", err)
}
Expand Down Expand Up @@ -314,7 +314,7 @@ func (s *GRPCServer) ListResources(ctx context.Context, req *guardianv1beta1.Lis
}

func (s *GRPCServer) GetResource(ctx context.Context, req *guardianv1beta1.GetResourceRequest) (*guardianv1beta1.GetResourceResponse, error) {
r, err := s.resourceService.GetOne(uint(req.GetId()))
r, err := s.resourceService.GetOne(req.GetId())
if err != nil {
switch err {
case resource.ErrRecordNotFound:
Expand All @@ -336,7 +336,7 @@ func (s *GRPCServer) GetResource(ctx context.Context, req *guardianv1beta1.GetRe

func (s *GRPCServer) UpdateResource(ctx context.Context, req *guardianv1beta1.UpdateResourceRequest) (*guardianv1beta1.UpdateResourceResponse, error) {
r := s.adapter.FromResourceProto(req.GetResource())
r.ID = uint(req.GetId())
r.ID = req.GetId()

if err := s.resourceService.Update(r); err != nil {
return nil, status.Errorf(codes.Internal, "failed to update resource: %v", err)
Expand Down Expand Up @@ -500,7 +500,7 @@ func (s *GRPCServer) ListApprovals(ctx context.Context, req *guardianv1beta1.Lis

func (s *GRPCServer) GetAppeal(ctx context.Context, req *guardianv1beta1.GetAppealRequest) (*guardianv1beta1.GetAppealResponse, error) {
id := req.GetId()
appeal, err := s.appealService.GetByID(uint(id))
appeal, err := s.appealService.GetByID(id)
if err != nil {
return nil, status.Errorf(codes.Internal, "failed to retrieve appeal: %v", err)
}
Expand All @@ -526,7 +526,7 @@ func (s *GRPCServer) UpdateApproval(ctx context.Context, req *guardianv1beta1.Up

id := req.GetId()
a, err := s.appealService.MakeAction(domain.ApprovalAction{
AppealID: uint(id),
AppealID: id,
ApprovalName: req.GetApprovalName(),
Actor: actor,
Action: req.GetAction().GetAction(),
Expand Down Expand Up @@ -568,7 +568,7 @@ func (s *GRPCServer) UpdateApproval(ctx context.Context, req *guardianv1beta1.Up

func (s *GRPCServer) CancelAppeal(ctx context.Context, req *guardianv1beta1.CancelAppealRequest) (*guardianv1beta1.CancelAppealResponse, error) {
id := req.GetId()
a, err := s.appealService.Cancel(uint(id))
a, err := s.appealService.Cancel(id)
if err != nil {
switch err {
case appeal.ErrAppealNotFound:
Expand Down Expand Up @@ -602,7 +602,7 @@ func (s *GRPCServer) RevokeAppeal(ctx context.Context, req *guardianv1beta1.Revo
}
reason := req.GetReason().GetReason()

a, err := s.appealService.Revoke(uint(id), actor, reason)
a, err := s.appealService.Revoke(id, actor, reason)
if err != nil {
switch err {
case appeal.ErrAppealNotFound:
Expand Down
Loading

0 comments on commit f400eef

Please sign in to comment.