Compare commits
1 commit
a6011106d5
...
d9c2fcd61a
Author | SHA1 | Date | |
---|---|---|---|
d9c2fcd61a |
2 changed files with 20 additions and 13 deletions
|
@ -54,7 +54,7 @@ type OpenConnectConfig struct {
|
|||
Issuer string `json:"issuer"`
|
||||
}
|
||||
|
||||
type StorageConfigConfig struct {
|
||||
type StorageConfig struct {
|
||||
File string `json:"file"`
|
||||
Host string `json:"host"`
|
||||
Port int `json:"port"`
|
||||
|
@ -78,8 +78,8 @@ type jsonConf struct {
|
|||
SockPath string `json:"sock"`
|
||||
} `json:"server"`
|
||||
Storage struct {
|
||||
StorageType string `json:"type"`
|
||||
StorageConfig *StorageConfigConfig `json:"config"`
|
||||
StorageType string `json:"type"`
|
||||
Config *StorageConfig `json:"config"`
|
||||
} `json:"storage"`
|
||||
OpenConnectConfig *OpenConnectConfig `json:"openconnect"`
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ type AppConfig struct {
|
|||
Port int
|
||||
SockPath string
|
||||
StorageType string
|
||||
StorageConfig *StorageConfigConfig
|
||||
StorageConfig *StorageConfig
|
||||
OpenConnectConfig *OpenConnectConfig
|
||||
}
|
||||
|
||||
|
@ -122,7 +122,7 @@ func (ac *AppConfig) UnmarshalJSON(data []byte) error {
|
|||
ac.Port = jsonConf.Server.Port
|
||||
ac.OpenConnectConfig = jsonConf.OpenConnectConfig
|
||||
ac.StorageType = jsonConf.Storage.StorageType
|
||||
ac.StorageConfig = jsonConf.Storage.StorageConfig
|
||||
ac.StorageConfig = jsonConf.Storage.Config
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ import (
|
|||
"context"
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/signal"
|
||||
"time"
|
||||
|
@ -34,6 +35,17 @@ func parseArgs() *cliArgs {
|
|||
}
|
||||
}
|
||||
|
||||
func initStorage(conf *config.AppConfig) (storage.Storage, error) {
|
||||
var storageType storage.Storage
|
||||
switch conf.StorageType {
|
||||
case "memory":
|
||||
storageType = memory.New(logger.L)
|
||||
default:
|
||||
return storageType, fmt.Errorf("Unsupported storage backend type: %s", conf.StorageType)
|
||||
}
|
||||
return storageType, nil
|
||||
}
|
||||
|
||||
func main() {
|
||||
args := parseArgs()
|
||||
|
||||
|
@ -47,16 +59,11 @@ func main() {
|
|||
logger.Init(conf.LogLevel)
|
||||
logger.L.Infof("Initialized logger with level %v", conf.LogLevel)
|
||||
|
||||
var storageType storage.Storage
|
||||
switch conf.StorageType {
|
||||
case "memory":
|
||||
storageType = memory.New(logger.L)
|
||||
default:
|
||||
logger.L.Fatalf("Unsupported storage backend type: %s", conf.StorageType)
|
||||
storageType, err := initStorage(conf)
|
||||
if err != nil {
|
||||
logger.L.Errorf("Failed to initialize storage backend: %s", err.Error())
|
||||
}
|
||||
|
||||
logger.L.Infof("Initialized storage backend \"%s\"", conf.StorageType)
|
||||
|
||||
dexConf := dex_server.Config{
|
||||
Web: dex_server.WebConfig{
|
||||
Dir: "./",
|
||||
|
|
Loading…
Add table
Reference in a new issue