本文整理汇总了Golang中github.com/docker/docker/daemon/graphdriver.NaiveDiffDriver函数的典型用法代码示例。如果您正苦于以下问题:Golang NaiveDiffDriver函数的具体用法?Golang NaiveDiffDriver怎么用?Golang NaiveDiffDriver使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NaiveDiffDriver函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: Init
func Init(home string, options []string) (graphdriver.Driver, error) {
rootdir := path.Dir(home)
var buf syscall.Statfs_t
if err := syscall.Statfs(rootdir, &buf); err != nil {
return nil, err
}
if graphdriver.FsMagic(buf.Type) != graphdriver.FsMagicBtrfs {
return nil, graphdriver.ErrPrerequisites
}
if err := os.MkdirAll(home, 0700); err != nil {
return nil, err
}
if err := graphdriver.MakePrivate(home); err != nil {
return nil, err
}
driver := &Driver{
home: home,
}
return graphdriver.NaiveDiffDriver(driver), nil
}
开发者ID:TencentSA,项目名称:docker-1.3,代码行数:26,代码来源:btrfs.go
示例2: Init
// Init creates a driver with the given home and the set of options.
func Init(home string, options []string) (graphdriver.Driver, error) {
fsMagic, err := graphdriver.GetFSMagic(home)
if err != nil {
return nil, err
}
if fsName, ok := graphdriver.FsNames[fsMagic]; ok {
backingFs = fsName
}
deviceSet, err := NewDeviceSet(home, true, options)
if err != nil {
return nil, err
}
if err := mount.MakePrivate(home); err != nil {
return nil, err
}
d := &Driver{
DeviceSet: deviceSet,
home: home,
}
return graphdriver.NaiveDiffDriver(d), nil
}
开发者ID:waterytowers,项目名称:global-hack-day-3,代码行数:26,代码来源:driver.go
示例3: main
func main() {
s := Struct{
x: 1,
}
if s.t.IsZero() {
fmt.Println("s.t is nil, %v %v", s.t, s)
}
fmt.Println("%v", s.t)
var used, total uint64 = 9, 18
fmt.Println(float64(used)/float64(total) > 0.4)
var f float64 = 12.45
fmtFloat := strconv.FormatFloat(f, 'f', 3, 64)
fmt.Println(fmtFloat)
fmt.Println(strconv.ParseFloat(fmtFloat, 64))
if "xx" == "x" {
fmt.Println("xx==x")
}
if "xx" == "xx" {
fmt.Println("xx==xx")
}
s1 := Struct1{
a: 1,
Struct: Struct{
x: 3,
y: 5,
},
}
fmt.Println(reflect.TypeOf(s1.Struct).String())
fmt.Println(s1.Struct.x)
d := &Driver{
h: 4,
}
fmt.Println(d.M())
driver := graphdriver.NaiveDiffDriver(d)
fmt.Println(driver)
fmt.Println(reflect.TypeOf(driver.(graphdriver.ProtoDriver)).String())
fmt.Println(reflect.TypeOf(driver).String())
fmt.Println(reflect.ValueOf(driver).Elem().FieldByName("ProtoDriver").Elem())
fmt.Println(reflect.ValueOf(driver).Elem().FieldByName("ProtoDriver").Elem().Elem())
fmt.Println(reflect.ValueOf(driver).Elem().FieldByName("ProtoDriver").Elem().Elem().FieldByName("h").Int())
fmt.Println(reflect.ValueOf(driver).Elem().FieldByName("ProtoDriver").Elem().Interface().(*Driver).M())
// fmt.Println(reflect.ValueOf(driver).Elem().FieldByName("ProtoDriver").Elem().Elem().Interface().(Driver).M())
// fmt.Println(driver.(graphdriver.ProtoDriver).(*Driver))
// fmt.Println(driver.(graphdriver.ProtoDriver).(*Driver).h)
fmt.Printf("%#v", driver.String())
fmt.Println()
// fmt.Printf("%#v", driver.(graphdriver.ProtoDriver).(*Driver))
}
开发者ID:chenchun,项目名称:accumulation,代码行数:52,代码来源:type.go
示例4: Init
func Init(home string, options []string) (graphdriver.Driver, error) {
deviceSet, err := NewDeviceSet(home, true, options)
if err != nil {
return nil, err
}
if err := mount.MakePrivate(home); err != nil {
return nil, err
}
d := &Driver{
DeviceSet: deviceSet,
home: home,
}
return graphdriver.NaiveDiffDriver(d), nil
}
开发者ID:harshavardhana,项目名称:docker,代码行数:17,代码来源:driver.go
示例5: Init
func Init(home string, options []string) (graphdriver.Driver, error) {
if err := os.MkdirAll(home, 0700); err != nil && !os.IsExist(err) {
log.Errorf("Rbd create home dir %s failed: %v", err)
return nil, err
}
rbdSet, err := NewRbdSet(home, true, options)
if err != nil {
return nil, err
}
if err := graphdriver.MakePrivate(home); err != nil {
return nil, err
}
d := &RbdDriver{
RbdSet: rbdSet,
home: home,
}
return graphdriver.NaiveDiffDriver(d), nil
}
开发者ID:hustcat,项目名称:docker-rbd-driver,代码行数:22,代码来源:rbd_test.go
示例6: Init
func Init(home string, options []string) (graphdriver.Driver, error) {
d := &Driver{
home: home,
}
return graphdriver.NaiveDiffDriver(d), nil
}
开发者ID:hustcat,项目名称:docker-1.3,代码行数:6,代码来源:driver.go
示例7: Init
// Init returns a new ZFS driver.
// It takes base mount path and a array of options which are represented as key value pairs.
// Each option is in the for key=value. 'zfs.fsname' is expected to be a valid key in the options.
func Init(base string, opt []string) (graphdriver.Driver, error) {
var err error
if _, err := exec.LookPath("zfs"); err != nil {
logrus.Debugf("[zfs] zfs command is not available: %v", err)
return nil, graphdriver.ErrPrerequisites
}
file, err := os.OpenFile("/dev/zfs", os.O_RDWR, 600)
if err != nil {
logrus.Debugf("[zfs] cannot open /dev/zfs: %v", err)
return nil, graphdriver.ErrPrerequisites
}
defer file.Close()
options, err := parseOptions(opt)
if err != nil {
return nil, err
}
options.mountPath = base
rootdir := path.Dir(base)
if options.fsName == "" {
err = checkRootdirFs(rootdir)
if err != nil {
return nil, err
}
}
if options.fsName == "" {
options.fsName, err = lookupZfsDataset(rootdir)
if err != nil {
return nil, err
}
}
zfs.SetLogger(new(Logger))
filesystems, err := zfs.Filesystems(options.fsName)
if err != nil {
return nil, fmt.Errorf("Cannot find root filesystem %s: %v", options.fsName, err)
}
filesystemsCache := make(map[string]bool, len(filesystems))
var rootDataset *zfs.Dataset
for _, fs := range filesystems {
if fs.Name == options.fsName {
rootDataset = fs
}
filesystemsCache[fs.Name] = true
}
if rootDataset == nil {
return nil, fmt.Errorf("BUG: zfs get all -t filesystem -rHp '%s' should contain '%s'", options.fsName, options.fsName)
}
d := &Driver{
dataset: rootDataset,
options: options,
filesystemsCache: filesystemsCache,
}
return graphdriver.NaiveDiffDriver(d), nil
}
开发者ID:nilsotto,项目名称:docker,代码行数:67,代码来源:zfs.go
示例8: NaiveDiffDriverWithApply
func NaiveDiffDriverWithApply(driver ApplyDiffProtoDriver) graphdriver.Driver {
return &naiveDiffDriverWithApply{
Driver: graphdriver.NaiveDiffDriver(driver),
applyDiff: driver,
}
}
开发者ID:prologic,项目名称:docker,代码行数:6,代码来源:overlayfs.go
示例9: SetUpSuite
func (s *DockerExternalGraphdriverSuite) SetUpSuite(c *check.C) {
mux := http.NewServeMux()
s.server = httptest.NewServer(mux)
type graphDriverRequest struct {
ID string `json:",omitempty"`
Parent string `json:",omitempty"`
MountLabel string `json:",omitempty"`
}
type graphDriverResponse struct {
Err error `json:",omitempty"`
Dir string `json:",omitempty"`
Exists bool `json:",omitempty"`
Status [][2]string `json:",omitempty"`
Metadata map[string]string `json:",omitempty"`
Changes []archive.Change `json:",omitempty"`
Size int64 `json:",omitempty"`
}
respond := func(w http.ResponseWriter, data interface{}) {
w.Header().Set("Content-Type", "appplication/vnd.docker.plugins.v1+json")
switch t := data.(type) {
case error:
fmt.Fprintln(w, fmt.Sprintf(`{"Err": %s}`, t.Error()))
case string:
fmt.Fprintln(w, t)
default:
json.NewEncoder(w).Encode(&data)
}
}
base, err := ioutil.TempDir("", "external-graph-test")
c.Assert(err, check.IsNil)
vfsProto, err := vfs.Init(base, []string{})
if err != nil {
c.Fatalf("error initializing graph driver: %v", err)
}
driver := graphdriver.NaiveDiffDriver(vfsProto)
mux.HandleFunc("/Plugin.Activate", func(w http.ResponseWriter, r *http.Request) {
s.ec.activations++
respond(w, `{"Implements": ["GraphDriver"]}`)
})
mux.HandleFunc("/GraphDriver.Init", func(w http.ResponseWriter, r *http.Request) {
s.ec.init++
respond(w, "{}")
})
mux.HandleFunc("/GraphDriver.Create", func(w http.ResponseWriter, r *http.Request) {
s.ec.creations++
var req graphDriverRequest
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
http.Error(w, err.Error(), 500)
return
}
if err := driver.Create(req.ID, req.Parent); err != nil {
respond(w, err)
return
}
respond(w, "{}")
})
mux.HandleFunc("/GraphDriver.Remove", func(w http.ResponseWriter, r *http.Request) {
s.ec.removals++
var req graphDriverRequest
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
http.Error(w, err.Error(), 500)
return
}
if err := driver.Remove(req.ID); err != nil {
respond(w, err)
return
}
respond(w, "{}")
})
mux.HandleFunc("/GraphDriver.Get", func(w http.ResponseWriter, r *http.Request) {
s.ec.gets++
var req graphDriverRequest
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
http.Error(w, err.Error(), 500)
}
dir, err := driver.Get(req.ID, req.MountLabel)
if err != nil {
respond(w, err)
return
}
respond(w, &graphDriverResponse{Dir: dir})
})
mux.HandleFunc("/GraphDriver.Put", func(w http.ResponseWriter, r *http.Request) {
s.ec.puts++
//.........这里部分代码省略.........
开发者ID:tino415,项目名称:docker,代码行数:101,代码来源:docker_cli_external_graphdriver_unix_test.go
注:本文中的github.com/docker/docker/daemon/graphdriver.NaiveDiffDriver函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论