35610a042e7170aa462552c014dd96a3d2469b98

Author
Ayman Bagabas <ayman.bagabas@gmail.com>
Committer
Ayman Bagabas <ayman.bagabas@gmail.com>
Date

Message

Remove RepoSource from config.Config and remove Server.AppConfig

Diff

 1diff --git a/config/config.go b/config/config.go
 2index 1bb7908261b7a3e4e1aa9eeaf8edef4a8bd97705..160e71120b1b4607e1567431cdf6fdc5a93a1555 100644
 3--- a/config/config.go
 4+++ b/config/config.go
 5@@ -3,7 +3,6 @@ package config
 6 import (
 7 	"log"
 8 
 9-	"github.com/charmbracelet/soft/internal/git"
10 	"github.com/charmbracelet/soft/stats"
11 	"github.com/meowgorithm/babyenv"
12 )
13@@ -15,7 +14,6 @@ type Config struct {
14 	KeyPath         string `env:"SOFT_SERVE_KEY_PATH" default:".ssh/soft_serve_server_ed25519"`
15 	RepoPath        string `env:"SOFT_SERVE_REPO_PATH" default:".repos"`
16 	InitialAdminKey string `env:"SOFT_SERVE_INITIAL_ADMIN_KEY" default:""`
17-	RepoSource      *git.RepoSource
18 	Stats           stats.Stats
19 }
20 
21@@ -27,16 +25,10 @@ func DefaultConfig() *Config {
22 	if err != nil {
23 		log.Fatalln(err)
24 	}
25-	rs := git.NewRepoSource(scfg.RepoPath)
26-	return scfg.WithRepoSource(rs).WithStats(stats.NewStats())
27+	return scfg.WithStats(stats.NewStats())
28 }
29 
30 func (cfg *Config) WithStats(s stats.Stats) *Config {
31 	cfg.Stats = s
32 	return cfg
33 }
34-
35-func (cfg *Config) WithRepoSource(rs *git.RepoSource) *Config {
36-	cfg.RepoSource = rs
37-	return cfg
38-}
39diff --git a/internal/config/config.go b/internal/config/config.go
40index 741c7a625463939b78e28449680328d4b519e3f5..9c7f1cfb8ab750a3b7eac579625d15216453ae91 100644
41--- a/internal/config/config.go
42+++ b/internal/config/config.go
43@@ -48,7 +48,7 @@ func NewConfig(cfg *config.Config) (*Config, error) {
44 	host := cfg.Host
45 	port := cfg.Port
46 	pk := cfg.InitialAdminKey
47-	rs := cfg.RepoSource
48+	rs := git.NewRepoSource(cfg.RepoPath)
49 	c := &Config{
50 		Cfg: cfg,
51 	}
52diff --git a/server/server.go b/server/server.go
53index 8d2819c13cd1b473e3ded030f0e90bb309de1576..f767abc8dd2764602ee00c56ede1b93602742bc2 100644
54--- a/server/server.go
55+++ b/server/server.go
56@@ -18,7 +18,6 @@ import (
57 type Server struct {
58 	SSHServer *ssh.Server
59 	Config    *config.Config
60-	AppConfig *appCfg.Config
61 }
62 
63 // NewServer returns a new *ssh.Server configured to serve Soft Serve. The SSH
64@@ -49,7 +48,6 @@ func NewServer(cfg *config.Config) *Server {
65 	return &Server{
66 		SSHServer: s,
67 		Config:    cfg,
68-		AppConfig: ac,
69 	}
70 }
71