本文整理匯總了Golang中github.com/cloudfoundry-incubator/ltc/config.Config.S3BlobStore方法的典型用法代碼示例。如果您正苦於以下問題:Golang Config.S3BlobStore方法的具體用法?Golang Config.S3BlobStore怎麽用?Golang Config.S3BlobStore使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/cloudfoundry-incubator/ltc/config.Config
的用法示例。
在下文中一共展示了Config.S3BlobStore方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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())
}
示例2: Verify
func (v Verifier) Verify(config *config_package.Config) (authorized bool, err error) {
blobStoreConfig := config.S3BlobStore()
client := s3.New(session.New(&aws.Config{
Credentials: credentials.NewStaticCredentials(blobStoreConfig.AccessKey, blobStoreConfig.SecretKey, ""),
Region: aws.String(blobStoreConfig.Region),
S3ForcePathStyle: aws.Bool(true),
}))
if v.Endpoint != "" {
client.Endpoint = v.Endpoint
}
_, err = client.ListObjects(&s3.ListObjectsInput{
Bucket: aws.String(blobStoreConfig.BucketName),
})
if err != nil {
if awsErr, ok := err.(awserr.RequestFailure); ok && awsErr.StatusCode() == 403 {
return false, nil
}
return false, err
}
return true, nil
}
示例3:
fakePasswordReader.PromptForPasswordReturns("some-secret")
doneChan := test_helpers.AsyncExecuteCommandWithArgs(targetCommand, []string{"myapi.com", "--s3"})
Eventually(outputBuffer).Should(test_helpers.Say("S3 Access Key: "))
stdinWriter.Write([]byte("some-access\n"))
Eventually(outputBuffer).Should(test_helpers.Say("S3 Bucket: "))
stdinWriter.Write([]byte("some-bucket\n"))
Eventually(outputBuffer).Should(test_helpers.Say("S3 Region: "))
stdinWriter.Write([]byte("some-region\n"))
Eventually(doneChan, 3).Should(BeClosed())
Expect(fakeBlobStoreVerifier.VerifyCallCount()).To(Equal(1))
config := fakeBlobStoreVerifier.VerifyArgsForCall(0)
s3BlobTargetInfo := config.S3BlobStore()
Expect(s3BlobTargetInfo.AccessKey).To(Equal("some-access"))
Expect(s3BlobTargetInfo.SecretKey).To(Equal("some-secret"))
Expect(s3BlobTargetInfo.BucketName).To(Equal("some-bucket"))
Expect(s3BlobTargetInfo.Region).To(Equal("some-region"))
newConfig := config_package.New(configPersister)
Expect(newConfig.Load()).To(Succeed())
newS3BlobTargetInfo := newConfig.S3BlobStore()
Expect(newS3BlobTargetInfo.AccessKey).To(Equal("some-access"))
Expect(newS3BlobTargetInfo.SecretKey).To(Equal("some-secret"))
Expect(newS3BlobTargetInfo.BucketName).To(Equal("some-bucket"))
Expect(newS3BlobTargetInfo.Region).To(Equal("some-region"))
})
})
示例4:
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() {
It("sets the s3 blob target", func() {
testConfig.SetS3BlobStore("some-access-key", "some-secret-key", "some-bucket-name", "some-region")
Expect(testConfig.S3BlobStore()).To(Equal(config.S3BlobStoreConfig{
Region: "some-region",
AccessKey: "some-access-key",
SecretKey: "some-secret-key",
BucketName: "some-bucket-name",
}))
})
It("sets the activeBlobStore to 's3'", func() {
testConfig.SetS3BlobStore("some-access-key", "some-secret-key", "some-bucket-name", "some-region")
Expect(testConfig.ActiveBlobStore().String()).To(Equal("s3"))
})
})
})
type fakePersister struct {