1+ // This package is for validating all contributors within the main Registry
2+ // directory. It validates that it has nothing but sub-directories, and that
3+ // each sub-directory has a README.md file. Each of those files must then
4+ // describe a specific contributor. The contents of these files will be parsed
5+ // by the Registry site build step, to be displayed in the Registry site's UI.
16package main
27
38import (
@@ -104,7 +109,7 @@ func validateContributorGithubUsername(fm contributorFrontmatterWithFilePath) []
104109 problems = append (
105110 problems ,
106111 fmt .Errorf (
107- "missing GitHub username for %q " ,
112+ "%q: missing GitHub username" ,
108113 fm .FilePath ,
109114 ),
110115 )
@@ -116,9 +121,9 @@ func validateContributorGithubUsername(fm contributorFrontmatterWithFilePath) []
116121 problems = append (
117122 problems ,
118123 fmt .Errorf (
119- "gitHub username %q (%q) is not a valid URL path segment" ,
120- fm .GithubUsername ,
124+ "%q: gitHub username %q is not a valid URL path segment" ,
121125 fm .FilePath ,
126+ fm .GithubUsername ,
122127 ),
123128 )
124129 }
@@ -137,7 +142,7 @@ func validateContributorEmployerGithubUsername(fm contributorFrontmatterWithFile
137142 problems = append (
138143 problems ,
139144 fmt .Errorf (
140- "company_github field is defined but has empty value for %q " ,
145+ "%q: company_github field is defined but has empty value" ,
141146 fm .FilePath ,
142147 ),
143148 )
@@ -149,9 +154,9 @@ func validateContributorEmployerGithubUsername(fm contributorFrontmatterWithFile
149154 problems = append (
150155 problems ,
151156 fmt .Errorf (
152- "gitHub company username %q (%q) is not a valid URL path segment" ,
153- * fm .EmployerGithubUsername ,
157+ "%q: gitHub company username %q is not a valid URL path segment" ,
154158 fm .FilePath ,
159+ * fm .EmployerGithubUsername ,
155160 ),
156161 )
157162 }
@@ -160,9 +165,9 @@ func validateContributorEmployerGithubUsername(fm contributorFrontmatterWithFile
160165 problems = append (
161166 problems ,
162167 fmt .Errorf (
163- "cannot list own GitHub name (%q) as employer (%q)" ,
164- fm .GithubUsername ,
168+ "%q: cannot list own GitHub name (%q) as employer" ,
165169 fm .FilePath ,
170+ fm .GithubUsername ,
166171 ),
167172 )
168173 }
@@ -176,9 +181,9 @@ func validateContributorDisplayName(fm contributorFrontmatterWithFilePath) []err
176181 problems = append (
177182 problems ,
178183 fmt .Errorf (
179- "GitHub user %q (%q) is missing display name" ,
180- fm .GithubUsername ,
184+ "%q: GitHub user %q is missing display name" ,
181185 fm .FilePath ,
186+ fm .GithubUsername ,
182187 ),
183188 )
184189 }
@@ -196,7 +201,7 @@ func validateContributorLinkedinURL(fm contributorFrontmatterWithFilePath) []err
196201 problems = append (
197202 problems ,
198203 fmt .Errorf (
199- "linkedIn URL %q (%q) is not valid: %v" ,
204+ "%q: linkedIn URL %q is not valid: %v" ,
200205 * fm .LinkedinURL ,
201206 fm .FilePath ,
202207 err ,
@@ -223,9 +228,9 @@ func validateContributorEmail(fm contributorFrontmatterWithFilePath) []error {
223228 problems = append (
224229 problems ,
225230 fmt .Errorf (
226- "email address %q (%q) is missing @ symbol" ,
227- * fm .LinkedinURL ,
231+ "%q: email address %q is missing @ symbol" ,
228232 fm .FilePath ,
233+ * fm .LinkedinURL ,
229234 ),
230235 )
231236 return problems
@@ -235,9 +240,9 @@ func validateContributorEmail(fm contributorFrontmatterWithFilePath) []error {
235240 problems = append (
236241 problems ,
237242 fmt .Errorf (
238- "email address %q (%q) is missing username" ,
239- * fm .LinkedinURL ,
243+ "%q: email address %q is missing username" ,
240244 fm .FilePath ,
245+ * fm .LinkedinURL ,
241246 ),
242247 )
243248 }
@@ -247,9 +252,9 @@ func validateContributorEmail(fm contributorFrontmatterWithFilePath) []error {
247252 problems = append (
248253 problems ,
249254 fmt .Errorf (
250- "email address %q (%q) is missing period for server segment" ,
251- * fm .LinkedinURL ,
255+ "%q: email address %q is missing period for server segment" ,
252256 fm .FilePath ,
257+ * fm .LinkedinURL ,
253258 ),
254259 )
255260 return problems
@@ -259,9 +264,9 @@ func validateContributorEmail(fm contributorFrontmatterWithFilePath) []error {
259264 problems = append (
260265 problems ,
261266 fmt .Errorf (
262- "email address %q (%q) is missing domain" ,
263- * fm .LinkedinURL ,
267+ "%q: email address %q is missing domain" ,
264268 fm .FilePath ,
269+ * fm .LinkedinURL ,
265270 ),
266271 )
267272 }
@@ -270,9 +275,9 @@ func validateContributorEmail(fm contributorFrontmatterWithFilePath) []error {
270275 problems = append (
271276 problems ,
272277 fmt .Errorf (
273- "email address %q (%q) is missing top-level domain" ,
274- * fm .LinkedinURL ,
278+ "%q: email address %q is missing top-level domain" ,
275279 fm .FilePath ,
280+ * fm .LinkedinURL ,
276281 ),
277282 )
278283 }
@@ -281,7 +286,7 @@ func validateContributorEmail(fm contributorFrontmatterWithFilePath) []error {
281286 problems = append (
282287 problems ,
283288 fmt .Errorf (
284- "email for %q is not allowed to contain search parameters" ,
289+ "%q: email is not allowed to contain search parameters" ,
285290 fm .FilePath ,
286291 ),
287292 )
@@ -300,9 +305,9 @@ func validateContributorWebsite(fm contributorFrontmatterWithFilePath) []error {
300305 problems = append (
301306 problems ,
302307 fmt .Errorf (
303- "LinkedIn URL %q (%q) is not valid: %v" ,
304- * fm .WebsiteURL ,
308+ "%q: LinkedIn URL %q is not valid: %v" ,
305309 fm .FilePath ,
310+ * fm .WebsiteURL ,
306311 err ,
307312 ),
308313 )
@@ -322,9 +327,9 @@ func validateContributorStatus(fm contributorFrontmatterWithFilePath) []error {
322327 problems = append (
323328 problems ,
324329 fmt .Errorf (
325- "contributor status %q (%q) is not valid" ,
326- * fm .ContributorStatus ,
330+ "%q: contributor status %q is not valid" ,
327331 fm .FilePath ,
332+ * fm .ContributorStatus ,
328333 ),
329334 )
330335 }
@@ -344,7 +349,7 @@ func validateContributorAvatarURL(fm contributorFrontmatterWithFilePath) []error
344349 problems = append (
345350 problems ,
346351 fmt .Errorf (
347- "avatar URL for %q must be omitted or non-empty string" ,
352+ "%q: avatar URL must be omitted or non-empty string" ,
348353 fm .FilePath ,
349354 ),
350355 )
@@ -357,9 +362,9 @@ func validateContributorAvatarURL(fm contributorFrontmatterWithFilePath) []error
357362 problems = append (
358363 problems ,
359364 fmt .Errorf (
360- "error %q (%q) is not a valid relative or absolute URL" ,
361- * fm .AvatarURL ,
365+ "%q: URL %q is not a valid relative or absolute URL" ,
362366 fm .FilePath ,
367+ * fm .AvatarURL ,
363368 ),
364369 )
365370 }
@@ -368,7 +373,7 @@ func validateContributorAvatarURL(fm contributorFrontmatterWithFilePath) []error
368373 problems = append (
369374 problems ,
370375 fmt .Errorf (
371- "avatar URL for %q is not allowed to contain search parameters" ,
376+ "%q: avatar URL is not allowed to contain search parameters" ,
372377 fm .FilePath ,
373378 ),
374379 )
@@ -383,11 +388,14 @@ func validateContributorAvatarURL(fm contributorFrontmatterWithFilePath) []error
383388 }
384389 }
385390 if ! matched {
391+ segments := strings .Split (* fm .AvatarURL , "." )
392+ fileExtension := segments [len (segments )- 1 ]
386393 problems = append (
387394 problems ,
388395 fmt .Errorf (
389- "avatar URL for %q does not end in a supported file format: [%s]" ,
396+ "%q: avatar URL '.%s' does not end in a supported file format: [%s]" ,
390397 fm .FilePath ,
398+ fileExtension ,
391399 strings .Join (supportedFileFormats , ", " ),
392400 ),
393401 )
@@ -427,7 +435,7 @@ func parseContributorFiles(readmeEntries []readme) (
427435 if err != nil {
428436 yamlParsingErrors .Errors = append (
429437 yamlParsingErrors .Errors ,
430- fmt .Errorf ("failed to parse %q : %v" , rm .FilePath , err ),
438+ fmt .Errorf ("%q: failed to parse: %v" , rm .FilePath , err ),
431439 )
432440 continue
433441 }
@@ -436,7 +444,7 @@ func parseContributorFiles(readmeEntries []readme) (
436444 if err := yaml .Unmarshal ([]byte (fm ), & yml ); err != nil {
437445 yamlParsingErrors .Errors = append (
438446 yamlParsingErrors .Errors ,
439- fmt .Errorf ("failed to parse %q : %v" , rm .FilePath , err ),
447+ fmt .Errorf ("%q: failed to parse: %v" , rm .FilePath , err ),
440448 )
441449 continue
442450 }
@@ -449,10 +457,10 @@ func parseContributorFiles(readmeEntries []readme) (
449457 yamlParsingErrors .Errors = append (
450458 yamlParsingErrors .Errors ,
451459 fmt .Errorf (
452- "GitHub name conflict for %q for files %q and %q" ,
460+ "%q: GitHub name %s conflicts with field defined in %q" ,
461+ processed .FilePath ,
453462 processed .GithubUsername ,
454463 prev .FilePath ,
455- processed .FilePath ,
456464 ),
457465 )
458466 continue
@@ -583,9 +591,9 @@ func validateRelativeUrls(
583591 problems = append (
584592 problems ,
585593 fmt .Errorf (
586- "relative avatar path %q for %q does not point to image in file system" ,
587- * con .AvatarURL ,
594+ "%q: relative avatar path %q does not point to image in file system" ,
588595 con .FilePath ,
596+ * con .AvatarURL ,
589597 ),
590598 )
591599 }
0 commit comments