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


Golang Finder.FindImage方法代碼示例

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


在下文中一共展示了Finder.FindImage方法的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.FindImage方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。