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

@@ -19,7 +19,7 @@ func GetServerInfo(connectionString string, repoName string) error {
}
if resp.IsError() {
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)
}

View File

@@ -36,6 +36,10 @@ func LockFiles(input string, inputType string, conf *clientconfig.Gvcconfig) err
}
fmt.Println("Adding folder to locked: ", 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
case "wildcard":
var wildcard string
@@ -50,6 +54,10 @@ func LockFiles(input string, inputType string, conf *clientconfig.Gvcconfig) err
}
fmt.Println("Adding wildcard to locked: ", 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 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 {
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)
return nil

View File

@@ -4,12 +4,14 @@ import (
"fmt"
clientconfig "github.com/deranjer/gvc/client/clientconfig"
"github.com/deranjer/gvc/common"
"github.com/go-resty/resty/v2"
)
// 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
connectionString, err := FindServer("", conf.CurrentBranch, conf)
var refreshResult common.RepoRefreshRequest
if err != nil {
return err
}
@@ -18,16 +20,18 @@ func RefreshContent(conf *clientconfig.Gvcconfig, repoName string) error { //TOD
SetPathParams(map[string]string{
"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 {
return fmt.Errorf("error connecting to server at: %s: error was: %s", connectionString, err)
}
if resp.IsError() {
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.Printf("%+v\n", refreshResult)
return nil
}