本文整理汇总了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
}
示例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
}
示例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, ""),
),
)
})
示例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"))
})
示例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")
示例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"))
示例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 {
示例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"))
})
})
})