// initDefaultLibStorageServices initializes the config object with a default // libStorage service if one is not present. // // TODO Move this into libStorage in libStorage 0.1.2 func initDefaultLibStorageServices( ctx apitypes.Context, config gofig.Config) error { if config.IsSet(apitypes.ConfigServices) { ctx.Debug( "libStorage auto service mode disabled; services defined") return nil } serviceName := config.GetString(apitypes.ConfigService) if serviceName == "" { ctx.Debug( "libStorage auto service mode disabled; service name empty") return nil } ctx.WithField("driver", serviceName).Info( "libStorage auto service mode enabled") buf := &bytes.Buffer{} fmt.Fprintf(buf, defaultServiceConfigFormat, serviceName) if err := config.ReadConfig(buf); err != nil { return err } return nil }
func getTestConfigs( t *testing.T, driver string, config gofig.Config) (map[int]string, []gofig.Config) { libstorageConfigMap := map[string]interface{}{ "server": map[string]interface{}{ "services": map[string]interface{}{ driver: map[string]interface{}{ "libstorage": map[string]interface{}{ "storage": map[string]interface{}{ "driver": driver, }, }, }, }, }, } initTestConfigs(libstorageConfigMap) libstorageConfig := map[string]interface{}{ "libstorage": libstorageConfigMap, } yamlBuf, err := yaml.Marshal(libstorageConfig) assert.NoError(t, err) assert.NoError(t, config.ReadConfig(bytes.NewReader(yamlBuf))) configNames := map[int]string{} configs := []gofig.Config{} if tcpTest { configNames[len(configNames)] = "tcp" configs = append(configs, config.Scope("libstorage.tests.tcp")) } if tcpTLSTest { configNames[len(configNames)] = "tcpTLS" configs = append(configs, config.Scope("libstorage.tests.tcpTLS")) } if sockTest { configNames[len(configNames)] = "unix" configs = append(configs, config.Scope("libstorage.tests.unix")) } if sockTLSTest { configNames[len(configNames)] = "unixTLS" configs = append(configs, config.Scope("libstorage.tests.unixTLS")) } return configNames, configs }