Skip to content

Commit d004200

Browse files
authored
chore: add avatars for each contributor (#117)
## Changes made - Added avatars for each contributor - Updated validation steps to account for avatars, if the avatar field exists - Went ahead and made some slog changes, ahead of @cstyan's refactor PR
1 parent a8d92df commit d004200

File tree

12 files changed

+86
-26
lines changed

12 files changed

+86
-26
lines changed

cmd/readmevalidation/contributors.go

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,13 @@ import (
1616
var validContributorStatuses = []string{"official", "partner", "community"}
1717

1818
type contributorProfileFrontmatter struct {
19-
DisplayName string `yaml:"display_name"`
20-
Bio string `yaml:"bio"`
21-
ContributorStatus string `yaml:"status"`
22-
// Script assumes that if avatar URL is nil, the Registry site build step
23-
// will backfill the value with the user's GitHub avatar URL
24-
AvatarURL *string `yaml:"avatar"`
25-
LinkedinURL *string `yaml:"linkedin"`
26-
WebsiteURL *string `yaml:"website"`
27-
SupportEmail *string `yaml:"support_email"`
19+
DisplayName string `yaml:"display_name"`
20+
Bio string `yaml:"bio"`
21+
ContributorStatus string `yaml:"status"`
22+
AvatarURL *string `yaml:"avatar"`
23+
LinkedinURL *string `yaml:"linkedin"`
24+
WebsiteURL *string `yaml:"website"`
25+
SupportEmail *string `yaml:"support_email"`
2826
}
2927

3028
type contributorProfileReadme struct {
@@ -275,11 +273,8 @@ func aggregateContributorReadmeFiles() ([]readme, error) {
275273
func validateContributorRelativeUrls(contributors map[string]contributorProfileReadme) error {
276274
// This function only validates relative avatar URLs for now, but it can be
277275
// beefed up to validate more in the future
278-
errs := []error{}
279-
276+
var errs []error
280277
for _, con := range contributors {
281-
// If the avatar URL is missing, we'll just assume that the Registry
282-
// site build step will take care of filling in the data properly
283278
if con.frontmatter.AvatarURL == nil {
284279
continue
285280
}
@@ -290,16 +285,18 @@ func validateContributorRelativeUrls(contributors map[string]contributorProfileR
290285
continue
291286
}
292287

293-
if strings.HasPrefix(*con.frontmatter.AvatarURL, "..") {
288+
isAvatarInApprovedSpot := strings.HasPrefix(*con.frontmatter.AvatarURL, "./.images/") ||
289+
strings.HasPrefix(*con.frontmatter.AvatarURL, ".images/")
290+
if !isAvatarInApprovedSpot {
294291
errs = append(errs, fmt.Errorf("%q: relative avatar URLs cannot be placed outside a user's namespaced directory", con.filePath))
295292
continue
296293
}
297294

298295
absolutePath := strings.TrimSuffix(con.filePath, "README.md") +
299296
*con.frontmatter.AvatarURL
300-
_, err := os.ReadFile(absolutePath)
297+
_, err := os.Stat(absolutePath)
301298
if err != nil {
302-
errs = append(errs, fmt.Errorf("%q: relative avatar path %q does not point to image in file system", con.filePath, *con.frontmatter.AvatarURL))
299+
errs = append(errs, fmt.Errorf("%q: path %q does not point to image in file system", con.filePath, absolutePath))
303300
}
304301
}
305302

cmd/readmevalidation/main.go

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,30 @@
66
package main
77

88
import (
9-
"fmt"
9+
"context"
1010
"log"
1111
"os"
12+
13+
"cdr.dev/slog"
14+
"cdr.dev/slog/sloggers/sloghuman"
1215
)
1316

17+
var logger = slog.Make(sloghuman.Sink(os.Stdout))
18+
1419
func main() {
15-
log.Println("Starting README validation")
20+
logger.Info(context.Background(), "Starting README validation")
1621

1722
// If there are fundamental problems with how the repo is structured, we
1823
// can't make any guarantees that any further validations will be relevant
1924
// or accurate
20-
repoErr := validateRepoStructure()
21-
if repoErr != nil {
22-
log.Println(repoErr)
25+
err := validateRepoStructure()
26+
if err != nil {
27+
log.Println(err)
2328
os.Exit(1)
2429
}
2530

2631
var errs []error
27-
err := validateAllContributorFiles()
32+
err = validateAllContributorFiles()
2833
if err != nil {
2934
errs = append(errs, err)
3035
}
@@ -34,11 +39,11 @@ func main() {
3439
}
3540

3641
if len(errs) == 0 {
37-
log.Printf("Processed all READMEs in the %q directory\n", rootRegistryPath)
42+
logger.Info(context.Background(), "Processed all READMEs in directory", "dir", rootRegistryPath)
3843
os.Exit(0)
3944
}
4045
for _, err := range errs {
41-
fmt.Println(err)
46+
logger.Error(context.Background(), err.Error())
4247
}
4348
os.Exit(1)
4449
}

go.mod

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,24 @@ module coder.com/coder-registry
22

33
go 1.23.2
44

5-
require gopkg.in/yaml.v3 v3.0.1
5+
require (
6+
cdr.dev/slog v1.6.1
7+
gopkg.in/yaml.v3 v3.0.1
8+
)
9+
10+
require (
11+
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
12+
github.com/charmbracelet/lipgloss v0.7.1 // indirect
13+
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
14+
github.com/mattn/go-isatty v0.0.19 // indirect
15+
github.com/mattn/go-runewidth v0.0.15 // indirect
16+
github.com/muesli/reflow v0.3.0 // indirect
17+
github.com/muesli/termenv v0.15.2 // indirect
18+
github.com/rivo/uniseg v0.4.4 // indirect
19+
go.opentelemetry.io/otel v1.16.0 // indirect
20+
go.opentelemetry.io/otel/trace v1.16.0 // indirect
21+
golang.org/x/crypto v0.11.0 // indirect
22+
golang.org/x/sys v0.10.0 // indirect
23+
golang.org/x/term v0.10.0 // indirect
24+
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
25+
)

go.sum

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,37 @@
1+
cdr.dev/slog v1.6.1 h1:IQjWZD0x6//sfv5n+qEhbu3wBkmtBQY5DILXNvMaIv4=
2+
cdr.dev/slog v1.6.1/go.mod h1:eHEYQLaZvxnIAXC+XdTSNLb/kgA/X2RVSF72v5wsxEI=
3+
github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k=
4+
github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8=
5+
github.com/charmbracelet/lipgloss v0.7.1 h1:17WMwi7N1b1rVWOjMT+rCh7sQkvDU75B2hbZpc5Kc1E=
6+
github.com/charmbracelet/lipgloss v0.7.1/go.mod h1:yG0k3giv8Qj8edTCbbg6AlQ5e8KNWpFujkNawKNhE2c=
7+
github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
8+
github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
9+
github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA=
10+
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
11+
github.com/mattn/go-runewidth v0.0.12/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk=
12+
github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U=
13+
github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
14+
github.com/muesli/reflow v0.3.0 h1:IFsN6K9NfGtjeggFP+68I4chLZV2yIKsXJFNZ+eWh6s=
15+
github.com/muesli/reflow v0.3.0/go.mod h1:pbwTDkVPibjO2kyvBQRBxTWEEGDGq0FlB1BIKtnHY/8=
16+
github.com/muesli/termenv v0.15.2 h1:GohcuySI0QmI3wN8Ok9PtKGkgkFIk7y6Vpb5PvrY+Wo=
17+
github.com/muesli/termenv v0.15.2/go.mod h1:Epx+iuz8sNs7mNKhxzH4fWXGNpZwUaJKRS1noLXviQ8=
18+
github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
19+
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
20+
github.com/rivo/uniseg v0.4.4 h1:8TfxU8dW6PdqD27gjM8MVNuicgxIjxpm4K7x4jp8sis=
21+
github.com/rivo/uniseg v0.4.4/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
22+
go.opentelemetry.io/otel v1.16.0 h1:Z7GVAX/UkAXPKsy94IU+i6thsQS4nb7LviLpnaNeW8s=
23+
go.opentelemetry.io/otel v1.16.0/go.mod h1:vl0h9NUa1D5s1nv3A5vZOYWn8av4K8Ml6JDeHrT/bx4=
24+
go.opentelemetry.io/otel/trace v1.16.0 h1:8JRpaObFoW0pxuVPapkgH8UhHQj+bJW8jJsCZEu5MQs=
25+
go.opentelemetry.io/otel/trace v1.16.0/go.mod h1:Yt9vYq1SdNz3xdjZZK7wcXv1qv2pwLkqr2QVwea0ef0=
26+
golang.org/x/crypto v0.11.0 h1:6Ewdq3tDic1mg5xRO4milcWCfMVQhI4NkqWWvqejpuA=
27+
golang.org/x/crypto v0.11.0/go.mod h1:xgJhtzW8F9jGdVFWZESrid1U1bjeNy4zgy5cRr/CIio=
28+
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
29+
golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA=
30+
golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
31+
golang.org/x/term v0.10.0 h1:3R7pNqamzBraeqj/Tj8qt1aQ2HpmlC+Cx/qL/7hn4/c=
32+
golang.org/x/term v0.10.0/go.mod h1:lpqdcUyK/oCiQxvxVrppt5ggO2KCZ5QblwqPnfZ6d5o=
33+
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 h1:H2TDz8ibqkAF6YGhCdN3jS9O0/s90v0rJh3X/OLHEUk=
34+
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8=
135
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
236
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
337
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=

registry/coder/.images/avatar.png

22.3 KB
Loading

registry/coder/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
display_name: Coder
33
bio: Coder provisions cloud development environments via Terraform, supporting Linux, macOS, Windows, X86, ARM, Kubernetes and more.
44
github: coder
5+
avatar: ./.images/avatar.png
56
linkedin: https://www.linkedin.com/company/coderhq
67
website: https://www.coder.com
78
status: official
121 KB
Loading

registry/nataindata/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
display_name: Nataindata
33
bio: Data engineer
44
github: nataindata
5+
avatar: ./.images/avatar.png
56
website: https://www.nataindata.com
67
status: community
78
---

registry/thezoker/.images/avatar.jpeg

21 KB
Loading

registry/thezoker/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
---
22
display_name: TheZoker
3-
bio: I'm a master computer science student at the TU munich and a webdesigner.
3+
bio: I'm a master computer science student at the TU munich and a web designer.
44
github: TheZoker
5+
avatar: ./.images/avatar.jpeg
56
website: https://gareis.io/
67
status: community
78
---

0 commit comments

Comments
 (0)