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


Golang image.Finder类代码示例

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


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

示例1: getStage1HashFromPath

func getStage1HashFromPath(fn *image.Finder, imgLoc, imgFileName string) (*types.Hash, error) {
	var fetchErr error
	var fallbackErr error
	if imgLoc != "" {
		hash, err := fn.FindImage(imgLoc, "", apps.AppImagePath)
		if err == nil {
			return hash, nil
		}
		fetchErr = err
	}
	if imgFileName != "" {
		exePath, err := os.Readlink("/proc/self/exe")
		if err != nil {
			fallbackErr = err
		} else {
			// using stage1 image in rkt's path, don't check the signature
			fn.Ks = nil
			rktDir := filepath.Dir(exePath)
			imgPath := filepath.Join(rktDir, imgFileName)
			hash, err := fn.FindImage(imgPath, "", apps.AppImagePath)
			if err == nil {
				return hash, nil
			}
			fallbackErr = err
		}
	}
	return nil, mergeStage1Errors(fetchErr, fallbackErr)
}
开发者ID:coderhaoxin,项目名称:rkt,代码行数:28,代码来源:stage1hash.go

示例2: getCustomStage1Hash

func getCustomStage1Hash(fn *image.Finder, path string) (*types.Hash, error) {
	s1img, err := fn.FindImage(path, "", apps.AppImageGuess)
	if err != nil {
		return nil, errwrap.Wrap(fmt.Errorf("error finding stage1 image %q", path), err)
	}
	return s1img, nil
}
开发者ID:hwinkel,项目名称:rkt,代码行数:7,代码来源:stage1hash.go

示例3: getDefaultStage1HashFromStore

func getDefaultStage1HashFromStore(fn *image.Finder) *types.Hash {
	// we make sure we've built rkt with a clean git tree,
	// otherwise we don't know if something changed
	if !strings.HasSuffix(defaultStage1Version, "-dirty") {
		stage1AppName := fmt.Sprintf("%s:%s", defaultStage1Name, defaultStage1Version)
		fn.StoreOnly = true
		s1img, _ := fn.FindImage(stage1AppName, "", apps.AppImageName)
		fn.StoreOnly = false
		return s1img
	}
	return nil
}
开发者ID:hwinkel,项目名称:rkt,代码行数:12,代码来源:stage1hash.go

示例4: getLocalDefaultStage1Hash

func getLocalDefaultStage1Hash(fn *image.Finder) (*types.Hash, error) {
	var firstErr error = nil
	// Guard against relative path to default stage1 image. It
	// could be fine for some custom stage1 path passed via
	// --stage1-image parameter, but not for default, not
	// overridden ones. Usually, if the path is relative, then it
	// means we simply didn't pass --with-stage1-image-path
	// parameter to configure script, so it defaulted to desired
	// filename like "stuff/yadda/stage1-lkvm.aci" (or something).
	if filepath.IsAbs(defaultStage1Image) {
		s1img, err := fn.FindImage(defaultStage1Image, "", apps.AppImagePath)
		if s1img != nil {
			return s1img, nil
		}
		firstErr = err
	}
	// could not find default stage1 image in a given path
	// (or we ignored it), lets try to load one in the
	// same directory as rkt itself
	imgBase := filepath.Base(defaultStage1Image)
	exePath, err := os.Readlink("/proc/self/exe")
	if err != nil {
		if firstErr != nil {
			innerErr := errwrap.Wrap(firstErr, err)
			return nil, errwrap.Wrap(fmt.Errorf("error finding stage1 images %q and %q in rkt binary directory", defaultStage1Image, imgBase), innerErr)
		} else {
			return nil, errwrap.Wrap(fmt.Errorf("error finding stage1 image %q in rkt binary directory", imgBase), err)
		}
	}
	fallbackPath := filepath.Join(filepath.Dir(exePath), imgBase)
	s1img, err := fn.FindImage(fallbackPath, "", apps.AppImagePath)
	if err != nil {
		if firstErr != nil {
			innerErr := errwrap.Wrap(firstErr, err)
			return nil, errwrap.Wrap(fmt.Errorf("error finding stage1 images %q and %q", defaultStage1Image, fallbackPath), innerErr)
		} else {
			return nil, errwrap.Wrap(fmt.Errorf("error finding stage1 image %q", fallbackPath), err)
		}
	}
	return s1img, nil
}
开发者ID:hwinkel,项目名称:rkt,代码行数:41,代码来源:stage1hash.go


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