moving a function and struct over to a common library, starting on lockfile for server
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package engine
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"github.com/labstack/echo"
|
||||
@@ -18,16 +19,26 @@ func (Server *GVCServer) GetInfo(context echo.Context) error {
|
||||
repoInfo.RawPort = config.RawPort
|
||||
repoInfo.Version = config.Version
|
||||
repoInfo.Repo = knownRepo
|
||||
clients := repoInfo.Repo.KnownClients
|
||||
for _, client := range clients { // Blank out the client keys
|
||||
client.Key = ""
|
||||
for i := range repoInfo.Repo.KnownClients { // Blank out the client keys
|
||||
repoInfo.Repo.KnownClients[i].Key = "REDACTED"
|
||||
}
|
||||
repoInfo.Repo.KnownClients = clients
|
||||
}
|
||||
}
|
||||
return context.JSONPretty(http.StatusAccepted, repoInfo, " ")
|
||||
}
|
||||
|
||||
// LockFile just locks the file/folder/wildcard
|
||||
func (Server *GVCServer) LockFile(context echo.Context) error {
|
||||
fileType := context.Param("type")
|
||||
fileName := context.Param("name")
|
||||
switch fileType {
|
||||
case "file":
|
||||
//common.CheckFileTypes(fileName, fileType,)
|
||||
fmt.Println("Filename: ", fileName)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Hello just verifies the server is running //TODO remove this, just extra shit we are sending
|
||||
func (Server *GVCServer) Hello(context echo.Context) error {
|
||||
helloMsg := "server alive"
|
||||
|
@@ -50,5 +50,6 @@ func main() {
|
||||
//Start the routes
|
||||
//e.GET("/hello", server.Hello)
|
||||
e.GET("/info/:repoName", server.GetInfo)
|
||||
e.GET("/lock/:type/:name", server.LockFile)
|
||||
e.Logger.Fatal(e.Start(fmt.Sprintf("%s:%d", server.Config.BindIP, server.Config.Port)))
|
||||
}
|
||||
|
@@ -9,6 +9,20 @@ reporootpath = "F:\\repos"
|
||||
reponame = "gvc"
|
||||
defaultbranch = "master"
|
||||
localbranches = ["master"]
|
||||
|
||||
[[repo.client]]
|
||||
name = "deranjer"
|
||||
key = "12345"
|
||||
lastcommit = "4343434343434"
|
||||
[repo.locked]
|
||||
[repo.defaultignore]
|
||||
[repo.nocompress]
|
||||
|
||||
[[repo]]
|
||||
rootpath = ""
|
||||
reponame = "testrepo"
|
||||
defaultbranch = "master"
|
||||
localbranches = ["master", "feature1"]
|
||||
[repo.locked]
|
||||
[repo.defaultignore]
|
||||
[repo.nocompress]
|
||||
|
@@ -1,5 +1,7 @@
|
||||
package config
|
||||
|
||||
import "github.com/deranjer/gvc/common"
|
||||
|
||||
// GvcServerConfig will hold the base server settings
|
||||
type GvcServerConfig struct {
|
||||
Version string `toml:"version"` // The server version
|
||||
@@ -12,14 +14,14 @@ type GvcServerConfig struct {
|
||||
|
||||
// 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 FileTypes `toml:"locked"`
|
||||
DefaultIgnores FileTypes `toml:"defaultignore"` //These are the recommended ignores that clients can pull
|
||||
NoCompress FileTypes `toml:"nocompress"` //For binary compression some files should be ignored because the performance hit isn't worth the size savings
|
||||
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
|
||||
@@ -28,10 +30,3 @@ type Clients struct {
|
||||
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
|
||||
}
|
||||
|
||||
//FileTypes is for ignoring files to add or ignoring compress, or for locked files, all use the same type of struct (files, folders and exts)
|
||||
type FileTypes struct {
|
||||
Files []string `toml:"files"`
|
||||
Exts []string `toml:"exts"`
|
||||
Folders []string `toml:"folders"`
|
||||
}
|
||||
|
Reference in New Issue
Block a user