Pull-based GitOps-style Docker Compose deployer: polls a (private) Git repo, detects changed stacks and reconciles only the affected
at main 32 lines 615 B view raw
1package stacks 2 3import ( 4 "strings" 5) 6 7func DetectChangedStacks(changedFiles []string) ([]string, error) { 8 stackSet := make(map[string]bool) 9 10 for _, file := range changedFiles { 11 if file == "" { 12 continue 13 } 14 15 if strings.HasPrefix(file, "stacks/") { 16 parts := strings.Split(file, "/") 17 if len(parts) >= 2 { 18 stackName := parts[1] 19 if len(parts) >= 3 && (parts[2] == "compose.yml" || parts[2] == "compose.yaml") { 20 stackSet[stackName] = true 21 } 22 } 23 } 24 } 25 26 stacks := make([]string, 0, len(stackSet)) 27 for stack := range stackSet { 28 stacks = append(stacks, stack) 29 } 30 31 return stacks, nil 32}