Skip to content

Commit

Permalink
wip: remove gorm.seed package
Browse files Browse the repository at this point in the history
  • Loading branch information
katallaxie authored Oct 29, 2024
1 parent c5d56fa commit 361ee8d
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 24 deletions.
4 changes: 2 additions & 2 deletions cmd/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ package cmd

import (
"github.com/zeiss/fiber-goth/adapters"
"github.com/zeiss/pkg/dbx"
"github.com/zeiss/service-lens/internal/adapters/db"
"github.com/zeiss/service-lens/internal/models"

"github.com/spf13/cobra"
seed "github.com/zeiss/gorm-seed"
"gorm.io/driver/postgres"
"gorm.io/gorm"
"gorm.io/gorm/schema"
Expand All @@ -25,7 +25,7 @@ var Migrate = &cobra.Command{
return err
}

store, err := seed.NewDatabase(conn, db.NewReadTx(), db.NewWriteTx())
store, err := dbx.NewDatabase(conn, db.NewReadTx(), db.NewWriteTx())
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/zeiss/fiber-goth/providers"
"github.com/zeiss/fiber-goth/providers/entraid"
"github.com/zeiss/fiber-goth/providers/github"
"github.com/zeiss/pkg/dbx"
"github.com/zeiss/service-lens/internal/adapters/db"
"github.com/zeiss/service-lens/internal/adapters/handlers"
"github.com/zeiss/service-lens/internal/cfg"
Expand All @@ -26,7 +27,6 @@ import (
htmx "github.com/zeiss/fiber-htmx"
"github.com/zeiss/fiber-htmx/components/toasts"
reload "github.com/zeiss/fiber-reload"
seed "github.com/zeiss/gorm-seed"
"gorm.io/driver/postgres"
"gorm.io/gorm"
"gorm.io/gorm/schema"
Expand Down Expand Up @@ -108,7 +108,7 @@ func (s *WebSrv) Start(ctx context.Context, ready server.ReadyFunc, run server.R
return err
}

store, err := seed.NewDatabase(conn, db.NewReadTx(), db.NewWriteTx())
store, err := dbx.NewDatabase(conn, db.NewReadTx(), db.NewWriteTx())
if err != nil {
return err
}
Expand Down
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ require (
github.com/teekennedy/goldmark-markdown v0.3.0
github.com/yuin/goldmark v1.7.8
github.com/yuin/goldmark-emoji v1.0.4
github.com/zeiss/fiber-goth v1.2.13
github.com/zeiss/fiber-goth v1.2.15
github.com/zeiss/fiber-htmx v1.3.29
github.com/zeiss/fiber-reload v0.1.1
github.com/zeiss/gorm-seed v0.1.2
Expand Down Expand Up @@ -49,7 +49,7 @@ require (
github.com/alexkohler/nakedret/v2 v2.0.4 // indirect
github.com/alexkohler/prealloc v1.0.0 // indirect
github.com/alingse/asasalint v0.0.11 // indirect
github.com/andybalholm/brotli v1.1.0 // indirect
github.com/andybalholm/brotli v1.1.1 // indirect
github.com/ashanbrown/forbidigo v1.6.0 // indirect
github.com/ashanbrown/makezero v1.1.1 // indirect
github.com/beorn7/perks v1.0.1 // indirect
Expand Down Expand Up @@ -140,7 +140,7 @@ require (
github.com/karamaru-alpha/copyloopvar v1.1.0 // indirect
github.com/kisielk/errcheck v1.7.0 // indirect
github.com/kkHAIKE/contextcheck v1.1.5 // indirect
github.com/klauspost/compress v1.17.9 // indirect
github.com/klauspost/compress v1.17.11 // indirect
github.com/kulti/thelper v0.6.3 // indirect
github.com/kunwardeep/paralleltest v1.0.10 // indirect
github.com/kyoh86/exportloopref v0.1.11 // indirect
Expand Down Expand Up @@ -226,7 +226,7 @@ require (
github.com/ultraware/whitespace v0.1.1 // indirect
github.com/uudashr/gocognit v1.1.3 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasthttp v1.56.0 // indirect
github.com/valyala/fasthttp v1.57.0 // indirect
github.com/valyala/tcplisten v1.0.0 // indirect
github.com/xen0n/gosmopolitan v1.2.2 // indirect
github.com/yagipy/maintidx v1.0.0 // indirect
Expand Down
18 changes: 10 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ github.com/alexkohler/prealloc v1.0.0 h1:Hbq0/3fJPQhNkN0dR95AVrr6R7tou91y0uHG5pO
github.com/alexkohler/prealloc v1.0.0/go.mod h1:VetnK3dIgFBBKmg0YnD9F9x6Icjd+9cvfHR56wJVlKE=
github.com/alingse/asasalint v0.0.11 h1:SFwnQXJ49Kx/1GghOFz1XGqHYKp21Kq1nHad/0WQRnw=
github.com/alingse/asasalint v0.0.11/go.mod h1:nCaoMhw7a9kSJObvQyVzNTPBDbNpdocqrSP7t/cW5+I=
github.com/andybalholm/brotli v1.1.0 h1:eLKJA0d02Lf0mVpIDgYnqXcUn0GqVmEFny3VuID1U3M=
github.com/andybalholm/brotli v1.1.0/go.mod h1:sms7XGricyQI9K10gOSf56VKKWS4oLer58Q+mhRPtnY=
github.com/andybalholm/brotli v1.1.1 h1:PR2pgnyFznKEugtsUo0xLdDop5SKXd5Qf5ysW+7XdTA=
github.com/andybalholm/brotli v1.1.1/go.mod h1:05ib4cKhjx3OQYUY22hTVd34Bc8upXjOLL2rKwwZBoA=
github.com/ashanbrown/forbidigo v1.6.0 h1:D3aewfM37Yb3pxHujIPSpTf6oQk9sc9WZi8gerOIVIY=
github.com/ashanbrown/forbidigo v1.6.0/go.mod h1:Y8j9jy9ZYAEHXdu723cUlraTqbzjKF1MUyfOKL+AjcU=
github.com/ashanbrown/makezero v1.1.1 h1:iCQ87C0V0vSyO+M9E/FZYbu65auqH0lnsOkf5FcB28s=
Expand Down Expand Up @@ -282,8 +282,8 @@ github.com/kisielk/errcheck v1.7.0 h1:+SbscKmWJ5mOK/bO1zS60F5I9WwZDWOfRsC4RwfwRV
github.com/kisielk/errcheck v1.7.0/go.mod h1:1kLL+jV4e+CFfueBmI1dSK2ADDyQnlrnrY/FqKluHJQ=
github.com/kkHAIKE/contextcheck v1.1.5 h1:CdnJh63tcDe53vG+RebdpdXJTc9atMgGqdx8LXxiilg=
github.com/kkHAIKE/contextcheck v1.1.5/go.mod h1:O930cpht4xb1YQpK+1+AgoM3mFsvxr7uyFptcnWTYUA=
github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA=
github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw=
github.com/klauspost/compress v1.17.11 h1:In6xLpyWOi1+C7tXUUWv2ot1QvBjxevKAaI6IXrJmUc=
github.com/klauspost/compress v1.17.11/go.mod h1:pMDklpSncoRMuLFrf1W9Ss9KT+0rH90U12bZKk7uwG0=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
Expand Down Expand Up @@ -510,12 +510,14 @@ github.com/uudashr/gocognit v1.1.3 h1:l+a111VcDbKfynh+airAy/DJQKaXh2m9vkoysMPSZy
github.com/uudashr/gocognit v1.1.3/go.mod h1:aKH8/e8xbTRBwjbCkwZ8qt4l2EpKXl31KMHgSS+lZ2U=
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
github.com/valyala/fasthttp v1.56.0 h1:bEZdJev/6LCBlpdORfrLu/WOZXXxvrUQSiyniuaoW8U=
github.com/valyala/fasthttp v1.56.0/go.mod h1:sReBt3XZVnudxuLOx4J/fMrJVorWRiWY2koQKgABiVI=
github.com/valyala/fasthttp v1.57.0 h1:Xw8SjWGEP/+wAAgyy5XTvgrWlOD1+TxbbvNADYCm1Tg=
github.com/valyala/fasthttp v1.57.0/go.mod h1:h6ZBaPRlzpZ6O3H5t2gEk1Qi33+TmLvfwgLLp0t9CpE=
github.com/valyala/tcplisten v1.0.0 h1:rBHj/Xf+E1tRGZyWIWwJDiRY0zc1Js+CV5DqwacVSA8=
github.com/valyala/tcplisten v1.0.0/go.mod h1:T0xQ8SeCZGxckz9qRXTfG43PvQ/mcWh7FwZEA7Ioqkc=
github.com/xen0n/gosmopolitan v1.2.2 h1:/p2KTnMzwRexIW8GlKawsTWOxn7UHA+jCMF/V8HHtvU=
github.com/xen0n/gosmopolitan v1.2.2/go.mod h1:7XX7Mj61uLYrj0qmeN0zi7XDon9JRAEhYQqAPLVNTeg=
github.com/xyproto/randomstring v1.0.5 h1:YtlWPoRdgMu3NZtP45drfy1GKoojuR7hmRcnhZqKjWU=
github.com/xyproto/randomstring v1.0.5/go.mod h1:rgmS5DeNXLivK7YprL0pY+lTuhNQW3iGxZ18UQApw/E=
github.com/yagipy/maintidx v1.0.0 h1:h5NvIsCz+nRDapQ0exNv4aJ0yXSI0420omVANTv3GJM=
github.com/yagipy/maintidx v1.0.0/go.mod h1:0qNf/I/CCZXSMhsRsrEPDZ+DkekpKLXAJfsTACwgXLk=
github.com/yeya24/promlinter v0.3.0 h1:JVDbMp08lVCP7Y6NP3qHroGAO6z2yGKQtS5JsjqtoFs=
Expand All @@ -535,8 +537,8 @@ github.com/yuin/goldmark-emoji v1.0.4 h1:vCwMkPZSNefSUnOW2ZKRUjBSD5Ok3W78IXhGxxA
github.com/yuin/goldmark-emoji v1.0.4/go.mod h1:tTkZEbwu5wkPmgTcitqddVxY9osFZiavD+r4AzQrh1U=
github.com/zeiss/fiber-authz v1.0.33 h1:KZnVTxG+VoQLowoCqoMwam/5H4PVu89rn9ZJ2AGOtCE=
github.com/zeiss/fiber-authz v1.0.33/go.mod h1:oVkhY0X9/xFa0Pu3BuEU8ubE7pAQmIjFMUwUGD2pQqc=
github.com/zeiss/fiber-goth v1.2.13 h1:/DQe5VtEJONUiJo8ZF7ZDqdYcPZYYklqrpN184/cDwY=
github.com/zeiss/fiber-goth v1.2.13/go.mod h1:W/2sDRAoA+1Cijksb4syHKiWvSNupW2hhAfcEWtitX0=
github.com/zeiss/fiber-goth v1.2.15 h1:5imQDAf6lG8xKAzjjsaab25TAYdc5QtyaaqaCwEUbp4=
github.com/zeiss/fiber-goth v1.2.15/go.mod h1:nBus53MvxBZwPIul1TJVwg4bDOvoIoqs9Bj86YFUkoo=
github.com/zeiss/fiber-htmx v1.3.29 h1:0KSbp1HqkFBR4XDUA8Y8e97I1Y7iTAJO5ykDhXWIulY=
github.com/zeiss/fiber-htmx v1.3.29/go.mod h1:taAh4uaXoY+NRqn6t0bnknbzGmVQ70smg6SYK2yaYCI=
github.com/zeiss/fiber-reload v0.1.1 h1:ozSpAjXfCkHa4x2y+lY4cqBWiQ9ORbECMBsMruMexo0=
Expand Down
9 changes: 4 additions & 5 deletions internal/adapters/db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@ import (
"context"
"slices"

"github.com/zeiss/fiber-htmx/components/tables"

"github.com/zeiss/service-lens/internal/models"
"github.com/zeiss/service-lens/internal/ports"

"github.com/google/uuid"
"github.com/zeiss/fiber-goth/adapters"
seed "github.com/zeiss/gorm-seed"
"github.com/zeiss/fiber-htmx/components/tables"
"github.com/zeiss/pkg/cast"
"github.com/zeiss/pkg/dbx"
"gorm.io/gorm"
"gorm.io/gorm/clause"
)
Expand All @@ -24,7 +23,7 @@ type readTxImpl struct {
}

// NewReadTx ...
func NewReadTx() seed.ReadTxFactory[ports.ReadTx] {
func NewReadTx() dbx.ReadTxFactory[ports.ReadTx] {
return func(db *gorm.DB) (ports.ReadTx, error) {
return &readTxImpl{conn: db}, nil
}
Expand Down Expand Up @@ -212,7 +211,7 @@ type writeTxImpl struct {
}

// NewWriteTx ...
func NewWriteTx() seed.ReadWriteTxFactory[ports.ReadWriteTx] {
func NewWriteTx() dbx.ReadWriteTxFactory[ports.ReadWriteTx] {
return func(db *gorm.DB) (ports.ReadWriteTx, error) {
return &writeTxImpl{conn: db}, nil
}
Expand Down
6 changes: 4 additions & 2 deletions internal/adapters/handlers/settings_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ package handlers

import (
"github.com/gofiber/fiber/v2"
goth "github.com/zeiss/fiber-goth"
htmx "github.com/zeiss/fiber-htmx"
"github.com/zeiss/fiber-htmx/components/cards"
"github.com/zeiss/fiber-htmx/components/tailwind"
reload "github.com/zeiss/fiber-reload"
"github.com/zeiss/pkg/errorx"
"github.com/zeiss/service-lens/internal/components"
)

Expand All @@ -18,8 +20,8 @@ func NewSettingsHandler() *SettingsHandler {
func (h *SettingsHandler) ListSettings(c *fiber.Ctx) (htmx.Node, error) {
return components.DefaultLayout(
components.DefaultLayoutProps{
Path: c.Path(),
// User: d.Session().User,
Path: c.Path(),
User: errorx.Ignore(goth.SessionFromContext(c)).User,
Development: reload.IsDevelopment(c.UserContext()),
},
func() htmx.Node {
Expand Down
1 change: 0 additions & 1 deletion internal/components/layout.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
// LayoutProps is the properties for the Layout component.
type LayoutProps struct {
// Team is the teams to user adapters.
Team adapters.GothTeam
User adapters.GothUser
Path string
}
Expand Down

0 comments on commit 361ee8d

Please sign in to comment.