Skip to content

Commit

Permalink
refactor!: more conventional marshaling
Browse files Browse the repository at this point in the history
This commit refactors marshaling API. It has two objectives:

- Align how marshaling works with conventional Go practices, ensuring
  new users familiar with other Go libraries have minimal surprises.
- Minimize the impact of marshaling on IClaims interface, relieving the
  burden on current and future implementations.

To that end, the following changes are made:

- From/To* marshaling API are replaced with implementations of standard
  cbor and json marshaling interfaces (i.e. Unmasrshal/Marshal*). As per
  convention, these implementations do not validate.
- There are no validating versions of marshaling methods (thus no
  requirement for every IClaims implementation to re-implement them).
  Instead, there are convenience functions that instantiate, marshal,
  and validate in a single call.
- The functions have been renamed such that Decode* now only performs
  unmarshaling, and DecodeAndValidate* unmarshals and validates.
- Decoding/Encoding functions for IClaims have been moved from
  profile.go to iclaims.go.

note: this is implemented on top of a similar refactor inside psatoken

BREAKING CHANGE: the From/To marshaling API have been removed; Decode*
functions have been renamed to be consistent with marshaling (rather
then DecodeXXX--that validates--and DecodeUnvalidatedXXX, there is now
DecodeAndValidateXXX and DecodeXXX--that does not validate).

Signed-off-by: Sergei Trofimov <sergei.trofimov@arm.com>
  • Loading branch information
setrofim committed Jul 22, 2024
1 parent 27e89f6 commit 8f040b5
Show file tree
Hide file tree
Showing 12 changed files with 552 additions and 575 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-go-cover.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# 1. Change workflow name from "cover 100%" to "cover ≥92.5%". Script will automatically use 92.5%.
# 2. Update README.md to use the new path to badge.svg because the path includes the workflow name.

name: cover ≥85.0%
name: cover ≥83.1%
on: [push, pull_request]
jobs:
cover:
Expand Down
Loading

0 comments on commit 8f040b5

Please sign in to comment.