Skip to content

Commit

Permalink
Remove RepoSource from config.Config and remove Server.AppConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
aymanbagabas committed Oct 13, 2021
1 parent 331c3bb commit 35610a0
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 12 deletions.
10 changes: 1 addition & 9 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package config
import (
"log"

"github.com/charmbracelet/soft/internal/git"
"github.com/charmbracelet/soft/stats"
"github.com/meowgorithm/babyenv"
)
Expand All @@ -15,7 +14,6 @@ type Config struct {
KeyPath string `env:"SOFT_SERVE_KEY_PATH" default:".ssh/soft_serve_server_ed25519"`
RepoPath string `env:"SOFT_SERVE_REPO_PATH" default:".repos"`
InitialAdminKey string `env:"SOFT_SERVE_INITIAL_ADMIN_KEY" default:""`
RepoSource *git.RepoSource
Stats stats.Stats
}

Expand All @@ -27,16 +25,10 @@ func DefaultConfig() *Config {
if err != nil {
log.Fatalln(err)
}
rs := git.NewRepoSource(scfg.RepoPath)
return scfg.WithRepoSource(rs).WithStats(stats.NewStats())
return scfg.WithStats(stats.NewStats())
}

func (cfg *Config) WithStats(s stats.Stats) *Config {
cfg.Stats = s
return cfg
}

func (cfg *Config) WithRepoSource(rs *git.RepoSource) *Config {
cfg.RepoSource = rs
return cfg
}
2 changes: 1 addition & 1 deletion internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func NewConfig(cfg *config.Config) (*Config, error) {
host := cfg.Host
port := cfg.Port
pk := cfg.InitialAdminKey
rs := cfg.RepoSource
rs := git.NewRepoSource(cfg.RepoPath)
c := &Config{
Cfg: cfg,
}
Expand Down
2 changes: 0 additions & 2 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
type Server struct {
SSHServer *ssh.Server
Config *config.Config
AppConfig *appCfg.Config
}

// NewServer returns a new *ssh.Server configured to serve Soft Serve. The SSH
Expand Down Expand Up @@ -49,7 +48,6 @@ func NewServer(cfg *config.Config) *Server {
return &Server{
SSHServer: s,
Config: cfg,
AppConfig: ac,
}
}

Expand Down

0 comments on commit 35610a0

Please sign in to comment.