Skip to content

Commit 2972bd9

Browse files
committed
fixup! Adds new constructor for setting up networks
Signed-off-by: xibz <[email protected]>
1 parent 98d75b0 commit 2972bd9

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

machine.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ func NewMachine(ctx context.Context, cfg Config, opts ...Opt) (*Machine, error)
255255
}
256256

257257
m.Handlers = defaultHandlers
258+
258259
if cfg.JailerCfg != nil {
259260
m.Handlers.Validation = m.Handlers.Validation.Append(JailerConfigValidationHandler)
260261
if err := jail(ctx, m, &cfg); err != nil {
@@ -267,6 +268,10 @@ func NewMachine(ctx context.Context, cfg Config, opts ...Opt) (*Machine, error)
267268
Build(ctx)
268269
}
269270

271+
for _, opt := range opts {
272+
opt(m)
273+
}
274+
270275
if m.logger == nil {
271276
logger := log.New()
272277
if cfg.Debug {
@@ -291,10 +296,8 @@ func NewMachine(ctx context.Context, cfg Config, opts ...Opt) (*Machine, error)
291296
m.machineConfig = cfg.MachineCfg
292297
m.Cfg = cfg
293298

294-
m.Handlers.FcInit = m.Handlers.FcInit.Swap(NewSetupNetworkHandler(m.netNSPath()))
295-
296-
for _, opt := range opts {
297-
opt(m)
299+
if netNSPath := m.netNSPath(); netNSPath != "" {
300+
m.Handlers.FcInit = m.Handlers.FcInit.Swap(NewSetupNetworkHandler(netNSPath))
298301
}
299302

300303
m.logger.Debug("Called NewMachine()")

0 commit comments

Comments
 (0)