Add typed Notarius cache controls
This commit is contained in:
@@ -39,10 +39,12 @@ func validateNotarius(cfg *NotariusConfig, scriptorium *ScriptoriumConfig) error
|
||||
if len(cfg.References) > MaxNotariusReferenceBindings {
|
||||
return fmt.Errorf("pipeline.notarius.references must contain at most %d bindings", MaxNotariusReferenceBindings)
|
||||
}
|
||||
|
||||
if err := validateNotariusCanonicalScalars(cfg); err != nil {
|
||||
return err
|
||||
}
|
||||
if !validNotariusChunkCacheMode(cfg.ChunkCache) {
|
||||
return fmt.Errorf("pipeline.notarius.chunk_cache must be empty, auto, bypass, or refresh")
|
||||
}
|
||||
if err := validateNotariusReferences(cfg.References); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -56,6 +58,7 @@ func validateNotariusCanonicalScalars(cfg *NotariusConfig) error {
|
||||
want string
|
||||
}{
|
||||
{name: "binary", got: cfg.Binary, want: strings.TrimSpace(cfg.Binary)},
|
||||
{name: "chunk_cache", got: cfg.ChunkCache, want: strings.TrimSpace(cfg.ChunkCache)},
|
||||
{name: "config_path", got: cfg.ConfigPath, want: cleanNotariusPath(cfg.ConfigPath)},
|
||||
{name: "pipeline_id", got: cfg.PipelineID, want: strings.TrimSpace(cfg.PipelineID)},
|
||||
{name: "timeout", got: cfg.Timeout, want: strings.TrimSpace(cfg.Timeout)},
|
||||
@@ -69,6 +72,15 @@ func validateNotariusCanonicalScalars(cfg *NotariusConfig) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func validNotariusChunkCacheMode(mode string) bool {
|
||||
switch mode {
|
||||
case "", "auto", "bypass", "refresh":
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
func normalizeNotariusReferences(references map[string]string) (map[string]string, error) {
|
||||
selectors := make([]string, 0, len(references))
|
||||
for selector := range references {
|
||||
|
||||
Reference in New Issue
Block a user