当前位置: 首页>>代码示例>>Golang>>正文


Golang Container.SetProperty方法代码示例

本文整理汇总了Golang中github.com/cloudfoundry-incubator/garden.Container.SetProperty方法的典型用法代码示例。如果您正苦于以下问题:Golang Container.SetProperty方法的具体用法?Golang Container.SetProperty怎么用?Golang Container.SetProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/cloudfoundry-incubator/garden.Container的用法示例。


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

示例1: transitionToComplete

func (store *GardenStore) transitionToComplete(logger lager.Logger, gardenContainer garden.Container, result executor.ContainerRunResult) error {
	resultJson, err := json.Marshal(result)
	if err != nil {
		return err
	}

	err = gardenContainer.SetProperty(ContainerResultProperty, string(resultJson))
	if err != nil {
		return err
	}

	err = gardenContainer.SetProperty(ContainerStateProperty, string(executor.StateCompleted))
	if err != nil {
		return err
	}

	executorContainer, err := store.exchanger.Info(logger, gardenContainer)
	if err != nil {
		return err
	}

	store.eventEmitter.Emit(executor.NewContainerCompleteEvent(executorContainer))

	return nil
}
开发者ID:snowsnail,项目名称:executor,代码行数:25,代码来源:garden_store.go

示例2: transitionToRunning

func (store *GardenStore) transitionToRunning(logger lager.Logger, gardenContainer garden.Container) error {
	err := gardenContainer.SetProperty(ContainerStateProperty, string(executor.StateRunning))
	if err != nil {
		return err
	}

	executorContainer, err := store.exchanger.Info(logger, gardenContainer)
	if err != nil {
		return err
	}

	store.eventEmitter.Emit(executor.NewContainerRunningEvent(executorContainer))

	return nil
}
开发者ID:snowsnail,项目名称:executor,代码行数:15,代码来源:garden_store.go

示例3:

				ghttp.CombineHandlers(
					ghttp.VerifyRequest("PUT", "/api/containers/containerhandle/properties/key"),
					func() http.HandlerFunc {
						return func(w http.ResponseWriter, req *http.Request) {
							body, err := ioutil.ReadAll(req.Body)
							Expect(err).NotTo(HaveOccurred())
							Expect(string(body)).Should(Equal(payloadText))
						}
					}(),
					ghttp.RespondWith(200, "a body that doesn't matter"),
				),
			)
		})

		It("makes a call out to an external service", func() {
			err := container.SetProperty("key", payloadText)
			Expect(err).NotTo(HaveOccurred())
			Expect(server.ReceivedRequests()).Should(HaveLen(1))
		})
	})

	Describe("RemoveProperty", func() {
		BeforeEach(func() {
			server.AppendHandlers(
				ghttp.CombineHandlers(
					ghttp.VerifyRequest("DELETE", "/api/containers/containerhandle/properties/key"),
					ghttp.RespondWith(204, ""),
				),
			)
		})
开发者ID:stefanschneider,项目名称:garden-windows,代码行数:30,代码来源:container_test.go

示例4:

	Describe("Properties", func() {
		BeforeEach(func() {
			propertyManager = new(fakes.FakePropertyManager)
			container = gardener.NewContainer(nil, "some-handle", nil, nil, propertyManager)
		})

		It("delegates to the property manager for Properties", func() {
			container.Properties()
			Expect(propertyManager.AllCallCount()).To(Equal(1))
			handle := propertyManager.AllArgsForCall(0)
			Expect(handle).To(Equal("some-handle"))
		})

		It("delegates to the property manager for SetProperty", func() {
			container.SetProperty("name", "value")
			Expect(propertyManager.SetCallCount()).To(Equal(1))
			handle, prop, val := propertyManager.SetArgsForCall(0)
			Expect(handle).To(Equal("some-handle"))
			Expect(prop).To(Equal("name"))
			Expect(val).To(Equal("value"))
		})

		It("delegates to the property manager for Property", func() {
			container.Property("name")
			Expect(propertyManager.GetCallCount()).To(Equal(1))
			handle, name := propertyManager.GetArgsForCall(0)
			Expect(handle).To(Equal("some-handle"))
			Expect(name).To(Equal("name"))
		})
开发者ID:digideskio,项目名称:guardian,代码行数:29,代码来源:container_test.go

示例5:

		Describe("info for one container", func() {
			It("includes the properties", func() {
				info, err := container.Info()
				Expect(err).ToNot(HaveOccurred())

				Expect(info.Properties["foo"]).To(Equal("bar"))
				Expect(info.Properties["a"]).To(Equal("b"))

				Expect(info.Properties).To(HaveLen(2))
			})
		})

		Describe("getting container properties without getting info", func() {
			It("can list properties", func() {
				err := container.SetProperty("bar", "baz")

				value, err := container.Properties()
				Expect(err).ToNot(HaveOccurred())
				Expect(value).To(HaveKeyWithValue("foo", "bar"))
				Expect(value).To(HaveKeyWithValue("bar", "baz"))
			})
		})

		Describe("updating container properties", func() {
			It("can CRUD", func() {
				value, err := container.Property("foo")
				Expect(err).ToNot(HaveOccurred())
				Expect(value).To(Equal("bar"))

				err = container.SetProperty("foo", "baz")
开发者ID:khassib,项目名称:garden-windows,代码行数:30,代码来源:container_info_test.go

示例6:

		})
		Expect(err).NotTo(HaveOccurred())
	})

	AfterEach(func() {
		Expect(client.DestroyAndStop()).To(Succeed())
	})

	It("can get properties", func() {
		properties, err := container.Properties()
		Expect(err).NotTo(HaveOccurred())
		Expect(properties).To(HaveKeyWithValue("somename", "somevalue"))
	})

	It("can set a single property", func() {
		err := container.SetProperty("someothername", "someothervalue")
		Expect(err).NotTo(HaveOccurred())

		properties, err := container.Properties()
		Expect(err).NotTo(HaveOccurred())
		Expect(properties).To(HaveKeyWithValue("somename", "somevalue"))
		Expect(properties).To(HaveKeyWithValue("someothername", "someothervalue"))
	})

	It("can get a single property", func() {
		err := container.SetProperty("bing", "bong")
		Expect(err).NotTo(HaveOccurred())

		value, err := container.Property("bing")
		Expect(err).NotTo(HaveOccurred())
		Expect(value).To(Equal("bong"))
开发者ID:digideskio,项目名称:guardian,代码行数:31,代码来源:properties_test.go

示例7:

					It("returns an error", func() {
						value, err := container.GetProperty("some-property")
						Ω(err).Should(HaveOccurred())
						Ω(value).Should(BeZero())
					})
				})
			})

			Describe("setting", func() {
				Context("when setting the property succeeds", func() {
					BeforeEach(func() {
						fakeContainer.SetPropertyReturns(nil)
					})

					It("sets the property on the container", func() {
						err := container.SetProperty("some-property", "some-value")
						Ω(err).ShouldNot(HaveOccurred())

						Ω(fakeContainer.SetPropertyCallCount()).Should(Equal(1))

						name, value := fakeContainer.SetPropertyArgsForCall(0)
						Ω(name).Should(Equal("some-property"))
						Ω(value).Should(Equal("some-value"))
					})

					itResetsGraceTimeWhenHandling(func() {
						err := container.SetProperty("some-property", "some-value")
						Ω(err).ShouldNot(HaveOccurred())
					})

					itFailsWhenTheContainerIsNotFound(func() error {
开发者ID:julz,项目名称:garden-runc,代码行数:31,代码来源:request_handling_test.go

示例8:

			Consistently(client).ShouldNot(gbytes.Say("banana"))
		})
	})

	Context("when working with properties", func() {
		BeforeEach(func() {
			containerSpec = garden.ContainerSpec{
				Properties: garden.Properties{
					"super": "banana",
				},
			}
		})

		It("should not log the properties when we are getting them", func() {
			_, err := container.Properties()
			Expect(err).ToNot(HaveOccurred())

			Consistently(client).ShouldNot(gbytes.Say("super"))
			Consistently(client).ShouldNot(gbytes.Say("banana"))
		})

		It("should not log the properties when we are setting them", func() {
			err := container.SetProperty("super", "banana")
			Expect(err).ToNot(HaveOccurred())

			Consistently(client).ShouldNot(gbytes.Say("super"))
			Consistently(client).ShouldNot(gbytes.Say("banana"))
		})
	})
})
开发者ID:nagyistoce,项目名称:garden-linux,代码行数:30,代码来源:logging_test.go


注:本文中的github.com/cloudfoundry-incubator/garden.Container.SetProperty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。