feat(forbidden file): customize stdpath
Some checks failed
build / build (push) Failing after 1m18s
build / trigger-build-image (push) Has been skipped

This commit is contained in:
zzjc1234 2024-10-21 16:09:28 +08:00
parent 213bff201f
commit e1fdc17e14
2 changed files with 7 additions and 5 deletions

View File

@ -46,6 +46,8 @@ func main() {
localList := flag.String("localList", "", "local file list for non-ascii file check")
checkFileNameList := flag.String("checkFileNameList", "", "comma-separated list of files to check")
checkFileSumList := flag.String("checkFileSumList", "", "comma-separated list of expected checksums")
stdout := flag.String("stdout", "stdout", "location of stdout")
stderr := flag.String("stderr", "stderr", "location of stderr")
parseMultiValueFlag(&metaFile, "meta", "meta files to check")
// TODO: remove gitWhitelist, it is only for backward compatibility now
var gitWhitelist []string
@ -69,7 +71,7 @@ func main() {
if err != nil {
fmt.Printf("### Repo Size Check Failed:\n%s\n", err.Error())
}
err = healthcheck.ForbiddenCheck(*rootDir)
err = healthcheck.ForbiddenCheck(*rootDir, *stdout, *stderr)
if err != nil {
fmt.Printf("### Forbidden File Check Failed:\n%s\n", err.Error())
}

View File

@ -12,7 +12,7 @@ import (
// getForbiddens retrieves a list of forbidden files in the specified root directory.
// It searches for files that match the specified ignore patterns in the .gitignore file.
func getForbiddens(root string) ([]string, error) {
func getForbiddens(root string, stdout string, stderr string) ([]string, error) {
var matches []string
// Create a gitignore instance from the .gitignore file
@ -38,7 +38,7 @@ func getForbiddens(root string) ([]string, error) {
return err
}
// TODO: remove this temporary fix for stdout and stderr
if relPath == "stdout" || relPath == "stderr" {
if relPath == stdout || relPath == stderr {
return nil
}
match := ignore.Relative(relPath, true)
@ -56,8 +56,8 @@ func getForbiddens(root string) ([]string, error) {
// ForbiddenCheck checks for forbidden files in the specified root directory.
// It prints the list of forbidden files found, along with instructions on how to fix them.
func ForbiddenCheck(rootDir string) error {
forbids, err := getForbiddens(rootDir)
func ForbiddenCheck(rootDir string, stdout string, stderr string) error {
forbids, err := getForbiddens(rootDir, stdout, stderr)
if err != nil {
slog.Error("getting forbiddens", "error", err)
return fmt.Errorf("error getting forbiddens: %w", err)