• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang client.CreateHTTPClient函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/deis/workflow/client/controller/client.CreateHTTPClient函数的典型用法代码示例。如果您正苦于以下问题:Golang CreateHTTPClient函数的具体用法?Golang CreateHTTPClient怎么用?Golang CreateHTTPClient使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了CreateHTTPClient函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: TestAppsRun

func TestAppsRun(t *testing.T) {
	t.Parallel()

	expected := api.AppRunResponse{
		Output:     "hi\n",
		ReturnCode: 0,
	}

	handler := fakeHTTPServer{}
	server := httptest.NewServer(&handler)
	defer server.Close()

	u, err := url.Parse(server.URL)

	if err != nil {
		t.Fatal(err)
	}

	httpClient := client.CreateHTTPClient(false)

	client := client.Client{HTTPClient: httpClient, ControllerURL: *u, Token: "abc"}

	actual, err := Run(&client, "example-go", "echo hi")

	if err != nil {
		t.Fatal(err)
	}

	if !reflect.DeepEqual(expected, actual) {
		t.Errorf("Expected %v, Got %v", expected, actual)
	}
}
开发者ID:arschles,项目名称:deis-controller,代码行数:32,代码来源:apps_test.go


示例2: TestCertsList

func TestCertsList(t *testing.T) {
	t.Parallel()

	expected := []api.Cert{
		{
			Name:    "test.example.com",
			Expires: "2014-01-01T00:00:00UTC",
		},
	}

	handler := fakeHTTPServer{}
	server := httptest.NewServer(handler)
	defer server.Close()

	u, err := url.Parse(server.URL)

	if err != nil {
		t.Fatal(err)
	}

	httpClient := client.CreateHTTPClient(false)

	client := client.Client{HTTPClient: httpClient, ControllerURL: *u, Token: "abc"}

	actual, _, err := List(&client, 100)

	if err != nil {
		t.Fatal(err)
	}

	if !reflect.DeepEqual(expected, actual) {
		t.Errorf("Expected %v, Got %v", expected, actual)
	}
}
开发者ID:arschles,项目名称:deis-controller,代码行数:34,代码来源:certs_test.go


示例3: TestListAdmins

func TestListAdmins(t *testing.T) {
	t.Parallel()

	expected := []string{
		"test",
		"foo",
	}

	handler := fakeHTTPServer{}
	server := httptest.NewServer(handler)
	defer server.Close()

	u, err := url.Parse(server.URL)

	if err != nil {
		t.Fatal(err)
	}

	httpClient := client.CreateHTTPClient(false)

	client := client.Client{HTTPClient: httpClient, ControllerURL: *u, Token: "abc"}

	actual, _, err := ListAdmins(&client, 100)

	if err != nil {
		t.Fatal(err)
	}

	if !reflect.DeepEqual(expected, actual) {
		t.Errorf("Expected %v, Got %v", expected, actual)
	}
}
开发者ID:arschles,项目名称:deis-controller,代码行数:32,代码来源:perms_test.go


示例4: TestLogin

func TestLogin(t *testing.T) {
	t.Parallel()

	handler := fakeHTTPServer{}
	server := httptest.NewServer(&handler)
	defer server.Close()

	u, err := url.Parse(server.URL)

	if err != nil {
		t.Fatal(err)
	}

	httpClient := client.CreateHTTPClient(false)
	client := client.Client{HTTPClient: httpClient, ControllerURL: *u}

	actual, err := Login(&client, "test", "opensesame")

	if err != nil {
		t.Error(err)
	}

	expected := "abc"

	if actual != expected {
		t.Errorf("Expected %s, Got %s", expected, actual)
	}
}
开发者ID:arschles,项目名称:deis-controller,代码行数:28,代码来源:auth_test.go


示例5: TestRollbacker

func TestRollbacker(t *testing.T) {
	t.Parallel()

	expected := 7

	handler := fakeHTTPServer{}
	server := httptest.NewServer(handler)
	defer server.Close()

	u, err := url.Parse(server.URL)

	if err != nil {
		t.Fatal(err)
	}

	httpClient := client.CreateHTTPClient(false)

	client := client.Client{HTTPClient: httpClient, ControllerURL: *u, Token: "abc"}

	actual, err := Rollback(&client, "rollbacker", -1)

	if err != nil {
		t.Fatal(err)
	}

	if expected != actual {
		t.Error(fmt.Errorf("Expected %v, Got %v", expected, actual))
	}
}
开发者ID:arschles,项目名称:deis-controller,代码行数:29,代码来源:releases_test.go


示例6: TestDomainsAdd

func TestDomainsAdd(t *testing.T) {
	t.Parallel()

	expected := api.Domain{
		App:     "example-go",
		Created: "2014-01-01T00:00:00UTC",
		Domain:  "example.example.com",
		Owner:   "test",
		Updated: "2014-01-01T00:00:00UTC",
	}

	handler := fakeHTTPServer{}
	server := httptest.NewServer(handler)
	defer server.Close()

	u, err := url.Parse(server.URL)

	if err != nil {
		t.Fatal(err)
	}

	httpClient := client.CreateHTTPClient(false)

	client := client.Client{HTTPClient: httpClient, ControllerURL: *u, Token: "abc"}

	actual, err := New(&client, "example-go", "example.example.com")

	if err != nil {
		t.Fatal(err)
	}

	if !reflect.DeepEqual(expected, actual) {
		t.Error(fmt.Errorf("Expected %v, Got %v", expected, actual))
	}
}
开发者ID:arschles,项目名称:deis-controller,代码行数:35,代码来源:domains_test.go


示例7: TestRegenerate

func TestRegenerate(t *testing.T) {
	t.Parallel()

	handler := fakeHTTPServer{}
	server := httptest.NewServer(&handler)
	defer server.Close()

	u, err := url.Parse(server.URL)

	if err != nil {
		t.Fatal(err)
	}

	httpClient := client.CreateHTTPClient(false)
	client := client.Client{HTTPClient: httpClient, ControllerURL: *u}

	token, err := Regenerate(&client, "", true)

	if err != nil {
		t.Error(err)
	}

	if token != "" {
		t.Errorf("Expected token be empty, Got %s", token)
	}

	token, err = Regenerate(&client, "test", false)

	if err != nil {
		t.Error(err)
	}

	expected := "123"
	if token != expected {
		t.Errorf("Expected %s, Got %s", expected, token)
	}

	token, err = Regenerate(&client, "", false)

	if err != nil {
		t.Error(err)
	}

	expected = "abc"
	if token != expected {
		t.Errorf("Expected %s, Got %s", expected, token)
	}
}
开发者ID:arschles,项目名称:deis-controller,代码行数:48,代码来源:auth_test.go


示例8: TestBuildsList

func TestBuildsList(t *testing.T) {
	t.Parallel()

	expected := []api.Build{
		{
			App:        "example-go",
			Created:    "2014-01-01T00:00:00UTC",
			Dockerfile: "FROM deis/slugrunner RUN mkdir -p /app WORKDIR /app ENTRYPOINT [\"/runner/init\"] ADD slug.tgz /app ENV GIT_SHA 060da68f654e75fac06dbedd1995d5f8ad9084db",
			Image:      "example-go",
			Owner:      "test",
			Procfile: map[string]string{
				"web": "example-go",
			},
			Sha:     "060da68f",
			Updated: "2014-01-01T00:00:00UTC",
			UUID:    "de1bf5b5-4a72-4f94-a10c-d2a3741cdf75",
		},
	}

	handler := fakeHTTPServer{}
	server := httptest.NewServer(handler)
	defer server.Close()

	u, err := url.Parse(server.URL)

	if err != nil {
		t.Fatal(err)
	}

	httpClient := client.CreateHTTPClient(false)

	client := client.Client{HTTPClient: httpClient, ControllerURL: *u, Token: "abc"}

	actual, _, err := List(&client, "example-go", 100)

	if err != nil {
		t.Fatal(err)
	}

	if !reflect.DeepEqual(expected, actual) {
		t.Error(fmt.Errorf("Expected %v, Got %v", expected, actual))
	}
}
开发者ID:arschles,项目名称:deis-controller,代码行数:43,代码来源:builds_test.go


示例9: TestBuildCreate

func TestBuildCreate(t *testing.T) {
	t.Parallel()

	expected := api.Build{
		App:     "example-go",
		Created: "2014-01-01T00:00:00UTC",
		Image:   "deis/example-go:latest",
		Owner:   "test",
		Procfile: map[string]string{
			"web": "example-go",
		},
		Updated: "2014-01-01T00:00:00UTC",
		UUID:    "de1bf5b5-4a72-4f94-a10c-d2a3741cdf75",
	}

	handler := fakeHTTPServer{}
	server := httptest.NewServer(handler)
	defer server.Close()

	u, err := url.Parse(server.URL)

	if err != nil {
		t.Fatal(err)
	}

	httpClient := client.CreateHTTPClient(false)

	client := client.Client{HTTPClient: httpClient, ControllerURL: *u, Token: "abc"}

	procfile := map[string]string{
		"web": "example-go",
	}

	actual, err := New(&client, "example-go", "deis/example-go", procfile)

	if err != nil {
		t.Fatal(err)
	}

	if !reflect.DeepEqual(expected, actual) {
		t.Error(fmt.Errorf("Expected %v, Got %v", expected, actual))
	}
}
开发者ID:arschles,项目名称:deis-controller,代码行数:43,代码来源:builds_test.go


示例10: TestUsersList

func TestUsersList(t *testing.T) {
	t.Parallel()

	expected := []api.User{
		{
			ID:          1,
			LastLogin:   "2014-10-19T22:01:00.601Z",
			IsSuperuser: true,
			Username:    "test",
			FirstName:   "test",
			LastName:    "testerson",
			Email:       "[email protected]",
			IsStaff:     true,
			IsActive:    true,
			DateJoined:  "2014-10-19T22:01:00.601Z",
		},
	}

	handler := fakeHTTPServer{}
	server := httptest.NewServer(handler)
	defer server.Close()

	u, err := url.Parse(server.URL)

	if err != nil {
		t.Fatal(err)
	}

	httpClient := client.CreateHTTPClient(false)

	client := client.Client{HTTPClient: httpClient, ControllerURL: *u, Token: "abc"}

	actual, _, err := List(&client, 100)

	if err != nil {
		t.Fatal(err)
	}

	if !reflect.DeepEqual(expected, actual) {
		t.Errorf("Expected %v, Got %v", expected, actual)
	}
}
开发者ID:arschles,项目名称:deis-controller,代码行数:42,代码来源:users_test.go


示例11: TestPasswd

func TestPasswd(t *testing.T) {
	t.Parallel()

	handler := fakeHTTPServer{}
	server := httptest.NewServer(&handler)
	defer server.Close()

	u, err := url.Parse(server.URL)

	if err != nil {
		t.Fatal(err)
	}

	httpClient := client.CreateHTTPClient(false)
	client := client.Client{HTTPClient: httpClient, ControllerURL: *u}

	if err := Passwd(&client, "test", "old", "new"); err != nil {
		t.Error(err)
	}
}
开发者ID:arschles,项目名称:deis-controller,代码行数:20,代码来源:auth_test.go


示例12: TestReleasesList

func TestReleasesList(t *testing.T) {
	t.Parallel()

	expected := []api.Release{
		{
			App:     "example-go",
			Build:   "",
			Config:  "95bd6dea-1685-4f78-a03d-fd7270b058d1",
			Created: "2014-01-01T00:00:00UTC",
			Owner:   "test",
			Summary: "test created initial release",
			Updated: "2014-01-01T00:00:00UTC",
			UUID:    "de1bf5b5-4a72-4f94-a10c-d2a3741cdf75",
			Version: 1,
		},
	}

	handler := fakeHTTPServer{}
	server := httptest.NewServer(handler)
	defer server.Close()

	u, err := url.Parse(server.URL)

	if err != nil {
		t.Fatal(err)
	}

	httpClient := client.CreateHTTPClient(false)

	client := client.Client{HTTPClient: httpClient, ControllerURL: *u, Token: "abc"}

	actual, _, err := List(&client, "example-go", 100)

	if err != nil {
		t.Fatal(err)
	}

	if !reflect.DeepEqual(expected, actual) {
		t.Error(fmt.Errorf("Expected %v, Got %v", expected, actual))
	}
}
开发者ID:arschles,项目名称:deis-controller,代码行数:41,代码来源:releases_test.go


示例13: TestProcessesList

func TestProcessesList(t *testing.T) {
	t.Parallel()

	expected := []api.Process{
		{
			Owner:   "test",
			App:     "example-go",
			Release: "v2",
			Created: "2014-01-01T00:00:00UTC",
			Updated: "2014-01-01T00:00:00UTC",
			UUID:    "de1bf5b5-4a72-4f94-a10c-d2a3741cdf75",
			Type:    "web",
			Num:     1,
			State:   "up",
		},
	}

	handler := fakeHTTPServer{}
	server := httptest.NewServer(handler)
	defer server.Close()

	u, err := url.Parse(server.URL)

	if err != nil {
		t.Fatal(err)
	}

	httpClient := client.CreateHTTPClient(false)

	client := client.Client{HTTPClient: httpClient, ControllerURL: *u, Token: "abc"}

	actual, _, err := List(&client, "example-go", 100)

	if err != nil {
		t.Fatal(err)
	}

	if !reflect.DeepEqual(expected, actual) {
		t.Error(fmt.Errorf("Expected %v, Got %v", expected, actual))
	}
}
开发者ID:arschles,项目名称:deis-controller,代码行数:41,代码来源:ps_test.go


示例14: TestRegister

func TestRegister(t *testing.T) {
	t.Parallel()

	handler := fakeHTTPServer{}
	server := httptest.NewServer(&handler)
	defer server.Close()

	u, err := url.Parse(server.URL)

	if err != nil {
		t.Fatal(err)
	}

	httpClient := client.CreateHTTPClient(false)

	client := client.Client{HTTPClient: httpClient, ControllerURL: *u}

	if err = Register(&client, "test", "opensesame", "[email protected]"); err != nil {
		t.Error(err)
	}
}
开发者ID:arschles,项目名称:deis-controller,代码行数:21,代码来源:auth_test.go


示例15: TestDeleteAdmin

func TestDeleteAdmin(t *testing.T) {
	t.Parallel()

	handler := fakeHTTPServer{}
	server := httptest.NewServer(handler)
	defer server.Close()

	u, err := url.Parse(server.URL)

	if err != nil {
		t.Fatal(err)
	}

	httpClient := client.CreateHTTPClient(false)

	client := client.Client{HTTPClient: httpClient, ControllerURL: *u, Token: "abc"}

	if err = DeleteAdmin(&client, "test"); err != nil {
		t.Fatal(err)
	}
}
开发者ID:arschles,项目名称:deis-controller,代码行数:21,代码来源:perms_test.go


示例16: TestScale

func TestScale(t *testing.T) {
	t.Parallel()

	handler := fakeHTTPServer{}
	server := httptest.NewServer(&handler)
	defer server.Close()

	u, err := url.Parse(server.URL)

	if err != nil {
		t.Fatal(err)
	}

	httpClient := client.CreateHTTPClient(false)

	client := client.Client{HTTPClient: httpClient, ControllerURL: *u, Token: "abc"}

	if err = Scale(&client, "example-go", map[string]int{"web": 2}); err != nil {
		t.Fatal(err)
	}
}
开发者ID:arschles,项目名称:deis-controller,代码行数:21,代码来源:ps_test.go


示例17: TestAppsLogs

func TestAppsLogs(t *testing.T) {
	t.Parallel()

	tests := []testExpected{
		{
			Input:    -1,
			Expected: "test\nfoo\nbar\n",
		},
		{
			Input:    1,
			Expected: "test\n",
		},
	}

	handler := fakeHTTPServer{}
	server := httptest.NewServer(&handler)
	defer server.Close()

	u, err := url.Parse(server.URL)

	if err != nil {
		t.Fatal(err)
	}

	httpClient := client.CreateHTTPClient(false)

	client := client.Client{HTTPClient: httpClient, ControllerURL: *u, Token: "abc"}

	for _, test := range tests {
		actual, err := Logs(&client, "example-go", test.Input)

		if err != nil {
			t.Error(err)
		}

		if actual != test.Expected {
			t.Errorf("Expected %s, Got %s", test.Expected, actual)
		}
	}
}
开发者ID:arschles,项目名称:deis-controller,代码行数:40,代码来源:apps_test.go


示例18: TestAppsCreate

func TestAppsCreate(t *testing.T) {
	t.Parallel()

	expected := api.App{
		ID:      "example-go",
		Created: "2014-01-01T00:00:00UTC",
		Owner:   "test",
		Updated: "2014-01-01T00:00:00UTC",
		URL:     "example-go.example.com",
		UUID:    "de1bf5b5-4a72-4f94-a10c-d2a3741cdf75",
	}

	handler := fakeHTTPServer{createID: false, createWithoutID: false}
	server := httptest.NewServer(&handler)
	defer server.Close()

	u, err := url.Parse(server.URL)

	if err != nil {
		t.Fatal(err)
	}

	httpClient := client.CreateHTTPClient(false)

	client := client.Client{HTTPClient: httpClient, ControllerURL: *u, Token: "abc"}

	for _, id := range []string{"example-go", ""} {
		actual, err := New(&client, id)

		if err != nil {
			t.Fatal(err)
		}

		if !reflect.DeepEqual(expected, actual) {
			t.Errorf("Expected %v, Got %v", expected, actual)
		}
	}
}
开发者ID:arschles,项目名称:deis-controller,代码行数:38,代码来源:apps_test.go


示例19: TestAppsList

func TestAppsList(t *testing.T) {
	t.Parallel()

	expected := []api.App{
		{
			ID:      "example-go",
			Created: "2014-01-01T00:00:00UTC",
			Owner:   "test",
			Updated: "2014-01-01T00:00:00UTC",
			URL:     "example-go.example.com",
			UUID:    "de1bf5b5-4a72-4f94-a10c-d2a3741cdf75",
		},
	}

	handler := fakeHTTPServer{}
	server := httptest.NewServer(&handler)
	defer server.Close()

	u, err := url.Parse(server.URL)

	if err != nil {
		t.Fatal(err)
	}

	httpClient := client.CreateHTTPClient(false)

	client := client.Client{HTTPClient: httpClient, ControllerURL: *u, Token: "abc"}

	actual, _, err := List(&client, 100)

	if err != nil {
		t.Fatal(err)
	}

	if !reflect.DeepEqual(expected, actual) {
		t.Errorf("Expected %v, Got %v", expected, actual)
	}
}
开发者ID:arschles,项目名称:deis-controller,代码行数:38,代码来源:apps_test.go


示例20: Login

// Login to a Deis controller.
func Login(controller string, username string, password string, sslVerify bool) error {
	u, err := url.Parse(controller)

	if err != nil {
		return err
	}

	controllerURL, err := chooseScheme(*u)
	httpClient := client.CreateHTTPClient(sslVerify)

	if err != nil {
		return err
	}

	if err = client.CheckConnection(httpClient, controllerURL); err != nil {
		return err
	}

	if username == "" {
		fmt.Print("username: ")
		fmt.Scanln(&username)
	}

	if password == "" {
		fmt.Print("password: ")
		password, err = readPassword()
		fmt.Println()

		if err != nil {
			return err
		}
	}

	c := &client.Client{ControllerURL: controllerURL, SSLVerify: sslVerify, HTTPClient: httpClient}

	return doLogin(c, username, password)
}
开发者ID:arschles,项目名称:deis-controller,代码行数:38,代码来源:auth.go



注:本文中的github.com/deis/workflow/client/controller/client.CreateHTTPClient函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang client.Client类代码示例发布时间:2022-05-23
下一篇:
Golang auth.Register函数代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap