<commit_before>package daemon

import (
	"encoding/json"
	"fmt"
	"net/http"
	"strconv"

	"github.com/rancher/convoy/api"
	. "github.com/rancher/convoy/convoydriver"
	"github.com/rancher/convoy/util"
)

type pluginInfo struct {
	Implements []string
}

type pluginResponse struct {
	Mountpoint string          `json:",omitempty"`
	Err        string          `json:",omitempty"`
	Volumes    []*DockerVolume `json:",omitempty"`
	Volume     *DockerVolume   `json:",omitempty"`
}

type DockerVolume struct {
	Name       string `json:",omitempty"`
	Mountpoint string `json:",omitempty"`
}

type pluginRequest struct {
	Name string
	Opts map[string]string
}

func (s *daemon) dockerActivate(w http.ResponseWriter, r *http.Request) {
	log.Debugf("Handle plugin activate: %v %v", r.Method, r.RequestURI)
	info := pluginInfo{
		Implements: []string{"VolumeDriver"},
	}
	writeResponseOutput(w, info)
}

func convertToPluginRequest(r *http.Request) (*pluginRequest, error) {
	request := &pluginRequest{}
	if err := json.NewDecoder(r.Body).Decode(request); err != nil {
		return nil, err
	}
	log.Debugf("Request from docker: %v", request)
	return request, nil
}

func (s *daemon) createDockerVolume(request *pluginRequest) (*Volume, error) {
	name := request.Name
	log.Debugf("Create a new volume %v for docker", name)

	if !util.ValidateName(name) {
		return nil, fmt.Errorf("Invalid volume %s. Must be only contains 0-9, a-z, dash(-), underscore(_) and dot(.)", name)
	}

	size, err := util.ParseSize(request.Opts["size"])
	if err != nil {<commit_msg>Correct gramar in validation message<commit_after>package daemon

import (
	"encoding/json"
	"fmt"
	"net/http"
	"strconv"

	"github.com/rancher/convoy/api"
	. "github.com/rancher/convoy/convoydriver"
	"github.com/rancher/convoy/util"
)

type pluginInfo struct {
	Implements []string
}

type pluginResponse struct {
	Mountpoint string          `json:",omitempty"`
	Err        string          `json:",omitempty"`
	Volumes    []*DockerVolume `json:",omitempty"`
	Volume     *DockerVolume   `json:",omitempty"`
}

type DockerVolume struct {
	Name       string `json:",omitempty"`
	Mountpoint string `json:",omitempty"`
}

type pluginRequest struct {
	Name string
	Opts map[string]string
}

func (s *daemon) dockerActivate(w http.ResponseWriter, r *http.Request) {
	log.Debugf("Handle plugin activate: %v %v", r.Method, r.RequestURI)
	info := pluginInfo{
		Implements: []string{"VolumeDriver"},
	}
	writeResponseOutput(w, info)
}

func convertToPluginRequest(r *http.Request) (*pluginRequest, error) {
	request := &pluginRequest{}
	if err := json.NewDecoder(r.Body).Decode(request); err != nil {
		return nil, err
	}
	log.Debugf("Request from docker: %v", request)
	return request, nil
}

func (s *daemon) createDockerVolume(request *pluginRequest) (*Volume, error) {
	name := request.Name
	log.Debugf("Create a new volume %v for docker", name)

	if !util.ValidateName(name) {
		return nil, fmt.Errorf("Invalid volume name %s. Can only contain 0-9, a-z, dash(-), underscore(_) and dot(.)", name)
	}

	size, err := util.ParseSize(request.Opts["size"])
	if err != nil {
{'fraction_non_alphanumeric': 0.14575943244114803, 'fraction_numerical': 0.0012899064817800709, 'mean_word_length': 4.451669595782074, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6047840', 'n_tokens_mistral': 1059, 'n_tokens_neox': 1041, 'n_words': 264}