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


Golang engine.Env類代碼示例

本文整理匯總了Golang中github.com/fsouza/go-dockerclient/engine.Env的典型用法代碼示例。如果您正苦於以下問題:Golang Env類的具體用法?Golang Env怎麽用?Golang Env使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: Info

// Info returns system-wide information, like the number of running containers.
//
// See http://goo.gl/LOmySw for more details.
func (c *Client) Info() (*engine.Env, error) {
	body, _, err := c.do("GET", "/info", nil)
	if err != nil {
		return nil, err
	}
	var info engine.Env
	err = info.Decode(bytes.NewReader(body))
	if err != nil {
		return nil, err
	}
	return &info, nil
}
開發者ID:Jingzhe88,項目名稱:kubernetes,代碼行數:15,代碼來源:misc.go

示例2: GetConnection

func GetConnection(dockerSocket string) (*DockerClient, error) {
	var (
		client          *gdocker.Client
		err             error
		info            *engine.Env
		executionDriver string
	)

	client, err = gdocker.NewClient(dockerSocket)
	if err != nil {
		fmt.Println("Unable to connect to docker server:", err.Error())
		return nil, err
	}

	if info, err = client.Info(); err != nil {
		return nil, err
	}
	executionDriver = info.Get("ExecutionDriver")

	return &DockerClient{client, executionDriver}, nil
}
開發者ID:jcantrill,項目名稱:geard,代碼行數:21,代碼來源:docker.go

示例3: TestInfo

func TestInfo(t *testing.T) {
	body := `{
     "Containers":11,
     "Images":16,
     "Debug":0,
     "NFd":11,
     "NGoroutines":21,
     "MemoryLimit":1,
     "SwapLimit":0
}`
	fakeRT := FakeRoundTripper{message: body, status: http.StatusOK}
	client := newTestClient(&fakeRT)
	expected := engine.Env{}
	expected.SetInt("Containers", 11)
	expected.SetInt("Images", 16)
	expected.SetBool("Debug", false)
	expected.SetInt("NFd", 11)
	expected.SetInt("NGoroutines", 21)
	expected.SetBool("MemoryLimit", true)
	expected.SetBool("SwapLimit", false)
	info, err := client.Info()
	if err != nil {
		t.Fatal(err)
	}
	infoSlice := []string(*info)
	expectedSlice := []string(expected)
	sort.Strings(infoSlice)
	sort.Strings(expectedSlice)
	if !reflect.DeepEqual(expectedSlice, infoSlice) {
		t.Errorf("Info(): Wrong result.\nWant %#v.\nGot %#v.", expected, *info)
	}
	req := fakeRT.requests[0]
	if req.Method != "GET" {
		t.Errorf("Info(): Wrong HTTP method. Want GET. Got %s.", req.Method)
	}
	u, _ := url.Parse(client.getURL("/info"))
	if req.URL.Path != u.Path {
		t.Errorf("Info(): Wrong request path. Want %q. Got %q.", u.Path, req.URL.Path)
	}
}
開發者ID:289,項目名稱:kubernetes,代碼行數:40,代碼來源:misc_test.go


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