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


Golang Git.ValidCloneSpec方法代碼示例

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


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

示例1: checkSourceURI

// checkSourceURI performs a check on the URI associated with the build
// to make sure that it is valid.  It also optionally tests the connection
// to the source uri.
func checkSourceURI(git git.Git, rawurl string, testConnection bool, timeout time.Duration) error {
	if !git.ValidCloneSpec(rawurl) {
		return fmt.Errorf("Invalid git source url: %s", rawurl)
	}
	if strings.HasPrefix(rawurl, "[email protected]") || strings.HasPrefix(rawurl, "git://") {
		return nil
	}
	srcURL, err := url.Parse(rawurl)
	if err != nil {
		return err
	}
	if !testConnection {
		return nil
	}
	host := srcURL.Host
	if strings.Index(host, ":") == -1 {
		switch srcURL.Scheme {
		case "http":
			host += ":80"
		case "https":
			host += ":443"
		}
	}
	dialer := net.Dialer{Timeout: timeout}
	conn, err := dialer.Dial("tcp", host)
	if err != nil {
		return err
	}
	return conn.Close()
}
開發者ID:hloganathan,項目名稱:origin,代碼行數:33,代碼來源:source.go

示例2: checkSourceURI

// checkSourceURI performs a check on the URI associated with the build
// to make sure that it is valid.  It also optionally tests the connection
// to the source uri.
func checkSourceURI(git git.Git, rawurl string, timeout time.Duration) error {
	if !git.ValidCloneSpec(rawurl) {
		return fmt.Errorf("Invalid git source url: %s", rawurl)
	}
	return checkRemoteGit(rawurl, timeout)
}
開發者ID:Waxolunist,項目名稱:origin,代碼行數:9,代碼來源:source.go


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