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