@@ -44,11 +44,10 @@ type bundleSet map[string]*bundle
4444// the following constraints:
4545// 1. Completeness. For each bundle in the set, every bundle included by that
4646// bundle is also in the set.
47- // 2. Cycle-Free. The set contains no bundle include cycles.
4847func validateAndFillBundleSet (bundles bundleSet ) error {
4948 // Sort the bundles so that all includes and optional (also-add) includes appear
5049 // before a bundle, then calculate AllPackages for each bundle.
51- // Cycles and missing bundles are identified as part of sorting the bundles.
50+ // Missing bundles are identified as part of sorting the bundles.
5251 sortedBundles , err := sortBundles (bundles )
5352 if err != nil {
5453 return err
@@ -59,6 +58,15 @@ func validateAndFillBundleSet(bundles bundleSet) error {
5958 b .AllPackages [k ] = v
6059 }
6160 }
61+ for _ , b := range sortedBundles {
62+ if b .Header .Maintainer != "pundle" {
63+ for _ , include := range b .DirectIncludes {
64+ for k , v := range bundles [include ].AllPackages {
65+ b .AllPackages [k ] = v
66+ }
67+ }
68+ }
69+ }
6270
6371 return nil
6472}
@@ -85,6 +93,7 @@ func sortBundles(bundles bundleSet) ([]*bundle, error) {
8593 visit = func (b * bundle ) error {
8694 switch mark [b ] {
8795 case Visiting :
96+ // In a cycle, short circuit
8897 return nil
8998 case NotVisited :
9099 mark [b ] = Visiting
@@ -156,14 +165,21 @@ func validateBundleFile(filename string, lvl ValidationLevel) error {
156165 }
157166
158167 // Strict Validation
159- err = validateBundle (b )
160- if err != nil {
161- errText += err .Error () + "\n "
162- }
168+ if b .Header .Maintainer == "pundle" {
169+ err = validatePundle (b )
170+ if err != nil {
171+ errText += err .Error () + "\n "
172+ }
173+ } else {
174+ err = validateBundle (b )
175+ if err != nil {
176+ errText += err .Error () + "\n "
177+ }
163178
164- name := filepath .Base (filename )
165- if name != b .Header .Title {
166- errText += fmt .Sprintf ("Bundle name %q and bundle header Title %q do not match\n " , name , b .Header .Title )
179+ name := filepath .Base (filename )
180+ if name != b .Header .Title {
181+ errText += fmt .Sprintf ("Bundle name %q and bundle header Title %q do not match\n " , name , b .Header .Title )
182+ }
167183 }
168184
169185 if errText != "" {
@@ -190,6 +206,31 @@ func validateBundleFilename(filename string) error {
190206 return nil
191207}
192208
209+ func validatePundle (b * bundle ) error {
210+ var errText string
211+
212+ if b .Header .Title != "" {
213+ errText = fmt .Sprintf ("pundle name %q detected in pundle header Title (should be empty)\n " , b .Header .Title )
214+ }
215+ if b .Header .Description != "" {
216+ errText += "Non-empty Description in pundle header\n "
217+ }
218+ if b .Header .Maintainer != "pundle" {
219+ errText += "Non-pundle Maintainer in bundle header\n "
220+ }
221+ if b .Header .Status == "" {
222+ errText += "Non-empty Status in bundle header\n "
223+ }
224+ if b .Header .Capabilities == "" {
225+ errText += "Non-empty Capabilities in bundle header\n "
226+ }
227+ if errText != "" {
228+ return errors .New (strings .TrimSuffix (errText , "\n " ))
229+ }
230+
231+ return nil
232+ }
233+
193234func validateBundle (b * bundle ) error {
194235 var errText string
195236
0 commit comments