artefactual-sdps / temporal-activities

Temporal activities is a library of general purpose activities
Apache License 2.0
1 stars 0 forks source link

Add an activity to create a BagIt bag (refs #11) #16

Closed djjuhasz closed 6 months ago

djjuhasz commented 6 months ago
codecov[bot] commented 6 months ago

Codecov Report

Attention: Patch coverage is 94.11765% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 80.92%. Comparing base (c6647df) to head (82579f8).

:exclamation: Current head 82579f8 differs from pull request most recent head 0d1f5de

Please upload reports for the commit 0d1f5de to get more accurate results.

Files Patch % Lines
bagit/create_bag_activity.go 90.90% 1 Missing and 1 partial :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #16 +/- ## ========================================== + Coverage 77.69% 80.92% +3.22% ========================================== Files 3 5 +2 Lines 139 173 +34 ========================================== + Hits 108 140 +32 - Misses 17 18 +1 - Partials 14 15 +1 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

djjuhasz commented 6 months ago

@jraddaoui I've added bagit.Config Validate() method that uses https://pkg.go.dev/github.com/go-playground/validator/v10 to do the validation. I think using https://pkg.go.dev/github.com/go-playground/validator/v10 is overkill for validating this one field, but I wanted to explore it as a general validation library we could potentially use for general config validation in Enduro.

Before I tried this validation method I went down the road of defining a HashAlgorithm "enum" type and validating against that. Implementing an enum in Go has it's own drawbacks though (see https://github.com/artefactual-sdps/enduro/issues/516), so I decided to try https://pkg.go.dev/github.com/go-playground/validator/v10.

I'm open to using a validator or an enum here, as there are trade-offs for both methods. What do you think?

djjuhasz commented 6 months ago

P.S. obviously I could just implement a simple Validate() method for "ChecksumAlgorithm" that doesn't use any third-party libraries, but I think this is a general problem that calls for a general solution.