go-sprout / sprout

From sprig to sprout - Useful template functions for Go templates with steroids
https://sprout.atom.codes
MIT License
94 stars 3 forks source link

feat: implement registry system (alias: loader) #46

Closed 42atomys closed 2 months ago

42atomys commented 3 months ago

Description

Following the discussion about function loading in #31, this huge refactor implement each method behind multiples registries.

[!WARNING] This pull request are in progress, somes tests must be done before allowing it to be merge and release. Each feedback are welcome !

TODO

Changes

Fixes #10

Checklist

Additional Information

This update following the discussions #31

42atomys commented 3 months ago

First self feedback: allow registry to register aliases with functions

42atomys commented 2 months ago

Second step :

42atomys commented 2 months ago

Currently start the last step :

🎉 This pull request are done in case of functionalities and tests. This will be merged soon as the documentation are ready too

42atomys commented 2 months ago

Hi @ccoVeille, thanks for your contribution in reviewing this big PR 💜

According to multiple comments on the crypto package, this package was backported from sprig and will be dropped in a few versions due to significant security issues.

I've been focusing on rewriting and enhancing other registries, so I haven't made any changes to this one.

ccoVeille commented 2 months ago

Old code is not funny. Noted

caarlos0 commented 2 months ago

it looks really good! I liked the registry idea, and the implementation looks good!

lgtm!

42atomys commented 2 months ago

Thanks @ccoVeille and @caarlos0 for your time and your contribution to reviewing this next step of Sprout 🌱 💜

codecov[bot] commented 2 months ago

Codecov Report

Attention: Patch coverage is 96.87500% with 39 lines in your changes missing coverage. Please review.

Files Patch % Lines
registry/backward/functions.go 90.4% 2 Missing and 2 partials :warning:
registry/backward/backward.go 84.6% 2 Missing :warning:
registry/checksum/checksum.go 84.6% 2 Missing :warning:
registry/conversion/conversion.go 90.0% 2 Missing :warning:
registry/encoding/encoding.go 92.0% 2 Missing :warning:
registry/env/env.go 81.8% 2 Missing :warning:
registry/filesystem/filesystem.go 89.4% 2 Missing :warning:
registry/maps/maps.go 91.6% 2 Missing :warning:
registry/numeric/numeric.go 93.1% 2 Missing :warning:
registry/random/random.go 88.8% 2 Missing :warning:
... and 9 more
Files Coverage Δ
alias.go 100.0% <100.0%> (ø)
error.go 100.0% <100.0%> (ø)
handler.go 100.0% <100.0%> (ø)
internal/helpers/helpers.go 100.0% <100.0%> (ø)
pesticide/rand_test_helpers.go 100.0% <100.0%> (ø)
pesticide/test_helpers.go 100.0% <100.0%> (ø)
registry.go 100.0% <100.0%> (ø)
registry/checksum/functions.go 100.0% <100.0%> (ø)
registry/conversion/functions.go 100.0% <100.0%> (ø)
registry/encoding/functions.go 95.8% <100.0%> (ø)
... and 39 more