adding more server/client communication commands, need to fix echo path params
This commit is contained in:
@@ -9,7 +9,7 @@ remotebranches = ["master", "test", "test2"]
|
||||
name = "test2"
|
||||
host = "localhost"
|
||||
port = 80
|
||||
default = false
|
||||
default = true
|
||||
|
||||
[[remote]]
|
||||
name = "test4"
|
||||
@@ -27,7 +27,7 @@ remotebranches = ["master", "test", "test2"]
|
||||
name = "test5"
|
||||
host = "localhost1"
|
||||
port = 9997
|
||||
default = true
|
||||
default = false
|
||||
|
||||
[[remote]]
|
||||
name = "test6"
|
||||
|
@@ -323,11 +323,18 @@ func infoCommands(cli *clir.Cli, conf *clientconfig.Gvcconfig) {
|
||||
fmt.Println("no valid repo found.. please run 'init' to setup a repo first")
|
||||
os.Exit(0)
|
||||
}
|
||||
if len(remoteInfoCmd.OtherArgs()) == 0 {
|
||||
remoteInfoCmd.PrintHelp()
|
||||
return fmt.Errorf("Please supply a server name to test a remote")
|
||||
var server string
|
||||
if len(remoteInfoCmd.OtherArgs()) == 0 { //Notify that we are using default server if none specified
|
||||
fmt.Println("No server specified, using default...")
|
||||
for _, remote := range conf.Remotes {
|
||||
if remote.Default {
|
||||
server = remote.Name
|
||||
}
|
||||
}
|
||||
} else { // Server name was specified, using that server
|
||||
server = remoteInfoCmd.OtherArgs()[0]
|
||||
}
|
||||
server := remoteInfoCmd.OtherArgs()[0]
|
||||
|
||||
connectionString, err := clientcmd.FindServer(server, "master", conf)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@@ -40,7 +40,7 @@ func FindServer(serverName string, branchName string, conf *clientconfig.Gvcconf
|
||||
if serverName == remote.Name {
|
||||
fmt.Printf("Server found in config, connecting to: %s, host: %s, port: %d \n", remote.Name, remote.Host, remote.Port)
|
||||
port := ":" + strconv.Itoa(remote.Port)
|
||||
connectionString := "http://" + remote.Host + port //Create our connection string
|
||||
connectionString := "http://" + remote.Host + port + "/" + conf.RepoName //Create our connection string //'http://server:port/:repo' //TODO, what about admin commands for entire server management, not just one repo?
|
||||
fmt.Println("Generated connection string: ", connectionString)
|
||||
return connectionString, nil
|
||||
}
|
||||
|
@@ -8,21 +8,16 @@ import (
|
||||
|
||||
// GetServerInfo queries the supplied connection string for server info and uses the provided repoName to get repo specific information
|
||||
func GetServerInfo(connectionString string, repoName string) error {
|
||||
serverURL := connectionString + "/info/" //creating the full string to get info
|
||||
client := resty.New()
|
||||
resp, err := client.R().
|
||||
SetPathParams(map[string]string{
|
||||
"repoName": repoName,
|
||||
}).
|
||||
Get(serverURL + "{repoName}")
|
||||
resp, err := client.R().Get(connectionString + "/info") //creating the full string to get info
|
||||
if err != nil {
|
||||
return fmt.Errorf("error connecting to server at: %s: error was: %s", serverURL, err)
|
||||
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)
|
||||
return fmt.Errorf("response not a success: %d: connection URL: %s", resp.StatusCode(), resp.Request.URL)
|
||||
}
|
||||
fmt.Println(resp)
|
||||
return nil
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user