From 40ca2370b3fac5a47f7177c3e192105ae9601fc2 Mon Sep 17 00:00:00 2001 From: Mike Cantelon Date: Wed, 28 Aug 2024 14:02:13 -0700 Subject: [PATCH] work --- Dockerfile | 7 +++++++ cmd/enduro-am-worker/main.go | 5 +++++ internal/workflow/processing.go | 11 +++++++++++ 3 files changed, 23 insertions(+) diff --git a/Dockerfile b/Dockerfile index fb09f437..6d23d698 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,6 +3,12 @@ ARG TARGET=enduro ARG GO_VERSION +FROM golang:${GO_VERSION}-bookworm AS deb_extractor +RUN cd /tmp && \ + apt-get update && apt-get download libxml2-utils && \ + mkdir /dpkg && \ + for deb in *.deb; do dpkg --extract $deb /dpkg || exit 10; done + FROM golang:${GO_VERSION}-alpine AS build-go WORKDIR /src ENV CGO_ENABLED=0 @@ -66,5 +72,6 @@ FROM base AS enduro-am-worker COPY --from=build-enduro-am-worker --link /out/enduro-am-worker /home/enduro/bin/enduro-am-worker COPY --from=build-enduro-am-worker --link /src/enduro.toml /home/enduro/.config/enduro.toml CMD ["/home/enduro/bin/enduro-am-worker", "--config", "/home/enduro/.config/enduro.toml"] +COPY --from=deb_extractor /dpkg / FROM ${TARGET} diff --git a/cmd/enduro-am-worker/main.go b/cmd/enduro-am-worker/main.go index adc0a340..a6fc4c13 100644 --- a/cmd/enduro-am-worker/main.go +++ b/cmd/enduro-am-worker/main.go @@ -19,6 +19,7 @@ import ( "github.com/artefactual-sdps/temporal-activities/bagcreate" "github.com/artefactual-sdps/temporal-activities/bagvalidate" "github.com/artefactual-sdps/temporal-activities/removepaths" + "github.com/artefactual-sdps/temporal-activities/xmlvalidate" "github.com/hashicorp/go-cleanhttp" "github.com/jonboulle/clockwork" "github.com/oklog/run" @@ -303,6 +304,10 @@ func main() { removepaths.New().Execute, temporalsdk_activity.RegisterOptions{Name: removepaths.Name}, ) + w.RegisterActivityWithOptions( + xmlvalidate.New().Execute, + temporalsdk_activity.RegisterOptions{Name: xmlvalidate.Name}, + ) g.Add( func() error { diff --git a/internal/workflow/processing.go b/internal/workflow/processing.go index 85cde189..ab9eca23 100644 --- a/internal/workflow/processing.go +++ b/internal/workflow/processing.go @@ -19,6 +19,7 @@ import ( "github.com/artefactual-sdps/temporal-activities/bagcreate" "github.com/artefactual-sdps/temporal-activities/bagvalidate" "github.com/artefactual-sdps/temporal-activities/removepaths" + "github.com/artefactual-sdps/temporal-activities/xmlvalidate" "github.com/google/uuid" "go.artefactual.dev/tools/ref" temporal_tools "go.artefactual.dev/tools/temporal" @@ -417,6 +418,16 @@ func (w *ProcessingWorkflow) SessionHandler( return err } + // Validate PREMIS. + activityOpts := withActivityOptsForRequest(sessCtx) + err := temporalsdk_workflow.ExecuteActivity(activityOpts, xmlvalidate.Name, xmlvalidate.Params{ + XMLFilePath: filepath.Join(tinfo.TempPath, "data", "metadata", "premis.xml"), + XSDFilePath: tinfo.TempPath, + }).Get(activityOpts, nil) + if err != nil { + return err + } + // Classify the SIP. { activityOpts := withActivityOptsForLocalAction(sessCtx)