A free and open source instant messaging and VoIP chat app built for friends, groups, and communities.
fix(rexctl): stop upgrade when custom file has removed services
Hampus08fd6338b555
diff --git a/fluxer_rexctl/cmd/upgrade.go b/fluxer_rexctl/cmd/upgrade.goindex 3273f7e3d..66f79aa65 100644--- a/fluxer_rexctl/cmd/upgrade.go+++ b/fluxer_rexctl/cmd/upgrade.go@@ -373,6 +373,10 @@ func upgradeStack(ctx context.Context, app *App, inst *instance.Instance, e *engclearUpgrade(inst)return ui.Wrap(err, "This rexctl has no Fluxer release built in.", "Download rexctl again, then run rexctl upgrade.")}+ if retired := instance.RetiredService(inst.Dir); retired != "" {+ clearUpgrade(inst)+ return ui.Refused(fmt.Sprintf("%s changes %s, which Fluxer %s no longer runs.", instance.CustomCompose, retired, toShort), retiredFix(retired, fromShort))+ }if err := release.Snapshot(inst, from, refList(inst.State.Images.Refs)); err != nil {clearUpgrade(inst)return ui.Wrap(err, fmt.Sprintf("Couldn't save the files of %s.", fluxerName(fromShort)), "Check that the disk isn't full, then run rexctl upgrade again.")@@ -594,6 +598,14 @@ func printRecoveryPlan(app *App, inst *instance.Instance) string {return pend.From}+func retiredFix(name, fromShort string) string {+ still := fmt.Sprintf("You're still on %s.", fluxerName(fromShort))+ if base, ok := strings.CutSuffix(name, "-shard"); ok && slices.Contains(stack.Services, base) {+ return fmt.Sprintf("%s Move those changes to %s, then run rexctl upgrade again.", still, base)+ }+ return fmt.Sprintf("%s Remove %s from %s, then run rexctl upgrade again.", still, name, instance.CustomCompose)+}+func nextState(inst *instance.Instance, set *stack.Set, images stack.ImageSet, to string) (*instance.State, []string, error) {cur := inst.Statenext := *curdiff --git a/fluxer_rexctl/internal/instance/import.go b/fluxer_rexctl/internal/instance/import.goindex 531b429d7..a0d578251 100644--- a/fluxer_rexctl/internal/instance/import.go+++ b/fluxer_rexctl/internal/instance/import.go@@ -489,6 +489,22 @@ func releaseSet(dir, release string) (*stack.Set, error) {return diskSet(filesDir, release, profiles)}+func RetiredService(dir string) string {+ var doc map[string]any+ if err := yaml.Unmarshal(readCustom(dir), &doc); err != nil {+ return ""+ }+ services, _ := doc["services"].(map[string]any)+ for _, name := range slices.Sorted(maps.Keys(services)) {+ svc, _ := services[name].(map[string]any)+ if _, ok := svc["image"]; ok || slices.Contains(stack.Services, name) {+ continue+ }+ return name+ }+ return ""+}+func readCustom(dir string) []byte {data, _ := os.ReadFile(filepath.Join(dir, CustomCompose))return data