Skip to content

Commit

Permalink
implement review suggestions
Browse files Browse the repository at this point in the history
Signed-off-by: Mike Mason <[email protected]>
  • Loading branch information
mikemrm committed Dec 7, 2023
1 parent d9d8992 commit 1f15a23
Show file tree
Hide file tree
Showing 26 changed files with 936 additions and 800 deletions.
6 changes: 3 additions & 3 deletions cmd/createrole.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import (
"go.infratographer.com/x/viperx"

"go.infratographer.com/permissions-api/internal/config"
"go.infratographer.com/permissions-api/internal/database"
"go.infratographer.com/permissions-api/internal/iapl"
"go.infratographer.com/permissions-api/internal/query"
"go.infratographer.com/permissions-api/internal/spicedbx"
"go.infratographer.com/permissions-api/internal/storage"
)

const (
Expand Down Expand Up @@ -70,7 +70,7 @@ func createRole(ctx context.Context, cfg *config.AppConfig) {
logger.Fatalw("unable to initialize permissions-api database", "error", err)
}

permDB := database.NewDatabase(db, database.WithLogger(logger))
store := storage.New(db, storage.WithLogger(logger))

var policy iapl.Policy

Expand Down Expand Up @@ -99,7 +99,7 @@ func createRole(ctx context.Context, cfg *config.AppConfig) {
logger.Fatalw("error parsing subject ID", "error", err)
}

engine := query.NewEngine("infratographer", spiceClient, permDB, query.WithPolicy(policy), query.WithLogger(logger))
engine := query.NewEngine("infratographer", spiceClient, store, query.WithPolicy(policy), query.WithLogger(logger))

resource, err := engine.NewResourceFromID(resourceID)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import (
"go.infratographer.com/x/viperx"
"go.uber.org/zap"

dbm "go.infratographer.com/permissions-api/db"
"go.infratographer.com/permissions-api/internal/config"
"go.infratographer.com/permissions-api/internal/storage"
)

var (
Expand Down Expand Up @@ -50,7 +50,7 @@ func init() {

// Add migrate command
goosex.RegisterCobraCommand(rootCmd, func() {
goosex.SetBaseFS(dbm.Migrations)
goosex.SetBaseFS(storage.Migrations)
goosex.SetLogger(logger)
goosex.SetDBURI(globalCfg.CRDB.GetURI())
})
Expand Down
8 changes: 4 additions & 4 deletions cmd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import (

"go.infratographer.com/permissions-api/internal/api"
"go.infratographer.com/permissions-api/internal/config"
"go.infratographer.com/permissions-api/internal/database"
"go.infratographer.com/permissions-api/internal/iapl"
"go.infratographer.com/permissions-api/internal/query"
"go.infratographer.com/permissions-api/internal/spicedbx"
"go.infratographer.com/permissions-api/internal/storage"
)

var (
Expand Down Expand Up @@ -58,7 +58,7 @@ func serve(ctx context.Context, cfg *config.AppConfig) {
logger.Fatalw("unable to initialize permissions-api database", "error", err)
}

permDB := database.NewDatabase(db, database.WithLogger(logger))
store := storage.New(db, storage.WithLogger(logger))

var policy iapl.Policy

Expand All @@ -77,7 +77,7 @@ func serve(ctx context.Context, cfg *config.AppConfig) {
logger.Fatalw("invalid spicedb policy", "error", err)
}

engine := query.NewEngine("infratographer", spiceClient, permDB, query.WithPolicy(policy))
engine := query.NewEngine("infratographer", spiceClient, store, query.WithPolicy(policy))

srv, err := echox.NewServer(
logger.Desugar(),
Expand All @@ -95,7 +95,7 @@ func serve(ctx context.Context, cfg *config.AppConfig) {

srv.AddHandler(r)
srv.AddReadinessCheck("spicedb", spicedbx.Healthcheck(spiceClient))
srv.AddReadinessCheck("database", permDB.HealthCheck)
srv.AddReadinessCheck("storage", store.HealthCheck)

if err := srv.Run(); err != nil {
logger.Fatal("failed to run server", zap.Error(err))
Expand Down
8 changes: 4 additions & 4 deletions cmd/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ import (
"go.uber.org/zap"

"go.infratographer.com/permissions-api/internal/config"
"go.infratographer.com/permissions-api/internal/database"
"go.infratographer.com/permissions-api/internal/iapl"
"go.infratographer.com/permissions-api/internal/pubsub"
"go.infratographer.com/permissions-api/internal/query"
"go.infratographer.com/permissions-api/internal/spicedbx"
"go.infratographer.com/permissions-api/internal/storage"
)

const shutdownTimeout = 10 * time.Second
Expand Down Expand Up @@ -59,7 +59,7 @@ func worker(ctx context.Context, cfg *config.AppConfig) {
logger.Fatalw("unable to initialize permissions-api database", "error", err)
}

permDB := database.NewDatabase(db, database.WithLogger(logger))
store := storage.New(db, storage.WithLogger(logger))

var policy iapl.Policy

Expand All @@ -78,7 +78,7 @@ func worker(ctx context.Context, cfg *config.AppConfig) {
logger.Fatalw("invalid spicedb policy", "error", err)
}

engine := query.NewEngine("infratographer", spiceClient, permDB, query.WithPolicy(policy), query.WithLogger(logger))
engine := query.NewEngine("infratographer", spiceClient, store, query.WithPolicy(policy), query.WithLogger(logger))

events, err := events.NewConnection(cfg.Events.Config, events.WithLogger(logger))
if err != nil {
Expand Down Expand Up @@ -115,7 +115,7 @@ func worker(ctx context.Context, cfg *config.AppConfig) {
}

srv.AddReadinessCheck("spicedb", spicedbx.Healthcheck(spiceClient))
srv.AddReadinessCheck("database", permDB.HealthCheck)
srv.AddReadinessCheck("storage", store.HealthCheck)

quit := make(chan os.Signal, 1)

Expand Down
11 changes: 0 additions & 11 deletions db/migrations.go

This file was deleted.

8 changes: 4 additions & 4 deletions internal/api/roles.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func (r *Router) roleCreate(c echo.Context) error {
Name: role.Name,
Actions: role.Actions,
ResourceID: role.ResourceID,
Creator: role.Creator,
Creator: role.CreatorID,
CreatedAt: role.CreatedAt.Format(time.RFC3339),
UpdatedAt: role.UpdatedAt.Format(time.RFC3339),
}
Expand Down Expand Up @@ -117,7 +117,7 @@ func (r *Router) roleUpdate(c echo.Context) error {
Name: role.Name,
Actions: role.Actions,
ResourceID: role.ResourceID,
Creator: role.Creator,
Creator: role.CreatorID,
CreatedAt: role.CreatedAt.Format(time.RFC3339),
UpdatedAt: role.UpdatedAt.Format(time.RFC3339),
}
Expand Down Expand Up @@ -169,7 +169,7 @@ func (r *Router) roleGet(c echo.Context) error {
Name: role.Name,
Actions: role.Actions,
ResourceID: role.ResourceID,
Creator: role.Creator,
Creator: role.CreatorID,
CreatedAt: role.CreatedAt.Format(time.RFC3339),
UpdatedAt: role.UpdatedAt.Format(time.RFC3339),
}
Expand Down Expand Up @@ -216,7 +216,7 @@ func (r *Router) rolesList(c echo.Context) error {
ID: role.ID,
Name: role.Name,
Actions: role.Actions,
Creator: role.Creator,
Creator: role.CreatorID,
CreatedAt: role.CreatedAt.Format(time.RFC3339),
UpdatedAt: role.UpdatedAt.Format(time.RFC3339),
}
Expand Down
54 changes: 0 additions & 54 deletions internal/database/db.go

This file was deleted.

13 changes: 0 additions & 13 deletions internal/database/options.go

This file was deleted.

Loading

0 comments on commit 1f15a23

Please sign in to comment.