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


Golang client.CreateHTTPClient函數代碼示例

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


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

示例1: TestCertsList

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

	expected := []api.Cert{
		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)

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

	if !reflect.DeepEqual(expected, actual) {
		t.Errorf("Expected %v, Got %v", expected, actual)
	}
}
開發者ID:laurrentt,項目名稱:deis,代碼行數:34,代碼來源:certs_test.go

示例2: 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:rsackler,項目名稱:deis,代碼行數:32,代碼來源:apps_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)

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

	if !reflect.DeepEqual(expected, actual) {
		t.Errorf("Expected %v, Got %v", expected, actual)
	}
}
開發者ID:laurrentt,項目名稱:deis,代碼行數:32,代碼來源:perms_test.go

示例4: 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:laurrentt,項目名稱:deis,代碼行數:29,代碼來源:releases_test.go

示例5: 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:rsackler,項目名稱:deis,代碼行數:35,代碼來源:domains_test.go

示例6: 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)

	if err != nil {
		return err
	}

	if err = client.CheckConection(client.CreateHTTPClient(sslVerify), 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
		}
	}

	return client.Login(controllerURL, username, password, sslVerify)
}
開發者ID:Kazanz,項目名稱:deis,代碼行數:35,代碼來源:auth.go

示例7: 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:kuvi-innovations,項目名稱:deis,代碼行數:28,代碼來源:auth_test.go

示例8: TestConfigUnset

func TestConfigUnset(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"}

	expected := api.Config{
		Owner:   "test",
		App:     "unset-test",
		Values:  map[string]interface{}{},
		Memory:  map[string]interface{}{},
		CPU:     map[string]interface{}{},
		Tags:    map[string]interface{}{},
		Created: "2014-01-01T00:00:00UTC",
		Updated: "2014-01-01T00:00:00UTC",
		UUID:    "de1bf5b5-4a72-4f94-a10c-d2a3741cdf75",
	}

	configVars := api.Config{
		Values: map[string]interface{}{
			"TEST": nil,
			"FOO":  nil,
		},
		Memory: map[string]interface{}{
			"web": nil,
		},
		CPU: map[string]interface{}{
			"web": nil,
		},
		Tags: map[string]interface{}{
			"test": nil,
		},
	}

	actual, err := Set(&client, "unset-test", configVars)

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

	if !reflect.DeepEqual(expected, actual) {
		t.Errorf("Expected %v, Got %v", expected, actual)
	}
}
開發者ID:laurrentt,項目名稱:deis,代碼行數:55,代碼來源:config_test.go

示例9: 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:kuvi-innovations,項目名稱:deis,代碼行數:48,代碼來源:auth_test.go

示例10: Register

// Register creates a account on a Deis controller.
func Register(controller string, username string, password string, email string,
	sslVerify bool) error {

	u, err := url.Parse(controller)

	if err != nil {
		return err
	}

	controllerURL, err := chooseScheme(*u)

	if err != nil {
		return err
	}

	if err = client.CheckConection(client.CreateHTTPClient(sslVerify), controllerURL); err != nil {
		return err
	}

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

	if password == "" {
		fmt.Print("password: ")
		password, err = readPassword()
		fmt.Printf("\npassword (confirm): ")
		passwordConfirm, err := readPassword()
		fmt.Println()

		if err != nil {
			return err
		}

		if password != passwordConfirm {
			return errors.New("Password mismatch, aborting registration.")
		}
	}

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

	return client.Register(controllerURL, username, password, email, sslVerify, true)
}
開發者ID:Kazanz,項目名稱:deis,代碼行數:48,代碼來源:auth.go

示例11: TestBuildsList

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

	expected := []api.Build{
		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")

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

	if !reflect.DeepEqual(expected, actual) {
		t.Error(fmt.Errorf("Expected %v, Got %v", expected, actual))
	}
}
開發者ID:laurrentt,項目名稱:deis,代碼行數:43,代碼來源:builds_test.go

示例12: 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:laurrentt,項目名稱:deis,代碼行數:43,代碼來源:builds_test.go

示例13: TestUsersList

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

	expected := []api.User{
		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)

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

	if !reflect.DeepEqual(expected, actual) {
		t.Errorf("Expected %v, Got %v", expected, actual)
	}
}
開發者ID:laurrentt,項目名稱:deis,代碼行數:42,代碼來源:users_test.go

示例14: TestDelete

func TestDelete(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 := Delete(&client); err != nil {
		t.Error(err)
	}
}
開發者ID:kuvi-innovations,項目名稱:deis,代碼行數:20,代碼來源:auth_test.go

示例15: TestProcessesList

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

	expected := []api.Process{
		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:rsackler,項目名稱:deis,代碼行數:41,代碼來源:ps_test.go


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