func (s *volumeStore) CreateVolumes(volumes []*volumetypes.Volume) error {
	for _, vol := range volumes {
		if err := s.store.Put(vol); err != nil {
			return fmt.Errorf("failed to create volume %s: %v", vol.Name, err)
		}
	}
	return nil
}
CreateVolumes put all volumes information to volume boltdb
package migrator
import (
	"fmt"
	"os"
	"path"
	"reflect"
	"strings"
	"github.com/pouchcontainer/d2p-migrator/docker"
	localtypes "github.com/pouchcontainer/d2p-migrator/pouch/types"
	"github.com/alibaba/pouch/pkg/meta"
	volumetypes "github.com/alibaba/pouch/storage/volume/types"
	dockertypes "github.com/docker/engine-api/types"
	"github.com/sirupsen/logrus"
)
func PrepareVolumes(homeDir string, volumes []*volumetypes.Volume, volumeRefs map[string]string) error {
	dockerCli, err := docker.NewDockerd()
	if err != nil {
		return err
	}
	store, err := newVolumeStore(path.Join(homeDir, "volume"))
	if err != nil {
		return err
	}
	defer store.Shutdown()
	for _, vol := range volumes {
		refs, ok := volumeRefs[vol.Name]
		if !ok || refs == "" {
			continue
		}
		vol.Spec.Extra["ref"] = refs
		if vol.Driver() == "alilocal" {
			volume, err := dockerCli.VolumeInspect(vol.Name)
			if err != nil {
				logrus.Errorf("failed to inspect volume %s: %v", vol.Name, err)
				continue
			}
			vol.Spec.Size = getVolumeSize(volume)
		}
	}
	return store.CreateVolumes(volumes)
}
type volumeStore struct {
	baseDir string
	store   *meta.Store
}
func newVolumeStore(baseDir string) (*volumeStore, error) {
	if _, err := os.Stat(baseDir); err != nil && os.IsNotExist(err) {
		if err := os.MkdirAll(baseDir, 0666); err != nil {
			return nil, fmt.Errorf("failed to prepare volume store dir %s: %v", baseDir, err)
		}
	}
	boltdbCfg := meta.Config{
		Driver:  "boltdb",
		BaseDir: path.Join(baseDir, "volume.db"),
		Buckets: []meta.Bucket{
			{
				Name: "volume",
				Type: reflect.TypeOf(volumetypes.Volume{}),
			},
		},
	}
	boltStore, err := meta.NewStore(boltdbCfg)
	if err != nil {
		return nil, fmt.Errorf("failed to initialize a new boltdb store: %v", err)
	}
	return &volumeStore{baseDir: baseDir, store: boltStore}, nil
}