isle/go/daemon/network/constructors.go

64 lines
1.5 KiB
Go
Raw Permalink Normal View History

2024-12-17 15:05:41 +00:00
//go:generate mockery --name constructors --inpackage --filename constructors_mock.go
package network
import (
"context"
"isle/bootstrap"
"isle/daemon/children"
"isle/nebula"
"isle/toolkit"
"dev.mediocregopher.com/mediocre-go-lib.git/mlog"
)
// constructors wraps the various Network constructor functions in an interface,
// so that they can be mocked.
//
// This is needed primarily for testing the Loader. We can't test the Loader
// during Network integration tests because the Loader doesn't allow multiple
// Networks with the same ID to be loaded, but we need to do so in integration
// tests. Working around that requirement in the integration tests would add
// extra complexity there, and it's better to do unit testing anyway.
type constructors interface {
load(
ctx context.Context,
logger *mlog.Logger,
envBinDirPath string,
nebulaDeviceNamer *children.NebulaDeviceNamer,
stateDir toolkit.Dir,
runtimeDir toolkit.Dir,
opts *Opts,
) (
Network, error,
)
join(
ctx context.Context,
logger *mlog.Logger,
envBinDirPath string,
nebulaDeviceNamer *children.NebulaDeviceNamer,
joiningBootstrap JoiningBootstrap,
stateDir toolkit.Dir,
runtimeDir toolkit.Dir,
opts *Opts,
) (
Network, error,
)
create(
ctx context.Context,
logger *mlog.Logger,
envBinDirPath string,
nebulaDeviceNamer *children.NebulaDeviceNamer,
stateDir toolkit.Dir,
runtimeDir toolkit.Dir,
creationParams bootstrap.CreationParams,
ipNet nebula.IPNet,
hostName nebula.HostName,
opts *Opts,
) (
Network, error,
)
}