<commit_before>package volumeapi

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

const (
	defaultDockerRootDirectory    = "/var/lib/docker/volumes"
	defaultContentTypeV1          = "appplication/vnd.docker.plugins.v1+json"
	defaultImplementationManifest = `{"Implements": ["VolumeDriver"]}`
)

type VolumeRequest struct {
	Root string `json:",omitempty"`
	Name string
}

type VolumeResponse struct {
	Mountpoint string
	Err        error
}

type VolumeDriver interface {
	Create(VolumeRequest) VolumeResponse
	Remove(VolumeRequest) VolumeResponse
	Path(VolumeRequest) VolumeResponse
	Mount(VolumeRequest) VolumeResponse
	Umount(VolumeRequest) VolumeResponse
}

type VolumeHandler struct {
	rootDirectory string
	handler       VolumeDriver
	mux           *http.ServeMux
}

type actionHandler func(VolumeRequest) VolumeResponse

func NewVolumeHandler(handler VolumeDriver) *VolumeHandler {
	return NewVolumeHandlerWithRoot(defaultDockerRootDirectory, handler)
}

func NewVolumeHandlerWithRoot(rootDirectory string, handler VolumeDriver) *VolumeHandler {
	h := &VolumeHandler{rootDirectory, handler, http.NewServeMux()}
	h.initMux()
	return h
}

func (h *VolumeHandler) initMux() {
	h.mux.HandleFunc("/Plugin.Activate", func(w http.ResponseWriter, r *http.Request) {
		w.Header().Set("Content-Type", defaultContentTypeV1)
		fmt.Fprintln(w, defaultImplementationManifest)
	})

	h.handle("/VolumeDriver.Create", func(req VolumeRequest) VolumeResponse {
		return h.handler.Create(req)
	})

	h.handle("/VolumeDriver.Remove", func(req VolumeRequest) VolumeResponse {
		return h.handler.Remove(req)
	})<commit_msg>Make the default volumes directory public.<commit_after>package volumeapi

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

const (
	DefaultDockerRootDirectory    = "/var/lib/docker/volumes"
	defaultContentTypeV1          = "appplication/vnd.docker.plugins.v1+json"
	defaultImplementationManifest = `{"Implements": ["VolumeDriver"]}`
)

type VolumeRequest struct {
	Root string `json:",omitempty"`
	Name string
}

type VolumeResponse struct {
	Mountpoint string
	Err        error
}

type VolumeDriver interface {
	Create(VolumeRequest) VolumeResponse
	Remove(VolumeRequest) VolumeResponse
	Path(VolumeRequest) VolumeResponse
	Mount(VolumeRequest) VolumeResponse
	Umount(VolumeRequest) VolumeResponse
}

type VolumeHandler struct {
	rootDirectory string
	handler       VolumeDriver
	mux           *http.ServeMux
}

type actionHandler func(VolumeRequest) VolumeResponse

func NewVolumeHandler(handler VolumeDriver) *VolumeHandler {
	return NewVolumeHandlerWithRoot(DefaultDockerRootDirectory, handler)
}

func NewVolumeHandlerWithRoot(rootDirectory string, handler VolumeDriver) *VolumeHandler {
	h := &VolumeHandler{rootDirectory, handler, http.NewServeMux()}
	h.initMux()
	return h
}

func (h *VolumeHandler) initMux() {
	h.mux.HandleFunc("/Plugin.Activate", func(w http.ResponseWriter, r *http.Request) {
		w.Header().Set("Content-Type", defaultContentTypeV1)
		fmt.Fprintln(w, defaultImplementationManifest)
	})

	h.handle("/VolumeDriver.Create", func(req VolumeRequest) VolumeResponse {
		return h.handler.Create(req)
	})

	h.handle("/VolumeDriver.Remove", func(req VolumeRequest) VolumeResponse {
		return h.handler.Remove(req)
	})
{'fraction_non_alphanumeric': 0.10359667998770365, 'fraction_numerical': 0.0018444512757454657, 'mean_word_length': 5.573737373737374, 'pattern_counts': {'":': 2, '<': 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': '1471148', 'n_tokens_mistral': 988, 'n_tokens_neox': 977, 'n_words': 207}