Files
distributor/internal/app/validate.go

33 lines
641 B
Go
Raw Normal View History

2026-05-31 01:47:39 +00:00
package app
import (
"context"
"fmt"
"io"
"gitea.maximumdirect.net/eric/distributor/internal/bundle"
2026-05-31 01:47:39 +00:00
)
type ValidateOptions struct {
Path string
Stdout io.Writer
2026-05-31 01:47:39 +00:00
}
func Validate(ctx context.Context, options ValidateOptions) error {
if options.Path == "" {
return fmt.Errorf("validate command requires a path")
}
2026-05-31 03:27:49 +00:00
backend, err := newBackendFactory().openLocalPath(ctx, options.Path)
if err != nil {
return err
}
bundles, err := bundle.Discover(ctx, backend, "")
if err != nil {
return err
}
if options.Stdout != nil {
_, err = fmt.Fprintf(options.Stdout, "Validated %d bundle(s)\n", len(bundles))
}
return err
2026-05-31 01:47:39 +00:00
}