Skip to content

Commit

Permalink
Fix after rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
adambabik committed May 18, 2024
1 parent 748f034 commit fba647d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 40 deletions.
16 changes: 0 additions & 16 deletions internal/command/command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -535,19 +535,3 @@ func testExecuteCommand(
assert.Equal(t, expectedStdout, stdout.String())
assert.Equal(t, expectedStderr, stderr.String())
}

func newSessionWithEnv(env ...string) (*Session, error) {
s := NewSession()
if err := s.SetEnv(env...); err != nil {
return nil, err
}
return s, nil
}

func mustNewSessionWithEnv(env ...string) *Session {
s, err := newSessionWithEnv(env...)
if err != nil {
panic(err)
}
return s
}
47 changes: 23 additions & 24 deletions internal/config/autoconfig/autoconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ func mustProvide(err error) {
}

func init() {
mustProvide(container.Provide(getRootConfig))
mustProvide(container.Provide(getCommandFactory))
mustProvide(container.Provide(getConfigLoader))
mustProvide(container.Provide(getKernel))
Expand All @@ -54,29 +53,6 @@ func init() {
mustProvide(container.Provide(getUserConfigDir))
}

func getRootConfig(cfgLoader *config.Loader, userCfgDir UserConfigDir) (*config.Config, error) {
content, err := cfgLoader.RootConfig()
if err != nil {
return nil, errors.WithMessage(err, "failed to load project configuration")
}

cfg, err := config.ParseYAML(content)
if err != nil {
return nil, err
}

if cfg.ServerTLSEnabled {
if cfg.ServerTLSCertFile == "" {
cfg.ServerTLSCertFile = filepath.Join(string(userCfgDir), "cert.pem")
}
if cfg.ServerTLSKeyFile == "" {
cfg.ServerTLSKeyFile = filepath.Join(string(userCfgDir), "key.pem")
}
}

return cfg, nil
}

func getCommandFactory(cfg *config.Config, kernel command.Kernel, logger *zap.Logger) command.Factory {
return command.NewFactory(cfg, kernel, logger)
}
Expand Down Expand Up @@ -240,6 +216,29 @@ func getProjectFilters(c *config.Config) ([]project.Filter, error) {
return filters, nil
}

func getRootConfig(cfgLoader *config.Loader, userCfgDir UserConfigDir) (*config.Config, error) {
content, err := cfgLoader.RootConfig()
if err != nil {
return nil, errors.WithMessage(err, "failed to load project configuration")
}

cfg, err := config.ParseYAML(content)
if err != nil {
return nil, err
}

if cfg.ServerTLSEnabled {
if cfg.ServerTLSCertFile == "" {
cfg.ServerTLSCertFile = filepath.Join(string(userCfgDir), "cert.pem")
}
if cfg.ServerTLSKeyFile == "" {
cfg.ServerTLSKeyFile = filepath.Join(string(userCfgDir), "key.pem")
}
}

return cfg, nil
}

func getSession(cfg *config.Config, proj *project.Project) (*command.Session, error) {
sess := command.NewSession()

Expand Down

0 comments on commit fba647d

Please sign in to comment.