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


Golang Config.SetBlobTarget方法代碼示例

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


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

示例1:

		fakeExitHandler = new(fake_exit_handler.FakeExitHandler)
		terminalUI = terminal.NewUI(stdinReader, outputBuffer, nil)
		config = config_package.New(persister.NewMemPersister())
	})

	Describe("TargetBlobCommand", func() {
		var targetBlobCommand cli.Command

		BeforeEach(func() {
			commandFactory := command_factory.NewConfigCommandFactory(config, terminalUI, fakeTargetVerifier, fakeExitHandler)
			targetBlobCommand = commandFactory.MakeTargetBlobCommand()
		})

		Context("displaying the blob target", func() {
			It("outputs the current target", func() {
				config.SetBlobTarget("192.168.11.11", 8980, "datkeyyo", "supersecretJKJK", "bucket")
				config.Save()

				test_helpers.ExecuteCommandWithArgs(targetBlobCommand, []string{})

				Expect(outputBuffer).To(test_helpers.Say("Blob Target:\t192.168.11.11:8980\n"))
				Expect(outputBuffer).To(test_helpers.Say("Access Key:\tdatkeyyo"))
				Expect(outputBuffer).To(test_helpers.Say("Secret Key:\tsupersecretJKJK"))
				Expect(outputBuffer).To(test_helpers.Say("Bucket Name:\tbucket"))
			})

			It("alerts the user if no target is set", func() {
				config.SetBlobTarget("", 0, "", "", "")
				config.Save()

				test_helpers.ExecuteCommandWithArgs(targetBlobCommand, []string{})
開發者ID:se77en,項目名稱:lattice,代碼行數:31,代碼來源:blob_config_command_factory_test.go

示例2:

			responseBody   string
		)

		BeforeEach(func() {
			targetVerifier = target_verifier.New(func(string) receptor.Client {
				return &fake_receptor.FakeClient{}
			})
			fakeServer = ghttp.NewServer()

			config = config_package.New(persister.NewMemPersister())
			proxyURL, err := url.Parse(fakeServer.URL())
			Expect(err).NotTo(HaveOccurred())
			proxyHostArr := strings.Split(proxyURL.Host, ":")
			Expect(proxyHostArr).To(HaveLen(2))
			proxyHostPort, _ := strconv.Atoi(proxyHostArr[1])
			config.SetBlobTarget(proxyHostArr[0], uint16(proxyHostPort), "V8GDQFR_VDOGM55IV8OH", "Wv_kltnl98hNWNdNwyQPYnFhK4gVPTxVS3NNMg==", "bucket")

			httpHeader := http.Header{
				"Content-Type": []string{"application/xml"},
			}

			fakeServer.AppendHandlers(ghttp.CombineHandlers(
				ghttp.VerifyRequest("GET", "/bucket/"),
				ghttp.RespondWithPtr(&statusCode, &responseBody, httpHeader),
			))
		})

		It("returns ok=true if able to connect and auth and it exists", func() {
			statusCode = http.StatusOK
			responseBody = `<?xml version="1.0" encoding="UTF-8"?><ListAllMyBucketsResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><Owner><ID>x</ID><DisplayName>x</DisplayName></Owner><Buckets><Bucket><Name>bucket</Name><CreationDate>2015-06-11T16:50:43.000Z</CreationDate></Bucket></Buckets></ListAllMyBucketsResult>`
開發者ID:rajkumargithub,項目名稱:lattice,代碼行數:30,代碼來源:blob_target_verifier_test.go

示例3:

			Expect(fakePersister.target).To(Equal("mysavedapi.com"))
			Expect(testConfig.Receptor()).To(Equal("http://saveduser:[email protected]"))
		})

		It("returns errors from loading the config", func() {
			testConfig = config.New(&fakePersister{err: errors.New("Error")})

			err := testConfig.Load()

			Expect(err).To(MatchError("Error"))
		})
	})

	Describe("TargetBlob", func() {
		It("sets the blob target", func() {
			testConfig.SetBlobTarget("s3-compatible-store", 7474, "NUYP3C_MBM-WDDWYKIUN", "Nb5vjT2V-ZX0O0s00xURSsg2Se0w-bmX40IQNg4==", "the-bucket")

			blobTarget := testConfig.BlobTarget()
			Expect(blobTarget.TargetHost).To(Equal("s3-compatible-store"))
			Expect(blobTarget.TargetPort).To(Equal(uint16(7474)))
			Expect(blobTarget.AccessKey).To(Equal("NUYP3C_MBM-WDDWYKIUN"))
			Expect(blobTarget.SecretKey).To(Equal("Nb5vjT2V-ZX0O0s00xURSsg2Se0w-bmX40IQNg4=="))
			Expect(blobTarget.BucketName).To(Equal("the-bucket"))
		})
	})

	Describe("BlobTargetInfo", func() {
		var blobTargetInfo config.BlobTargetInfo

		Describe("Proxy", func() {
			It("returns the proxy func", func() {
開發者ID:rajkumargithub,項目名稱:lattice,代碼行數:31,代碼來源:config_test.go

示例4:

	)

	BeforeEach(func() {
		fakeAppRunner = &fake_app_runner.FakeAppRunner{}
		fakeTaskRunner = &fake_task_runner.FakeTaskRunner{}
		config = config_package.New(persister.NewMemPersister())
		fakeBlobStore = &fake_blob_store.FakeBlobStore{}
		fakeBlobBucket = &fake_blob_bucket.FakeBlobBucket{}
		fakeTargetVerifier = &fake_target_verifier.FakeTargetVerifier{}
		fakeAppExaminer = &fake_app_examiner.FakeAppExaminer{}
		dropletRunner = droplet_runner.New(fakeAppRunner, fakeTaskRunner, config, fakeBlobStore, fakeBlobBucket, fakeTargetVerifier, fakeAppExaminer)
	})

	Describe("ListDroplets", func() {
		It("returns a list of droplets in the blob store", func() {
			config.SetBlobTarget("blob-host", 7474, "access-key", "secret-key", "bucket-name")
			config.Save()

			fakeBlobBucket.ListStub = func(prefix, delim, marker string, max int) (result *s3.ListResp, err error) {
				switch prefix {
				case "":
					return &s3.ListResp{
						Name:           "bucket-name",
						Prefix:         "",
						Delimiter:      "/",
						CommonPrefixes: []string{"X/", "Y/", "Z/"},
					}, nil
				case "X/":
					return &s3.ListResp{
						Name:      "bucket-name",
						Prefix:    "X/",
開發者ID:thomasdarimont,項目名稱:lattice,代碼行數:31,代碼來源:droplet_runner_test.go

示例5:

		}

		BeforeEach(func() {
			targetVerifier = target_verifier.New(func(string) receptor.Client {
				return &fake_receptor.FakeClient{}
			})
			fakeServer = ghttp.NewServer()

			config = config_package.New(persister.NewMemPersister())
			proxyURL, err := url.Parse(fakeServer.URL())
			Expect(err).NotTo(HaveOccurred())
			proxyHostArr := strings.Split(proxyURL.Host, ":")
			Expect(proxyHostArr).To(HaveLen(2))
			proxyHostPort, err := strconv.Atoi(proxyHostArr[1])
			Expect(err).NotTo(HaveOccurred())
			config.SetBlobTarget(proxyHostArr[0], uint16(proxyHostPort), accessKey, secretKey, bucketName)
			httpHeader := http.Header{
				http.CanonicalHeaderKey("Content-Type"): []string{"application/xml"},
			}

			fakeServer.AppendHandlers(ghttp.CombineHandlers(
				ghttp.VerifyRequest("GET", fmt.Sprintf("/%s/", bucketName)),
				ghttp.RespondWithPtr(&statusCode, &responseBody, httpHeader),
			))
		})

		It("returns ok=true if able to connect and auth and it exists", func() {
			statusCode = http.StatusOK
			responseBody = `<?xml version="1.0" encoding="UTF-8"?><ListAllMyBucketsResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><Owner><ID>x</ID><DisplayName>x</DisplayName></Owner><Buckets><Bucket><Name>bucket</Name><CreationDate>2015-06-11T16:50:43.000Z</CreationDate></Bucket></Buckets></ListAllMyBucketsResult>`

			ok, err := verifyBlobTarget()
開發者ID:se77en,項目名稱:lattice,代碼行數:31,代碼來源:blob_target_verifier_test.go


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