cedar-policy / cedar-go

Golang implementation of the Cedar Policy Language
Apache License 2.0
83 stars 9 forks source link

Add the extension types, datetime and duration #35

Closed apg closed 2 months ago

apg commented 2 months ago

See merged RFC 80.

This PR adds:

This does not extend ComparableValue to Decimal, as there's no RFC / specification to make that so (doing so would be straightforward, however).

Both datetime and duration are backed by an int64 and can be lifted from a Go time.Time and a time.Duration respectively. It would be possible to remove the struct wrapper around the int64, as no other state is stored. We aren't doing this to prevent accidental casting / type assertions that remove the semantic meaning of these values.

(Note: there was some previous discussion in the strongdm fork of this repo: https://github.com/strongdm/cedar-go/pull/3)

apg commented 2 months ago

@philhassey I think all of your comments have been addressed.

philhassey commented 2 months ago

I think this will be the next release, so maybe add in something to the README.md explaining the latest goodies in 0.3.2.

And also add some explanation as to how datetime is an accepted RFC, but it's a bit bleeding edge (as discussed in the meeting yesterday)

apg commented 2 months ago

OK. At 100% coverage for all changes. There's one line that's not covered in cedar_unmarshal that is unrelated to my changes. I tried to figure out a quick way to reach it, but failed. :)