More cli compatibility check
All checks were successful
release-nightly / build-docker (push) Successful in 1m6s

This commit is contained in:
LittleSheep 2023-12-13 20:05:34 +08:00
parent 0d8583e395
commit 17196c5835
3 changed files with 12 additions and 3 deletions

View File

@ -44,7 +44,7 @@ var CliCommands = []*cli.Command{
Credential: ctx.Args().Get(2),
}
if err := c.GetConnectivity(); err != nil {
if err := c.CheckConnectivity(); err != nil {
return fmt.Errorf("couldn't connect server: %s", err.Error())
} else {
var servers []CliConnection

View File

@ -3,6 +3,7 @@ package conn
import (
"encoding/json"
"fmt"
"strings"
roadsign "code.smartsheep.studio/goatworks/roadsign/pkg"
"github.com/gofiber/fiber/v2"
@ -15,7 +16,7 @@ type CliConnection struct {
Credential string `json:"credential"`
}
func (v CliConnection) GetConnectivity() error {
func (v CliConnection) CheckConnectivity() error {
client := fiber.Get(v.Url + "/cgi/connectivity")
client.BasicAuth("RoadSign CLI", v.Credential)
@ -30,7 +31,11 @@ func (v CliConnection) GetConnectivity() error {
} else if resp["server"] != "RoadSign" {
return fmt.Errorf("remote server isn't roadsign")
} else if resp["version"] != roadsign.AppVersion {
log.Warn().Msg("Server connected successfully, but remote server version mismatch than CLI version, some features may buggy or completely unusable.")
if strings.Contains(roadsign.AppVersion, "#") {
return fmt.Errorf("remote server version mismatch client version, update or downgrade client required")
} else {
log.Warn().Msg("RoadSign CLI didn't complied with vcs information, compatibility was disabled. To enable it, reinstall cli with -buildvcs flag.")
}
}
}
return nil

View File

@ -31,6 +31,8 @@ var DeployCommands = []*cli.Command{
server, ok := conn.GetConnection(ctx.Args().Get(0))
if !ok {
return fmt.Errorf("server was not found, use \"rds connect\" add one first")
} else if err := server.CheckConnectivity(); err != nil {
return fmt.Errorf("couldn't connect server: %s", err.Error())
}
// Send request
@ -65,6 +67,8 @@ var DeployCommands = []*cli.Command{
server, ok := conn.GetConnection(ctx.Args().Get(0))
if !ok {
return fmt.Errorf("server was not found, use \"rds connect\" add one first")
} else if err := server.CheckConnectivity(); err != nil {
return fmt.Errorf("couldn't connect server: %s", err.Error())
}
var site sign.SiteConfig