summaryrefslogtreecommitdiff
path: root/go/internal/config/config.go
diff options
context:
space:
mode:
Diffstat (limited to 'go/internal/config/config.go')
-rw-r--r--go/internal/config/config.go29
1 files changed, 21 insertions, 8 deletions
diff --git a/go/internal/config/config.go b/go/internal/config/config.go
index 7d521f5..435cb29 100644
--- a/go/internal/config/config.go
+++ b/go/internal/config/config.go
@@ -13,31 +13,44 @@ const (
logFile = "gitlab-shell.log"
)
+type MigrationConfig struct {
+ Enabled bool `yaml:"enabled"`
+ Features []string `yaml:"features"`
+}
+
type Config struct {
RootDir string
- LogFile string `yaml:"log_file"`
- LogFormat string `yaml:"log_format"`
+ LogFile string `yaml:"log_file"`
+ LogFormat string `yaml:"log_format"`
+ Migration MigrationConfig `yaml:"migration"`
}
func New() (*Config, error) {
- cfg := Config{}
-
dir, err := os.Getwd()
if err != nil {
return nil, err
}
- cfg.RootDir = dir
- configBytes, err := ioutil.ReadFile(path.Join(cfg.RootDir, configFile))
+ return NewFromDir(dir)
+}
+
+func NewFromDir(dir string) (*Config, error) {
+ return newFromFile(path.Join(dir, configFile))
+}
+
+func newFromFile(filename string) (*Config, error) {
+ cfg := &Config{RootDir: path.Dir(filename)}
+
+ configBytes, err := ioutil.ReadFile(filename)
if err != nil {
return nil, err
}
- if err := parseConfig(configBytes, &cfg); err != nil {
+ if err := parseConfig(configBytes, cfg); err != nil {
return nil, err
}
- return &cfg, nil
+ return cfg, nil
}
// parseConfig expects YAML data in configBytes and a Config instance with RootDir set.