Skip to content

Commit

Permalink
fix(device): always take apps input as source of truth
Browse files Browse the repository at this point in the history
Instead of overriding the input given with what our api is giving back,
it is much better to just take what the user is giving us as what needs
to be set.

Signed-off-by: Eric Bode <[email protected]>
  • Loading branch information
StealthyCoder committed Feb 28, 2024
1 parent e80ab46 commit 1d44591
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions subcommands/common_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,19 +223,16 @@ func SetUpdatesConfig(opts *SetUpdatesConfigOptions, reportedTag string, reporte
configuredApps := sota.GetDefault("pacman.docker_apps", "").(string)
configuredTag := sota.GetDefault("pacman.tags", "").(string)

if len(configuredTag) == 0 && len(reportedTag) > 0 {
configuredTag = reportedTag
}
if len(configuredApps) == 0 && reportedApps != nil {
configuredApps = strings.Join(reportedApps, ",")
}

changed := false
if opts.UpdateApps != "" && configuredApps != opts.UpdateApps {
if strings.TrimSpace(opts.UpdateApps) == "," {
opts.UpdateApps = ""
}
fmt.Printf("Changing apps from: [%s] -> [%s]\n", configuredApps, opts.UpdateApps)
fmt.Printf("Currently configured apps: [%s]\n", configuredApps)
if reportedApps != nil {
fmt.Printf("Apps reported as installed on device: [%s]\n", strings.Join(reportedApps, ","))
}
fmt.Printf("Setting apps to [%s]\n", opts.UpdateApps)
sota.Set("pacman.docker_apps", opts.UpdateApps)
sota.Set("pacman.compose_apps", opts.UpdateApps)
changed = true
Expand All @@ -244,7 +241,11 @@ func SetUpdatesConfig(opts *SetUpdatesConfigOptions, reportedTag string, reporte
if strings.TrimSpace(opts.UpdateTag) == "," {
opts.UpdateTag = ""
}
fmt.Printf("Changing tag from: %s -> %s\n", configuredTag, opts.UpdateTag)
fmt.Printf("Currently configured tag: %s\n", configuredTag)
if len(reportedTag) > 0 {
fmt.Printf("Tag reported by device: %s\n", reportedTag)
}
fmt.Printf("Setting tag to %s\n", opts.UpdateTag)
sota.Set("pacman.tags", opts.UpdateTag)
changed = true
}
Expand Down

0 comments on commit 1d44591

Please sign in to comment.