@@ -12,7 +12,7 @@ import (
1212 "strings"
1313 "sync"
1414
15- "sigs.k8s.io /yaml"
15+ "github.com/ghodss /yaml"
1616)
1717
1818const rootRegistryPath = "./registry"
@@ -306,6 +306,11 @@ website:
306306 }
307307 }
308308
309+ // Avatar URL
310+ if yml .AvatarUrl != nil {
311+
312+ }
313+
309314 return errors
310315}
311316
@@ -338,7 +343,12 @@ func remapContributorProfile(
338343 }
339344 if employeeGitHubNames != nil {
340345 remapped .EmployeeGithubUsernames = employeeGitHubNames [:]
341- slices .Sort (remapped .EmployeeGithubUsernames )
346+ slices .SortFunc (
347+ remapped .EmployeeGithubUsernames ,
348+ func (name1 string , name2 string ) int {
349+ return strings .Compare (name1 , name2 )
350+ },
351+ )
342352 }
343353
344354 return remapped
@@ -447,18 +457,36 @@ func parseContributorFiles(input []directoryReadme) (
447457}
448458
449459func backfillAvatarUrls (contributors map [string ]contributorProfile ) error {
460+ if contributors == nil {
461+ return errors .New ("provided map is nil" )
462+ }
463+
450464 wg := sync.WaitGroup {}
451- requestBuffer := make (chan struct {}, 10 )
452465 errors := []error {}
466+ errorsMutex := sync.Mutex {}
467+
468+ // Todo: Add actual fetching logic once everything else has been verified
469+ requestAvatarUrl := func (string ) (string , error ) {
470+ return "" , nil
471+ }
472+
473+ for ghUsername , conCopy := range contributors {
474+ if conCopy .AvatarUrl != "" {
475+ continue
476+ }
453477
454- for _ , c := range contributors {
455478 wg .Add (1 )
456479 go func () {
457- requestBuffer <- struct {}{}
458- // Do request stuff
459-
460- <- requestBuffer
461- wg .Done ()
480+ defer wg .Done ()
481+ url , err := requestAvatarUrl (ghUsername )
482+ if err != nil {
483+ errorsMutex .Lock ()
484+ errors = append (errors , err )
485+ errorsMutex .Unlock ()
486+ return
487+ }
488+ conCopy .AvatarUrl = url
489+ contributors [ghUsername ] = conCopy
462490 }()
463491 }
464492
@@ -481,12 +509,12 @@ func main() {
481509 if err != nil {
482510 log .Panic (err )
483511 }
512+
484513 allReadmeFiles := []directoryReadme {}
485514 fsErrors := workflowPhaseError {
486515 Phase : "FileSystem reading" ,
487516 Errors : []error {},
488517 }
489-
490518 for _ , e := range dirEntries {
491519 dirPath := path .Join (rootRegistryPath , e .Name ())
492520 if ! e .IsDir () {
0 commit comments