Changes on the server.json format and the API (#562)

This commit is contained in:
Radoslav Dimitrov 2025-09-29 23:30:35 +03:00 • committed by GitHub
commit b21c6f564d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -39,7 +39,7 @@ func PublishCommand(args []string) error {
// Check for deprecated schema and recommend migration
// Allow empty schema (will use default) but reject old schemas
if serverJSON.Schema != "" && !strings.Contains(serverJSON.Schema, "2025-09-16") {
if serverJSON.Schema != "" && !strings.Contains(serverJSON.Schema, "2025-09-29") {
return fmt.Errorf(`deprecated schema detected :%s.
Migrate to the current schema format for new servers.
@ -82,14 +82,12 @@ Migrate to the current schema format for new servers.
}
_, _ = fmt.Fprintln(os.Stdout, "✓ Successfully published")
if serverID := response.GetServerID(); serverID != "" {
_, _ = fmt.Fprintf(os.Stdout, "✓ Server Id %s version %s\n", serverID, response.Version)
}
_, _ = fmt.Fprintf(os.Stdout, "✓ Server %s version %s\n", response.Server.Name, response.Server.Version)
return nil
}
func publishToRegistry(registryURL string, serverData []byte, token string) (*apiv0.ServerJSON, error) {
func publishToRegistry(registryURL string, serverData []byte, token string) (*apiv0.ServerResponse, error) {
// Parse the server JSON data
var serverJSON apiv0.ServerJSON
err := json.Unmarshal(serverData, &serverJSON)
@ -134,9 +132,10 @@ func publishToRegistry(registryURL string, serverData []byte, token string) (*ap
return nil, fmt.Errorf("server returned status %d: %s", resp.StatusCode, body)
}
if err := json.Unmarshal(body, &serverJSON); err != nil {
var serverResponse apiv0.ServerResponse
if err := json.Unmarshal(body, &serverResponse); err != nil {
return nil, err
}
return &serverJSON, nil
return &serverResponse, nil
}