MCPcopy Create free account
hub / github.com/conforma/cli / buildPolicyDiffDisplay

Function buildPolicyDiffDisplay

cmd/validate/vsa.go:1030–1064  ·  view source on GitHub ↗

buildPolicyDiffDisplay creates a PolicyDiffDisplay from AllSectionsData Returns nil if there is no policy diff

(data AllSectionsData)

Source from the content-addressed store, hash-verified

1028// buildPolicyDiffDisplay creates a PolicyDiffDisplay from AllSectionsData
1029// Returns nil if there is no policy diff
1030func buildPolicyDiffDisplay(data AllSectionsData) *PolicyDiffDisplay {
1031 if !data.HasPolicyDiff {
1032 return nil
1033 }
1034
1035 diff := &PolicyDiffDisplay{
1036 AffectedImages: strings.Join(data.AffectedImages, ", "),
1037 }
1038
1039 // Aggregate policy diff counts across all affected images
1040 totals := aggregatePolicyDiffTotals(data.PolicyDiffCounts)
1041
1042 // Build added line
1043 if totals.Added > 0 {
1044 diff.Added = fmt.Sprintf("[include] %d", totals.Added)
1045 } else {
1046 diff.Added = noPolicyDiff
1047 }
1048
1049 // Build removed line
1050 if totals.Removed > 0 {
1051 diff.Removed = fmt.Sprintf("%d", totals.Removed)
1052 } else {
1053 diff.Removed = noPolicyDiff
1054 }
1055
1056 // Build changed line
1057 if totals.Changed > 0 {
1058 diff.Changed = fmt.Sprintf("%d", totals.Changed)
1059 } else {
1060 diff.Changed = noPolicyDiff
1061 }
1062
1063 return diff
1064}
1065
1066// String formats the Policy Diff section for display
1067func (p PolicyDiffDisplay) String() string {

Calls 1

Tested by 2