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


Golang Client.Create方法代碼示例

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


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

示例1: createContainer

func createContainer(gardenClient garden.Client) (string, error) {
	container, err := gardenClient.Create(garden.ContainerSpec{})
	if err != nil {
		return "", err
	}

	processSpec := garden.ProcessSpec{
		Path: "sleep",
		Args: []string{"1000000"},
		User: "root",
	}
	processIO := garden.ProcessIO{}
	_, err = container.Run(processSpec, processIO)
	if err != nil {
		panic(err)
	}

	handle := container.Handle()
	fmt.Println(handle)

	return handle, nil
}
開發者ID:sykesm,項目名稱:container-networking-release,代碼行數:22,代碼來源:main.go

示例2: createContainer

func createContainer(client garden.Client, spec garden.ContainerSpec) garden.Container {
	container, err := client.Create(spec)
	Ω(err).ShouldNot(HaveOccurred(), fmt.Sprintf("Error while creating container with spec: %+v", spec))
	return container
}
開發者ID:cloudfoundry-incubator,項目名稱:garden-acceptance,代碼行數:5,代碼來源:garden_acceptance_suite_test.go

示例3:

		})
	})

	Context("and the client sends a CreateRequest", func() {
		var fakeContainer *fakes.FakeContainer

		BeforeEach(func() {
			fakeContainer = new(fakes.FakeContainer)
			fakeContainer.HandleReturns("some-handle")

			serverBackend.CreateReturns(fakeContainer, nil)
		})

		It("returns a container with the created handle", func() {
			container, err := apiClient.Create(garden.ContainerSpec{
				Handle: "some-handle",
			})
			Ω(err).ShouldNot(HaveOccurred())

			Ω(container.Handle()).Should(Equal("some-handle"))
		})

		It("creates the container with the spec from the request", func() {
			_, err := apiClient.Create(garden.ContainerSpec{
				Handle:     "some-handle",
				GraceTime:  42 * time.Second,
				Network:    "some-network",
				RootFSPath: "/path/to/rootfs",
				BindMounts: []garden.BindMount{
					{
						SrcPath: "/bind/mount/src",
開發者ID:julz,項目名稱:garden-runc,代碼行數:31,代碼來源:request_handling_test.go

示例4:

				finishCreating = make(chan struct{})

				fakeBackend.CreateStub = func(garden.ContainerSpec) (garden.Container, error) {
					close(creating)
					<-finishCreating
					return new(fakes.FakeContainer), nil
				}
			})

			It("waits for it to complete and stops accepting requests", func() {
				created := make(chan garden.Container, 1)

				go func() {
					defer GinkgoRecover()

					container, err := apiClient.Create(garden.ContainerSpec{})
					Ω(err).ShouldNot(HaveOccurred())

					created <- container
				}()

				Eventually(creating).Should(BeClosed())

				stopExited := make(chan struct{})
				go func() {
					apiServer.Stop()
					close(stopExited)
				}()

				Consistently(stopExited).ShouldNot(BeClosed())
開發者ID:nagyistoce,項目名稱:garden,代碼行數:30,代碼來源:server_test.go


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