// getDepList gets list of dependencies in root path format and nature order.
193409
func getDepList(ctx *cli.Context, target, pkgPath, vendor string) ([]string, error) {
	vendorSrc := path.Join(vendor, "src")
	rootPath := doc.GetRootPath(target)
	// If work directory is not in GOPATH, then need to setup a vendor path.
	if !setting.HasGOPATHSetting || !strings.HasPrefix(pkgPath, setting.InstallGopath) {
		// Make link of self.
		log.Debug("Linking %s...", rootPath)
		from := pkgPath
		to := path.Join(vendorSrc, rootPath)
		if setting.Debug {
			log.Debug("Linking from %s to %s", from, to)
		}
		if err := autoLink(from, to); err != nil {
			return nil, err
		}
	}

	imports, err := doc.ListImports(target, rootPath, vendor, pkgPath, ctx.String("tags"), ctx.Bool("test"))
	if err != nil {
		return nil, err
	}

	list := make([]string, 0, len(imports))
	for _, name := range imports {
		name = doc.GetRootPath(name)
		if !base.IsSliceContainsStr(list, name) {
			list = append(list, name)
		}
	}
	sort.Strings(list)
	return list, nil
}
583046
func findTypeDef(importPath, typeName string) (*ast.TypeSpec, error) {
	cwd, err := os.Getwd()
	if err != nil {
		return nil, err
	}

	conf := loader.Config{
		ParserMode: goparser.SpuriousErrors,
		Cwd:        cwd,
	}

	conf.Import(importPath)

	lprog, err := conf.Load()
	if err != nil {
		return nil, err
	}

	// If the pkg is vendored, the actual pkg path is going to resemble
	// something like "{importPath}/vendor/{importPath}"
	for k := range lprog.AllPackages {
		realPkgPath := k.Path()

		if strings.Contains(realPkgPath, "vendor/"+importPath) {
			importPath = realPkgPath
		}
	}

	pkgInfo := lprog.Package(importPath)

	if pkgInfo == nil {
		return nil, errors.New("package was nil")
	}

	// TODO: possibly cache pkgInfo since it's an expensive operation

	for i := range pkgInfo.Files {
		for _, astDeclaration := range pkgInfo.Files[i].Decls {
			if generalDeclaration, ok := astDeclaration.(*ast.GenDecl); ok && generalDeclaration.Tok == token.TYPE {
				for _, astSpec := range generalDeclaration.Specs {
					if typeSpec, ok := astSpec.(*ast.TypeSpec); ok {
						if typeSpec.Name.String() == typeName {
							return typeSpec, nil
						}
					}
				}
			}
		}
	}
	return nil, errors.New("type spec not found")
}
1150952
func getChaincodeDeploymentSpec(spec *pb.ChaincodeSpec, crtPkg bool) (*pb.ChaincodeDeploymentSpec, error) {
	var codePackageBytes []byte
	if chaincode.IsDevMode() == false && crtPkg {
		var err error
		if err = checkSpec(spec); err != nil {
			return nil, err
		}

		codePackageBytes, err = container.GetChaincodePackageBytes(platformRegistry, spec)
		if err != nil {
			err = errors.WithMessage(err, "error getting chaincode package bytes")
			return nil, err
		}
	}
	chaincodeDeploymentSpec := &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec, CodePackage: codePackageBytes}
	return chaincodeDeploymentSpec, nil
}
1170000
func (ccpack *SignedCDSPackage) GetDepSpec() *pb.ChaincodeDeploymentSpec {
	//this has to be after creating a package and initializing it
	//If those steps fail, GetDepSpec() should never be called
	if ccpack.depSpec == nil {
		panic("GetDepSpec called on uninitialized package")
	}
	return ccpack.depSpec
}
1106971
func sortDependencies(root Root, depFunc func(Root) []Root) []Root {
	seen := make(map[string]bool, len(roots))
	var sorted []Root
	sortDependenciesR(root, seen, &sorted, depFunc)
	return sorted
}
746958
func (rt *requireTree) GetList(extInfo *types.ExtensionInfo) (requiredFiles []string, lastModified int64, err error) {
	finalPath := rt.Path
	if !filepath.IsAbs(finalPath) {
		finalPath = filepath.Join(rt.BaseDir, rt.Path)
		if newPath, err := filepath.EvalSymlinks(finalPath); err == nil {
			finalPath = newPath
		}
	}
	alterExts := extInfo.AlterExts
	if alterExts.Len() == 0 {
		return nil, 0, errors.New("Extension Format unknown for require:" + extInfo.CurrentExtension)
	}
	err = filepath.Walk(finalPath, func(walkpath string, f os.FileInfo, err error) error {
		if err != nil {
			return err
		}
		if modified := f.ModTime().Unix(); lastModified < modified {
			lastModified = modified
		}
		if f.IsDir() {
			return nil
		}
		curExt := filepath.Ext(walkpath)
		if curExt == extInfo.CurrentExtension {
			requiredFiles = append(requiredFiles, walkpath)
			return nil
		}
		for e := alterExts.Front(); e != nil; e = e.Next() {
			if e.Value == curExt {
				requiredFiles = append(requiredFiles, walkpath)
				break
			}
		}
		return nil
	})
	if err != nil {
		return nil, 0, err
	}
	sort.Strings(requiredFiles)
	return
}
592729
func GetRepoLogger(repo string) (RepoLogger, error) {
	logger.Lock()
	defer logger.Unlock()
	r, ok := logger.repoMap[repo]
	if !ok {
		return nil, errors.New("no packages registered for repo " + repo)
	}
	return r, nil
}
571114
func GetMapDiff(map1, map2 map[string]PackageInfo) PackageDiff {
	diff := diffMaps(map1, map2)
	diffVal := reflect.ValueOf(diff)
	packDiff := diffVal.Interface().(PackageDiff)
	return packDiff
}
1048878
func (e *File) GetDependencies(tasks map[string]fi.Task) []fi.Task {
	var deps []fi.Task
	if e.Owner != nil {
		ownerTask := tasks["user/"+*e.Owner]
		if ownerTask == nil {
			// The user might be a pre-existing user (e.g. admin)
			glog.Warningf("Unable to find task %q", "user/"+*e.Owner)
		} else {
			deps = append(deps, ownerTask)
		}
	}

	// Depend on disk mounts
	// For simplicity, we just depend on _all_ disk mounts
	// We could check the mountpath, but that feels excessive...
	for _, v := range tasks {
		if _, ok := v.(*MountDiskTask); ok {
			deps = append(deps, v)
		}
	}

	// Requires parent directories to be created
	for _, v := range findCreatesDirParents(e.Path, tasks) {
		deps = append(deps, v)
	}

	// Requires other files to be created first
	for _, f := range e.AfterFiles {
		for _, v := range tasks {
			if file, ok := v.(*File); ok {
				if file.Path == f {
					deps = append(deps, v)
				}
			}
		}
	}

	return deps
}
78407
func (rd *requireDirectory) GetList(extInfo *types.ExtensionInfo) (requiredFiles []string, lastModified int64, err error) {
	finalPath := rd.Path
	if !filepath.IsAbs(finalPath) {
		finalPath = filepath.Join(rd.BaseDir, rd.Path)
		if newPath, err := filepath.EvalSymlinks(finalPath); err == nil {
			finalPath = newPath
		}
	}
	f, err := os.Stat(finalPath)
	if err != nil {
		return nil, 0, err
	}
	if modified := f.ModTime().Unix(); lastModified < modified {
		lastModified = modified
	}
	alterExts := extInfo.AlterExts
	if alterExts.Len() == 0 {
		return nil, 0, errors.New("Extension Format unknown for require:" + extInfo.CurrentExtension)
	}
	for e := alterExts.Front(); e != nil; e = e.Next() {
		files, err := filepath.Glob(filepath.Join(finalPath, "*"+e.Value))
		if err != nil {
			return nil, 0, err
		}
		for _, file := range files {
			f, err := os.Stat(file)
			if err != nil {
				return nil, 0, err
			}
			if modified := f.ModTime().Unix(); lastModified < modified {
				lastModified = modified
			}
		}

		requiredFiles = append(requiredFiles, files...)
	}
	sort.Strings(requiredFiles)
	return

}
737132
func (e *Port) GetDependencies(tasks map[string]fi.Task) []fi.Task {
	var deps []fi.Task
	for _, task := range tasks {
		if _, ok := task.(*Subnet); ok {
			deps = append(deps, task)
		}
		if _, ok := task.(*SecurityGroup); ok {
			deps = append(deps, task)
		}
		if _, ok := task.(*Network); ok {
			deps = append(deps, task)
		}
	}
	return deps
}
3692
func (p *PackageProvider) GetChaincodeCodePackage(name, version string) ([]byte, error) {
	codePackage, err := p.getCodePackageFromStore(name, version)
	if err == nil {
		return codePackage, nil
	}
	if _, ok := err.(*CodePackageNotFoundErr); !ok {
		// return the error if the hash cannot be retrieved or the code package
		// fails to load from the persistence store
		return nil, err
	}

	codePackage, err = p.getCodePackageFromLegacyPP(name, version)
	if err != nil {
		logger.Debug(err.Error())
		err = errors.Errorf("code package not found for chaincode with name '%s', version '%s'", name, version)
		return nil, err
	}
	return codePackage, nil
}
478539
func (e *Chattr) GetDependencies(tasks map[string]fi.Task) []fi.Task {
	return e.Deps
}
447860
func (g *Gitignore) GetSource() string {
	if g == nil || g.Source == nil {
		return ""
	}
	return *g.Source
}
831435
func (rf *requireFile) GetList(extInfo *types.ExtensionInfo) ([]string, int64, error) {
	assetPath, _, err := resolvePath(extInfo, rf.Path, rf.BaseDir)
	if err != nil {
		return nil, 0, err
	}
	f, err := os.Stat(assetPath)
	if err != nil {
		return nil, 0, err
	}
	return []string{assetPath}, f.ModTime().Unix(), nil
}
1310261
func (ccpack *CDSPackage) GetDepSpecBytes() []byte {
	//this has to be after creating a package and initializing it
	//If those steps fail, GetDepSpecBytes() should never be called
	if ccpack.buf == nil {
		panic("GetDepSpecBytes called on uninitialized package")
	}
	return ccpack.buf
}
1236252
func NewDependency(opts ...depConsOpt) *Dependency {
	d := new(Dependency)

	for _, opt := range opts {
		opt(d)
	}
	return d
}