libnetwork/config: remove options that were only used in tests
The OptionLocalKVProvider, OptionLocalKVProviderURL, and OptionLocalKVProviderConfig options were only used in tests, so un-export them, and move them to the test-files. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
bc80c5d067
commit
cda187222e
3 changed files with 34 additions and 41 deletions
|
@ -7,7 +7,6 @@ import (
|
|||
"github.com/containerd/containerd/log"
|
||||
"github.com/docker/docker/libnetwork/cluster"
|
||||
"github.com/docker/docker/libnetwork/datastore"
|
||||
store "github.com/docker/docker/libnetwork/internal/kvstore"
|
||||
"github.com/docker/docker/libnetwork/ipamutils"
|
||||
"github.com/docker/docker/libnetwork/netlabel"
|
||||
"github.com/docker/docker/libnetwork/osl"
|
||||
|
@ -141,30 +140,6 @@ func IsValidName(name string) bool {
|
|||
return strings.TrimSpace(name) != ""
|
||||
}
|
||||
|
||||
// OptionLocalKVProvider function returns an option setter for kvstore provider
|
||||
func OptionLocalKVProvider(provider string) Option {
|
||||
return func(c *Config) {
|
||||
log.G(context.TODO()).Debugf("Option OptionLocalKVProvider: %s", provider)
|
||||
c.Scope.Client.Provider = strings.TrimSpace(provider)
|
||||
}
|
||||
}
|
||||
|
||||
// OptionLocalKVProviderURL function returns an option setter for kvstore url
|
||||
func OptionLocalKVProviderURL(url string) Option {
|
||||
return func(c *Config) {
|
||||
log.G(context.TODO()).Debugf("Option OptionLocalKVProviderURL: %s", url)
|
||||
c.Scope.Client.Address = strings.TrimSpace(url)
|
||||
}
|
||||
}
|
||||
|
||||
// OptionLocalKVProviderConfig function returns an option setter for kvstore config
|
||||
func OptionLocalKVProviderConfig(config *store.Config) Option {
|
||||
return func(c *Config) {
|
||||
log.G(context.TODO()).Debugf("Option OptionLocalKVProviderConfig: %v", config)
|
||||
c.Scope.Client.Config = config
|
||||
}
|
||||
}
|
||||
|
||||
// OptionActiveSandboxes function returns an option setter for passing the sandboxes
|
||||
// which were active during previous daemon life
|
||||
func OptionActiveSandboxes(sandboxes map[string]interface{}) Option {
|
||||
|
|
|
@ -32,15 +32,13 @@ func TestMain(m *testing.M) {
|
|||
|
||||
func newController(t *testing.T) *libnetwork.Controller {
|
||||
t.Helper()
|
||||
genericOption := map[string]interface{}{
|
||||
netlabel.GenericData: options.Generic{
|
||||
"EnableIPForwarding": true,
|
||||
},
|
||||
}
|
||||
|
||||
c, err := libnetwork.New(
|
||||
libnetwork.OptionBoltdbWithRandomDBFile(t),
|
||||
config.OptionDriverConfig(bridgeNetType, genericOption),
|
||||
config.OptionDriverConfig(bridgeNetType, map[string]interface{}{
|
||||
netlabel.GenericData: options.Generic{
|
||||
"EnableIPForwarding": true,
|
||||
},
|
||||
}),
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
@ -56,9 +54,7 @@ func createTestNetwork(c *libnetwork.Controller, networkType, networkName string
|
|||
}
|
||||
|
||||
func getEmptyGenericOption() map[string]interface{} {
|
||||
genericOption := make(map[string]interface{})
|
||||
genericOption[netlabel.GenericData] = map[string]string{}
|
||||
return genericOption
|
||||
return map[string]interface{}{netlabel.GenericData: map[string]string{}}
|
||||
}
|
||||
|
||||
func getPortMapping() []types.PortBinding {
|
||||
|
|
|
@ -3,6 +3,7 @@ package libnetwork
|
|||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/docker/docker/libnetwork/config"
|
||||
|
@ -14,9 +15,9 @@ import (
|
|||
|
||||
func testLocalBackend(t *testing.T, provider, url string, storeConfig *store.Config) {
|
||||
cfgOptions := []config.Option{}
|
||||
cfgOptions = append(cfgOptions, config.OptionLocalKVProvider(provider))
|
||||
cfgOptions = append(cfgOptions, config.OptionLocalKVProviderURL(url))
|
||||
cfgOptions = append(cfgOptions, config.OptionLocalKVProviderConfig(storeConfig))
|
||||
cfgOptions = append(cfgOptions, optionLocalKVProvider(provider))
|
||||
cfgOptions = append(cfgOptions, optionLocalKVProviderURL(url))
|
||||
cfgOptions = append(cfgOptions, optionLocalKVProviderConfig(storeConfig))
|
||||
|
||||
driverOptions := options.Generic{}
|
||||
genericOption := make(map[string]interface{})
|
||||
|
@ -65,9 +66,30 @@ func OptionBoltdbWithRandomDBFile(t *testing.T) config.Option {
|
|||
}
|
||||
|
||||
return func(c *config.Config) {
|
||||
config.OptionLocalKVProvider("boltdb")(c)
|
||||
config.OptionLocalKVProviderURL(tmp)(c)
|
||||
config.OptionLocalKVProviderConfig(&store.Config{Bucket: "testBackend"})(c)
|
||||
optionLocalKVProvider("boltdb")(c)
|
||||
optionLocalKVProviderURL(tmp)(c)
|
||||
optionLocalKVProviderConfig(&store.Config{Bucket: "testBackend"})(c)
|
||||
}
|
||||
}
|
||||
|
||||
// optionLocalKVProvider function returns an option setter for kvstore provider
|
||||
func optionLocalKVProvider(provider string) config.Option {
|
||||
return func(c *config.Config) {
|
||||
c.Scope.Client.Provider = strings.TrimSpace(provider)
|
||||
}
|
||||
}
|
||||
|
||||
// optionLocalKVProviderURL function returns an option setter for kvstore url
|
||||
func optionLocalKVProviderURL(url string) config.Option {
|
||||
return func(c *config.Config) {
|
||||
c.Scope.Client.Address = strings.TrimSpace(url)
|
||||
}
|
||||
}
|
||||
|
||||
// optionLocalKVProviderConfig function returns an option setter for kvstore config
|
||||
func optionLocalKVProviderConfig(cfg *store.Config) config.Option {
|
||||
return func(c *config.Config) {
|
||||
c.Scope.Client.Config = cfg
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue