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


Golang Git.GetInfo方法代碼示例

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


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

示例1: fetchSource

// fetchSource retrieves the inputs defined by the build source into the
// provided directory, or returns an error if retrieval is not possible.
func fetchSource(dir string, build *api.Build, urlTimeout time.Duration, in io.Reader, git git.Git) (*s2iapi.SourceInfo, error) {
    hasGitSource := false

    // expect to receive input from STDIN
    if err := extractInputBinary(in, build.Spec.Source.Binary, dir); err != nil {
        return nil, err
    }

    // may retrieve source from Git
    hasGitSource, err := extractGitSource(git, build.Spec.Source.Git, build.Spec.Revision, dir, urlTimeout)
    if err != nil {
        return nil, err
    }
    var sourceInfo *s2iapi.SourceInfo
    if hasGitSource {
        sourceInfo = git.GetInfo(dir)
    }

    // a Dockerfile has been specified, create or overwrite into the destination
    if dockerfileSource := build.Spec.Source.Dockerfile; dockerfileSource != nil {
        baseDir := dir
        // if a context dir has been defined and we cloned source, overwrite the destination
        if hasGitSource && len(build.Spec.Source.ContextDir) != 0 {
            baseDir = filepath.Join(baseDir, build.Spec.Source.ContextDir)
        }
        return sourceInfo, ioutil.WriteFile(filepath.Join(baseDir, "Dockerfile"), []byte(*dockerfileSource), 0660)
    }

    return sourceInfo, nil
}
開發者ID:Waxolunist,項目名稱:origin,代碼行數:32,代碼來源:source.go


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