// Import implements volume.Volume.Import
541032
func (v *RsyncVolume) Import(label string, reader io.Reader) error {
	v.Lock()
	defer v.Unlock()
	label = v.rawSnapshotLabel(label)
	if exists, err := volume.IsDir(v.snapshotPath(label)); err != nil {
		return err
	} else if exists {
		return volume.ErrSnapshotExists
	}
	driverfile := fmt.Sprintf("%s-driver", label)
	volumedir := fmt.Sprintf("%s-volume", label)
	metadatadir := fmt.Sprintf("%s-metadata", label)
	var drivertype string
	tarfile := tar.NewReader(reader)
	for {
		header, err := tarfile.Next()
		if err == io.EOF {
			break
		} else if err != nil {
			glog.Errorf("Could not import archive: %s", err)
			return err
		}
		if header.Name == driverfile {
			buf := bytes.NewBufferString("")
			if _, err := buf.ReadFrom(tarfile); err != nil {
				return err
			}
			drivertype = buf.String()
		} else if strings.HasPrefix(header.Name, volumedir) {
			header.Name = strings.Replace(header.Name, volumedir, label, 1)
			if err := volume.ImportArchiveHeader(header, tarfile, v.driver.Root()); err != nil {
				return err
			}
		} else if strings.HasPrefix(header.Name, metadatadir) {
			header.Name = strings.Replace(header.Name, metadatadir, label, 1)
			if err := volume.ImportArchiveHeader(header, tarfile, v.driver.MetadataDir()); err != nil {
				return err
			}
		}
	}
	if drivertype == "" {
		return errors.New("incompatible snapshot")
	}
	return nil
}
1036962
func (w *Wrapper) importDirsUsed() []string {
	used := []string{}
	for _, imp := range w.ImportDirs {
		for _, proto := range w.ProtoFiles {
			if strings.HasPrefix(proto, imp) {
				used = append(used, imp)
				break
			}
		}
	}
	return used
}
932178
func (importer *MemoryImporter) Import(importedFrom, importedPath string) (contents Contents, foundAt string, err error) {
	if content, ok := importer.Data[importedPath]; ok {
		return content, importedPath, nil
	}
	return Contents{}, "", fmt.Errorf("import not available %v", importedPath)
}
455402
func (gm serverMethod) Imports() []string {
	ip := map[string]struct{}{
		`"net/http"`: struct{}{},
	}
	if gm.firstSuccessRespBodyType() != "" || gm.reqBody != "" {
		ip[`"encoding/json"`] = struct{}{}
	}
	if gm.needImportGoramlTypes() {
		ip[`"`+globRootImportPath+"/types"+`"`] = struct{}{}
	}
	for lib := range gm.libImported(globRootImportPath) {
		ip[lib] = struct{}{}
	}
	return commons.MapToSortedStrings(ip)
}
1100691
func (imp *Import) Compare(other *Import) int {
	if imp == nil {
		if other == nil {
			return 0
		}
		return -1
	} else if other == nil {
		return 1
	}
	if cmp := Compare(imp.Path, other.Path); cmp != 0 {
		return cmp
	}
	return Compare(imp.Alias, other.Alias)
}
717222
func (cli *Client) VolumeInspect(ctx context.Context, volumeID string) (types.Volume, error) {
	volume, _, err := cli.VolumeInspectWithRaw(ctx, volumeID)
	return volume, err
}
40181
func (imp *Import) Copy() *Import {
	cpy := *imp
	cpy.Path = imp.Path.Copy()
	return &cpy
}
1252791
func (a *API) AddImport(v string) error {
	a.imports[v] = true
	return nil
}
670982
func (v *volumeSource) ImportVolume(ctx context.ProviderCallContext, volName string, tags map[string]string) (storage.VolumeInfo, error) {
	zone, _, err := parseVolumeId(volName)
	if err != nil {
		return storage.VolumeInfo{}, errors.Annotatef(err, "cannot get volume %q", volName)
	}
	disk, err := v.gce.Disk(zone, volName)
	if err != nil {
		return storage.VolumeInfo{}, google.HandleCredentialError(errors.Annotatef(err, "cannot get volume %q", volName), ctx)
	}
	if disk.Status != google.StatusReady {
		return storage.VolumeInfo{}, errors.Errorf(
			"cannot import volume %q with status %q",
			volName, disk.Status,
		)
	}
	if disk.Labels == nil {
		disk.Labels = make(map[string]string)
	}
	for k, v := range resourceTagsToDiskLabels(tags) {
		disk.Labels[k] = v
	}
	if err := v.gce.SetDiskLabels(zone, volName, disk.LabelFingerprint, disk.Labels); err != nil {
		return storage.VolumeInfo{}, google.HandleCredentialError(errors.Annotatef(err, "cannot update labels on volume %q", volName), ctx)
	}
	return storage.VolumeInfo{
		VolumeId:   disk.Name,
		Size:       disk.Size,
		Persistent: true,
	}, nil
}
626992
func (engine *Engine) ImportFile(ddlPath string) ([]sql.Result, error) {
	file, err := os.Open(ddlPath)
	if err != nil {
		return nil, err
	}
	defer file.Close()
	return engine.Import(file)
}
675108
func Init(params map[string]string) (volume.VolumeDriver, error) {
	url, ok := params[config.UrlKey]
	if !ok {
		url = DefaultUrl
	}
	version, ok := params[config.VersionKey]
	if !ok {
		version = volume.APIVersion
	}
	c, err := client.NewClient(url, version, "")
	if err != nil {
		return nil, err
	}

	return &driver{VolumeDriver: volumeclient.VolumeDriver(c)}, nil
}
969024
func (f *file) imports(importPath string) bool {
	all := astutil.Imports(f.fset, f.f)
	for _, p := range all {
		for _, i := range p {
			uq, err := strconv.Unquote(i.Path.Value)
			if err == nil && importPath == uq {
				return true
			}
		}
	}
	return false
}
1108814
func (i *Imports) Add(alias string, path string) Import {
	path = imports.VendorlessPath(strings.TrimSpace(path))
	alias = strings.TrimSpace(alias)

	imp, exists := i.ByPkgPath[path]
	if exists {
		return imp
	}

	_, exists = i.ByAlias[alias]
	if exists {
		alias = uniqueAliasForImport(alias, i.ByAlias)
	}

	result := Import{Alias: alias, PkgPath: path}
	i.ByPkgPath[path] = result
	i.ByAlias[alias] = result
	return result
}
1076070
func (a *StorageAPI) Import(args params.BulkImportStorageParams) (params.ImportStorageResults, error) {
	if err := a.checkCanWrite(); err != nil {
		return params.ImportStorageResults{}, errors.Trace(err)
	}

	blockChecker := common.NewBlockChecker(a.backend)
	if err := blockChecker.ChangeAllowed(); err != nil {
		return params.ImportStorageResults{}, errors.Trace(err)
	}

	results := make([]params.ImportStorageResult, len(args.Storage))
	for i, arg := range args.Storage {
		details, err := a.importStorage(arg)
		if err != nil {
			results[i].Error = common.ServerError(err)
			continue
		}
		results[i].Result = details
	}
	return params.ImportStorageResults{Results: results}, nil
}
3843
func (dir *Directory) Import(ctx *build.Context, mode build.ImportMode) (*build.Package, error) {
	safeCopy := *ctx
	ctx = &safeCopy
	ctx.JoinPath = path.Join
	ctx.IsAbsPath = path.IsAbs
	ctx.SplitPathList = func(list string) []string { return strings.Split(list, ":") }
	ctx.IsDir = func(path string) bool { return path == "." }
	ctx.HasSubdir = func(root, dir string) (rel string, ok bool) { return "", false }
	ctx.ReadDir = dir.readDir
	ctx.OpenFile = dir.openFile
	return ctx.ImportDir(".", mode)
}
199180
func Imports(p []string) func(r *Rego) {
	return func(r *Rego) {
		r.imports = append(r.imports, p...)
	}
}
587727
func (c *Client) Import(bytes []byte) error {
	serialized := params.SerializedModel{Bytes: bytes}
	return c.caller.FacadeCall("Import", serialized, nil)
}