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


Golang Config.BlobStore方法代码示例

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


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

示例1: New

func New(config *config_package.Config) BlobStore {
	switch config.ActiveBlobStore() {
	case config_package.DAVBlobStore:
		return dav_blob_store.New(config.BlobStore())
	case config_package.S3BlobStore:
		return s3_blob_store.New(config.S3BlobStore())
	}

	return dav_blob_store.New(config.BlobStore())
}
开发者ID:cloudfoundry-incubator,项目名称:ltc,代码行数:10,代码来源:blob_store.go

示例2: Verify

func (Verifier) Verify(config *config_package.Config) (authorized bool, err error) {
	blobStoreURL := url.URL{
		Scheme: "http",
		Host:   fmt.Sprintf("%s:%s", config.BlobStore().Host, config.BlobStore().Port),
		User:   url.UserPassword(config.BlobStore().Username, config.BlobStore().Password),
	}

	baseURL := &url.URL{
		Scheme: blobStoreURL.Scheme,
		Host:   blobStoreURL.Host,
		User:   blobStoreURL.User,
		Path:   "/blobs/",
	}

	req, err := http.NewRequest("PROPFIND", baseURL.String(), nil)
	if err != nil {
		return false, err
	}

	req.Header.Add("Depth", "1")
	resp, err := http.DefaultClient.Do(req)
	if err != nil {
		return false, err
	}

	defer resp.Body.Close()

	return resp.StatusCode == 207, err
}
开发者ID:cloudfoundry-incubator,项目名称:ltc,代码行数:29,代码来源:blob_store_verifier.go

示例3:

			It("returns an error when the upload fails", func() {
				fakeBlobStore.UploadReturns(errors.New("some error"))

				err := dropletRunner.UploadBits("droplet-name", tmpFile.Name())
				Expect(err).To(MatchError("some error"))
			})
		})
	})

	Describe("BuildDroplet", func() {
		It("does the build droplet task", func() {
			config.SetBlobStore("blob-host", "7474", "dav-user", "dav-pass")
			Expect(config.Save()).To(Succeed())

			blobURL := fmt.Sprintf("http://%s:%[email protected]%s:%s%s",
				config.BlobStore().Username,
				config.BlobStore().Password,
				config.BlobStore().Host,
				config.BlobStore().Port,
				"/blobs/droplet-name")

			fakeBlobStore.DownloadAppBitsActionReturns(models.WrapAction(&models.DownloadAction{
				From: blobURL + "/bits.zip",
				To:   "/tmp/app",
				User: "vcap",
			}))

			fakeBlobStore.DeleteAppBitsActionReturns(models.WrapAction(&models.RunAction{
				Path: "/tmp/davtool",
				Dir:  "/",
				Args: []string{"delete", blobURL + "/bits.zip"},
开发者ID:davidwadden,项目名称:ltc,代码行数:31,代码来源:droplet_runner_test.go

示例4:

			It("clears out existing saved target credentials", func() {
				test_helpers.ExecuteCommandWithArgs(targetCommand, []string{"myapi.com"})

				Expect(fakeTargetVerifier.VerifyTargetCallCount()).To(Equal(1))
				Expect(fakeTargetVerifier.VerifyTargetArgsForCall(0)).To(Equal("http://receptor.myapi.com"))
			})

			It("saves the new blob store target", func() {
				fakeBlobStoreVerifier.VerifyReturns(true, nil)

				test_helpers.ExecuteCommandWithArgs(targetCommand, []string{"myapi.com"})

				Expect(fakeBlobStoreVerifier.VerifyCallCount()).To(Equal(1))

				config := fakeBlobStoreVerifier.VerifyArgsForCall(0)
				blobStoreConfig := config.BlobStore()
				Expect(blobStoreConfig).To(Equal(config_package.BlobStoreConfig{
					Host: "myapi.com",
					Port: "8444",
				}))

				newConfig := config_package.New(configPersister)
				Expect(newConfig.Load()).To(Succeed())
				Expect(newConfig.BlobStore()).To(Equal(config_package.BlobStoreConfig{
					Host: "myapi.com",
					Port: "8444",
				}))
			})

			Context("when the blob store requires authorization", func() {
				It("exits", func() {
开发者ID:davidwadden,项目名称:ltc,代码行数:31,代码来源:config_command_factory_test.go

示例5:

	Describe("ActiveBlobStore", func() {
		It("defaults to 'dav'", func() {
			Expect(testConfig.ActiveBlobStore().String()).To(Equal("dav"))
		})

		It("reports the active blobstore", func() {
			testConfig.SetS3BlobStore("some-access-key", "some-secret-key", "some-bucket-name", "some-s3-region")
			Expect(testConfig.ActiveBlobStore().String()).To(Equal("s3"))
		})
	})

	Describe("TargetBlob", func() {
		It("sets the blob target", func() {
			testConfig.SetBlobStore("some-host", "7474", "some-username", "some-password")

			Expect(testConfig.BlobStore()).To(Equal(config.BlobStoreConfig{
				Host:     "some-host",
				Port:     "7474",
				Username: "some-username",
				Password: "some-password",
			}))
		})

		It("sets the activeBlobStore to 'dav'", func() {
			testConfig.SetS3BlobStore("some-access-key", "some-secret-key", "some-bucket-name", "some-region")
			testConfig.SetBlobStore("some-host", "7474", "some-username", "some-password")
			Expect(testConfig.ActiveBlobStore().String()).To(Equal("dav"))
		})
	})

	Describe("TargetS3Blob", func() {
开发者ID:cloudfoundry-incubator,项目名称:ltc,代码行数:31,代码来源:config_test.go


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