Check committed file sizes
This commit is contained in:
@@ -131,6 +131,15 @@ type ValidationSettings struct {
|
||||
// Omitted or false disables the check.
|
||||
GoFormat bool `json:"go_format,omitempty"`
|
||||
ModuleDistribution ModuleDistributionSettings `json:"module_distribution,omitempty"`
|
||||
// FileSize checks the size of each committed blob. Null or omission disables
|
||||
// the check; an empty object enables the default limit.
|
||||
FileSize *FileSizeSettings `json:"file_size,omitempty"`
|
||||
}
|
||||
|
||||
// FileSizeSettings selects the maximum committed-file size and literal exclusions.
|
||||
type FileSizeSettings struct {
|
||||
LimitBytes *int64 `json:"limit_bytes,omitempty"`
|
||||
Exclusions []string `json:"exclusions,omitempty"`
|
||||
}
|
||||
|
||||
// ModuleDistributionSettings selects committed module-source distribution checks.
|
||||
@@ -236,6 +245,9 @@ func LoadSettings(repoDir, configPath string) (Settings, error) {
|
||||
}
|
||||
}
|
||||
if settings.Validation != nil {
|
||||
if fileSize := settings.Validation.FileSize; fileSize != nil && fileSize.LimitBytes != nil && *fileSize.LimitBytes < 0 {
|
||||
return Settings{}, fmt.Errorf("profile %q: validation.file_size.limit_bytes must not be negative", configPath)
|
||||
}
|
||||
for i, target := range settings.Validation.Go.CompileTargets {
|
||||
if strings.Count(target, "/") != 1 {
|
||||
return Settings{}, fmt.Errorf("profile %q: validation.go.compile_targets[%d] must be GOOS/GOARCH", configPath, i)
|
||||
|
||||
Reference in New Issue
Block a user