• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang urljoiner.Join函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/cloudfoundry/gunk/urljoiner.Join函数的典型用法代码示例。如果您正苦于以下问题:Golang Join函数的具体用法?Golang Join怎么用?Golang Join使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: GetProviders

func (of OAuthFactory) GetProviders(teamName string) (Providers, error) {
	team, found, err := of.db.GetTeamByName(teamName)
	if err != nil {
		return Providers{}, err
	}
	if !found {
		return Providers{}, errors.New("team not found")
	}

	providers := Providers{}

	if len(team.GitHubAuth.Organizations) > 0 ||
		len(team.GitHubAuth.Teams) > 0 ||
		len(team.GitHubAuth.Users) > 0 {

		redirectURL, err := of.routes.CreatePathForRoute(of.callback, rata.Params{
			"provider": github.ProviderName,
		})
		if err != nil {
			return Providers{}, err
		}
		gitHubAuthProvider := github.NewProvider(team.GitHubAuth, urljoiner.Join(of.atcExternalURL, redirectURL))

		providers[github.ProviderName] = gitHubAuthProvider
	}

	return providers, err
}
开发者ID:xoebus,项目名称:checkin,代码行数:28,代码来源:oauth_factory.go


示例2: compilerDownloadURL

func (backend *dockerBackend) compilerDownloadURL() (*url.URL, error) {
	lifecycleFilename := backend.config.Lifecycles["docker"]
	if lifecycleFilename == "" {
		return nil, ErrNoCompilerDefined
	}

	parsed, err := url.Parse(lifecycleFilename)
	if err != nil {
		return nil, errors.New("couldn't parse compiler URL")
	}

	switch parsed.Scheme {
	case "http", "https":
		return parsed, nil
	case "":
		break
	default:
		return nil, fmt.Errorf("unknown scheme: '%s'", parsed.Scheme)
	}

	urlString := urljoiner.Join(backend.config.FileServerURL, "/v1/static", lifecycleFilename)

	url, err := url.ParseRequestURI(urlString)
	if err != nil {
		return nil, fmt.Errorf("failed to parse compiler download URL: %s", err)
	}

	return url, nil
}
开发者ID:cfibmers,项目名称:stager,代码行数:29,代码来源:docker_backend.go


示例3: compilerDownloadURL

func (backend *traditionalBackend) compilerDownloadURL(request cc_messages.StagingRequestFromCC, buildpackData cc_messages.BuildpackStagingData) (*url.URL, error) {
	compilerPath, ok := backend.config.Lifecycles[request.Lifecycle+"/"+buildpackData.Stack]
	if !ok {
		return nil, ErrNoCompilerDefined
	}

	parsed, err := url.Parse(compilerPath)
	if err != nil {
		return nil, errors.New("couldn't parse compiler URL")
	}

	switch parsed.Scheme {
	case "http", "https":
		return parsed, nil
	case "":
		break
	default:
		return nil, errors.New("Unknown Scheme")
	}

	staticPath, err := fileserver.Routes.CreatePathForRoute(fileserver.StaticRoute, nil)
	if err != nil {
		return nil, fmt.Errorf("couldn't generate the compiler download path: %s", err)
	}

	urlString := urljoiner.Join(backend.config.FileServerURL, staticPath, compilerPath)

	url, err := url.ParseRequestURI(urlString)
	if err != nil {
		return nil, fmt.Errorf("failed to parse compiler download URL: %s", err)
	}

	return url, nil
}
开发者ID:emc-xchallenge,项目名称:stager,代码行数:34,代码来源:buildpack_backend.go


示例4: lifecycleDownloadURL

func lifecycleDownloadURL(lifecyclePath string, fileServerURL string) string {
	staticPath, err := fileserver.Routes.CreatePathForRoute(fileserver.StaticRoute, nil)
	if err != nil {
		panic("couldn't generate the download path for the bundle of app lifecycle binaries: " + err.Error())
	}

	return urljoiner.Join(fileServerURL, staticPath, lifecyclePath)
}
开发者ID:emc-xchallenge,项目名称:nsync,代码行数:8,代码来源:recipe_builder.go


示例5: pollingResponseBody

func pollingResponseBody(jobGuid, status string, baseUrl string) string {
	url := urljoiner.Join("/v2/jobs", jobGuid)
	if baseUrl != "" {
		url = urljoiner.Join(baseUrl, url)
	}
	return fmt.Sprintf(`
				{
					"metadata":{
						"guid": "%s",
						"url": "%s"
					},
					"entity": {
						"status": "%s"
					}
				}
			`, jobGuid, url, status)
}
开发者ID:emc-xchallenge,项目名称:cc-uploader,代码行数:17,代码来源:handlers_test.go


示例6: verifyPollingRequest

func verifyPollingRequest(jobGuid, status string, timeClicker chan time.Time) http.HandlerFunc {
	return ghttp.CombineHandlers(
		ghttp.VerifyRequest("GET", urljoiner.Join("/v2/jobs/", jobGuid)),
		ghttp.RespondWith(http.StatusOK, pollingResponseBody(jobGuid, status, "")),
		func(w http.ResponseWriter, r *http.Request) {
			timeClicker <- time.Now()
		},
	)
}
开发者ID:emc-xchallenge,项目名称:cc-uploader,代码行数:9,代码来源:handlers_test.go


示例7: cloudfrontURL

func (up *RequestURLProvider) cloudfrontURL(request InRequest, remotePath string) string {
	url := urljoiner.Join(request.Source.CloudfrontURL, remotePath)

	if request.Version.VersionID != "" {
		url = url + "?versionId=" + request.Version.VersionID
	}

	return url
}
开发者ID:dgodd,项目名称:ssh-resource,代码行数:9,代码来源:in_command.go


示例8: buildArtifactsUploadURL

func (backend *traditionalBackend) buildArtifactsUploadURL(request cc_messages.StagingRequestFromCC, buildpackData cc_messages.BuildpackStagingData) (*url.URL, error) {
	path, err := ccuploader.Routes.CreatePathForRoute(ccuploader.UploadBuildArtifactsRoute, rata.Params{
		"app_guid": request.AppId,
	})
	if err != nil {
		return nil, fmt.Errorf("couldn't generate build artifacts cache upload URL: %s", err)
	}

	urlString := urljoiner.Join(backend.config.CCUploaderURL, path)

	u, err := url.ParseRequestURI(urlString)
	if err != nil {
		return nil, fmt.Errorf("failed to parse build artifacts cache upload URL: %s", err)
	}

	values := make(url.Values, 1)
	values.Add(cc_messages.CcBuildArtifactsUploadUriKey, buildpackData.BuildArtifactsCacheUploadUri)
	u.RawQuery = values.Encode()

	return u, nil
}
开发者ID:emc-xchallenge,项目名称:stager,代码行数:21,代码来源:buildpack_backend.go


示例9: NewCcClient

func NewCcClient(baseURI string, username string, password string, skipCertVerify bool) CcClient {
	httpClient := &http.Client{
		Timeout: appCrashedRequestTimeout,
		Transport: &http.Transport{
			Proxy: http.ProxyFromEnvironment,
			Dial: (&net.Dialer{
				Timeout:   10 * time.Second,
				KeepAlive: 30 * time.Second,
			}).Dial,
			TLSHandshakeTimeout: 10 * time.Second,
			TLSClientConfig: &tls.Config{
				InsecureSkipVerify: skipCertVerify,
				MinVersion:         tls.VersionTLS10,
			},
		},
	}

	return &ccClient{
		ccURI:      urljoiner.Join(baseURI, appCrashedPath),
		username:   username,
		password:   password,
		httpClient: httpClient,
	}
}
开发者ID:emc-xchallenge,项目名称:tps,代码行数:24,代码来源:cc_client.go


示例10:

		BeforeEach(func() {
			var err error
			page, err = agoutiDriver.NewPage()
			Expect(err).NotTo(HaveOccurred())
		})

		AfterEach(func() {
			Expect(page.Destroy()).To(Succeed())
		})

		homepage := func() string {
			return fmt.Sprintf("http://127.0.0.1:%d", atcPort)
		}

		withPath := func(path string) string {
			return urljoiner.Join(homepage(), path)
		}

		allBuildsListIcon := ".nav-right .nav-item"
		allBuildsListIconLink := ".nav-right .nav-item a"
		firstBuildNumber := ".table-row:nth-of-type(1) .build-number"
		firstBuildLink := ".table-row:nth-of-type(1) a"
		secondBuildLink := ".table-row:nth-of-type(2) a"
		homeLink := ".js-groups li:nth-of-type(2) a"

		Context("with a one off build", func() {
			var oneOffBuild db.Build
			var build db.Build

			BeforeEach(func() {
				location := event.OriginLocation{ID: 1, ParentID: 0, ParallelGroup: 0}
开发者ID:ACPK,项目名称:atc,代码行数:31,代码来源:builds_list_test.go


示例11:

			{"bbs", componentMaker.BBS()},
			{"receptor", componentMaker.Receptor()},
			{"auctioneer", componentMaker.Auctioneer()},
			{"file-server", fileServer},
		}))

		bridge = ginkgomon.Invoke(grouper.NewParallel(os.Kill, grouper.Members{
			{"cc", fakeCC},
			{"stager", componentMaker.Stager()},
			{"nsync-listener", componentMaker.NsyncListener()},
		}))

		u, err := url.Parse(fakeCC.Address())
		Expect(err).NotTo(HaveOccurred())
		u.User = url.UserPassword(fakeCC.Username(), fakeCC.Password())
		u.Path = urljoiner.Join("staging", "droplets", appId, "upload?async=true")
		dropletUploadUri = u.String()
		u.Path = urljoiner.Join("staging", "buildpack_cache", appId, "upload")
		buildArtifactsUploadUri = u.String()
	})

	AfterEach(func() {
		helpers.StopProcesses(cell, brain, bridge)
	})

	stageApplication := func(stagingGuid, payload string) (*http.Response, error) {
		stageURL := urljoiner.Join("http://"+componentMaker.Addresses.Stager, "v1", "staging", stagingGuid)
		request, err := http.NewRequest("PUT", stageURL, strings.NewReader(payload))
		Expect(err).NotTo(HaveOccurred())

		return http.DefaultClient.Do(request)
开发者ID:Gerg,项目名称:inigo,代码行数:31,代码来源:stager_test.go


示例12: storeStatsEndpoint

func (t *ETCDMetrics) storeStatsEndpoint(etcdAddr string) string {
	return urljoiner.Join(etcdAddr, "v2", "stats", "store")
}
开发者ID:timani,项目名称:bbs,代码行数:3,代码来源:metrics.go


示例13: keysEndpoint

func (t *ETCDMetrics) keysEndpoint(etcdAddr string) string {
	return urljoiner.Join(etcdAddr, "v2", "keys")
}
开发者ID:timani,项目名称:bbs,代码行数:3,代码来源:metrics.go


示例14:

						))
					})

					It("succeeds and prints an error message to help the user", func() {
						flyCmd := exec.Command(flyPath, "-t", atcServer.URL()+"/", "configure", "awesome-pipeline", "-c", configFile.Name())

						stdin, err := flyCmd.StdinPipe()
						Ω(err).ShouldNot(HaveOccurred())

						sess, err := gexec.Start(flyCmd, GinkgoWriter, GinkgoWriter)
						Ω(err).ShouldNot(HaveOccurred())

						Eventually(sess).Should(gbytes.Say(`apply configuration\? \(y/n\): `))
						fmt.Fprintln(stdin, "y")

						pipelineURL := urljoiner.Join(atcServer.URL(), "pipelines", "awesome-pipeline")

						Eventually(sess).Should(gbytes.Say("pipeline created!"))
						Eventually(sess).Should(gbytes.Say(fmt.Sprintf("you can view your pipeline here: %s", pipelineURL)))

						Eventually(sess).Should(gbytes.Say("the pipeline is currently paused. to unpause, either:"))
						Eventually(sess).Should(gbytes.Say("  - run again with --paused=false"))
						Eventually(sess).Should(gbytes.Say("  - click play next to the pipeline in the web ui"))

						<-sess.Exited
						Ω(sess.ExitCode()).Should(Equal(0))

						Ω(atcServer.ReceivedRequests()).Should(HaveLen(2))
					})
				})
开发者ID:simonjjones,项目名称:fly,代码行数:30,代码来源:configure_test.go


示例15:

							"num_instances": `+strconv.Itoa(instances)+`,
							"memory_mb": 256,
							"disk_mb": 1024,
							"file_descriptors": 16384,
							"environment":[{"name":"VCAP_APPLICATION", "value":"{}"}],
							"routes": `+routes+`,
							"log_guid": "%s"
						}
						`,
			guid,
			fmt.Sprintf("http://%s/v1/static/%s", componentMaker.Addresses.FileServer, "droplet.zip"),
			componentMaker.DefaultStack(),
			appId,
		)

		desireURL := urljoiner.Join("http://"+componentMaker.Addresses.NsyncListener, "v1", "apps", guid)
		request, err := http.NewRequest("PUT", desireURL, strings.NewReader(desireMessage))
		Expect(err).NotTo(HaveOccurred())

		request.Header.Set("Content-Type", "application/json")
		return http.DefaultClient.Do(request)
	}

	BeforeEach(func() {
		appId = helpers.GenerateGuid()

		fileServer, fileServerStaticDir := componentMaker.FileServer()

		runtime = ginkgomon.Invoke(grouper.NewParallel(os.Kill, grouper.Members{
			{"bbs", componentMaker.BBS()},
			{"receptor", componentMaker.Receptor()},
开发者ID:Gerg,项目名称:inigo,代码行数:31,代码来源:cc_app_test.go


示例16:

		s    *Server
	)

	BeforeEach(func() {
		s = New()
	})

	AfterEach(func() {
		s.Close()
	})

	Describe("allowing unhandled requests", func() {
		BeforeEach(func() {
			s.AllowUnhandledRequests = true
			s.UnhandledRequestStatusCode = http.StatusForbidden
			resp, err = http.Get(urljoiner.Join(s.URL(), "/foo"))
			Expect(err).NotTo(HaveOccurred())
		})

		It("should allow unhandled requests and respond with the passed in status code", func() {
			Expect(err).NotTo(HaveOccurred())
			Expect(resp.StatusCode).To(Equal(http.StatusForbidden))

			data, err := ioutil.ReadAll(resp.Body)
			Expect(err).NotTo(HaveOccurred())
			Expect(data).To(BeEmpty())
		})

		It("should record the requests", func() {
			Expect(s.ReceivedRequestsCount()).To(Equal(1))
		})
开发者ID:glyn,项目名称:gunk,代码行数:31,代码来源:test_server_test.go


示例17:

			"-skipCertVerify",
		)

		session, err = gexec.Start(exec.Command(ccUploaderBinary, args...), GinkgoWriter, GinkgoWriter)
		Expect(err).NotTo(HaveOccurred())

		Eventually(session).Should(gbytes.Say("cc-uploader.ready"))

		return session
	}

	dropletUploadRequest := func(appGuid string, body io.Reader, contentLength int) *http.Request {
		ccUrl, err := url.Parse(fakeCC.Address())
		Expect(err).NotTo(HaveOccurred())
		ccUrl.User = url.UserPassword(fakeCC.Username(), fakeCC.Password())
		ccUrl.Path = urljoiner.Join("staging", "droplets", appGuid, "upload")
		v := url.Values{"async": []string{"true"}}
		ccUrl.RawQuery = v.Encode()

		route, ok := ccuploader.Routes.FindRouteByName(ccuploader.UploadDropletRoute)
		Expect(ok).To(BeTrue())

		path, err := route.CreatePath(map[string]string{"guid": appGuid})
		Expect(err).NotTo(HaveOccurred())

		u, err := url.Parse(urljoiner.Join(address, path))
		Expect(err).NotTo(HaveOccurred())
		v = url.Values{cc_messages.CcDropletUploadUriKey: []string{ccUrl.String()}}
		u.RawQuery = v.Encode()

		postRequest, err := http.NewRequest("POST", u.String(), body)
开发者ID:emc-xchallenge,项目名称:cc-uploader,代码行数:31,代码来源:main_test.go


示例18: EmitRunOnceStates

func EmitRunOnceStates(datadogClient *datadog.Client, store *etcdstoreadapter.ETCDStoreAdapter, etcdMachines []string) {
	for {
		now := time.Now().Unix()
		all, err := store.ListRecursively("/v1/run_once")
		if err != nil {
			log.Println("failed to get all RunOnces:", err)
			time.Sleep(1 * time.Second)
			continue
		}

		metrics := []datadog.Metric{}

		for i, etcdMachine := range etcdMachines {
			stats := map[string]int{}
			resp, err := http.Get(urljoiner.Join(etcdMachine, "/v2/stats/store"))
			if err != nil {
				log.Println("failed to fetch stats:", err)
				continue
			}
			data, _ := ioutil.ReadAll(resp.Body)
			resp.Body.Close()

			json.Unmarshal(data, &stats)

			metrics = append(metrics, datadog.Metric{
				Metric: fmt.Sprintf("etcd_watchers_%d", i),
				Points: []datadog.DataPoint{
					datadog.DataPoint(
						[2]float64{
							float64(now),
							float64(stats["watchers"]),
						},
					),
				},
			})
		}

		for _, state := range []string{"pending", "claimed", "running", "completed", "resolving"} {
			runOnces, found := all.Lookup(state)
			if !found {
				log.Println("failed to find RunOnces in", state, "state")
				time.Sleep(1 * time.Second)
				continue
			}

			metrics = append(metrics, datadog.Metric{
				Metric: "diego_runonce_" + state,
				Points: []datadog.DataPoint{
					datadog.DataPoint(
						[2]float64{
							float64(now),
							float64(len(runOnces.ChildNodes)),
						},
					),
				},
			})
		}

		executors, err := store.ListRecursively("/v1/executor")
		if err != nil {
			log.Println("failed to get all Executors:", err)
			time.Sleep(1 * time.Second)
			continue
		}

		metrics = append(metrics, datadog.Metric{
			Metric: "executors_maintaining_presence",
			Points: []datadog.DataPoint{
				datadog.DataPoint(
					[2]float64{
						float64(now),
						float64(len(executors.ChildNodes)),
					},
				),
			},
		})

		err = datadogClient.PostMetrics(metrics)
		if err != nil {
			log.Println("failed to post metrics:", err)
		}

		time.Sleep(1 * time.Second)
	}
}
开发者ID:pivotal-cf-experimental,项目名称:executor-tester,代码行数:85,代码来源:etcd_logger.go


示例19: leaderStatsEndpoint

func (t *ETCDMetrics) leaderStatsEndpoint(etcdAddr string) string {
	return urljoiner.Join(etcdAddr, "v2", "stats", "leader")
}
开发者ID:timani,项目名称:bbs,代码行数:3,代码来源:metrics.go



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang workpool.NewWorkPool函数代码示例发布时间:2022-05-23
下一篇:
Golang faketimeprovider.FakeTimeProvider类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap