<commit_before>package main

import (
	"fmt"
	"os"
	"path/filepath"
	"strings"

	"go.pedge.io/dockervolume"
	"go.pedge.io/env"
	"go.pedge.io/protolog/logrus"

	"github.com/pachyderm/pachyderm/src/pfs/fuse"
	"github.com/satori/go.uuid"
)

const (
	defaultShard   = 0
	defaultModulus = 1
)

var (
	defaultEnv = map[string]string{
		"PFS_ADDRESS":        "0.0.0.0:650",
		"BASE_MOUNTPOINT":    "/tmp/pfs-volume-driver",
		"GRPC_PORT":          "2150",
		"HTTP_PORT":          "1950",
		"VOLUME_DRIVER_NAME": "pfs",
	}
)

type appEnv struct {
	PachydermPfsd1Port string `env:"PACHYDERM_PFSD_1_PORT"`
	PfsAddress         string `env:"PFS_ADDRESS"`
	BaseMountpoint     string `env:"BASE_MOUNTPOINT"`
	GRPCPort           int    `env:"GRPC_PORT"`
	HTTPPort           int    `env:"HTTP_PORT"`
	VolumeDriverName   string `env:"VOLUME_DRIVER_NAME"`
}

func main() {
	logrus.Register()
	env.Main(do, &appEnv{}, defaultEnv)
}

func do(appEnvObj interface{}) error {
	return newServer(appEnvObj.(*appEnv)).Serve()
}

func newServer(appEnv *appEnv) dockervolume.Server {
	return dockervolume.NewTCPServer(
		newVolumeDriver(
			fuse.NewMounterProvider(getPFSAddress(appEnv)),
			appEnv.BaseMountpoint,
		),
		appEnv.VolumeDriverName,
		fmt.Sprintf(":%d", appEnv.HTTPPort),
		dockervolume.ServerOptions{
			GRPCPort: uint16(appEnv.GRPCPort),
		},
	)
}

func getPFSAddress(appEnv *appEnv) string {
	address := appEnv.PachydermPfsd1Port
	if address == "" {
		return appEnv.PfsAddress
	}

	return strings.Replace(address, "tcp://", "", -1)
}

type volumeDriver struct {
	mounterProvider fuse.MounterProvider
	baseMountpoint  string
}

func newVolumeDriver(
	mounterProvider fuse.MounterProvider,
	baseMountpoint string,
) *volumeDriver {<commit_msg>Revert "lint pfs-volume-driver"<commit_after>package main

import (
	"fmt"
	"os"
	"path/filepath"
	"strings"

	"go.pedge.io/dockervolume"
	"go.pedge.io/env"
	"go.pedge.io/protolog/logrus"

	"github.com/pachyderm/pachyderm/src/pfs/fuse"
	"github.com/satori/go.uuid"
)

const (
	defaultShard   = 0
	defaultModulus = 1
)

var (
	defaultEnv = map[string]string{
		"PFS_ADDRESS":        "0.0.0.0:650",
		"BASE_MOUNTPOINT":    "/tmp/pfs-volume-driver",
		"GRPC_PORT":          "2150",
		"HTTP_PORT":          "1950",
		"VOLUME_DRIVER_NAME": "pfs",
	}
)

type appEnv struct {
	PachydermPfsd1Port string `env:"PACHYDERM_PFSD_1_PORT"`
	PfsAddress         string `env:"PFS_ADDRESS"`
	BaseMountpoint     string `env:"BASE_MOUNTPOINT"`
	GRPCPort           int    `env:"GRPC_PORT"`
	HTTPPort           int    `env:"HTTP_PORT"`
	VolumeDriverName   string `env:"VOLUME_DRIVER_NAME"`
}

func main() {
	logrus.Register()
	env.Main(do, &appEnv{}, defaultEnv)
}

func do(appEnvObj interface{}) error {
	return newServer(appEnvObj.(*appEnv)).Serve()
}

func newServer(appEnv *appEnv) dockervolume.Server {
	return dockervolume.NewTCPServer(
		newVolumeDriver(
			fuse.NewMounterProvider(getPFSAddress(appEnv)),
			appEnv.BaseMountpoint,
		),
		appEnv.VolumeDriverName,
		fmt.Sprintf(":%d", appEnv.HTTPPort),
		dockervolume.ServerOptions{
			GRPCPort: uint16(appEnv.GRPCPort),
		},
	)
}

func getPFSAddress(appEnv *appEnv) string {
	address := appEnv.PachydermPfsd1Port
	if address == "" {
		return appEnv.PfsAddress
	} else {
		return strings.Replace(address, "tcp://", "", -1)
	}
}

type volumeDriver struct {
	mounterProvider fuse.MounterProvider
	baseMountpoint  string
}

func newVolumeDriver(
	mounterProvider fuse.MounterProvider,
	baseMountpoint string,
) *volumeDriver {
{'fraction_non_alphanumeric': 0.13646788990825687, 'fraction_numerical': 0.013188073394495414, 'mean_word_length': 4.1233480176211454, 'pattern_counts': {'":': 12, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '3932001', 'n_tokens_mistral': 1445, 'n_tokens_neox': 1378, 'n_words': 215}