package config

import (
	"github.com/asdine/storm"
	"github.com/deranjer/gvc/common"
)

// GvcServerConfig will hold the base server settings
type GvcServerConfig struct {
	LogFile          string       `toml:"logfile"`          // Where to store the echo logs
	LogLevel         int          `toml:"loglevel"`         // Panic: 5, Fatal: 4, Error: 3, Warn: 2, Info: 1, debug: 0, trace: -1
	DatabaseLocation string       `toml:"databaselocation"` // Location of the database
	Database         *storm.DB    // DB Handle for passing around
	Version          string       `toml:"version"`      // The server version
	Port             int          `toml:"port"`         // The port that the server will listed on
	BindIP           string       `toml:"ip"`           // What IP to bind the server to.  If empty will bind to all interfaces
	RawPort          int          `toml:"rawport"`      // The optional TCP port that the server will send raw files over
	RepoRootPath     string       `toml:"reporootpath"` // This will be the root path where (by default) all new repos will be stored at
	Repos            []RepoConfig `toml:"repo"`         // A struct of all the repos and their settings for the serve
}

// RepoConfig will be the struct that holds the config for a single repo
type RepoConfig struct {
	KnownClients   []Clients        `toml:"client"`   //The remote servers for the repo
	RootPath       string           `toml:"rootpath"` // The absolute path to the root of this particular repo
	RepoName       string           `toml:"reponame"`
	DefaultBranch  string           `toml:"defaultbranch"`
	LocalBranches  []string         `toml:"localbranches"` // LocalBranches constains a string list of branches on the server.  Names must be unique. \\TODO: someday add folders like git for branches
	Locked         common.FileTypes `toml:"locked"`
	DefaultIgnores common.FileTypes `toml:"defaultignore"` //These are the recommended ignores that clients can pull
	NoCompress     common.FileTypes `toml:"nocompress"`    //For binary compression some files should be ignored because the performance hit isn't worth the size savings
}

//Clients will be a slice of clients that have authenticated to the server
type Clients struct {
	Name       string `toml:"name"`
	Key        string `toml:"key"`        //TODO will change this once we figure out authentication
	LastCommit string `toml:"lastcommit"` //Last commit that this client pushed to the server? not sure if useful
}
