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


Golang InstallResult.Installed方法代码示例

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


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

示例1: Install

// Install downloads the script and fix its permissions.
func (s *URLScriptHandler) Install(r *api.InstallResult) error {
	downloadURL, err := url.Parse(r.URL)
	if err != nil {
		return err
	}
	dst := filepath.Join(s.DestinationDir, r.Script)
	if _, err := s.download.Download(downloadURL, dst); err != nil {
		if e, ok := err.(errors.Error); ok {
			if e.ErrorCode == errors.ScriptsInsideImageError {
				r.Installed = true
				return nil
			}
		}
		return err
	}
	if err := s.fs.Chmod(dst, 0755); err != nil {
		return err
	}
	r.Installed = true
	r.Downloaded = true
	return nil
}
开发者ID:sgallagher,项目名称:origin,代码行数:23,代码来源: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.Installed方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。