Skip to content

Commit

Permalink
fixed postgres repositories to use namespace id
Browse files Browse the repository at this point in the history
Signed-off-by: Kush Sharma <thekushsharma@gmail.com>
  • Loading branch information
kushsharma committed Sep 2, 2023
1 parent 59b7c5a commit 0aadc7f
Show file tree
Hide file tree
Showing 48 changed files with 3,269 additions and 1,233 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Main
on:
push:
branches:
- main
pull_request:

jobs:
dev:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.20"
- name: Login to DockerHub
uses: docker/login-action@v1
with:
registry: docker.io
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Publish dev image
id: docker_dev_build
uses: docker/build-push-action@v2
with:
push: true
file: "./Dockerfile"
tags: raystack/guardian:dev
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ COMMIT := $(shell git rev-parse --short HEAD)
TAG := "$(shell git rev-list --tags --max-count=1)"
VERSION := "$(shell git describe --tags ${TAG})-next"
BUILD_DIR=dist
PROTON_COMMIT := "ccbf219312db35a934361ebad895cb40145ca235"
PROTON_COMMIT := "95140abe54e3c27f0bf4f06bc780a289f41aadf1"

.PHONY: all build clean test tidy vet proto setup format generate

Expand All @@ -25,6 +25,10 @@ lint: ## Lint checker
@echo "Running lint checks using golangci-lint..."
@golangci-lint run

lintf: ## Lint checker and fix
@echo "Running lint checks using golangci-lint..."
@golangci-lint run --fix

clean: tidy ## Clean the build artifacts
@echo "Cleaning up build directories..."
@rm -rf $coverage.out ${BUILD_DIR}
Expand Down
27 changes: 19 additions & 8 deletions api/handler/v1beta1/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,24 @@ type grantService interface {
ImportFromProvider(ctx context.Context, criteria grant.ImportFromProviderCriteria) ([]*domain.Grant, error)
}

//go:generate mockery --name=namespaceService --exported --with-expecter
type namespaceService interface {
Get(ctx context.Context, id string) (*domain.Namespace, error)
Create(ctx context.Context, namespace *domain.Namespace) error
Update(ctx context.Context, namespace *domain.Namespace) error
List(ctx context.Context, filter domain.NamespaceFilter) ([]*domain.Namespace, error)
}

type GRPCServer struct {
resourceService resourceService
activityService activityService
providerService providerService
policyService policyService
appealService appealService
approvalService approvalService
grantService grantService
adapter ProtoAdapter
resourceService resourceService
activityService activityService
providerService providerService
policyService policyService
appealService appealService
approvalService approvalService
grantService grantService
namespaceService namespaceService
adapter ProtoAdapter

authenticatedUserContextKey interface{}

Expand All @@ -131,6 +140,7 @@ func NewGRPCServer(
appealService appealService,
approvalService approvalService,
grantService grantService,
namespaceService namespaceService,
adapter ProtoAdapter,
authenticatedUserContextKey interface{},
) *GRPCServer {
Expand All @@ -142,6 +152,7 @@ func NewGRPCServer(
appealService: appealService,
approvalService: approvalService,
grantService: grantService,
namespaceService: namespaceService,
adapter: adapter,
authenticatedUserContextKey: authenticatedUserContextKey,
}
Expand Down
19 changes: 11 additions & 8 deletions api/handler/v1beta1/grpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ type authEmailTestContextKey struct{}
type GrpcHandlersSuite struct {
suite.Suite

resourceService *mocks.ResourceService
activityService *mocks.ActivityService
providerService *mocks.ProviderService
policyService *mocks.PolicyService
appealService *mocks.AppealService
approvalService *mocks.ApprovalService
grantService *mocks.GrantService
grpcServer *v1beta1.GRPCServer
resourceService *mocks.ResourceService
activityService *mocks.ActivityService
providerService *mocks.ProviderService
policyService *mocks.PolicyService
appealService *mocks.AppealService
approvalService *mocks.ApprovalService
grantService *mocks.GrantService
namespaceService *mocks.NamespaceService
grpcServer *v1beta1.GRPCServer
}

func TestGrpcHandler(t *testing.T) {
Expand All @@ -35,6 +36,7 @@ func (s *GrpcHandlersSuite) setup() {
s.appealService = new(mocks.AppealService)
s.approvalService = new(mocks.ApprovalService)
s.grantService = new(mocks.GrantService)
s.namespaceService = new(mocks.NamespaceService)
s.grpcServer = v1beta1.NewGRPCServer(
s.resourceService,
s.activityService,
Expand All @@ -43,6 +45,7 @@ func (s *GrpcHandlersSuite) setup() {
s.appealService,
s.approvalService,
s.grantService,
s.namespaceService,
v1beta1.NewAdapter(),
authEmailTestContextKey{},
)
Expand Down
233 changes: 233 additions & 0 deletions api/handler/v1beta1/mocks/namespaceService.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 0aadc7f

Please sign in to comment.