@@ -20,6 +20,8 @@ import (
2020 "gopkg.in/yaml.v3"
2121)
2222
23+ var errCompliance = errors .New ("compliance check failed" )
24+
2325type loadOptions struct {
2426 lint bool
2527 ignoreLintErrors bool
@@ -73,7 +75,7 @@ func loadSource(in io.Reader) (k6registry.Registry, error) {
7375 return registry , nil
7476}
7577
76- func loadOne (ctx context.Context , ext * k6registry.Extension , lint bool , checks []string , ignoreLintErrors bool ) error {
78+ func loadOne (ctx context.Context , ext * k6registry.Extension , lint bool , checks []string ) error {
7779 if len (ext .Tier ) == 0 {
7880 ext .Tier = k6registry .TierCommunity
7981 }
@@ -97,6 +99,7 @@ func loadOne(ctx context.Context, ext *k6registry.Extension, lint bool, checks [
9799 ext .Compliance = make (k6registry.ExtensionCompliance )
98100 }
99101
102+ complianceErrors := []error {}
100103 for _ , version := range ext .Versions {
101104 official := ext .Tier == k6registry .TierOfficial
102105
@@ -106,7 +109,6 @@ func loadOne(ctx context.Context, ext *k6registry.Extension, lint bool, checks [
106109 version ,
107110 official ,
108111 checks ,
109- ignoreLintErrors ,
110112 repo .CloneURL ,
111113 int64 (repo .Timestamp ),
112114 )
@@ -122,12 +124,16 @@ func loadOne(ctx context.Context, ext *k6registry.Extension, lint bool, checks [
122124 }
123125 }
124126
127+ if len (issues ) > 0 {
128+ complianceErrors = append (complianceErrors , fmt .Errorf ("%w %s@%s" , errCompliance , ext .Module , version ))
129+ }
130+
125131 ext .Compliance [version ] = k6registry.Compliance {
126132 Issues : issues ,
127133 }
128134 }
129135
130- return nil
136+ return errors . Join ( complianceErrors ... )
131137}
132138
133139func load (
@@ -140,14 +146,19 @@ func load(
140146 return nil , err
141147 }
142148
149+ compliancedErrors := []error {}
143150 for idx := range registry {
144151 ext := & registry [idx ]
145152
146153 slog .Debug ("Process extension" , "module" , ext .Module )
147154
148- err := loadOne (ctx , ext , opts .lint , opts .lintChecks , opts . ignoreLintErrors )
155+ err := loadOne (ctx , ext , opts .lint , opts .lintChecks )
149156 if err != nil {
150- return nil , err
157+ if ! errors .Is (err , errCompliance ) {
158+ return nil , err
159+ }
160+
161+ compliancedErrors = append (compliancedErrors , err )
151162 }
152163
153164 if len (ext .Constraints ) > 0 {
@@ -164,7 +175,17 @@ func load(
164175 }
165176 }
166177
167- return registry , nil
178+ if len (compliancedErrors ) == 0 {
179+ return registry , nil
180+ }
181+
182+ slog .Warn (errors .Join (compliancedErrors ... ).Error ())
183+
184+ if opts .ignoreLintErrors {
185+ return registry , nil
186+ }
187+
188+ return registry , errCompliance
168189}
169190
170191func loadRepository (ctx context.Context , ext * k6registry.Extension ) (* k6registry.Repository , []string , error ) {
0 commit comments