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


Golang DirectoriesProvider.BoshDir方法代碼示例

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


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

示例1:

			fs          *fakefs.FakeFileSystem
			dirProvider boshdir.DirectoriesProvider
			inf         Infrastructure
		)

		BeforeEach(func() {
			fs = fakefs.NewFakeFileSystem()
			dirProvider = boshdir.NewDirectoriesProvider("/var/vcap")
			platform := fakeplatform.NewFakePlatform()
			fakeDevicePathResolver := fakedpresolv.NewFakeDevicePathResolver()
			inf = NewDummyInfrastructure(fs, dirProvider, platform, fakeDevicePathResolver)
		})

		Context("when infrastructure settings file is found", func() {
			BeforeEach(func() {
				settingsPath := filepath.Join(dirProvider.BoshDir(), "dummy-cpi-agent-env.json")

				expectedSettings := boshsettings.Settings{
					AgentID: "123-456-789",
					Blobstore: boshsettings.Blobstore{
						Type: boshsettings.BlobstoreTypeDummy,
					},
					Mbus: "nats://127.0.0.1:4222",
				}
				existingSettingsBytes, err := json.Marshal(expectedSettings)
				Expect(err).ToNot(HaveOccurred())

				fs.WriteFile(settingsPath, existingSettingsBytes)
			})

			It("returns settings", func() {
開發者ID:Bosh-for-Cpi,項目名稱:bosh-2605,代碼行數:31,代碼來源:dummy_infrastructure_test.go

示例2: init

func init() {
	Describe("bootstrap", func() {
		Describe("Run", func() {
			var (
				inf         *fakeinf.FakeInfrastructure
				platform    *fakeplatform.FakePlatform
				dirProvider boshdir.DirectoriesProvider

				settingsServiceProvider *fakesettings.FakeSettingsServiceProvider
				settingsService         *fakesettings.FakeSettingsService
			)

			BeforeEach(func() {
				inf = &fakeinf.FakeInfrastructure{
					GetEphemeralDiskPathFound:    true,
					GetEphemeralDiskPathRealPath: "/dev/sdz",
				}
				platform = fakeplatform.NewFakePlatform()
				dirProvider = boshdir.NewDirectoriesProvider("/var/vcap")

				settingsServiceProvider = fakesettings.NewServiceProvider()
				settingsService = settingsServiceProvider.NewServiceSettingsService
			})

			bootstrap := func() (boshsettings.Service, error) {
				logger := boshlog.NewLogger(boshlog.LevelNone)
				return New(inf, platform, dirProvider, settingsServiceProvider, logger).Run()
			}

			It("sets up runtime configuration", func() {
				_, err := bootstrap()
				Expect(err).NotTo(HaveOccurred())
				Expect(platform.SetupRuntimeConfigurationWasInvoked).To(BeTrue())
			})

			It("sets up ssh", func() {
				_, err := bootstrap()
				Expect(err).NotTo(HaveOccurred())
				Expect(inf.SetupSshUsername).To(Equal("vcap"))
			})

			It("sets up hostname", func() {
				settingsService.Settings.AgentID = "foo-bar-baz-123"

				_, err := bootstrap()
				Expect(err).NotTo(HaveOccurred())
				Expect(platform.SetupHostnameHostname).To(Equal("foo-bar-baz-123"))
			})

			It("returns the settings service", func() {
				settingsService, err := bootstrap()
				Expect(err).NotTo(HaveOccurred())
				Expect(settingsService).To(Equal(settingsService))

				Expect(settingsServiceProvider.NewServiceFs).To(Equal(platform.GetFs()))
				Expect(settingsServiceProvider.NewServiceDir).To(Equal(dirProvider.BoshDir()))

				fetchedSettings, err := settingsServiceProvider.NewServiceFetcher()
				Expect(err).NotTo(HaveOccurred())
				Expect(fetchedSettings).To(Equal(inf.Settings))
			})

			It("fetches initial settings", func() {
				_, err := bootstrap()
				Expect(err).NotTo(HaveOccurred())
				Expect(settingsService.SettingsWereLoaded).To(BeTrue())
			})

			It("returns error from loading initial settings", func() {
				settingsService.LoadSettingsError = errors.New("fake-load-error")

				_, err := bootstrap()
				Expect(err).To(HaveOccurred())
				Expect(err.Error()).To(ContainSubstring("fake-load-error"))
			})

			It("sets up networking", func() {
				networks := boshsettings.Networks{
					"bosh": boshsettings.Network{},
				}
				settingsService.Settings.Networks = networks

				_, err := bootstrap()
				Expect(err).NotTo(HaveOccurred())
				Expect(inf.SetupNetworkingNetworks).To(Equal(networks))
			})

			It("sets up ephemeral disk", func() {
				settingsService.Disks = boshsettings.Disks{
					Ephemeral: "fake-ephemeral-disk-setting",
				}

				inf.GetEphemeralDiskPathRealPath = "/dev/sda"
				inf.GetEphemeralDiskPathFound = true

				_, err := bootstrap()
				Expect(err).NotTo(HaveOccurred())
				Expect(platform.SetupEphemeralDiskWithPathDevicePath).To(Equal("/dev/sda"))
				Expect(inf.GetEphemeralDiskPathDevicePath).To(Equal("fake-ephemeral-disk-setting"))
			})
//.........這裏部分代碼省略.........
開發者ID:Jane4PKU,項目名稱:bosh,代碼行數:101,代碼來源:bootstrap_test.go

示例3:

		platform = NewDummyPlatform(collector, fs, cmdRunner, dirProvider, logger)
	})

	Describe("GetDefaultNetwork", func() {
		Context("when default networks settings file is found", func() {
			expectedNetwork := boshsettings.Network{
				Default: []string{"fake-default"},
				DNS:     []string{"fake-dns-name"},
				IP:      "fake-ip-address",
				Netmask: "fake-netmask",
				Gateway: "fake-gateway",
				Mac:     "fake-mac-address",
			}

			BeforeEach(func() {
				settingsPath := filepath.Join(dirProvider.BoshDir(), "dummy-default-network-settings.json")

				expectedNetworkBytes, err := json.Marshal(expectedNetwork)
				Expect(err).ToNot(HaveOccurred())

				fs.WriteFile(settingsPath, expectedNetworkBytes)
			})

			It("returns network", func() {
				network, err := platform.GetDefaultNetwork()
				Expect(err).ToNot(HaveOccurred())
				Expect(network).To(Equal(expectedNetwork))
			})
		})

		Context("when default networks settings file is not found", func() {
開發者ID:Bosh-for-Cpi,項目名稱:bosh-2605,代碼行數:31,代碼來源:dummy_platform_test.go


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