Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the extension types, datetime and duration #35

Merged
merged 4 commits into from
Sep 19, 2024

Commits on Sep 18, 2024

  1. This commit adds an extension type, datetime, to Cedar Go.

    This PR does not add the duration type, nor the methods `toTime()`,
    `offset()`, or `durationSince()` that would require it.
    
    This PR adds operator overloading, by introducing a set of "Virtual"
    comparison Evaler. Types that can overload operators must implement
    the `Lesser` interface. Long and Datetime are implemented in this
    PR. (Note: It is expected that there will be a Decimal operator
    overload RFC at some later date, but that is not hooked into this)
    
    The now obsolete Evalers for Long comparisons have not been
    removed. A possible improvement to this PR would be to utilize
    them when it is known that Longs are on the right and left side.
    
    The datetime itself is backed by an int64, and can be lifted from
    a Go `time.Time`, integer or float "unsafely."
    
    Signed-off-by: Andrew Gwozdziewycz <[email protected]>
    apg committed Sep 18, 2024
    Configuration menu
    Copy the full SHA
    537c4d8 View commit details
    Browse the repository at this point in the history
  2. Add a duration type, as per RFC 80.

    This builds on the Datetime PR.
    
    It adds the duration type, and all of the associated methods that
    require durations:
    
    - datetime.toTime
    - datetime.offset
    - datetime.durationSince
    - duration.toMilliseconds
    - duration.toSeconds
    - duration.toMinutes
    - duration.toHours
    - duration.toDays
    
    Signed-off-by: Andrew Gwozdziewycz <[email protected]>
    apg committed Sep 18, 2024
    Configuration menu
    Copy the full SHA
    e8728bb View commit details
    Browse the repository at this point in the history
  3. Address PR Feedback

    - Lesser becomes ComparableValue
    - Move ComparableValue to evalers only
    - Move all magic values to constants
    - TypeError when incompatible comparable types
    - Support more deserialization for duration/datetime
    - Make the datetime parser easier to follow
    - Drop UnsafeDatetime in favor of FromStdTime(time.UnixMilli(..))
    - Document methods
    - Test Coverage to 100%
    
    Signed-off-by: Andrew Gwozdziewycz <[email protected]>
    apg committed Sep 18, 2024
    Configuration menu
    Copy the full SHA
    a4e576e View commit details
    Browse the repository at this point in the history
  4. Update the README indicating datetime / duration support

    Signed-off-by: Andrew Gwozdziewycz <[email protected]>
    apg committed Sep 18, 2024
    Configuration menu
    Copy the full SHA
    125cddb View commit details
    Browse the repository at this point in the history