fix(ci): preserve installer compatibility with older releases
This commit is contained in:
5 files changed
+49
-23
No files matched your search
@@ -9,10 +9,17 @@ import (
|
||||
|
||||
func cmdBootstrapAssets(args []string, stdout, stderr io.Writer) int {
|
||||
if len(args) != 1 {
|
||||
fmt.Fprintln(stderr, "felis bootstrap-assets: usage: felis bootstrap-assets crd|game-stack")
|
||||
fmt.Fprintln(stderr, "felis bootstrap-assets: usage: felis bootstrap-assets crd|game-stack|config-keys")
|
||||
return 2
|
||||
}
|
||||
switch args[0] {
|
||||
case "config-keys":
|
||||
// Optional keys the installer may emit; older binaries reject this verb.
|
||||
_, err := fmt.Fprintln(stdout, "velocity.game_version")
|
||||
if err != nil {
|
||||
fmt.Fprintf(stderr, "felis bootstrap-assets: write: %v\n", err)
|
||||
return 1
|
||||
}
|
||||
case "crd":
|
||||
crd, err := felis.MinecraftServerCRD()
|
||||
if err != nil {
|
||||
@@ -32,7 +39,7 @@ func cmdBootstrapAssets(args []string, stdout, stderr io.Writer) int {
|
||||
return 1
|
||||
}
|
||||
default:
|
||||
fmt.Fprintln(stderr, "felis bootstrap-assets: usage: felis bootstrap-assets crd|game-stack")
|
||||
fmt.Fprintln(stderr, "felis bootstrap-assets: usage: felis bootstrap-assets crd|game-stack|config-keys")
|
||||
return 2
|
||||
}
|
||||
return 0
|
||||
|
||||
@@ -5,8 +5,27 @@ import (
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/BurntSushi/toml"
|
||||
|
||||
"felis.lolicon.best/internal/config"
|
||||
)
|
||||
|
||||
func TestBootstrapConfigKeys(t *testing.T) {
|
||||
var out, errBuf bytes.Buffer
|
||||
if code := run([]string{"bootstrap-assets", "config-keys"}, &out, &errBuf); code != 0 {
|
||||
t.Fatalf("exit code = %d: %s", code, errBuf.String())
|
||||
}
|
||||
var cfg config.Config
|
||||
meta, err := toml.Decode(strings.TrimSpace(out.String())+` = "26.3"`, &cfg)
|
||||
if err != nil || len(meta.Undecoded()) != 0 {
|
||||
t.Fatalf("advertised config key is unsupported: %v, undecoded: %v", err, meta.Undecoded())
|
||||
}
|
||||
if cfg.Velocity.GameVersion != "26.3" {
|
||||
t.Fatalf("advertised key did not set the game version: %q", cfg.Velocity.GameVersion)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRunNoArgsPrintsUsage(t *testing.T) {
|
||||
var out, errBuf bytes.Buffer
|
||||
if code := run(nil, &out, &errBuf); code != 2 {
|
||||
|
||||
Reference in new issue
Block a user