adding more server/client communication commands, need to fix echo path params

This commit is contained in:
2020-06-08 20:55:34 -04:00
parent b2238657c8
commit c2e74ce7f4
10 changed files with 111 additions and 33 deletions

View File

@@ -4,6 +4,7 @@ import (
"fmt"
clientconfig "github.com/deranjer/gvc/client/clientconfig"
"github.com/go-resty/resty/v2"
)
// RefreshContent gets all the new file locks and updated pulls from the server (like git fetch)
@@ -15,8 +16,24 @@ func RefreshContent(conf *clientconfig.Gvcconfig) error {
if err != nil {
return err
}
fmt.Println("Connection String; ", connectionString) //TODO: Remove not needed
//TODO: Now refresh content
client := resty.New()
resp, err := client.R().
// SetPathParams(map[string]string{
// "repoName": repoName,
// }).
//Get(connectionString + "{repoName}" + "/info") //creating the full string to get info
Get(connectionString + "/refresh")
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("reponse not a success: %d: connection URL: %s", resp.StatusCode(), resp.Request.URL)
}
fmt.Println(resp)
return nil
}
}
return nil