mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-11 18:17:35 +00:00
add basic config and change i18n pkg
This commit is contained in:
4
internal/admin/config.go
Normal file
4
internal/admin/config.go
Normal file
@@ -0,0 +1,4 @@
|
||||
package admin
|
||||
|
||||
type Config struct {
|
||||
}
|
34
internal/api/grpc/config.go
Normal file
34
internal/api/grpc/config.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package grpc
|
||||
|
||||
type Config struct {
|
||||
ServerPort string
|
||||
GatewayPort string
|
||||
SearchLimit int
|
||||
CustomHeaders []string
|
||||
}
|
||||
|
||||
func (c *Config) ToServerConfig() *ServerConfig {
|
||||
return &ServerConfig{
|
||||
Port: c.ServerPort,
|
||||
SearchLimit: c.SearchLimit,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Config) ToGatewayConfig() *GatewayConfig {
|
||||
return &GatewayConfig{
|
||||
Port: c.GatewayPort,
|
||||
GRPCEndpoint: c.ServerPort,
|
||||
CustomHeaders: c.CustomHeaders,
|
||||
}
|
||||
}
|
||||
|
||||
type ServerConfig struct {
|
||||
Port string
|
||||
SearchLimit int
|
||||
}
|
||||
|
||||
type GatewayConfig struct {
|
||||
Port string
|
||||
GRPCEndpoint string
|
||||
CustomHeaders []string
|
||||
}
|
@@ -8,9 +8,9 @@ import (
|
||||
|
||||
"github.com/BurntSushi/toml"
|
||||
"github.com/caos/logging"
|
||||
"github.com/ghodss/yaml"
|
||||
"github.com/nicksnyder/go-i18n/v2/i18n"
|
||||
"golang.org/x/text/language"
|
||||
"gopkg.in/yaml.v2"
|
||||
|
||||
"github.com/caos/zitadel/internal/api"
|
||||
http_util "github.com/caos/zitadel/internal/api/http"
|
||||
@@ -43,8 +43,9 @@ func NewTranslator(config TranslatorConfig) (*Translator, error) {
|
||||
|
||||
func newBundle(i18nDir string, defaultLanguage language.Tag) (*i18n.Bundle, error) {
|
||||
bundle := i18n.NewBundle(defaultLanguage)
|
||||
bundle.RegisterUnmarshalFunc("yaml", yaml.Unmarshal)
|
||||
bundle.RegisterUnmarshalFunc("yml", yaml.Unmarshal)
|
||||
yamlUnmarshal := func(data []byte, v interface{}) error { return yaml.Unmarshal(data, v) }
|
||||
bundle.RegisterUnmarshalFunc("yaml", yamlUnmarshal)
|
||||
bundle.RegisterUnmarshalFunc("yml", yamlUnmarshal)
|
||||
bundle.RegisterUnmarshalFunc("json", json.Unmarshal)
|
||||
bundle.RegisterUnmarshalFunc("toml", toml.Unmarshal)
|
||||
files, err := ioutil.ReadDir(i18nDir)
|
||||
|
4
internal/auth/config.go
Normal file
4
internal/auth/config.go
Normal file
@@ -0,0 +1,4 @@
|
||||
package auth
|
||||
|
||||
type Config struct {
|
||||
}
|
@@ -7,7 +7,7 @@ import (
|
||||
"path/filepath"
|
||||
|
||||
"github.com/BurntSushi/toml"
|
||||
"gopkg.in/yaml.v2"
|
||||
"github.com/ghodss/yaml"
|
||||
|
||||
"github.com/caos/zitadel/internal/errors"
|
||||
)
|
||||
@@ -21,7 +21,7 @@ type ReaderFunc func(data []byte, o interface{}) error
|
||||
var (
|
||||
JSONReader = json.Unmarshal
|
||||
TOMLReader = toml.Unmarshal
|
||||
YAMLReader = yaml.Unmarshal
|
||||
YAMLReader = func(data []byte, o interface{}) error { return yaml.Unmarshal(data, o) }
|
||||
)
|
||||
|
||||
// Read deserializes each config file to the target obj
|
||||
|
14
internal/config/flag.go
Normal file
14
internal/config/flag.go
Normal file
@@ -0,0 +1,14 @@
|
||||
package config
|
||||
|
||||
import "strings"
|
||||
|
||||
type ArrayFlags []string
|
||||
|
||||
func (i *ArrayFlags) String() string {
|
||||
return strings.Join(*i, ";")
|
||||
}
|
||||
|
||||
func (i *ArrayFlags) Set(value string) error {
|
||||
*i = append(*i, value)
|
||||
return nil
|
||||
}
|
4
internal/login/config.go
Normal file
4
internal/login/config.go
Normal file
@@ -0,0 +1,4 @@
|
||||
package login
|
||||
|
||||
type Config struct {
|
||||
}
|
3
internal/management/config.go
Normal file
3
internal/management/config.go
Normal file
@@ -0,0 +1,3 @@
|
||||
package management
|
||||
|
||||
type Config struct{}
|
Reference in New Issue
Block a user