diff options
| author | Nick Thomas <nick@gitlab.com> | 2018-09-28 14:50:26 +0100 |
|---|---|---|
| committer | Nick Thomas <nick@gitlab.com> | 2018-09-28 14:50:26 +0100 |
| commit | 7f1098a1d9fd79b394b53b0c43fcc4741349d43a (patch) | |
| tree | c31273b3b1a49c73c6c19ab2c008230e2d488b5a /go/internal | |
| parent | c37020bb5ae66bfb7596e2b1b4f7b5c79203ecf3 (diff) | |
| download | gitlab-shell-7f1098a1d9fd79b394b53b0c43fcc4741349d43a.tar.gz | |
Specify a richer scheme to run the migration with
Diffstat (limited to 'go/internal')
| -rw-r--r-- | go/internal/config/config.go | 13 | ||||
| -rw-r--r-- | go/internal/config/config_test.go | 24 |
2 files changed, 26 insertions, 11 deletions
diff --git a/go/internal/config/config.go b/go/internal/config/config.go index 64822c7..4069851 100644 --- a/go/internal/config/config.go +++ b/go/internal/config/config.go @@ -13,11 +13,16 @@ 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"` - Experimental bool `yaml:"experimental"` + RootDir string + LogFile string `yaml:"log_file"` + LogFormat string `yaml:"log_format"` + Migration MigrationConfig `yaml:"migration"` } func New() (*Config, error) { diff --git a/go/internal/config/config_test.go b/go/internal/config/config_test.go index 552a600..368ab29 100644 --- a/go/internal/config/config_test.go +++ b/go/internal/config/config_test.go @@ -2,22 +2,28 @@ package config import ( "fmt" + "strings" "testing" ) func TestConfigLogFile(t *testing.T) { testRoot := "/foo/bar" testCases := []struct { - yaml string - path string - format string - experimental bool + yaml string + path string + format string + migration MigrationConfig }{ {path: "/foo/bar/gitlab-shell.log", format: "text"}, {yaml: "log_file: my-log.log", path: "/foo/bar/my-log.log", format: "text"}, {yaml: "log_file: /qux/my-log.log", path: "/qux/my-log.log", format: "text"}, {yaml: "log_format: json", path: "/foo/bar/gitlab-shell.log", format: "json"}, - {yaml: "experimental: true", path: "/foo/bar/gitlab-shell.log", format: "text", experimental: true}, + { + yaml: "migration:\n enabled: true\n features:\n - foo\n - bar", + path: "/foo/bar/gitlab-shell.log", + format: "text", + migration: MigrationConfig{Enabled: true, Features: []string{"foo", "bar"}}, + }, } for _, tc := range testCases { @@ -27,8 +33,12 @@ func TestConfigLogFile(t *testing.T) { t.Fatal(err) } - if cfg.Experimental != tc.experimental { - t.Fatalf("expected %v, got %v", tc.experimental, cfg.Experimental) + if cfg.Migration.Enabled != tc.migration.Enabled { + t.Fatalf("migration.enabled: expected %v, got %v", tc.migration.Enabled, cfg.Migration.Enabled) + } + + if strings.Join(cfg.Migration.Features, ":") != strings.Join(tc.migration.Features, ":") { + t.Fatalf("migration.features: expected %#v, got %#v", tc.migration.Features, cfg.Migration.Features) } if cfg.LogFile != tc.path { |
