本文整理汇总了Golang中github.com/github/git-lfs/config.Configuration.Endpoint方法的典型用法代码示例。如果您正苦于以下问题:Golang Configuration.Endpoint方法的具体用法?Golang Configuration.Endpoint怎么用?Golang Configuration.Endpoint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/github/git-lfs/config.Configuration
的用法示例。
在下文中一共展示了Configuration.Endpoint方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: getCredURLForAPI
func getCredURLForAPI(cfg *config.Configuration, req *http.Request) (*url.URL, error) {
operation := GetOperationForRequest(req)
apiUrl, err := url.Parse(cfg.Endpoint(operation).Url)
if err != nil {
return nil, err
}
// if the LFS request doesn't match the current LFS url, don't bother
// attempting to set the Authorization header from the LFS or Git remote URLs.
if req.URL.Scheme != apiUrl.Scheme ||
req.URL.Host != apiUrl.Host {
return req.URL, nil
}
if setRequestAuthFromUrl(cfg, req, apiUrl) {
return nil, nil
}
credsUrl := apiUrl
if len(cfg.CurrentRemote) > 0 {
if u := cfg.GitRemoteUrl(cfg.CurrentRemote, operation == "upload"); u != "" {
gitRemoteUrl, err := url.Parse(u)
if err != nil {
return nil, err
}
if gitRemoteUrl.Scheme == apiUrl.Scheme &&
gitRemoteUrl.Host == apiUrl.Host {
if setRequestAuthFromUrl(cfg, req, gitRemoteUrl) {
return nil, nil
}
credsUrl = gitRemoteUrl
}
}
}
return credsUrl, nil
}
示例2: SshAuthenticate
func SshAuthenticate(cfg *config.Configuration, operation, oid string) (SshAuthResponse, config.Endpoint, error) {
// This is only used as a fallback where the Git URL is SSH but server doesn't support a full SSH binary protocol
// and therefore we derive a HTTPS endpoint for binaries instead; but check authentication here via SSH
endpoint := cfg.Endpoint(operation)
res := SshAuthResponse{}
if len(endpoint.SshUserAndHost) == 0 {
return res, endpoint, nil
}
tracerx.Printf("ssh: %s git-lfs-authenticate %s %s %s",
endpoint.SshUserAndHost, endpoint.SshPath, operation, oid)
exe, args := sshGetExeAndArgs(cfg, endpoint)
args = append(args,
fmt.Sprintf("git-lfs-authenticate %s %s %s", endpoint.SshPath, operation, oid))
cmd := exec.Command(exe, args...)
// Save stdout and stderr in separate buffers
var outbuf, errbuf bytes.Buffer
cmd.Stdout = &outbuf
cmd.Stderr = &errbuf
// Execute command
err := cmd.Start()
if err == nil {
err = cmd.Wait()
}
// Processing result
if err != nil {
res.Message = errbuf.String()
} else {
err = json.Unmarshal(outbuf.Bytes(), &res)
}
return res, endpoint, err
}
示例3: setErrorRequestContext
func setErrorRequestContext(cfg *config.Configuration, err error, req *http.Request) {
errors.SetContext(err, "Endpoint", cfg.Endpoint(auth.GetOperationForRequest(req)).Url)
errors.SetContext(err, "URL", TraceHttpReq(req))
setErrorHeaderContext(err, "Response", req.Header)
}