added server logging to file, added logging and formatting to info and lock commands

This commit is contained in:
2020-06-09 23:22:07 -04:00
parent 441a9ed233
commit 161843f4c8
15 changed files with 126 additions and 66 deletions

View File

@@ -469,6 +469,11 @@ func lockCommands(cli *clir.Cli, conf *clientconfig.Gvcconfig) {
//fmt.Println("Ignoring file: ", file) //fmt.Println("Ignoring file: ", file)
err := clientcmd.LockFiles(file, "file", conf) err := clientcmd.LockFiles(file, "file", conf)
if err != nil { if err != nil {
fmt.Println("error occurred locking file, attempting to roll back changes...")
err := clientcmd.RemoveLockFiles(file, "file", conf)
if err != nil {
return fmt.Errorf("fatal error: unable to roll back lock file changes, issue with config: %s", err)
}
return err return err
} }
return nil return nil
@@ -477,6 +482,10 @@ func lockCommands(cli *clir.Cli, conf *clientconfig.Gvcconfig) {
fmt.Println("Ignoring contents of folder: ", folder) fmt.Println("Ignoring contents of folder: ", folder)
err := clientcmd.LockFiles(folder, "folder", conf) err := clientcmd.LockFiles(folder, "folder", conf)
if err != nil { if err != nil {
err := clientcmd.RemoveLockFiles(folder, "folder", conf)
if err != nil {
return fmt.Errorf("fatal error: unable to roll back lock folder changes, issue with config: %s", err)
}
return err return err
} }
return nil return nil
@@ -485,6 +494,10 @@ func lockCommands(cli *clir.Cli, conf *clientconfig.Gvcconfig) {
fmt.Println("Ignoring files with wildcard filter: ", wildcard) fmt.Println("Ignoring files with wildcard filter: ", wildcard)
err := clientcmd.LockFiles(wildcard, "wildcard", conf) err := clientcmd.LockFiles(wildcard, "wildcard", conf)
if err != nil { if err != nil {
err := clientcmd.RemoveLockFiles(wildcard, "wildcard", conf)
if err != nil {
return fmt.Errorf("fatal error: unable to roll back lock wildcard changes, issue with config: %s", err)
}
return err return err
} }
return nil return nil

View File

@@ -19,7 +19,7 @@ func GetServerInfo(connectionString string, repoName string) error {
} }
if resp.IsError() { if resp.IsError() {
if resp.StatusCode() == 404 { if resp.StatusCode() == 404 {
return fmt.Errorf("error: repo was not found on server, 404: %s", resp.Request.URL) return fmt.Errorf("repo was not found on server, 404: %s", resp.Request.URL)
} }
return fmt.Errorf("response not a success: %d: connection URL: %s", resp.StatusCode(), resp.Request.URL) return fmt.Errorf("response not a success: %d: connection URL: %s", resp.StatusCode(), resp.Request.URL)
} }

View File

@@ -36,6 +36,10 @@ func LockFiles(input string, inputType string, conf *clientconfig.Gvcconfig) err
} }
fmt.Println("Adding folder to locked: ", input) fmt.Println("Adding folder to locked: ", input)
conf.Locked.Folders = append(conf.Locked.Folders, input) conf.Locked.Folders = append(conf.Locked.Folders, input)
err = SendLockToServer(connectionString, conf.RepoName, "folder", input)
if err != nil {
return fmt.Errorf("error sending lock to server: %s", err)
}
return nil return nil
case "wildcard": case "wildcard":
var wildcard string var wildcard string
@@ -50,6 +54,10 @@ func LockFiles(input string, inputType string, conf *clientconfig.Gvcconfig) err
} }
fmt.Println("Adding wildcard to locked: ", wildcard) fmt.Println("Adding wildcard to locked: ", wildcard)
conf.Locked.Exts = append(conf.Locked.Exts, wildcard) conf.Locked.Exts = append(conf.Locked.Exts, wildcard)
err = SendLockToServer(connectionString, conf.RepoName, "wildcard", input)
if err != nil {
return fmt.Errorf("error sending lock to server: %s", err)
}
return nil return nil
} }
return fmt.Errorf("This... should not have happened, some kind of internal error on LockFiles function call, switch failure") return fmt.Errorf("This... should not have happened, some kind of internal error on LockFiles function call, switch failure")
@@ -133,7 +141,7 @@ func SendLockToServer(connectionString string, repoName string, fileType string,
if resp.StatusCode() == 404 { if resp.StatusCode() == 404 {
return fmt.Errorf("error: repo was not found on server, 404: %s", resp.Request.URL) return fmt.Errorf("error: repo was not found on server, 404: %s", resp.Request.URL)
} }
return fmt.Errorf("response not a success: %d: connection URL: %s", resp.StatusCode(), resp.Request.URL) return fmt.Errorf("%s: response code: %d: %s", resp.Request.URL, resp.StatusCode(), resp)
} }
fmt.Println(resp) fmt.Println(resp)
return nil return nil

View File

@@ -4,12 +4,14 @@ import (
"fmt" "fmt"
clientconfig "github.com/deranjer/gvc/client/clientconfig" clientconfig "github.com/deranjer/gvc/client/clientconfig"
"github.com/deranjer/gvc/common"
"github.com/go-resty/resty/v2" "github.com/go-resty/resty/v2"
) )
// RefreshContent gets all the new file locks and updated pulls from the server (like git fetch) // RefreshContent gets all the new file locks and updated pulls from the server (like git fetch)
func RefreshContent(conf *clientconfig.Gvcconfig, repoName string) error { //TODO: need to change command to be able to target user specified servers func RefreshContent(conf *clientconfig.Gvcconfig, repoName string) error { //TODO: need to change command to be able to target user specified servers
connectionString, err := FindServer("", conf.CurrentBranch, conf) connectionString, err := FindServer("", conf.CurrentBranch, conf)
var refreshResult common.RepoRefreshRequest
if err != nil { if err != nil {
return err return err
} }
@@ -18,16 +20,18 @@ func RefreshContent(conf *clientconfig.Gvcconfig, repoName string) error { //TOD
SetPathParams(map[string]string{ SetPathParams(map[string]string{
"repoName": repoName, "repoName": repoName,
}). }).
Get(connectionString + "/refresh" + "{repoName}") //creating the full string to get info SetResult(&refreshResult). // Automatically unmarshal the JSON response to our struct
Get(connectionString + "/refresh/" + "{repoName}") //creating the full string to get info
if err != nil { if err != nil {
return fmt.Errorf("error connecting to server at: %s: error was: %s", connectionString, err) return fmt.Errorf("error connecting to server at: %s: error was: %s", connectionString, err)
} }
if resp.IsError() { if resp.IsError() {
if resp.StatusCode() == 404 { if resp.StatusCode() == 404 {
return fmt.Errorf("error: repo was not found on server, 404: %s", resp.Request.URL) return fmt.Errorf("error: repo %s was not found on server, 404: %s", repoName, resp.Request.URL)
} }
return fmt.Errorf("reponse not a success: %d: connection URL: %s", resp.StatusCode(), resp.Request.URL) return fmt.Errorf("response not a success: %d: connection URL: %s", resp.StatusCode(), resp.Request.URL)
} }
fmt.Println(resp) fmt.Println(resp)
fmt.Printf("%+v\n", refreshResult)
return nil return nil
} }

View File

@@ -2,23 +2,35 @@ package main
import ( import (
"fmt" "fmt"
"reflect"
"github.com/deranjer/clir" "github.com/imdario/mergo"
) )
func main() { type Foo struct {
Ignore []string
// Create new cli B int64
cli := clir.NewCli("Other Args", "A basic example", "v0.0.1") }
// Set long description func main() {
cli.LongDescription("This app shows positional arguments") src := Foo{
Ignore: []string{"one", "two", "three"},
name := cli.NewSubCommand("name", "Shows your name!") B: 2,
name.Action(func() error { }
fmt.Printf("The remaining arguments were: %+v\n", name.OtherArgs()) dest := Foo{
return nil Ignore: []string{"one", "two", "four", "seven"},
}) }
// Run!
cli.Run() mergo.Merge(&dest, src, mergo.WithTransformers())
fmt.Println(dest)
// Will print
// {two 2}
}
func MergeStrings(typ reflect.Type) func(dst, src reflect.Value) error {
if typ == reflect.TypeOf([]string{}) {
return func(dst, src reflect.Value) error {
}
}
} }

2
go.mod
View File

@@ -7,7 +7,9 @@ require (
github.com/deranjer/store v0.0.0-20200526205429-464dd59c6031 github.com/deranjer/store v0.0.0-20200526205429-464dd59c6031
github.com/firstrow/tcp_server v0.0.0-20190424084220-b7a05ff2879d github.com/firstrow/tcp_server v0.0.0-20190424084220-b7a05ff2879d
github.com/go-resty/resty/v2 v2.3.0 github.com/go-resty/resty/v2 v2.3.0
github.com/imdario/mergo v0.3.9 // indirect
github.com/labstack/echo v3.3.10+incompatible github.com/labstack/echo v3.3.10+incompatible
github.com/labstack/echo/v4 v4.1.16 // indirect github.com/labstack/echo/v4 v4.1.16 // indirect
github.com/smartystreets/goconvey v1.6.4 // indirect github.com/smartystreets/goconvey v1.6.4 // indirect
github.com/ziflex/lecho/v2 v2.0.0 // indirect
) )

17
go.sum
View File

@@ -1,10 +1,12 @@
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/deranjer/clir v1.0.5 h1:tEunZj5qJLYNBtzMQ/vH8hEAIv4NptWFmTldsP9U2qY= github.com/deranjer/clir v1.0.5 h1:tEunZj5qJLYNBtzMQ/vH8hEAIv4NptWFmTldsP9U2qY=
github.com/deranjer/clir v1.0.5/go.mod h1:x/FAjr5CHGsBT0yjs+NYxX3qFxx8G15gbeCcN6FFuyU= github.com/deranjer/clir v1.0.5/go.mod h1:x/FAjr5CHGsBT0yjs+NYxX3qFxx8G15gbeCcN6FFuyU=
github.com/deranjer/store v0.0.0-20200526205429-464dd59c6031 h1:sPjxPMNILoBbu6uhDfa97AhlUhTgtPY2HqySAzuLd4o= github.com/deranjer/store v0.0.0-20200526205429-464dd59c6031 h1:sPjxPMNILoBbu6uhDfa97AhlUhTgtPY2HqySAzuLd4o=
github.com/deranjer/store v0.0.0-20200526205429-464dd59c6031/go.mod h1:wPOs9IJ77lRTXyjEOQeegCFjIlm21qOFcv33lXmU7gE= github.com/deranjer/store v0.0.0-20200526205429-464dd59c6031/go.mod h1:wPOs9IJ77lRTXyjEOQeegCFjIlm21qOFcv33lXmU7gE=
github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM=
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
github.com/firstrow/tcp_server v0.0.0-20190424084220-b7a05ff2879d h1:3/oQzvZhwA8Jb5ykb0KehJfsdHokCJdC96k7xy6SJcs= github.com/firstrow/tcp_server v0.0.0-20190424084220-b7a05ff2879d h1:3/oQzvZhwA8Jb5ykb0KehJfsdHokCJdC96k7xy6SJcs=
github.com/firstrow/tcp_server v0.0.0-20190424084220-b7a05ff2879d/go.mod h1:hGkv6sO57ZC+XrSTyzdIGXX7+O6S3RJb9G8sPopEF/4= github.com/firstrow/tcp_server v0.0.0-20190424084220-b7a05ff2879d/go.mod h1:hGkv6sO57ZC+XrSTyzdIGXX7+O6S3RJb9G8sPopEF/4=
@@ -13,11 +15,14 @@ github.com/go-resty/resty/v2 v2.3.0 h1:JOOeAvjSlapTT92p8xiS19Zxev1neGikoHsXJeOq8
github.com/go-resty/resty/v2 v2.3.0/go.mod h1:UpN9CgLZNsv4e9XG50UU8xdI0F43UQ4HmxLBDwaroHU= github.com/go-resty/resty/v2 v2.3.0/go.mod h1:UpN9CgLZNsv4e9XG50UU8xdI0F43UQ4HmxLBDwaroHU=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/imdario/mergo v0.3.9 h1:UauaLniWCFHWd+Jp9oCEkTBj8VO/9DKg3PV3VCNMDIg=
github.com/imdario/mergo v0.3.9/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
github.com/labstack/echo v1.4.4 h1:1bEiBNeGSUKxcPDGfZ/7IgdhJJZx8wV/pICJh4W2NJI= github.com/labstack/echo v1.4.4 h1:1bEiBNeGSUKxcPDGfZ/7IgdhJJZx8wV/pICJh4W2NJI=
github.com/labstack/echo v3.3.10+incompatible h1:pGRcYk231ExFAyoAjAfD85kQzRJCRI8bbnE7CX5OEgg= github.com/labstack/echo v3.3.10+incompatible h1:pGRcYk231ExFAyoAjAfD85kQzRJCRI8bbnE7CX5OEgg=
github.com/labstack/echo v3.3.10+incompatible/go.mod h1:0INS7j/VjnFxD4E2wkz67b8cVwCLbBmJyDaka6Cmk1s= github.com/labstack/echo v3.3.10+incompatible/go.mod h1:0INS7j/VjnFxD4E2wkz67b8cVwCLbBmJyDaka6Cmk1s=
github.com/labstack/echo/v4 v4.1.10/go.mod h1:i541M3Fj6f76NZtHSj7TXnyM8n2gaodfvfxNnFqi74g=
github.com/labstack/echo/v4 v4.1.16 h1:8swiwjE5Jkai3RPfZoahp8kjVCRNq+y7Q0hPji2Kz0o= github.com/labstack/echo/v4 v4.1.16 h1:8swiwjE5Jkai3RPfZoahp8kjVCRNq+y7Q0hPji2Kz0o=
github.com/labstack/echo/v4 v4.1.16/go.mod h1:awO+5TzAjvL8XpibdsfXxPgHr+orhtXZJZIQCVjogKI= github.com/labstack/echo/v4 v4.1.16/go.mod h1:awO+5TzAjvL8XpibdsfXxPgHr+orhtXZJZIQCVjogKI=
github.com/labstack/gommon v0.3.0 h1:JEeO0bvc78PKdyHxloTKiF8BD5iGrH8T6MSeGvSgob0= github.com/labstack/gommon v0.3.0 h1:JEeO0bvc78PKdyHxloTKiF8BD5iGrH8T6MSeGvSgob0=
@@ -29,7 +34,11 @@ github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hd
github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2yME+cCiQ= github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2yME+cCiQ=
github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ=
github.com/rs/zerolog v1.15.0 h1:uPRuwkWF4J6fGsJ2R0Gn2jB1EQiav9k3S6CSdygQJXY=
github.com/rs/zerolog v1.15.0/go.mod h1:xYTKnLHcpfU2225ny5qZjxnj9NvkumZYjJHlAThCjNc=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s= github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s=
@@ -41,7 +50,12 @@ github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyC
github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8= github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8=
github.com/valyala/fasttemplate v1.1.0 h1:RZqt0yGBsps8NGvLSGW804QQqCUYYLsaOjTVHy1Ocw4= github.com/valyala/fasttemplate v1.1.0 h1:RZqt0yGBsps8NGvLSGW804QQqCUYYLsaOjTVHy1Ocw4=
github.com/valyala/fasttemplate v1.1.0/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8= github.com/valyala/fasttemplate v1.1.0/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8=
github.com/zenazn/goji v0.9.0/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxtB1Q=
github.com/ziflex/lecho v1.2.0 h1:/ykfd7V/aTsWUYNFimgbdhUiEMnWzvNaCxtbM/LX5F8=
github.com/ziflex/lecho/v2 v2.0.0 h1:ggrWF5LaGAC+Y+WX71jFK7uYR7cUFbHjIgGqCyrYC5Q=
github.com/ziflex/lecho/v2 v2.0.0/go.mod h1:s7dy9Fynjx6z+/7xE2BsK13vXIS3oQoo4ZaKXYG5xUs=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200221231518-2aa609cf4a9d h1:1ZiEyfaQIg3Qh0EoqpwAakHVhecoE5wlSg5GjnafJGw= golang.org/x/crypto v0.0.0-20200221231518-2aa609cf4a9d h1:1ZiEyfaQIg3Qh0EoqpwAakHVhecoE5wlSg5GjnafJGw=
golang.org/x/crypto v0.0.0-20200221231518-2aa609cf4a9d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200221231518-2aa609cf4a9d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
@@ -50,6 +64,7 @@ golang.org/x/net v0.0.0-20200226121028-0de0cce0169b h1:0mm1VjtFUOIlE1SbDlwjYaDxZ
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200513185701-a91f0712d120 h1:EZ3cVSzKOlJxAd8e8YAJ7no8nNypTxexh/YE/xW3ZEY= golang.org/x/net v0.0.0-20200513185701-a91f0712d120 h1:EZ3cVSzKOlJxAd8e8YAJ7no8nNypTxexh/YE/xW3ZEY=
golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@@ -57,12 +72,14 @@ golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae h1:/WDfKMnPU+m5M4xB+6x4kaepxRw6jWvR5iDRdvjHgy8= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae h1:/WDfKMnPU+m5M4xB+6x4kaepxRw6jWvR5iDRdvjHgy8=
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd h1:xhmwyvizuTgC2qz7ZlMluP20uW+C3Rm0FD/WLDX8884=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190425163242-31fd60d6bfdc/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=

View File

@@ -1,3 +1,4 @@
logfile = "gvclog.log"
version = "0.1" version = "0.1"
port = 80 port = 80
ip = "" ip = ""
@@ -15,7 +16,7 @@ reporootpath = "F:\\repos"
key = "12345" key = "12345"
lastcommit = "4343434343434" lastcommit = "4343434343434"
[repo.locked] [repo.locked]
files = ["client1.exe", "client2.exe"] files = ["client1.exe", "client2.exe", "client.go"]
[repo.defaultignore] [repo.defaultignore]
[repo.nocompress] [repo.nocompress]

View File

@@ -1,6 +0,0 @@
version = "0.1"
port = 80
ip = ""
rawport = 0
reporootpath = "F:\\repos"

View File

@@ -2,7 +2,6 @@ package engine
import ( import (
"fmt" "fmt"
"log"
"net/http" "net/http"
"github.com/deranjer/gvc/common" "github.com/deranjer/gvc/common"
@@ -28,6 +27,10 @@ func (Server *GVCServer) GetInfo(context echo.Context) error {
} }
} }
} }
if repoInfo.Repo.RepoName == "" {
return echo.NewHTTPError(http.StatusNotFound, "repo apparently not found")
}
Server.Echo.Logger.Infof("returning information about repo: %s", repo)
return context.JSONPretty(http.StatusAccepted, repoInfo, " ") return context.JSONPretty(http.StatusAccepted, repoInfo, " ")
} }
@@ -36,16 +39,18 @@ func (Server *GVCServer) LockFile(context echo.Context) error {
fileType := context.Param("type") fileType := context.Param("type")
fileName := context.Param("name") fileName := context.Param("name")
repoName := context.Param("repo") repoName := context.Param("repo")
fmt.Printf("Lockfile: %s %s %s", repoName, fileType, fileName) Server.Echo.Logger.Infof("Lockfile: %s %s %s", repoName, fileType, fileName)
var locked common.FileTypes var locked common.FileTypes
var index int
for i, repo := range Server.Config.Repos { for i, repo := range Server.Config.Repos {
if repo.RepoName == repoName { if repo.RepoName == repoName {
index = i
locked = Server.Config.Repos[i].Locked locked = Server.Config.Repos[i].Locked
} }
} }
err := common.CheckFileTypes(fileName, fileType, locked) // making sure fi/f/wc is not already locked or cannot be locked. err := common.CheckFileTypes(fileName, fileType, locked) // making sure fi/f/wc is not already locked or cannot be locked.
if err != nil { if err != nil {
return fmt.Errorf("failed checking file lock: %s", err) return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("failed checking file lock: %s", err))
} }
switch fileType { switch fileType {
case "file": case "file":
@@ -58,12 +63,13 @@ func (Server *GVCServer) LockFile(context echo.Context) error {
fmt.Println("Wildcard: ", fileName) fmt.Println("Wildcard: ", fileName)
locked.Exts = append(locked.Exts, fileName) locked.Exts = append(locked.Exts, fileName)
} }
fmt.Println("Locked: ", locked) // TODO!!!!!!!!!!!! Write this to conf Server.Config.Repos[index].Locked = locked
Server.Echo.Logger.Infof("server attempting to lock file: %s of type %s", fileName, fileType)
err = store.Save(serverconfig.DefaultConfigPath, Server.Config) // Save our new default config back to TOML so it can be read in err = store.Save(serverconfig.DefaultConfigPath, Server.Config) // Save our new default config back to TOML so it can be read in
if err != nil { if err != nil {
log.Fatalf("unable to save config to toml file: %s", err) return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("server unable to save lock to server: %s", err))
} }
return nil return context.String(http.StatusAccepted, "file locked on server")
} }
// Refresh sends all updated information to client (like git fetch) // Refresh sends all updated information to client (like git fetch)

14
server/gvclog.log Normal file
View File

@@ -0,0 +1,14 @@
{"time":"2020-06-09T20:56:46.5428576-04:00","id":"","remote_ip":"::1","host":"localhost:80","method":"GET","uri":"/lock/gvc/file/client.go","user_agent":"go-resty/2.3.0 (https://github.com/go-resty/resty)","status":500,"error":"code=500, message=failed checking file lock: file name is on excludeList, cannot add file with name client.go","latency":0,"latency_human":"0s","bytes_in":0,"bytes_out":106}
{"time":"2020-06-09T21:13:05.528876-04:00","id":"","remote_ip":"::1","host":"localhost:80","method":"GET","uri":"/lock/gvc/file/client.go","user_agent":"go-resty/2.3.0 (https://github.com/go-resty/resty)","status":500,"error":"code=500, message=failed checking file lock: file name is on excludeList, cannot add file with name client.go","latency":0,"latency_human":"0s","bytes_in":0,"bytes_out":106}
{"time":"2020-06-09T22:09:36.2468239-04:00","id":"","remote_ip":"::1","host":"localhost:80","method":"GET","uri":"/lock/gvc/file/client.go","user_agent":"go-resty/2.3.0 (https://github.com/go-resty/resty)","status":500,"error":"code=500, message=failed checking file lock: file name is on excludeList, cannot add file with name client.go","latency":0,"latency_human":"0s","bytes_in":0,"bytes_out":106}
{"time":"2020-06-09T22:33:08.8260147-04:00","id":"","remote_ip":"::1","host":"localhost:80","method":"GET","uri":"/info/gvc","user_agent":"go-resty/2.3.0 (https://github.com/go-resty/resty)","status":202,"error":"","latency":0,"latency_human":"0s","bytes_in":0,"bytes_out":588}
{"time":"2020-06-09T22:33:49.1917423-04:00","id":"","remote_ip":"::1","host":"localhost:80","method":"GET","uri":"/info/gvc","user_agent":"go-resty/2.3.0 (https://github.com/go-resty/resty)","status":404,"error":"code=404, message=repo apparently not found","latency":0,"latency_human":"0s","bytes_in":0,"bytes_out":40}
{"time":"2020-06-09T22:35:01.8253061-04:00","id":"","remote_ip":"::1","host":"localhost:80","method":"GET","uri":"/info/gvc","user_agent":"go-resty/2.3.0 (https://github.com/go-resty/resty)","status":404,"error":"code=404, message=repo apparently not found","latency":0,"latency_human":"0s","bytes_in":0,"bytes_out":40}
{"time":"2020-06-09T22:35:34.7362521-04:00","id":"","remote_ip":"::1","host":"localhost:80","method":"GET","uri":"/info/gvc","user_agent":"go-resty/2.3.0 (https://github.com/go-resty/resty)","status":202,"error":"","latency":1000500,"latency_human":"1.0005ms","bytes_in":0,"bytes_out":414}
{"time":"2020-06-09T22:35:59.5823542-04:00","id":"","remote_ip":"::1","host":"localhost:80","method":"GET","uri":"/info/gvc","user_agent":"go-resty/2.3.0 (https://github.com/go-resty/resty)","status":404,"error":"code=404, message=repo apparently not found","latency":0,"latency_human":"0s","bytes_in":0,"bytes_out":40}
{"time":"2020-06-09T22:52:11.3303094-04:00","id":"","remote_ip":"::1","host":"localhost:80","method":"GET","uri":"/refreshgvc","user_agent":"go-resty/2.3.0 (https://github.com/go-resty/resty)","status":404,"error":"code=404, message=Not Found","latency":0,"latency_human":"0s","bytes_in":0,"bytes_out":24}
{"time":"2020-06-09T22:53:26.1999036-04:00","id":"","remote_ip":"::1","host":"localhost:80","method":"GET","uri":"/refreshgvc","user_agent":"go-resty/2.3.0 (https://github.com/go-resty/resty)","status":404,"error":"code=404, message=Not Found","latency":0,"latency_human":"0s","bytes_in":0,"bytes_out":24}
{"time":"2020-06-09T22:54:20.1925112-04:00","id":"","remote_ip":"::1","host":"localhost:80","method":"GET","uri":"/refresh/gvc","user_agent":"go-resty/2.3.0 (https://github.com/go-resty/resty)","status":200,"error":"","latency":0,"latency_human":"0s","bytes_in":0,"bytes_out":177}
{"time":"2020-06-09T22:54:58.6865514-04:00","id":"","remote_ip":"::1","host":"localhost:80","method":"GET","uri":"/refresh/gvc","user_agent":"go-resty/2.3.0 (https://github.com/go-resty/resty)","status":200,"error":"","latency":0,"latency_human":"0s","bytes_in":0,"bytes_out":177}
{"time":"2020-06-09T22:56:01.309063-04:00","id":"","remote_ip":"::1","host":"localhost:80","method":"GET","uri":"/refresh/gvc","user_agent":"go-resty/2.3.0 (https://github.com/go-resty/resty)","status":200,"error":"","latency":0,"latency_human":"0s","bytes_in":0,"bytes_out":177}
{"time":"2020-06-09T22:56:25.9765046-04:00","id":"","remote_ip":"::1","host":"localhost:80","method":"GET","uri":"/refresh/gvc","user_agent":"go-resty/2.3.0 (https://github.com/go-resty/resty)","status":200,"error":"","latency":0,"latency_human":"0s","bytes_in":0,"bytes_out":177}

View File

@@ -2,12 +2,14 @@ package main
import ( import (
"fmt" "fmt"
"log"
"os"
"github.com/deranjer/gvc/server/engine" "github.com/deranjer/gvc/server/engine"
serverconfig "github.com/deranjer/gvc/server/serverconfig" serverconfig "github.com/deranjer/gvc/server/serverconfig"
"github.com/deranjer/store" "github.com/deranjer/store"
"github.com/labstack/echo" "github.com/labstack/echo"
"github.com/labstack/gommon/log" "github.com/labstack/echo/middleware"
) )
var version = "0.1" var version = "0.1"
@@ -22,6 +24,7 @@ func main() {
fmt.Printf("Unable to find config file: %s\n", err) fmt.Printf("Unable to find config file: %s\n", err)
fmt.Println("Since no config found, creating a default config to use...") fmt.Println("Since no config found, creating a default config to use...")
conf = serverconfig.GvcServerConfig{ conf = serverconfig.GvcServerConfig{
LogFile: "gvclog.log",
Version: "0.1", Version: "0.1",
Port: 80, Port: 80,
RepoRootPath: "repos", //default repos directory will be cwd\repos RepoRootPath: "repos", //default repos directory will be cwd\repos
@@ -43,9 +46,20 @@ func main() {
// Setup a new server instance // Setup a new server instance
var server engine.GVCServer var server engine.GVCServer
server.Config = conf server.Config = conf
log.Info("Logger starting...") fmt.Println("Attempting to start logger...")
// Setting up the logger to file output
logFile, err := os.OpenFile(conf.LogFile, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
if err != nil {
log.Fatalf("unable to open log file at: %s, exiting with error: %s", conf.LogFile, err)
}
defer logFile.Close()
// Setup the web server // Setup the web server
e := echo.New() e := echo.New()
// Setup the logger to print to the file specified in config
e.Use(middleware.LoggerWithConfig(middleware.LoggerConfig{
Output: logFile,
}))
e.Logger.Info("echo logger has started")
server.Echo = e server.Echo = e
//Start the routes //Start the routes
//e.GET("/hello", server.Hello) //e.GET("/hello", server.Hello)

View File

@@ -1,30 +0,0 @@
version = "0.1"
port = 80
ip = ""
rawport = 0
reporootpath = "F:\\repos"
[[repo]]
rootpath = ""
reponame = "gvc"
defaultbranch = "master"
localbranches = ["master"]
[[repo.client]]
name = "deranjer"
key = "12345"
lastcommit = "4343434343434"
[repo.locked]
files = ["client1.exe", "client2.exe"]
[repo.defaultignore]
[repo.nocompress]
[[repo]]
rootpath = ""
reponame = "testrepo"
defaultbranch = "master"
localbranches = ["master", "feature1"]
[repo.locked]
[repo.defaultignore]
[repo.nocompress]

View File

@@ -40,6 +40,10 @@ func ValidateConfig(conf *GvcServerConfig, configPath string, version string) er
fmt.Printf("No version found, inputing current server version: %s\n", version) fmt.Printf("No version found, inputing current server version: %s\n", version)
conf.Version = version conf.Version = version
} }
if conf.LogFile == "" { // If no log file specified, set log location
fmt.Printf("No logfile found in config, setting it to: gvclog.log :in root dir:")
conf.LogFile = "gvclog.log"
}
if conf.RepoRootPath == "" { if conf.RepoRootPath == "" {
fmt.Println("Repo root path: ", conf.RepoRootPath) fmt.Println("Repo root path: ", conf.RepoRootPath)
path, err := os.Getwd() path, err := os.Getwd()

View File

@@ -4,6 +4,7 @@ import "github.com/deranjer/gvc/common"
// GvcServerConfig will hold the base server settings // GvcServerConfig will hold the base server settings
type GvcServerConfig struct { type GvcServerConfig struct {
LogFile string `toml:"logfile"` // Where to store the echo logs
Version string `toml:"version"` // The server version Version string `toml:"version"` // The server version
Port int `toml:"port"` // The port that the server will listed on 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 BindIP string `toml:"ip"` // What IP to bind the server to. If empty will bind to all interfaces