Changes are broken down in to multiples commits to hopefully make reviewing easy. 1 commit for the slog change and then a commit per Go file for style changes. Style changes are generally: - try to use full sentences for all comments - try to stick to 120 column lines (not strict) instead of 80 - try to one line as many `call function, check if err != nil` blocks as possible (ex: only err or variables are not reused outside the if statement) - try to use `err` or `errs` for all return type names, previously used `problems` in some cases but `errs` in others - some minor readability changes - `Todo` -> `TODO`, sometimes also useful to do `TODO (name):` to make it easier to find things a specific author meant to follow up on - comments for types/functions should generally start with `// FunctionName/TypeName ...` --------- Signed-off-by: Callum Styan <callumstyan@gmail.com>
48 lines
1.3 KiB
Go
48 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"
|
|
"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 {
|
|
logger.Error(context.Background(), "error when validating the repo structure", "error", err.Error())
|
|
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)
|
|
}
|