Skip to content

Commit

Permalink
ref(command): rework config (#112)
Browse files Browse the repository at this point in the history
  • Loading branch information
plastikfan committed Jan 12, 2024
1 parent e103c1a commit 287a7d4
Show file tree
Hide file tree
Showing 17 changed files with 308 additions and 462 deletions.
25 changes: 13 additions & 12 deletions src/app/command/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"github.com/snivilised/extendio/xfs/storage"
"github.com/snivilised/extendio/xfs/utils"
"github.com/snivilised/pixa/src/app/proxy"
"github.com/snivilised/pixa/src/cfg"
"github.com/snivilised/pixa/src/i18n"
)

Expand Down Expand Up @@ -66,7 +67,7 @@ type ConfigInfo struct {
ConfigType string
ConfigPath string
Viper configuration.ViperConfig
Readers ConfigReaders
Readers cfg.ConfigReaders
}

// Bootstrap represents construct that performs start up of the cli
Expand All @@ -75,11 +76,11 @@ type ConfigInfo struct {
type Bootstrap struct {
Container *assistant.CobraContainer
OptionsInfo ConfigureOptionsInfo
ProfilesCFG proxy.ProfilesConfig
SchemesCFG proxy.SchemesConfig
SamplerCFG proxy.SamplerConfig
AdvancedCFG proxy.AdvancedConfig
LoggingCFG proxy.LoggingConfig
ProfilesCFG cfg.ProfilesConfig
SchemesCFG cfg.SchemesConfig
SamplerCFG cfg.SamplerConfig
AdvancedCFG cfg.AdvancedConfig
LoggingCFG cfg.LoggingConfig
Vfs storage.VirtualFS
}

Expand Down Expand Up @@ -107,12 +108,12 @@ func (b *Bootstrap) Root(options ...ConfigureOptionFn) *cobra.Command {
ConfigType: "yaml",
ConfigPath: home,
Viper: &configuration.GlobalViperConfig{},
Readers: ConfigReaders{
Profiles: &MsProfilesConfigReader{},
Schemes: &MsSchemesConfigReader{},
Sampler: &MsSamplerConfigReader{},
Advanced: &MsAdvancedConfigReader{},
Logging: &MsLoggingConfigReader{},
Readers: cfg.ConfigReaders{
Profiles: &cfg.MsProfilesConfigReader{},
Schemes: &cfg.MsSchemesConfigReader{},
Sampler: &cfg.MsSamplerConfigReader{},
Advanced: &cfg.MsAdvancedConfigReader{},
Logging: &cfg.MsLoggingConfigReader{},
},
},
}
Expand Down
3 changes: 2 additions & 1 deletion src/app/command/bootstrap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/snivilised/extendio/xfs/storage"
"github.com/snivilised/pixa/src/app/command"
"github.com/snivilised/pixa/src/app/mocks"
"github.com/snivilised/pixa/src/cfg"
"github.com/snivilised/pixa/src/internal/helpers"
"go.uber.org/mock/gomock"
"golang.org/x/text/language"
Expand Down Expand Up @@ -98,7 +99,7 @@ var _ = Describe("Bootstrap", Ordered, func() {
co.Config.Name = helpers.PixaConfigTestFilename
co.Config.ConfigPath = configPath
co.Config.Viper = &configuration.GlobalViperConfig{}
co.Config.Readers = command.ConfigReaders{
co.Config.Readers = cfg.ConfigReaders{
Profiles: mockProfilesReader,
Schemes: mockSchemesReader,
Sampler: mockSamplerReader,
Expand Down
3 changes: 2 additions & 1 deletion src/app/command/magick-cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/snivilised/extendio/xfs/storage"
"github.com/snivilised/pixa/src/app/command"
"github.com/snivilised/pixa/src/app/mocks"
"github.com/snivilised/pixa/src/cfg"
"github.com/snivilised/pixa/src/internal/helpers"
)

Expand Down Expand Up @@ -75,7 +76,7 @@ var _ = Describe("MagickCmd", Ordered, func() {
co.Config.Name = helpers.PixaConfigTestFilename
co.Config.ConfigPath = configPath
co.Config.Viper = &configuration.GlobalViperConfig{}
co.Config.Readers = command.ConfigReaders{
co.Config.Readers = cfg.ConfigReaders{
Profiles: mockProfilesReader,
Schemes: mockSchemesReader,
Sampler: mockSamplerReader,
Expand Down
169 changes: 0 additions & 169 deletions src/app/command/ms-config.go

This file was deleted.

16 changes: 8 additions & 8 deletions src/app/command/shrink-cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@ import (
cmocks "github.com/snivilised/cobrass/src/assistant/mocks"
"github.com/snivilised/pixa/src/app/command"
"github.com/snivilised/pixa/src/app/mocks"
"github.com/snivilised/pixa/src/app/proxy"
"github.com/snivilised/pixa/src/cfg"
"github.com/snivilised/pixa/src/internal/helpers"
"go.uber.org/mock/gomock"

"github.com/snivilised/extendio/xfs/storage"
)

var (
_ proxy.ProfilesConfig = &command.MsProfilesConfig{}
_ proxy.SamplerConfig = &command.MsSamplerConfig{}
_ proxy.ProfilesConfigReader = &command.MsProfilesConfigReader{}
_ proxy.SamplerConfigReader = &command.MsSamplerConfigReader{}
_ proxy.AdvancedConfigReader = &command.MsAdvancedConfigReader{}
_ proxy.LoggingConfigReader = &command.MsLoggingConfigReader{}
_ cfg.ProfilesConfig = &cfg.MsProfilesConfig{}
_ cfg.SamplerConfig = &cfg.MsSamplerConfig{}
_ cfg.ProfilesConfigReader = &cfg.MsProfilesConfigReader{}
_ cfg.SamplerConfigReader = &cfg.MsSamplerConfigReader{}
_ cfg.AdvancedConfigReader = &cfg.MsAdvancedConfigReader{}
_ cfg.LoggingConfigReader = &cfg.MsLoggingConfigReader{}
)

const (
Expand Down Expand Up @@ -96,7 +96,7 @@ func expectValidShrinkCmdInvocation(vfs storage.VirtualFS, entry *shrinkTE, root
co.Config.ConfigPath = entry.configPath

co.Config.Viper = &configuration.GlobalViperConfig{}
co.Config.Readers = command.ConfigReaders{
co.Config.Readers = cfg.ConfigReaders{
Profiles: mockProfilesReader,
Schemes: mockSchemesReader,
Sampler: mockSamplerReader,
Expand Down
Loading

0 comments on commit 287a7d4

Please sign in to comment.