]> ruderich.org/simon Gitweb - safcm/safcm.git/blobdiff - cmd/safcm/sync_sync.go
safcm: group_order: higher priority for listed groups over remaining groups
[safcm/safcm.git] / cmd / safcm / sync_sync.go
index e84b7f416c07b84df027f017c826d8b381324d4a..8b4cec45d0ba837cc490ac332a9b5d124883c136 100644 (file)
@@ -19,6 +19,7 @@ package main
 
 import (
        "fmt"
+       "math"
        "os"
        "path/filepath"
        "sort"
@@ -44,26 +45,9 @@ func (s *Sync) hostSync(conn *rpc.Conn, detectedGroups []string) error {
        }
 
        // Display changes
-       var changes []string
-       if len(resp.FileChanges) > 0 {
-               changes = append(changes,
-                       s.formatFileChanges(resp.FileChanges))
-       }
-       if len(resp.PackageChanges) > 0 {
-               changes = append(changes,
-                       s.formatPackageChanges(resp.PackageChanges))
-       }
-       if len(resp.ServiceChanges) > 0 {
-               changes = append(changes,
-                       s.formatServiceChanges(resp.ServiceChanges))
-       }
-       if len(resp.CommandChanges) > 0 {
-               changes = append(changes,
-                       s.formatCommandChanges(resp.CommandChanges))
-       }
-       if len(changes) > 0 {
-               s.logf(safcm.LogInfo, true, "%s",
-                       "\n"+strings.Join(changes, "\n"))
+       changes := s.formatChanges(resp)
+       if changes != "" {
+               s.logf(safcm.LogInfo, true, "%s", changes)
        }
 
        if resp.Error != "" {
@@ -108,7 +92,7 @@ func (s *Sync) hostSyncReq(detectedGroups []string) (
        allFiles := make(map[string]*safcm.File)
        allPackagesMap := make(map[string]bool) // map to deduplicate
        allServicesMap := make(map[string]bool) // map to deduplicate
-       var allCommands []string
+       var allCommands []*safcm.Command
 
        for _, group := range groups {
                // Skip non-existent group directories
@@ -205,10 +189,10 @@ func (s *Sync) resolveHostGroups(detectedGroups []string) (
        // Early entries have higher priorities
        groupPriority := make(map[string]int)
        for i, x := range s.config.GroupOrder {
-               groupPriority[x] = i + 1
+               groupPriority[x] = math.MinInt32 + i + 1
        }
        // Host itself always has highest priority
-       groupPriority[s.host.Name] = -1
+       groupPriority[s.host.Name] = math.MinInt32
 
        // Sort groups after priority and name
        sort.Slice(groups, func(i, j int) bool {