aboutsummaryrefslogtreecommitdiff
path: root/internal/db/db.go
diff options
context:
space:
mode:
authorᴜɴᴋɴᴡᴏɴ <u@gogs.io>2020-04-11 20:18:05 +0800
committerGitHub <noreply@github.com>2020-04-11 20:18:05 +0800
commit41f56ad05d12520bb90f91889fa979465d0b3d6b (patch)
tree1ec7bc62a427ec2da011e882c61f2bfe04adef37 /internal/db/db.go
parent76bb647d2437dbdea86ac1a0caf5d768ab924e18 (diff)
login_source: migrate to GORM and add tests (#6090)
* Use GORM in all write paths * Migrate to GORM * Fix lint errors * Use GORM to init table * dbutil: make writer detect error * Add more tests * Rename to clearTables * db: finish adding tests * osutil: add tests * Fix load source files path
Diffstat (limited to 'internal/db/db.go')
-rw-r--r--internal/db/db.go9
1 files changed, 7 insertions, 2 deletions
diff --git a/internal/db/db.go b/internal/db/db.go
index 1be2cc4b..77d78f53 100644
--- a/internal/db/db.go
+++ b/internal/db/db.go
@@ -124,7 +124,7 @@ func getLogWriter() (io.Writer, error) {
var tables = []interface{}{
new(AccessToken),
- new(LFSObject),
+ new(LFSObject), new(LoginSource),
}
func Init() error {
@@ -167,9 +167,14 @@ func Init() error {
return time.Now().UTC().Truncate(time.Microsecond)
}
+ sourceFiles, err := loadLoginSourceFiles(filepath.Join(conf.CustomDir(), "conf", "auth.d"))
+ if err != nil {
+ return errors.Wrap(err, "load login source files")
+ }
+
// Initialize stores, sorted in alphabetical order.
AccessTokens = &accessTokens{DB: db}
- LoginSources = &loginSources{DB: db}
+ LoginSources = &loginSources{DB: db, files: sourceFiles}
LFS = &lfs{DB: db}
Perms = &perms{DB: db}
Repos = &repos{DB: db}