当前位置: 首页>>代码示例>>Golang>>正文


Golang api.InstallResult类代码示例

本文整理汇总了Golang中github.com/openshift/source-to-image/pkg/api.InstallResult的典型用法代码示例。如果您正苦于以下问题:Golang InstallResult类的具体用法?Golang InstallResult怎么用?Golang InstallResult使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: Install

// Install copies the script into upload directory and fix its permissions.
func (s *SourceScriptHandler) Install(r *api.InstallResult) error {
	dst := filepath.Join(s.DestinationDir, api.UploadScripts, r.Script)
	if err := s.fs.Rename(r.URL, dst); err != nil {
		return err
	}
	if err := s.fs.Chmod(dst, 0755); err != nil {
		return err
	}
	// Make the path to scripts nicer in logs
	parts := strings.Split(r.URL, "/")
	if len(parts) > 3 {
		r.URL = sourcesRootAbbrev + strings.Join(parts[len(parts)-3:], "/")
	}
	r.Installed = true
	r.Downloaded = true
	return nil
}
开发者ID:sgallagher,项目名称:origin,代码行数:18,代码来源:install.go

示例2: install

func (i *installer) install(scripts []string, userResults, sourceResults, defaultResults map[string]*downloadResult, dstDir string) []api.InstallResult {
	resultList := make([]api.InstallResult, len(scripts))

	locationsResultsMap := map[string]map[string]*downloadResult{
		api.UserScripts:    userResults,
		api.SourceScripts:  sourceResults,
		api.DefaultScripts: defaultResults,
	}

	// iterate over scripts
	for idx, script := range scripts {
		result := api.InstallResult{Script: script}

		// and possible locations
		for _, location := range locationsOrder {
			locationResults, ok := locationsResultsMap[location]
			if !ok || locationResults == nil {
				continue
			}
			downloadResult, ok := locationResults[script]
			if !ok {
				continue
			}
			result.URL = downloadResult.location

			// if location results are erroneous we store error in result object
			// and continue searching other locations
			if downloadResult.err != nil {
				// one exception is when error contains information about scripts being inside the image
				if e, ok := downloadResult.err.(errors.Error); ok && e.ErrorCode == errors.ScriptsInsideImageError {
					// in which case update result object and break further searching
					result.Error = nil
					result.Downloaded = false
					result.Installed = true
					break
				} else {
					result.Error = downloadResult.err
					continue
				}
			}

			// if there was no error
			src := filepath.Join(dstDir, location, script)
			dst := filepath.Join(dstDir, api.UploadScripts, script)
			// move script to upload directory
			if err := i.fs.Rename(src, dst); err != nil {
				result.Error = err
				continue
			}
			// set appropriate permissions
			if err := i.fs.Chmod(dst, 0755); err != nil {
				result.Error = err
				continue
			}
			// and finally update result object
			result.Error = nil
			result.Downloaded = true
			result.Installed = true
			break
		}
		resultList[idx] = result
	}

	return resultList
}
开发者ID:cjnygard,项目名称:origin,代码行数:65,代码来源:install.go


注:本文中的github.com/openshift/source-to-image/pkg/api.InstallResult类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。