func (p *Provisioner) Prepare(ctx context.Context, localPath string) error {
	log := p.Log.With().Str("local-path", localPath).Logger()
	log.Debug().Msg("preparing local path")
	if err := os.RemoveAll(localPath); err != nil && !os.IsNotExist(err) {
		log.Error().Err(err).Msg("Failed to clean existing directory")
		return errors.WithStack(err)
	}
	if err := os.MkdirAll(localPath, 0755); err != nil {
		log.Error().Err(err).Msg("Failed to make directory")
		return errors.WithStack(err)
	}
	if err := os.Chmod(localPath, 0777); err != nil {
		log.Error().Err(err).Msg("Failed to set directory access")
		return errors.WithStack(err)
	}
	return nil
}
Prepare a volume at the given local path
package service
import (
	"context"
	"os"
	"github.com/arangodb/kube-arangodb/pkg/util/errors"
	"github.com/rs/zerolog"
	"golang.org/x/sys/unix"
	"github.com/arangodb/kube-arangodb/pkg/storage/provisioner"
)
type Config struct {
	Address  string  
	NodeName string  
}
type Dependencies struct {
	Log zerolog.Logger
}
type Provisioner struct {
	Config
	Dependencies
}
func New(config Config, deps Dependencies) (*Provisioner, error) {
	return &Provisioner{
		Config:       config,
		Dependencies: deps,
	}, nil
}
func (p *Provisioner) Run(ctx context.Context) {
	runServer(ctx, p.Log, p.Address, p)
}
func (p *Provisioner) GetNodeInfo(ctx context.Context) (provisioner.NodeInfo, error) {
	return provisioner.NodeInfo{
		NodeName: p.NodeName,
	}, nil
}
func (p *Provisioner) GetInfo(ctx context.Context, localPath string) (provisioner.Info, error) {
	log := p.Log.With().Str("local-path", localPath).Logger()
	log.Debug().Msg("gettting info for local path")
	statfs := &unix.Statfs_t{}
	if err := unix.Statfs(localPath, statfs); err != nil {
		log.Error().Err(err).Msg("Statfs failed")
		return provisioner.Info{}, errors.WithStack(err)
	}
	available := int64(statfs.Bavail) * statfs.Bsize
	capacity := int64(statfs.Blocks) * statfs.Bsize
	log.Debug().
		Str("node-name", p.NodeName).
		Int64("capacity", capacity).
		Int64("available", available).
		Msg("Returning info for local path")
	return provisioner.Info{
		NodeInfo: provisioner.NodeInfo{
			NodeName: p.NodeName,
		},
		Available: available,
		Capacity:  capacity,
	}, nil
}