當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Engine.Hack_GetGlobalVar方法代碼示例

本文整理匯總了Golang中github.com/dotcloud/docker/engine.Engine.Hack_GetGlobalVar方法的典型用法代碼示例。如果您正苦於以下問題:Golang Engine.Hack_GetGlobalVar方法的具體用法?Golang Engine.Hack_GetGlobalVar怎麽用?Golang Engine.Hack_GetGlobalVar使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/dotcloud/docker/engine.Engine的用法示例。


在下文中一共展示了Engine.Hack_GetGlobalVar方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: mkRuntimeFromEngine

func mkRuntimeFromEngine(eng *engine.Engine, t utils.Fataler) *docker.Runtime {
	iRuntime := eng.Hack_GetGlobalVar("httpapi.runtime")
	if iRuntime == nil {
		panic("Legacy runtime field not set in engine")
	}
	runtime, ok := iRuntime.(*docker.Runtime)
	if !ok {
		panic("Legacy runtime field in engine does not cast to *docker.Runtime")
	}
	return runtime
}
開發者ID:krast,項目名稱:docker,代碼行數:11,代碼來源:utils_test.go

示例2: mkServerFromEngine

func mkServerFromEngine(eng *engine.Engine, t utils.Fataler) *docker.Server {
	iSrv := eng.Hack_GetGlobalVar("httpapi.server")
	if iSrv == nil {
		panic("Legacy server field not set in engine")
	}
	srv, ok := iSrv.(*docker.Server)
	if !ok {
		panic("Legacy server field in engine does not cast to *docker.Server")
	}
	return srv
}
開發者ID:krast,項目名稱:docker,代碼行數:11,代碼來源:utils_test.go

示例3: mkDaemonFromEngine

func mkDaemonFromEngine(eng *engine.Engine, t utils.Fataler) *daemon.Daemon {
	iDaemon := eng.Hack_GetGlobalVar("httpapi.daemon")
	if iDaemon == nil {
		panic("Legacy daemon field not set in engine")
	}
	daemon, ok := iDaemon.(*daemon.Daemon)
	if !ok {
		panic("Legacy daemon field in engine does not cast to *daemon.Daemon")
	}
	return daemon
}
開發者ID:98pm,項目名稱:docker,代碼行數:11,代碼來源:utils_test.go

示例4: buildImage

func buildImage(context testContextTemplate, t *testing.T, eng *engine.Engine, useCache bool) (*image.Image, error) {
	if eng == nil {
		eng = NewTestEngine(t)
		runtime := mkDaemonFromEngine(eng, t)
		// FIXME: we might not need runtime, why not simply nuke
		// the engine?
		defer nuke(runtime)
	}
	srv := mkServerFromEngine(eng, t)

	httpServer, err := mkTestingFileServer(context.remoteFiles)
	if err != nil {
		t.Fatal(err)
	}
	defer httpServer.Close()

	idx := strings.LastIndex(httpServer.URL, ":")
	if idx < 0 {
		t.Fatalf("could not get port from test http server address %s", httpServer.URL)
	}
	port := httpServer.URL[idx+1:]

	iIP := eng.Hack_GetGlobalVar("httpapi.bridgeIP")
	if iIP == nil {
		t.Fatal("Legacy bridgeIP field not set in engine")
	}
	ip, ok := iIP.(net.IP)
	if !ok {
		panic("Legacy bridgeIP field in engine does not cast to net.IP")
	}
	dockerfile := constructDockerfile(context.dockerfile, ip, port)

	buildfile := server.NewBuildFile(srv, ioutil.Discard, ioutil.Discard, false, useCache, false, false, ioutil.Discard, utils.NewStreamFormatter(false), nil, nil)
	id, err := buildfile.Build(context.Archive(dockerfile, t))
	if err != nil {
		return nil, err
	}

	job := eng.Job("image_inspect", id)
	buffer := bytes.NewBuffer(nil)
	image := &image.Image{}
	job.Stdout.Add(buffer)
	if err := job.Run(); err != nil {
		return nil, err
	}
	err = json.NewDecoder(buffer).Decode(image)
	return image, err
}
開發者ID:98pm,項目名稱:docker,代碼行數:48,代碼來源:buildfile_test.go

示例5: buildImage

func buildImage(context testContextTemplate, t *testing.T, eng *engine.Engine, useCache bool) *docker.Image {
	if eng == nil {
		eng = NewTestEngine(t)
		runtime := mkRuntimeFromEngine(eng, t)
		// FIXME: we might not need runtime, why not simply nuke
		// the engine?
		defer nuke(runtime)
	}
	srv := mkServerFromEngine(eng, t)

	httpServer, err := mkTestingFileServer(context.remoteFiles)
	if err != nil {
		t.Fatal(err)
	}
	defer httpServer.Close()

	idx := strings.LastIndex(httpServer.URL, ":")
	if idx < 0 {
		t.Fatalf("could not get port from test http server address %s", httpServer.URL)
	}
	port := httpServer.URL[idx+1:]

	iIP := eng.Hack_GetGlobalVar("httpapi.bridgeIP")
	if iIP == nil {
		t.Fatal("Legacy bridgeIP field not set in engine")
	}
	ip, ok := iIP.(net.IP)
	if !ok {
		panic("Legacy bridgeIP field in engine does not cast to net.IP")
	}
	dockerfile := constructDockerfile(context.dockerfile, ip, port)

	buildfile := docker.NewBuildFile(srv, ioutil.Discard, false, useCache, false)
	id, err := buildfile.Build(mkTestContext(dockerfile, context.files, t))
	if err != nil {
		t.Fatal(err)
	}

	img, err := srv.ImageInspect(id)
	if err != nil {
		t.Fatal(err)
	}
	return img
}
開發者ID:kasiajanocha,項目名稱:docker,代碼行數:44,代碼來源:buildfile_test.go


注:本文中的github.com/dotcloud/docker/engine.Engine.Hack_GetGlobalVar方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。