this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

refactor(controller): remove heart beat from fast activities

Kinda redundant.

-24
-11
controller/activities/git.go
··· 31 31 logger := activity.GetLogger(ctx) 32 32 path := generateRepoPath(url, revision) 33 33 34 - safeHeartbeat(ctx, "Checking existing repository") 35 - 36 34 if hasCorrectRevision(ctx, path, revision) { 37 35 logger.Info("Repository already available", "path", path) 38 36 return path, nil 39 37 } 40 38 41 - safeHeartbeat(ctx, "Preparing to clone repository") 42 - 43 39 if err := os.MkdirAll(filepath.Dir(path), 0755); err != nil { 44 40 return "", fmt.Errorf("failed to create parent directory: %w", err) 45 41 } 46 42 os.RemoveAll(path) 47 43 48 44 logger.Info("Cloning repository", "url", url, "revision", revision) 49 - safeHeartbeat(ctx, fmt.Sprintf("Starting git clone: %s@%s", url, revision)) 50 45 51 46 cmd := exec.CommandContext(ctx, "git", "clone", "--branch", revision, url, path) 52 47 if err := cmd.Run(); err != nil { ··· 54 49 return "", fmt.Errorf("failed to clone repository: %w", err) 55 50 } 56 51 57 - safeHeartbeat(ctx, "Clone completed successfully") 58 52 return path, nil 59 53 } 60 54 61 55 func ChangedModules(ctx context.Context, repoPath string, oldRevision string) ([]string, error) { 62 - safeHeartbeat(ctx, "Analyzing changed files") 63 - 64 56 cmd := exec.CommandContext(ctx, "git", "diff", "--name-only", oldRevision, "HEAD") 65 57 cmd.Dir = repoPath 66 58 output, err := cmd.Output() 67 59 if err != nil { 68 60 return nil, err 69 61 } 70 - 71 - safeHeartbeat(ctx, "Processing changed files to identify modules") 72 62 73 63 seen := make(map[string]struct{}) 74 64 var modules []string ··· 94 84 } 95 85 } 96 86 97 - safeHeartbeat(ctx, fmt.Sprintf("Found %d changed modules", len(modules))) 98 87 return modules, nil 99 88 }
-7
controller/activities/graph.go
··· 37 37 } 38 38 39 39 func PruneGraph(ctx context.Context, graph *Graph, changed []string) (*Graph, error) { 40 - safeHeartbeat(ctx, fmt.Sprintf("Pruning graph with %d nodes, %d changed modules", len(graph.Nodes), len(changed))) 41 - 42 40 dependents := make(map[string][]string) 43 41 for src, dests := range graph.Edges { 44 42 for _, dest := range dests { 45 43 dependents[dest] = append(dependents[dest], src) 46 44 } 47 45 } 48 - 49 - safeHeartbeat(ctx, "Built reverse dependency map") 50 46 51 47 keep := make(map[string]bool) 52 48 var visit func(string) ··· 66 62 } 67 63 } 68 64 69 - safeHeartbeat(ctx, fmt.Sprintf("Identified %d nodes to keep", len(keep))) 70 - 71 65 prunedGraph := NewGraph() 72 66 for node := range keep { 73 67 prunedGraph.AddNode(node) ··· 82 76 } 83 77 } 84 78 85 - safeHeartbeat(ctx, fmt.Sprintf("Created pruned graph with %d nodes", len(prunedGraph.Nodes))) 86 79 return prunedGraph, nil 87 80 } 88 81
-6
controller/activities/terragrunt.go
··· 13 13 ) 14 14 15 15 func TerragruntGraph(ctx context.Context, path string) (*Graph, error) { 16 - safeHeartbeat(ctx, "Generating terragrunt dependency graph") 17 - 18 16 cmd := exec.CommandContext(ctx, "terragrunt", "dag", "graph") 19 17 cmd.Dir = path 20 18 output, err := cmd.Output() ··· 22 20 return nil, fmt.Errorf("failed to run terragrunt dag graph: %w", err) 23 21 } 24 22 25 - safeHeartbeat(ctx, "Parsing dependency graph") 26 23 return NewGraphFromDot(string(output)) 27 24 } 28 25 ··· 34 31 logger := activity.GetLogger(ctx) 35 32 logger.Info("Running terragrunt apply", "module", modulePath, "stack", stack) 36 33 37 - safeHeartbeat(ctx, fmt.Sprintf("Ensuring repository availability for %s", modulePath)) 38 - 39 34 repoPath, err := Clone(ctx, repoUrl, revision) 40 35 if err != nil { 41 36 return fmt.Errorf("failed to ensure repository is available: %w", err) 42 37 } 43 38 44 39 fullPath := filepath.Join(repoPath, "infra", stack, modulePath) 45 - safeHeartbeat(ctx, fmt.Sprintf("Starting terragrunt apply for %s", modulePath)) 46 40 47 41 cmd := exec.CommandContext(ctx, "terragrunt", "apply", "--backend-bootstrap", "--auto-approve") 48 42 cmd.Dir = fullPath