mirror of
https://github.com/coder/registry.git
synced 2026-06-02 20:48:14 +00:00
8b6a80b82d
This PR adds `golangci-lint` based on the configuration from `coder/coder` ([here](https://github.com/coder/coder/blob/main/.golangci.yaml)) then migrated to v2 using `golangci-lint migrate` plus the addition of few more linters. --------- Signed-off-by: Callum Styan <callumstyan@gmail.com>
50 lines
1.3 KiB
Go
50 lines
1.3 KiB
Go
// This package is for validating all contributors within the main Registry
|
|
// directory. It validates that it has nothing but sub-directories, and that
|
|
// each sub-directory has a README.md file. Each of those files must then
|
|
// describe a specific contributor. The contents of these files will be parsed
|
|
// by the Registry site build step, to be displayed in the Registry site's UI.
|
|
package main
|
|
|
|
import (
|
|
"context"
|
|
"log"
|
|
"os"
|
|
|
|
"cdr.dev/slog"
|
|
"cdr.dev/slog/sloggers/sloghuman"
|
|
)
|
|
|
|
var logger = slog.Make(sloghuman.Sink(os.Stdout))
|
|
|
|
func main() {
|
|
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.
|
|
err := validateRepoStructure()
|
|
if err != nil {
|
|
log.Println(err)
|
|
os.Exit(1)
|
|
}
|
|
|
|
var errs []error
|
|
err = validateAllContributorFiles()
|
|
if err != nil {
|
|
errs = append(errs, err)
|
|
}
|
|
err = validateAllCoderResourceFilesOfType("modules")
|
|
if err != nil {
|
|
errs = append(errs, err)
|
|
}
|
|
|
|
if len(errs) == 0 {
|
|
logger.Info(context.Background(), "processed all READMEs in directory", "dir", rootRegistryPath)
|
|
os.Exit(0)
|
|
}
|
|
for _, err := range errs {
|
|
logger.Error(context.Background(), err.Error())
|
|
}
|
|
os.Exit(1)
|
|
}
|