本文整理汇总了Golang中github.com/cloudfoundry/bosh-agent/settings/directories.Provider.InstanceDir方法的典型用法代码示例。如果您正苦于以下问题:Golang Provider.InstanceDir方法的具体用法?Golang Provider.InstanceDir怎么用?Golang Provider.InstanceDir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/cloudfoundry/bosh-agent/settings/directories.Provider
的用法示例。
在下文中一共展示了Provider.InstanceDir方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: init
func init() {
Describe("ApplyAction", func() {
var (
applier *fakeappl.FakeApplier
specService *fakeas.FakeV1Service
settingsService *fakesettings.FakeSettingsService
dirProvider boshdir.Provider
action ApplyAction
fs boshsys.FileSystem
)
BeforeEach(func() {
applier = fakeappl.NewFakeApplier()
specService = fakeas.NewFakeV1Service()
settingsService = &fakesettings.FakeSettingsService{}
dirProvider = boshdir.NewProvider("/var/vcap")
fs = fakesys.NewFakeFileSystem()
action = NewApply(applier, specService, settingsService, dirProvider.InstanceDir(), fs)
})
It("apply should be asynchronous", func() {
Expect(action.IsAsynchronous()).To(BeTrue())
})
It("is not persistent", func() {
Expect(action.IsPersistent()).To(BeFalse())
})
Describe("Run", func() {
settings := boshsettings.Settings{AgentID: "fake-agent-id"}
BeforeEach(func() {
settingsService.Settings = settings
})
Context("when desired spec has configuration hash", func() {
currentApplySpec := boshas.V1ApplySpec{ConfigurationHash: "fake-current-config-hash"}
desiredApplySpec := boshas.V1ApplySpec{ConfigurationHash: "fake-desired-config-hash"}
populatedDesiredApplySpec := boshas.V1ApplySpec{
ConfigurationHash: "fake-populated-desired-config-hash",
}
Context("when current spec can be retrieved", func() {
BeforeEach(func() {
specService.Spec = currentApplySpec
})
It("populates dynamic networks in desired spec", func() {
_, err := action.Run(desiredApplySpec)
Expect(err).ToNot(HaveOccurred())
Expect(specService.PopulateDHCPNetworksSpec).To(Equal(desiredApplySpec))
Expect(specService.PopulateDHCPNetworksSettings).To(Equal(settings))
})
Context("when resolving dynamic networks succeeds", func() {
BeforeEach(func() {
specService.PopulateDHCPNetworksResultSpec = populatedDesiredApplySpec
})
It("runs applier with populated desired spec", func() {
_, err := action.Run(desiredApplySpec)
Expect(err).ToNot(HaveOccurred())
Expect(applier.Applied).To(BeTrue())
Expect(applier.ApplyCurrentApplySpec).To(Equal(currentApplySpec))
Expect(applier.ApplyDesiredApplySpec).To(Equal(populatedDesiredApplySpec))
})
Context("when applier succeeds applying desired spec", func() {
Context("when saving desires spec as current spec succeeds", func() {
It("returns 'applied' after setting populated desired spec as current spec", func() {
value, err := action.Run(desiredApplySpec)
Expect(err).ToNot(HaveOccurred())
Expect(value).To(Equal("applied"))
Expect(specService.Spec).To(Equal(populatedDesiredApplySpec))
})
Context("desired spec has id, instance name, deployment name, and az", func() {
BeforeEach(func() {
desiredApplySpec = boshas.V1ApplySpec{ConfigurationHash: "fake-desired-config-hash", NodeID: "node-id01-123f-r2344", AvailabilityZone: "ex-az", Deployment: "deployment-name", Name: "instance-name"}
specService.PopulateDHCPNetworksResultSpec = desiredApplySpec
})
It("returns 'applied' and writes the id, instance name, deployment name, and az to files in the instance directory", func() {
value, err := action.Run(desiredApplySpec)
Expect(err).ToNot(HaveOccurred())
Expect(value).To(Equal("applied"))
instanceDir := dirProvider.InstanceDir()
id, err := fs.ReadFileString(path.Join(instanceDir, "id"))
Expect(err).ToNot(HaveOccurred())
Expect(id).To(Equal(desiredApplySpec.NodeID))
az, err := fs.ReadFileString(path.Join(instanceDir, "az"))
Expect(err).ToNot(HaveOccurred())
Expect(az).To(Equal(desiredApplySpec.AvailabilityZone))
instanceName, err := fs.ReadFileString(path.Join(instanceDir, "name"))
//.........这里部分代码省略.........