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.
1
6
package main
2
7
3
8
import (
@@ -104,7 +109,7 @@ func validateContributorGithubUsername(fm contributorFrontmatterWithFilePath) []
104
109
problems = append (
105
110
problems ,
106
111
fmt .Errorf (
107
- "missing GitHub username for %q " ,
112
+ "%q: missing GitHub username" ,
108
113
fm .FilePath ,
109
114
),
110
115
)
@@ -116,9 +121,9 @@ func validateContributorGithubUsername(fm contributorFrontmatterWithFilePath) []
116
121
problems = append (
117
122
problems ,
118
123
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" ,
121
125
fm .FilePath ,
126
+ fm .GithubUsername ,
122
127
),
123
128
)
124
129
}
@@ -137,7 +142,7 @@ func validateContributorEmployerGithubUsername(fm contributorFrontmatterWithFile
137
142
problems = append (
138
143
problems ,
139
144
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" ,
141
146
fm .FilePath ,
142
147
),
143
148
)
@@ -149,9 +154,9 @@ func validateContributorEmployerGithubUsername(fm contributorFrontmatterWithFile
149
154
problems = append (
150
155
problems ,
151
156
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" ,
154
158
fm .FilePath ,
159
+ * fm .EmployerGithubUsername ,
155
160
),
156
161
)
157
162
}
@@ -160,9 +165,9 @@ func validateContributorEmployerGithubUsername(fm contributorFrontmatterWithFile
160
165
problems = append (
161
166
problems ,
162
167
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" ,
165
169
fm .FilePath ,
170
+ fm .GithubUsername ,
166
171
),
167
172
)
168
173
}
@@ -176,9 +181,9 @@ func validateContributorDisplayName(fm contributorFrontmatterWithFilePath) []err
176
181
problems = append (
177
182
problems ,
178
183
fmt .Errorf (
179
- "GitHub user %q (%q) is missing display name" ,
180
- fm .GithubUsername ,
184
+ "%q: GitHub user %q is missing display name" ,
181
185
fm .FilePath ,
186
+ fm .GithubUsername ,
182
187
),
183
188
)
184
189
}
@@ -196,7 +201,7 @@ func validateContributorLinkedinURL(fm contributorFrontmatterWithFilePath) []err
196
201
problems = append (
197
202
problems ,
198
203
fmt .Errorf (
199
- "linkedIn URL %q (%q) is not valid: %v" ,
204
+ "%q: linkedIn URL %q is not valid: %v" ,
200
205
* fm .LinkedinURL ,
201
206
fm .FilePath ,
202
207
err ,
@@ -223,9 +228,9 @@ func validateContributorEmail(fm contributorFrontmatterWithFilePath) []error {
223
228
problems = append (
224
229
problems ,
225
230
fmt .Errorf (
226
- "email address %q (%q) is missing @ symbol" ,
227
- * fm .LinkedinURL ,
231
+ "%q: email address %q is missing @ symbol" ,
228
232
fm .FilePath ,
233
+ * fm .LinkedinURL ,
229
234
),
230
235
)
231
236
return problems
@@ -235,9 +240,9 @@ func validateContributorEmail(fm contributorFrontmatterWithFilePath) []error {
235
240
problems = append (
236
241
problems ,
237
242
fmt .Errorf (
238
- "email address %q (%q) is missing username" ,
239
- * fm .LinkedinURL ,
243
+ "%q: email address %q is missing username" ,
240
244
fm .FilePath ,
245
+ * fm .LinkedinURL ,
241
246
),
242
247
)
243
248
}
@@ -247,9 +252,9 @@ func validateContributorEmail(fm contributorFrontmatterWithFilePath) []error {
247
252
problems = append (
248
253
problems ,
249
254
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" ,
252
256
fm .FilePath ,
257
+ * fm .LinkedinURL ,
253
258
),
254
259
)
255
260
return problems
@@ -259,9 +264,9 @@ func validateContributorEmail(fm contributorFrontmatterWithFilePath) []error {
259
264
problems = append (
260
265
problems ,
261
266
fmt .Errorf (
262
- "email address %q (%q) is missing domain" ,
263
- * fm .LinkedinURL ,
267
+ "%q: email address %q is missing domain" ,
264
268
fm .FilePath ,
269
+ * fm .LinkedinURL ,
265
270
),
266
271
)
267
272
}
@@ -270,9 +275,9 @@ func validateContributorEmail(fm contributorFrontmatterWithFilePath) []error {
270
275
problems = append (
271
276
problems ,
272
277
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" ,
275
279
fm .FilePath ,
280
+ * fm .LinkedinURL ,
276
281
),
277
282
)
278
283
}
@@ -281,7 +286,7 @@ func validateContributorEmail(fm contributorFrontmatterWithFilePath) []error {
281
286
problems = append (
282
287
problems ,
283
288
fmt .Errorf (
284
- "email for %q is not allowed to contain search parameters" ,
289
+ "%q: email is not allowed to contain search parameters" ,
285
290
fm .FilePath ,
286
291
),
287
292
)
@@ -300,9 +305,9 @@ func validateContributorWebsite(fm contributorFrontmatterWithFilePath) []error {
300
305
problems = append (
301
306
problems ,
302
307
fmt .Errorf (
303
- "LinkedIn URL %q (%q) is not valid: %v" ,
304
- * fm .WebsiteURL ,
308
+ "%q: LinkedIn URL %q is not valid: %v" ,
305
309
fm .FilePath ,
310
+ * fm .WebsiteURL ,
306
311
err ,
307
312
),
308
313
)
@@ -322,9 +327,9 @@ func validateContributorStatus(fm contributorFrontmatterWithFilePath) []error {
322
327
problems = append (
323
328
problems ,
324
329
fmt .Errorf (
325
- "contributor status %q (%q) is not valid" ,
326
- * fm .ContributorStatus ,
330
+ "%q: contributor status %q is not valid" ,
327
331
fm .FilePath ,
332
+ * fm .ContributorStatus ,
328
333
),
329
334
)
330
335
}
@@ -344,7 +349,7 @@ func validateContributorAvatarURL(fm contributorFrontmatterWithFilePath) []error
344
349
problems = append (
345
350
problems ,
346
351
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" ,
348
353
fm .FilePath ,
349
354
),
350
355
)
@@ -357,9 +362,9 @@ func validateContributorAvatarURL(fm contributorFrontmatterWithFilePath) []error
357
362
problems = append (
358
363
problems ,
359
364
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" ,
362
366
fm .FilePath ,
367
+ * fm .AvatarURL ,
363
368
),
364
369
)
365
370
}
@@ -368,7 +373,7 @@ func validateContributorAvatarURL(fm contributorFrontmatterWithFilePath) []error
368
373
problems = append (
369
374
problems ,
370
375
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" ,
372
377
fm .FilePath ,
373
378
),
374
379
)
@@ -383,11 +388,14 @@ func validateContributorAvatarURL(fm contributorFrontmatterWithFilePath) []error
383
388
}
384
389
}
385
390
if ! matched {
391
+ segments := strings .Split (* fm .AvatarURL , "." )
392
+ fileExtension := segments [len (segments )- 1 ]
386
393
problems = append (
387
394
problems ,
388
395
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]" ,
390
397
fm .FilePath ,
398
+ fileExtension ,
391
399
strings .Join (supportedFileFormats , ", " ),
392
400
),
393
401
)
@@ -427,7 +435,7 @@ func parseContributorFiles(readmeEntries []readme) (
427
435
if err != nil {
428
436
yamlParsingErrors .Errors = append (
429
437
yamlParsingErrors .Errors ,
430
- fmt .Errorf ("failed to parse %q : %v" , rm .FilePath , err ),
438
+ fmt .Errorf ("%q: failed to parse: %v" , rm .FilePath , err ),
431
439
)
432
440
continue
433
441
}
@@ -436,7 +444,7 @@ func parseContributorFiles(readmeEntries []readme) (
436
444
if err := yaml .Unmarshal ([]byte (fm ), & yml ); err != nil {
437
445
yamlParsingErrors .Errors = append (
438
446
yamlParsingErrors .Errors ,
439
- fmt .Errorf ("failed to parse %q : %v" , rm .FilePath , err ),
447
+ fmt .Errorf ("%q: failed to parse: %v" , rm .FilePath , err ),
440
448
)
441
449
continue
442
450
}
@@ -449,10 +457,10 @@ func parseContributorFiles(readmeEntries []readme) (
449
457
yamlParsingErrors .Errors = append (
450
458
yamlParsingErrors .Errors ,
451
459
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 ,
453
462
processed .GithubUsername ,
454
463
prev .FilePath ,
455
- processed .FilePath ,
456
464
),
457
465
)
458
466
continue
@@ -583,9 +591,9 @@ func validateRelativeUrls(
583
591
problems = append (
584
592
problems ,
585
593
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" ,
588
595
con .FilePath ,
596
+ * con .AvatarURL ,
589
597
),
590
598
)
591
599
}
0 commit comments