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


Golang MungeConfig.GetFileContents方法代碼示例

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


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

示例1: getGeneratedFiles

// getGeneratedFiles returns a list of all automatically generated files in the repo. These include
// docs, deep_copy, and conversions
//
// It would be 'better' to call this for every commit but that takes
// a whole lot of time for almost always the same information, and if
// our results are slightly wrong, who cares? Instead look for the
// generated files once and if someone changed what files are generated
// we'll size slightly wrong. No biggie.
func (s *SizeMunger) getGeneratedFiles(config *config.MungeConfig) {
	if s.genFiles != nil {
		return
	}
	files := sets.NewString()
	prefixes := []string{}
	s.genFiles = &files
	s.genPrefixes = &prefixes

	file := s.generatedFilesFile
	if len(file) == 0 {
		glog.Infof("No --generated-files-config= supplied, applying no labels")
		return
	}
	fp, err := os.Open(file)
	if err != nil {
		glog.Errorf("Unable to open %q: %v", file, err)
		return
	}

	defer fp.Close()
	scanner := bufio.NewScanner(fp)
	for scanner.Scan() {
		line := scanner.Text()
		if strings.HasPrefix(line, "#") || line == "" {
			continue
		}
		fields := strings.Fields(line)
		if len(fields) != 2 {
			glog.Errorf("Invalid line in generated docs config %s: %q", file, line)
			continue
		}
		eType := fields[0]
		file := fields[1]
		if eType == "prefix" {
			prefixes = append(prefixes, file)
		} else if eType == "path" {
			files.Insert(file)
		} else if eType == "paths-from-repo" {
			docs, err := config.GetFileContents(file, "")
			if err != nil {
				continue
			}
			docSlice := strings.Split(docs, "\n")
			files.Insert(docSlice...)
		} else {
			glog.Errorf("Invalid line in generated docs config, unknown type: %s, %q", eType, line)
			continue
		}
	}
	if scanner.Err() != nil {
		glog.Errorf("Error scanning %s: %v", file, err)
		return
	}
	s.genFiles = &files
	s.genPrefixes = &prefixes

	return
}
開發者ID:RobertATX,項目名稱:contrib,代碼行數:67,代碼來源:size.go

示例2: getGeneratedFiles

// getGeneratedFiles returns a list of all automatically generated files in the repo. These include
// docs, deep_copy, and conversions
func getGeneratedFiles(config *config.MungeConfig, c github.RepositoryCommit) []string {
	genFiles := []string{
		"pkg/api/v1/deep_copy_generated.go",
		"pkg/api/deep_copy_generated.go",
		"pkg/expapi/v1/deep_copy_generated.go",
		"pkg/expapi/deep_copy_generated.go",
		"pkg/api/v1/conversion_generated.go",
		"pkg/expapi/v1/conversion_generated.go",
		"api/swagger-spec/resourceListing.json",
		"api/swagger-spec/version.json",
		"api/swagger-spec/api.json",
		"api/swagger-spec/v1.json",
	}
	docs, err := config.GetFileContents(".generated_docs", *c.SHA)
	if err != nil {
		docs = ""
	}
	docSlice := strings.Split(docs, "\n")
	genFiles = append(genFiles, docSlice...)

	return genFiles
}
開發者ID:sigma,項目名稱:kubernetes-contrib,代碼行數:24,代碼來源:size.go


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