✨ More cli compatibility check
	
		
			
	
		
	
	
		
	
		
			All checks were successful
		
		
	
	
		
			
				
	
				release-nightly / build-docker (push) Successful in 1m6s
				
					
					
				
			
		
		
	
	
				
					
				
			
		
			All checks were successful
		
		
	
	release-nightly / build-docker (push) Successful in 1m6s
				This commit is contained in:
		| @@ -44,7 +44,7 @@ var CliCommands = []*cli.Command{ | |||||||
| 				Credential: ctx.Args().Get(2), | 				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()) | 				return fmt.Errorf("couldn't connect server: %s", err.Error()) | ||||||
| 			} else { | 			} else { | ||||||
| 				var servers []CliConnection | 				var servers []CliConnection | ||||||
|   | |||||||
| @@ -3,6 +3,7 @@ package conn | |||||||
| import ( | import ( | ||||||
| 	"encoding/json" | 	"encoding/json" | ||||||
| 	"fmt" | 	"fmt" | ||||||
|  | 	"strings" | ||||||
|  |  | ||||||
| 	roadsign "code.smartsheep.studio/goatworks/roadsign/pkg" | 	roadsign "code.smartsheep.studio/goatworks/roadsign/pkg" | ||||||
| 	"github.com/gofiber/fiber/v2" | 	"github.com/gofiber/fiber/v2" | ||||||
| @@ -15,7 +16,7 @@ type CliConnection struct { | |||||||
| 	Credential string `json:"credential"` | 	Credential string `json:"credential"` | ||||||
| } | } | ||||||
|  |  | ||||||
| func (v CliConnection) GetConnectivity() error { | func (v CliConnection) CheckConnectivity() error { | ||||||
| 	client := fiber.Get(v.Url + "/cgi/connectivity") | 	client := fiber.Get(v.Url + "/cgi/connectivity") | ||||||
| 	client.BasicAuth("RoadSign CLI", v.Credential) | 	client.BasicAuth("RoadSign CLI", v.Credential) | ||||||
|  |  | ||||||
| @@ -30,7 +31,11 @@ func (v CliConnection) GetConnectivity() error { | |||||||
| 		} else if resp["server"] != "RoadSign" { | 		} else if resp["server"] != "RoadSign" { | ||||||
| 			return fmt.Errorf("remote server isn't roadsign") | 			return fmt.Errorf("remote server isn't roadsign") | ||||||
| 		} else if resp["version"] != roadsign.AppVersion { | 		} 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 | 	return nil | ||||||
|   | |||||||
| @@ -31,6 +31,8 @@ var DeployCommands = []*cli.Command{ | |||||||
| 			server, ok := conn.GetConnection(ctx.Args().Get(0)) | 			server, ok := conn.GetConnection(ctx.Args().Get(0)) | ||||||
| 			if !ok { | 			if !ok { | ||||||
| 				return fmt.Errorf("server was not found, use \"rds connect\" add one first") | 				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 | 			// Send request | ||||||
| @@ -65,6 +67,8 @@ var DeployCommands = []*cli.Command{ | |||||||
| 			server, ok := conn.GetConnection(ctx.Args().Get(0)) | 			server, ok := conn.GetConnection(ctx.Args().Get(0)) | ||||||
| 			if !ok { | 			if !ok { | ||||||
| 				return fmt.Errorf("server was not found, use \"rds connect\" add one first") | 				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 | 			var site sign.SiteConfig | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user