This repository has been archived by the owner on Mar 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 234
/
template_utils.go
189 lines (140 loc) · 6.85 KB
/
template_utils.go
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
/*
Copyright 2018 Google, Inc. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package util
const FSDiffOutput = `
-----{{.DiffType}}-----
These entries have been added to {{.Image2}}:{{if not .Diff.Adds}} None{{else}}
FILE SIZE{{range .Diff.Adds}}{{"\n"}}{{.Name}} {{.Size}}{{end}}{{end}}
These entries have been deleted from {{.Image2}}:{{if not .Diff.Dels}} None{{else}}
FILE SIZE{{range .Diff.Dels}}{{"\n"}}{{.Name}} {{.Size}}{{end}}{{end}}
These entries have been changed between {{.Image1}} and {{.Image2}}:{{if not .Diff.Mods}} None{{else}}
FILE SIZE1 SIZE2{{range .Diff.Mods}}{{"\n"}}{{.Name}} {{.Size1}} {{.Size2}}{{end}}
{{end}}
`
const FSLayerDiffOutput = `
-----{{.DiffType}}-----
{{range $index, $diff := .Diff}}
Diff for Layer {{$index}}:
These entries have been added to {{$.Image1}}:{{if not $diff.Adds}} None{{else}}
FILE SIZE{{range $diff.Adds}}{{"\n"}}{{.Name}} {{.Size}}{{end}}{{end}}
These entries have been deleted from {{$.Image1}}:{{if not $diff.Dels}} None{{else}}
FILE SIZE{{range $diff.Dels}}{{"\n"}}{{.Name}} {{.Size}}{{end}}{{end}}
These entries have been changed between {{$.Image1}} and {{$.Image2}}:{{if not $diff.Mods}} None{{else}}
FILE SIZE1 SIZE2{{range $diff.Mods}}{{"\n"}}{{.Name}} {{.Size1}} {{.Size2}}{{end}}
{{end}}
{{end}}
`
const SingleVersionDiffOutput = `
-----{{.DiffType}}-----
Packages found only in {{.Image1}}:{{if not .Diff.Packages1}} None{{else}}
NAME VERSION SIZE{{range .Diff.Packages1}}{{"\n"}}{{print "-"}}{{.Name}} {{.Version}} {{.Size}}{{end}}{{end}}
Packages found only in {{.Image2}}:{{if not .Diff.Packages2}} None{{else}}
NAME VERSION SIZE{{range .Diff.Packages2}}{{"\n"}}{{print "-"}}{{.Name}} {{.Version}} {{.Size}}{{end}}{{end}}
Version differences:{{if not .Diff.InfoDiff}} None{{else}}
PACKAGE IMAGE1 ({{.Image1}}) IMAGE2 ({{.Image2}}){{range .Diff.InfoDiff}}{{"\n"}}{{print "-"}}{{.Package}} {{.Info1.Version}}, {{.Info1.Size}} {{.Info2.Version}}, {{.Info2.Size}}{{end}}
{{end}}
`
const MultiVersionDiffOutput = `
-----{{.DiffType}}-----
Packages found only in {{.Image1}}:{{if not .Diff.Packages1}} None{{else}}
NAME VERSION SIZE{{range .Diff.Packages1}}{{"\n"}}{{print "-"}}{{.Name}} {{.Version}} {{.Size}}{{end}}{{end}}
Packages found only in {{.Image2}}:{{if not .Diff.Packages2}} None{{else}}
NAME VERSION SIZE{{range .Diff.Packages2}}{{"\n"}}{{print "-"}}{{.Name}} {{.Version}} {{.Size}}{{end}}{{end}}
Version differences:{{if not .Diff.InfoDiff}} None{{else}}
PACKAGE IMAGE1 ({{.Image1}}) IMAGE2 ({{.Image2}}){{range .Diff.InfoDiff}}{{"\n"}}{{print "-"}}{{.Package}} {{range .Info1}}{{.Version}}, {{.Size}}{{end}} {{range .Info2}}{{.Version}}, {{.Size}}{{end}}{{end}}
{{end}}
`
const HistoryDiffOutput = `
-----{{.DiffType}}-----
Docker history lines found only in {{.Image1}}:{{if not .Diff.Adds}} None{{else}}{{block "list" .Diff.Dels}}{{"\n"}}{{range .}}{{print "-" .}}{{"\n"}}{{end}}{{end}}{{end}}
Docker history lines found only in {{.Image2}}:{{if not .Diff.Dels}} None{{else}}{{block "list2" .Diff.Adds}}{{"\n"}}{{range .}}{{print "-" .}}{{"\n"}}{{end}}{{end}}{{end}}
`
const MetadataDiffOutput = `
-----{{.DiffType}}-----
Image metadata differences between {{.Image1}} and {{.Image2}}:
{{.Image1}}{{if not .Diff.Adds}} None{{else}}{{block "list" .Diff.Adds}}{{"\n"}}{{range .}}{{print "-" .}}{{"\n"}}{{end}}{{end}}{{end}}
{{.Image2}}{{if not .Diff.Dels}} None{{else}}{{block "list2" .Diff.Dels}}{{"\n"}}{{range .}}{{print "-" .}}{{"\n"}}{{end}}{{end}}{{end}}
`
const FilenameDiffOutput = `
-----Diff of {{.Filename}}-----
{{.Description}}
{{.Diff}}
`
const SizeDiffOutput = `
-----{{.DiffType}}-----
Image size difference between {{.Image1}} and {{.Image2}}:{{if not .Diff}} None{{else}}
SIZE1 SIZE2{{range .Diff}}{{"\n"}}{{.Size1}} {{.Size2}}{{end}}
{{end}}
`
const SizeLayerDiffOutput = `
-----{{.DiffType}}-----
Layer size differences between {{.Image1}} and {{.Image2}}:{{if not .Diff}} None{{else}}
LAYER SIZE1 SIZE2{{range .Diff}}{{"\n"}}{{.Name}} {{.Size1}} {{.Size2}}{{end}}
{{end}}
`
const ListAnalysisOutput = `
-----{{.AnalyzeType}}-----
Analysis for {{.Image}}:{{if not .Analysis}} None{{else}}{{block "list" .Analysis}}{{"\n"}}{{range .}}{{print "-" .}}{{"\n"}}{{end}}{{end}}{{end}}
`
const FileAnalysisOutput = `
-----{{.AnalyzeType}}-----
Analysis for {{.Image}}:{{if not .Analysis}} None{{else}}
FILE SIZE{{range .Analysis}}{{"\n"}}{{.Name}} {{.Size}}{{end}}
{{end}}
`
const FileLayerAnalysisOutput = `
-----{{.AnalyzeType}}-----
{{range $index, $analysis := .Analysis}}
Analysis for {{$.Image}} Layer {{$index}}:{{if not $analysis}} None{{else}}
FILE SIZE{{range $analysis}}{{"\n"}}{{.Name}} {{.Size}}{{end}}
{{end}}
{{end}}
`
const SizeAnalysisOutput = `
-----{{.AnalyzeType}}-----
Analysis for {{.Image}}:{{if not .Analysis}} None{{else}}
IMAGE DIGEST SIZE{{range .Analysis}}{{"\n"}}{{.Name}} {{.Digest}} {{.Size}}{{end}}
{{end}}
`
const SizeLayerAnalysisOutput = `
-----{{.AnalyzeType}}-----
Analysis for {{.Image}}:{{if not .Analysis}} None{{else}}
LAYER DIGEST SIZE{{range .Analysis}}{{"\n"}}{{.Name}} {{.Digest}} {{.Size}}{{end}}
{{end}}
`
const MultiVersionPackageOutput = `
-----{{.AnalyzeType}}-----
Packages found in {{.Image}}:{{if not .Analysis}} None{{else}}
NAME VERSION SIZE INSTALLATION{{range .Analysis}}{{"\n"}}{{print "-"}}{{.Name}} {{.Version}} {{.Size}} {{.Path}}{{end}}
{{end}}
`
const SingleVersionPackageOutput = `
-----{{.AnalyzeType}}-----
Packages found in {{.Image}}:{{if not .Analysis}} None{{else}}
NAME VERSION SIZE{{range .Analysis}}{{"\n"}}{{print "-"}}{{.Name}} {{.Version}} {{.Size}}{{end}}
{{end}}
`
const SingleVersionPackageLayerOutput = `
-----{{.AnalyzeType}}-----
{{range $index, $analysis := .Analysis}}
For Layer {{$index}}:{{if not (or (or $analysis.Packages1 $analysis.Packages2) $analysis.InfoDiff)}} No package changes {{else}}
{{if ne $index 0}}Deleted packages from previous layers:{{if not $analysis.Packages1}} None{{else}}
NAME VERSION SIZE{{range $analysis.Packages1}}{{"\n"}}{{print "-"}}{{.Name}} {{.Version}} {{.Size}}{{end}}{{end}}
{{end}}Packages added in this layer:{{if not $analysis.Packages2}} None{{else}}
NAME VERSION SIZE{{range $analysis.Packages2}}{{"\n"}}{{print "-"}}{{.Name}} {{.Version}} {{.Size}}{{end}}{{end}}
{{if ne $index 0}}
Version differences:{{if not $analysis.InfoDiff}} None{{else}}
PACKAGE PREV_LAYER CURRENT_LAYER {{range $analysis.InfoDiff}}{{"\n"}}{{print "-"}}{{.Package}} {{.Info1.Version}}, {{.Info1.Size}} {{.Info2.Version}}, {{.Info2.Size}}{{end}}
{{end}}{{end}}{{end}}
{{end}}
`