func (d *D2pMigrator) initPouchEnv() error {
	pouchHomeDir := getPouchHomeDir(d.config.DockerHomeDir)
	if err := prepareConfigForPouch(pouchHomeDir); err != nil {
		return fmt.Errorf("failed to prepare config for pouch: %v", err)
	}
	return nil
}
initPouchEnv initialize environment for pouch,
it will be called in PreMigrate.
package migrator
import (
	"context"
	"fmt"
	"github.com/pouchcontainer/d2p-migrator/ctrd"
	"github.com/pouchcontainer/d2p-migrator/docker"
	"github.com/pouchcontainer/d2p-migrator/hookplugins"
	"github.com/sirupsen/logrus"
)
var (
	DefaultDockerRpmName = "docker"
	DefaultPouchRpmPath = "pouch"
)
type Config struct {
	Type string
	DockerRpmName string
	PouchRpmPath string
	DockerHomeDir string
	ImageManifestOnly bool
	ContainerPlugin hookplugins.ContainerPlugin
}
type D2pMigrator struct {
	config          Config
	migrator        Migrator
	dockerCli       *docker.Dockerd
	ctrdCli         *ctrd.Client
	ctrdPid         int
	containerPlugin hookplugins.ContainerPlugin
}
func NewD2pMigrator(cfg Config) (*D2pMigrator, error) {
	if cfg.Type == "" {
		return nil, fmt.Errorf("must specify migrator type")
	}
	if cfg.DockerRpmName == "" {
		cfg.DockerRpmName = DefaultDockerRpmName
	}
	if cfg.PouchRpmPath == "" {
		cfg.PouchRpmPath = DefaultPouchRpmPath
	}
	if _, ok := migratorFactory[cfg.Type]; !ok {
		return nil, fmt.Errorf("migrator type %s not found", cfg.Type)
	}
	dockerCli, err := docker.NewDockerd()
	if err != nil {
		return nil, fmt.Errorf("failed to create docker client: %v", err)
	}
	info, err := dockerCli.Info()
	if err != nil {
		return nil, fmt.Errorf("failed to get docker info: %v", err)
	}
	if err := validateDocker(info); err != nil {
		return nil, err
	}
	cfg.DockerHomeDir = info.DockerRootDir
	ctrdPid, err := ctrd.StartContainerd(getPouchHomeDir(cfg.DockerHomeDir), true)
	if err != nil {
		return nil, fmt.Errorf("failed to start containerd instance: %v", err)
	}
	ctrdCli, err := ctrd.NewCtrdClient()
	if err != nil {
		return nil, fmt.Errorf("failed to get containerd client: %v", err)
	}
	d2pMigrator := &D2pMigrator{
		config:    cfg,
		dockerCli: dockerCli,
		ctrdPid:   ctrdPid,
		ctrdCli:   ctrdCli,
	}
	if err := d2pMigrator.loadPlugin(); err != nil {
		return nil, fmt.Errorf("failed to load plugins: %v", err)
	}
	cfg.ContainerPlugin = d2pMigrator.containerPlugin
	migrator, err := migratorFactory[cfg.Type](cfg)
	if err != nil {
		return nil, fmt.Errorf("failed to create migrator: %v", err)
	}
	d2pMigrator.migrator = migrator
	return d2pMigrator, nil
}
func (d *D2pMigrator) loadPlugin() error {
	var err error
	if containerPlugin := hookplugins.GetContainerPlugin(); containerPlugin != nil {
		d.containerPlugin = containerPlugin
	}
	return err
}