Skip to content

Commit

Permalink
Read XSD path from configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
jraddaoui committed Oct 31, 2024
1 parent c51ac66 commit 86321ba
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 1 deletion.
4 changes: 4 additions & 0 deletions enduro.toml
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,10 @@ namespace = "default"
taskQueue = "preprocessing"
workflowName = "preprocessing"

[validatePremis]
enabled = true
xsdPath = "/home/enduro/premis.xsd"

[failedSips]
endpoint = "http://minio.enduro-sdps:9000"
pathStyle = true
Expand Down
2 changes: 2 additions & 0 deletions hack/kube/base/enduro.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ spec:
value: "grafana-agent.enduro-sdps:4317"
- name: ENDURO_TELEMETRY_TRACES_SAMPLING_RATIO
value: "1.0"
- name: ENDURO_VALIDATEPREMIS_ENABLED
value: "false"
ports:
- containerPort: 9000
- containerPort: 9002
Expand Down
3 changes: 3 additions & 0 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"github.com/artefactual-sdps/enduro/internal/db"
"github.com/artefactual-sdps/enduro/internal/event"
"github.com/artefactual-sdps/enduro/internal/package_"
"github.com/artefactual-sdps/enduro/internal/premis"
"github.com/artefactual-sdps/enduro/internal/preprocessing"
"github.com/artefactual-sdps/enduro/internal/pres"
"github.com/artefactual-sdps/enduro/internal/storage"
Expand Down Expand Up @@ -54,6 +55,7 @@ type Configuration struct {
Upload package_.UploadConfig
Watcher watcher.Config
Telemetry telemetry.Config
ValidatePREMIS premis.Config

FailedSIPs bucket.Config
FailedPIPs bucket.Config
Expand All @@ -67,6 +69,7 @@ func (c *Configuration) Validate() error {
c.BagIt.Validate(),
c.Preprocessing.Validate(),
c.Upload.Validate(),
c.ValidatePREMIS.Validate(),
)
}

Expand Down
26 changes: 26 additions & 0 deletions internal/premis/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package premis

import (
"errors"
"fmt"
"os"
)

type Config struct {
Enabled bool
XSDPath string
}

// Validate implements config.ConfigurationValidator.
func (c Config) Validate() error {
if !c.Enabled {
return nil
}
if c.XSDPath == "" {
return errors.New("xsdPath is required in the [validatePremis] configuration when enabled")
}
if _, err := os.Stat(c.XSDPath); err != nil {
return fmt.Errorf("xsdPath in [validatePremis] not found: %v", err)
}
return nil
}
2 changes: 1 addition & 1 deletion internal/workflow/processing.go
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ func (w *ProcessingWorkflow) SessionHandler(
activityOpts := withActivityOptsForRequest(sessCtx)
err := temporalsdk_workflow.ExecuteActivity(activityOpts, xmlvalidate.Name, xmlvalidate.Params{
XMLPath: filepath.Join(tinfo.TempPath, "data", "metadata", "premis.xml"),
XSDPath: "/home/enduro/premis.xsd",
XSDPath: w.cfg.ValidatePREMIS.XSDPath,
}).Get(activityOpts, nil)
if err != nil {
return err
Expand Down

0 comments on commit 86321ba

Please sign in to comment.