diff --git a/cmd/readmevalidation/contributors.go b/cmd/readmevalidation/contributors.go index daee82c6d..53843dd37 100644 --- a/cmd/readmevalidation/contributors.go +++ b/cmd/readmevalidation/contributors.go @@ -16,15 +16,13 @@ import ( var validContributorStatuses = []string{"official", "partner", "community"} type contributorProfileFrontmatter struct { - DisplayName string `yaml:"display_name"` - Bio string `yaml:"bio"` - ContributorStatus string `yaml:"status"` - // Script assumes that if avatar URL is nil, the Registry site build step - // will backfill the value with the user's GitHub avatar URL - AvatarURL *string `yaml:"avatar"` - LinkedinURL *string `yaml:"linkedin"` - WebsiteURL *string `yaml:"website"` - SupportEmail *string `yaml:"support_email"` + DisplayName string `yaml:"display_name"` + Bio string `yaml:"bio"` + ContributorStatus string `yaml:"status"` + AvatarURL *string `yaml:"avatar"` + LinkedinURL *string `yaml:"linkedin"` + WebsiteURL *string `yaml:"website"` + SupportEmail *string `yaml:"support_email"` } type contributorProfileReadme struct { @@ -275,11 +273,8 @@ func aggregateContributorReadmeFiles() ([]readme, error) { func validateContributorRelativeUrls(contributors map[string]contributorProfileReadme) error { // This function only validates relative avatar URLs for now, but it can be // beefed up to validate more in the future - errs := []error{} - + var errs []error for _, con := range contributors { - // If the avatar URL is missing, we'll just assume that the Registry - // site build step will take care of filling in the data properly if con.frontmatter.AvatarURL == nil { continue } @@ -290,16 +285,18 @@ func validateContributorRelativeUrls(contributors map[string]contributorProfileR continue } - if strings.HasPrefix(*con.frontmatter.AvatarURL, "..") { + isAvatarInApprovedSpot := strings.HasPrefix(*con.frontmatter.AvatarURL, "./.images/") || + strings.HasPrefix(*con.frontmatter.AvatarURL, ".images/") + if !isAvatarInApprovedSpot { errs = append(errs, fmt.Errorf("%q: relative avatar URLs cannot be placed outside a user's namespaced directory", con.filePath)) continue } absolutePath := strings.TrimSuffix(con.filePath, "README.md") + *con.frontmatter.AvatarURL - _, err := os.ReadFile(absolutePath) + _, err := os.Stat(absolutePath) if err != nil { - errs = append(errs, fmt.Errorf("%q: relative avatar path %q does not point to image in file system", con.filePath, *con.frontmatter.AvatarURL)) + errs = append(errs, fmt.Errorf("%q: path %q does not point to image in file system", con.filePath, absolutePath)) } } diff --git a/cmd/readmevalidation/main.go b/cmd/readmevalidation/main.go index 6f33f7455..6a8b73fce 100644 --- a/cmd/readmevalidation/main.go +++ b/cmd/readmevalidation/main.go @@ -6,25 +6,30 @@ package main import ( - "fmt" + "context" "log" "os" + + "cdr.dev/slog" + "cdr.dev/slog/sloggers/sloghuman" ) +var logger = slog.Make(sloghuman.Sink(os.Stdout)) + func main() { - log.Println("Starting README validation") + logger.Info(context.Background(), "Starting README validation") // If there are fundamental problems with how the repo is structured, we // can't make any guarantees that any further validations will be relevant // or accurate - repoErr := validateRepoStructure() - if repoErr != nil { - log.Println(repoErr) + err := validateRepoStructure() + if err != nil { + log.Println(err) os.Exit(1) } var errs []error - err := validateAllContributorFiles() + err = validateAllContributorFiles() if err != nil { errs = append(errs, err) } @@ -34,11 +39,11 @@ func main() { } if len(errs) == 0 { - log.Printf("Processed all READMEs in the %q directory\n", rootRegistryPath) + logger.Info(context.Background(), "Processed all READMEs in directory", "dir", rootRegistryPath) os.Exit(0) } for _, err := range errs { - fmt.Println(err) + logger.Error(context.Background(), err.Error()) } os.Exit(1) } diff --git a/go.mod b/go.mod index e40742280..53e3a1c41 100644 --- a/go.mod +++ b/go.mod @@ -2,4 +2,24 @@ module coder.com/coder-registry go 1.23.2 -require gopkg.in/yaml.v3 v3.0.1 +require ( + cdr.dev/slog v1.6.1 + gopkg.in/yaml.v3 v3.0.1 +) + +require ( + github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect + github.com/charmbracelet/lipgloss v0.7.1 // indirect + github.com/lucasb-eyer/go-colorful v1.2.0 // indirect + github.com/mattn/go-isatty v0.0.19 // indirect + github.com/mattn/go-runewidth v0.0.15 // indirect + github.com/muesli/reflow v0.3.0 // indirect + github.com/muesli/termenv v0.15.2 // indirect + github.com/rivo/uniseg v0.4.4 // indirect + go.opentelemetry.io/otel v1.16.0 // indirect + go.opentelemetry.io/otel/trace v1.16.0 // indirect + golang.org/x/crypto v0.11.0 // indirect + golang.org/x/sys v0.10.0 // indirect + golang.org/x/term v0.10.0 // indirect + golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect +) diff --git a/go.sum b/go.sum index a62c313c5..12add4fb2 100644 --- a/go.sum +++ b/go.sum @@ -1,3 +1,37 @@ +cdr.dev/slog v1.6.1 h1:IQjWZD0x6//sfv5n+qEhbu3wBkmtBQY5DILXNvMaIv4= +cdr.dev/slog v1.6.1/go.mod h1:eHEYQLaZvxnIAXC+XdTSNLb/kgA/X2RVSF72v5wsxEI= +github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k= +github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8= +github.com/charmbracelet/lipgloss v0.7.1 h1:17WMwi7N1b1rVWOjMT+rCh7sQkvDU75B2hbZpc5Kc1E= +github.com/charmbracelet/lipgloss v0.7.1/go.mod h1:yG0k3giv8Qj8edTCbbg6AlQ5e8KNWpFujkNawKNhE2c= +github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY= +github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0= +github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA= +github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/mattn/go-runewidth v0.0.12/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk= +github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U= +github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= +github.com/muesli/reflow v0.3.0 h1:IFsN6K9NfGtjeggFP+68I4chLZV2yIKsXJFNZ+eWh6s= +github.com/muesli/reflow v0.3.0/go.mod h1:pbwTDkVPibjO2kyvBQRBxTWEEGDGq0FlB1BIKtnHY/8= +github.com/muesli/termenv v0.15.2 h1:GohcuySI0QmI3wN8Ok9PtKGkgkFIk7y6Vpb5PvrY+Wo= +github.com/muesli/termenv v0.15.2/go.mod h1:Epx+iuz8sNs7mNKhxzH4fWXGNpZwUaJKRS1noLXviQ8= +github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= +github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= +github.com/rivo/uniseg v0.4.4 h1:8TfxU8dW6PdqD27gjM8MVNuicgxIjxpm4K7x4jp8sis= +github.com/rivo/uniseg v0.4.4/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= +go.opentelemetry.io/otel v1.16.0 h1:Z7GVAX/UkAXPKsy94IU+i6thsQS4nb7LviLpnaNeW8s= +go.opentelemetry.io/otel v1.16.0/go.mod h1:vl0h9NUa1D5s1nv3A5vZOYWn8av4K8Ml6JDeHrT/bx4= +go.opentelemetry.io/otel/trace v1.16.0 h1:8JRpaObFoW0pxuVPapkgH8UhHQj+bJW8jJsCZEu5MQs= +go.opentelemetry.io/otel/trace v1.16.0/go.mod h1:Yt9vYq1SdNz3xdjZZK7wcXv1qv2pwLkqr2QVwea0ef0= +golang.org/x/crypto v0.11.0 h1:6Ewdq3tDic1mg5xRO4milcWCfMVQhI4NkqWWvqejpuA= +golang.org/x/crypto v0.11.0/go.mod h1:xgJhtzW8F9jGdVFWZESrid1U1bjeNy4zgy5cRr/CIio= +golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA= +golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.10.0 h1:3R7pNqamzBraeqj/Tj8qt1aQ2HpmlC+Cx/qL/7hn4/c= +golang.org/x/term v0.10.0/go.mod h1:lpqdcUyK/oCiQxvxVrppt5ggO2KCZ5QblwqPnfZ6d5o= +golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 h1:H2TDz8ibqkAF6YGhCdN3jS9O0/s90v0rJh3X/OLHEUk= +golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/registry/coder/.images/avatar.png b/registry/coder/.images/avatar.png new file mode 100644 index 000000000..b3e6ace7f Binary files /dev/null and b/registry/coder/.images/avatar.png differ diff --git a/registry/coder/README.md b/registry/coder/README.md index 13d5df2f0..7e2835768 100644 --- a/registry/coder/README.md +++ b/registry/coder/README.md @@ -2,6 +2,7 @@ display_name: Coder bio: Coder provisions cloud development environments via Terraform, supporting Linux, macOS, Windows, X86, ARM, Kubernetes and more. github: coder +avatar: ./.images/avatar.png linkedin: https://www.linkedin.com/company/coderhq website: https://www.coder.com status: official diff --git a/registry/nataindata/.images/avatar.png b/registry/nataindata/.images/avatar.png new file mode 100644 index 000000000..2e4de6337 Binary files /dev/null and b/registry/nataindata/.images/avatar.png differ diff --git a/registry/nataindata/README.md b/registry/nataindata/README.md index ddc5095f5..3e3beef38 100644 --- a/registry/nataindata/README.md +++ b/registry/nataindata/README.md @@ -2,6 +2,7 @@ display_name: Nataindata bio: Data engineer github: nataindata +avatar: ./.images/avatar.png website: https://www.nataindata.com status: community --- diff --git a/registry/thezoker/.images/avatar.jpeg b/registry/thezoker/.images/avatar.jpeg new file mode 100644 index 000000000..11238ad7a Binary files /dev/null and b/registry/thezoker/.images/avatar.jpeg differ diff --git a/registry/thezoker/README.md b/registry/thezoker/README.md index ba4ebf201..c174e1fcf 100644 --- a/registry/thezoker/README.md +++ b/registry/thezoker/README.md @@ -1,7 +1,8 @@ --- display_name: TheZoker -bio: I'm a master computer science student at the TU munich and a webdesigner. +bio: I'm a master computer science student at the TU munich and a web designer. github: TheZoker +avatar: ./.images/avatar.jpeg website: https://gareis.io/ status: community --- diff --git a/registry/whizus/.images/avatar.png b/registry/whizus/.images/avatar.png new file mode 100644 index 000000000..5ddd8c51e Binary files /dev/null and b/registry/whizus/.images/avatar.png differ diff --git a/registry/whizus/README.md b/registry/whizus/README.md index 7b6dec36b..8d29b6b23 100644 --- a/registry/whizus/README.md +++ b/registry/whizus/README.md @@ -1,6 +1,7 @@ --- display_name: WhizUs bio: WhizUs is your premier choice for DevOps, Kubernetes, and Cloud Native consulting. Based in Vienna we combine our expert solutions with a strong commitment to the community. Explore automation, scalability and drive success through collaboration. +avatar: ./.images/avatar.png github: WhizUs linkedin: https://www.linkedin.com/company/whizus website: https://www.whizus.com/