-
-
Notifications
You must be signed in to change notification settings - Fork 174
Expand file tree
/
Copy pathdescribe_affected_upload.go
More file actions
85 lines (77 loc) · 2.72 KB
/
Copy pathdescribe_affected_upload.go
File metadata and controls
85 lines (77 loc) · 2.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package exec
import (
"github.com/cloudposse/atmos/pkg/schema"
)
// StripAffectedForUpload removes fields from affected stacks that aren't used
// by Atmos Pro processing. This significantly reduces payload size
// (typically 70-75% reduction) to stay within serverless function payload limits.
//
// Fields kept:
// - component: Stack identification
// - stack: Stack identification
// - included_in_dependents: Used in filtering logic
// - dependents: Nested stack processing (recursively stripped)
// - pro / settings.pro: Workflow dispatch configuration. settings.pro is a deprecated
// alias for the top-level pro: section; both are kept so Atmos Pro can apply the same
// new-wins-over-legacy precedence server-side (see pro.ResolveSection).
// - deleted: Marks components removed in HEAD.
// - deletion_type: Whether a component or entire stack was deleted.
//
// Fields removed:
// - settings.depends_on: Dependency graph (largest contributor to size)
// - settings.github: Not used by downstream handlers
// - component_type, component_path: Not used in downstream processing
// - namespace, tenant, environment, stage: Redundant (encoded in stack name)
// - stack_slug, affected: Not used in downstream processing
func StripAffectedForUpload(affected []schema.Affected) []schema.Affected {
result := make([]schema.Affected, len(affected))
for i, a := range affected {
result[i] = stripAffected(a)
}
return result
}
func stripAffected(a schema.Affected) schema.Affected {
return schema.Affected{
Component: a.Component,
Stack: a.Stack,
IncludedInDependents: a.IncludedInDependents,
Dependents: stripDependents(a.Dependents),
Settings: stripSettings(a.Settings),
Pro: a.Pro,
Deleted: a.Deleted,
DeletionType: a.DeletionType,
}
}
func stripDependents(dependents []schema.Dependent) []schema.Dependent {
if len(dependents) == 0 {
return []schema.Dependent{}
}
result := make([]schema.Dependent, len(dependents))
for i, d := range dependents {
result[i] = stripDependent(d)
}
return result
}
func stripDependent(d schema.Dependent) schema.Dependent {
return schema.Dependent{
Component: d.Component,
Stack: d.Stack,
IncludedInDependents: d.IncludedInDependents,
Dependents: stripDependents(d.Dependents),
Settings: stripSettings(d.Settings),
Pro: d.Pro,
}
}
func stripSettings(settings schema.AtmosSectionMapType) schema.AtmosSectionMapType {
if settings == nil {
return nil
}
// Only keep settings.pro if it exists
pro, hasPro := settings["pro"]
if !hasPro {
return nil
}
return schema.AtmosSectionMapType{
"pro": pro,
}
}