本文整理匯總了Golang中github.com/emccode/rexray/core.New函數的典型用法代碼示例。如果您正苦於以下問題:Golang New函數的具體用法?Golang New怎麽用?Golang New使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了New函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: NewWithConfigReader
// NewWithConfigReader creates a new REX-Ray instance and configures it with a
// custom configuration stream.
func NewWithConfigReader(in io.Reader) (*core.RexRay, error) {
c := gofig.New()
if err := c.ReadConfig(in); err != nil {
return nil, err
}
return core.New(c), nil
}
示例2: NewWithConfigFile
// NewWithConfigFile creates a new REX-Ray instance and configures it with a
// custom configuration file.
func NewWithConfigFile(path string) (*core.RexRay, error) {
c := gofig.New()
if err := c.ReadConfigFile(path); err != nil {
return nil, err
}
return core.New(c), nil
}
示例3: TestNewWithBadVolumeDriver
func TestNewWithBadVolumeDriver(t *testing.T) {
r := core.New(nil)
r.Config.OSDrivers = []string{mock.MockOSDriverName}
r.Config.VolumeDrivers = []string{mock.BadMockVolDriverName}
r.Config.StorageDrivers = []string{mock.MockStorDriverName}
if err := r.InitDrivers(); err != errors.ErrNoVolumeDrivers {
t.Fatal(err)
}
}
示例4: newModule
func newModule(id int32, cfg *module.Config) (module.Module, error) {
return &mod{
id: id,
r: core.New(cfg.Config),
name: modName,
desc: modDescription,
addr: cfg.Address,
}, nil
}
示例5: getRexRayNoDrivers
func getRexRayNoDrivers() (*core.RexRay, error) {
c := gofig.New()
c.Set("rexray.osDrivers", []string{""})
c.Set("rexray.volumeDrivers", []string{""})
c.Set("rexray.storageDrivers", []string{""})
r := core.New(c)
r.InitDrivers()
return r, nil
}
示例6: getRexRayNoDrivers
func getRexRayNoDrivers() (*core.RexRay, error) {
c := config.New()
c.OSDrivers = []string{""}
c.VolumeDrivers = []string{""}
c.StorageDrivers = []string{""}
r := core.New(c)
r.InitDrivers()
return r, nil
}
示例7: TestNewWithBadStorageDriver
func TestNewWithBadStorageDriver(t *testing.T) {
r := core.New(nil)
r.Config.Set("osDrivers", []string{mock.MockOSDriverName})
r.Config.Set("volumeDrivers", []string{mock.MockVolDriverName})
r.Config.Set("storageDrivers", []string{mock.BadMockStorDriverName})
if err := r.InitDrivers(); err != errors.ErrNoStorageDrivers {
t.Fatal(err)
}
}
示例8: TestNewNoVolumeDrivers
func TestNewNoVolumeDrivers(t *testing.T) {
c := gofig.New()
c.Set("rexray.osDrivers", []string{mock.MockOSDriverName})
c.Set("rexray.volumeDrivers", []string{})
c.Set("rexray.storageDrivers", []string{mock.MockStorDriverName})
r := core.New(c)
if err := r.InitDrivers(); err != errors.ErrNoVolumeDrivers {
t.Fatal(err)
}
}
示例9: TestNewNoStorageDrivers
func TestNewNoStorageDrivers(t *testing.T) {
c := config.New()
c.Set("osDrivers", []string{mock.MockOSDriverName})
c.Set("volumeDrivers", []string{mock.MockVolDriverName})
c.Set("storageDrivers", []string{})
r := core.New(c)
if err := r.InitDrivers(); err != errors.ErrNoStorageDrivers {
t.Fatal(err)
}
}
示例10: TestNewNoVolumeDrivers
func TestNewNoVolumeDrivers(t *testing.T) {
c := config.New()
c.OSDrivers = []string{mock.MockOSDriverName}
c.VolumeDrivers = []string{}
c.StorageDrivers = []string{mock.MockStorDriverName}
r := core.New(c)
if err := r.InitDrivers(); err != errors.ErrNoVolumeDrivers {
t.Fatal(err)
}
}
示例11: TestNewWithNilConfig
func TestNewWithNilConfig(t *testing.T) {
r := core.New(nil)
r.Config.Set("rexray.osDrivers", []string{mock.MockOSDriverName})
r.Config.Set("rexray.volumeDrivers", []string{mock.MockVolDriverName})
r.Config.Set("rexray.storageDrivers", []string{mock.MockStorDriverName})
if err := r.InitDrivers(); err != nil {
t.Fatal(err)
}
assertDriverNames(t, r)
}
示例12: TestNewWithNilConfig
func TestNewWithNilConfig(t *testing.T) {
r := core.New(nil)
r.Config.OSDrivers = []string{mock.MockOSDriverName}
r.Config.VolumeDrivers = []string{mock.MockVolDriverName}
r.Config.StorageDrivers = []string{mock.MockStorDriverName}
if err := r.InitDrivers(); err != nil {
t.Fatal(err)
}
assertDriverNames(t, r)
}
示例13: getRexRay
func getRexRay() (*core.RexRay, error) {
c := gofig.New()
c.Set("rexray.osDrivers", []string{mock.MockOSDriverName})
c.Set("rexray.volumeDrivers", []string{mock.MockVolDriverName})
c.Set("rexray.storageDrivers", []string{mock.MockStorDriverName})
r := core.New(c)
if err := r.InitDrivers(); err != nil {
return nil, err
}
return r, nil
}
示例14: getRexRay
func getRexRay() (*core.RexRay, error) {
c := config.New()
c.OSDrivers = []string{mock.MockOSDriverName}
c.VolumeDrivers = []string{mock.MockVolDriverName}
c.StorageDrivers = []string{mock.MockStorDriverName}
r := core.New(c)
if err := r.InitDrivers(); err != nil {
return nil, err
}
return r, nil
}
示例15: newModule
func newModule(c *module.Config) (module.Module, error) {
host := strings.Trim(c.Address, " ")
if host == "" {
if c.Name == "default-docker" {
host = "unix:///run/docker/plugins/rexray.sock"
} else {
fname := cleanName(c.Name)
host = fmt.Sprintf("unix:///run/docker/plugins/%s.sock", fname)
}
}
c.Address = host
return &mod{
r: core.New(c.Config),
name: c.Name,
desc: c.Description,
addr: host,
}, nil
}