@@ -5,6 +5,7 @@ package configmgr
5
5
import (
6
6
"context"
7
7
"fmt"
8
+ "io/fs"
8
9
"os"
9
10
"sync"
10
11
"time"
@@ -42,7 +43,11 @@ type Manager struct {
42
43
// New creates a new *Manager that persists changes to the file pointed to by
43
44
// fileName. It reads the configuration file and populates the service fields.
44
45
// start is the startup time of AdGuard Home.
45
- func New (fileName string , start time.Time ) (m * Manager , err error ) {
46
+ func New (
47
+ fileName string ,
48
+ frontend fs.FS ,
49
+ start time.Time ,
50
+ ) (m * Manager , err error ) {
46
51
defer func () { err = errors .Annotate (err , "reading config" ) }()
47
52
48
53
conf := & config {}
@@ -79,7 +84,7 @@ func New(fileName string, start time.Time) (m *Manager, err error) {
79
84
ctx , cancel := context .WithTimeout (context .Background (), assemblyTimeout )
80
85
defer cancel ()
81
86
82
- err = m .assemble (ctx , conf , start )
87
+ err = m .assemble (ctx , conf , frontend , start )
83
88
if err != nil {
84
89
// Don't wrap the error, because it's informative enough as is.
85
90
return nil , err
@@ -90,7 +95,12 @@ func New(fileName string, start time.Time) (m *Manager, err error) {
90
95
91
96
// assemble creates all services and puts them into the corresponding fields.
92
97
// The fields of conf must not be modified after calling assemble.
93
- func (m * Manager ) assemble (ctx context.Context , conf * config , start time.Time ) (err error ) {
98
+ func (m * Manager ) assemble (
99
+ ctx context.Context ,
100
+ conf * config ,
101
+ frontend fs.FS ,
102
+ start time.Time ,
103
+ ) (err error ) {
94
104
dnsConf := & dnssvc.Config {
95
105
Addresses : conf .DNS .Addresses ,
96
106
BootstrapServers : conf .DNS .BootstrapDNS ,
@@ -104,6 +114,7 @@ func (m *Manager) assemble(ctx context.Context, conf *config, start time.Time) (
104
114
105
115
webSvcConf := & websvc.Config {
106
116
ConfigManager : m ,
117
+ Frontend : frontend ,
107
118
// TODO(a.garipov): Fill from config file.
108
119
TLS : nil ,
109
120
Start : start ,
@@ -199,7 +210,10 @@ func (m *Manager) updateWeb(ctx context.Context, c *websvc.Config) (err error) {
199
210
}
200
211
}
201
212
202
- m .web = websvc .New (c )
213
+ m .web , err = websvc .New (c )
214
+ if err != nil {
215
+ return fmt .Errorf ("creating web svc: %w" , err )
216
+ }
203
217
204
218
return nil
205
219
}
0 commit comments