-
Notifications
You must be signed in to change notification settings - Fork 11
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
feat(sdk): remove hex encoding for segment hash #1805
Open
sujankota
wants to merge
10
commits into
main
Choose a base branch
from
feat/remove-hex-encoding-tdf3
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 8 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
ae8144a
feat(kas): remove hex encoding for segment hash
sujankota 27daabe
fix the tests
sujankota 81af2b1
Merge branch 'main' into feat/remove-hex-encoding-tdf3
sujankota 8f17eff
fix assertion hash
sujankota ddda847
handle assertion for legacy tdfs
sujankota f7171d9
Merge branch 'main' into feat/remove-hex-encoding-tdf3
sujankota 4cf0aba
Update the intial version of the sdk to 4.3.0
sujankota ae6ce48
Merge branch 'main' into feat/remove-hex-encoding-tdf3
sujankota ac4073d
Address code review comments
sujankota e0ba076
add option to add build meta data
sujankota File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package sdk | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"strings" | ||
) | ||
|
||
type Version struct { | ||
Major int | ||
Minor int | ||
Patch int | ||
Preview int | ||
Revision int | ||
} | ||
|
||
func ReadVersion() (*Version, error) { | ||
content, err := os.ReadFile("VERSION") | ||
if err != nil { | ||
return nil, fmt.Errorf("reading VERSION file: %w", err) | ||
} | ||
|
||
return ParseVersion(strings.TrimSpace(string(content))) | ||
} | ||
|
||
func ParseVersion(v string) (*Version, error) { | ||
const maxParts = 2 | ||
var ver Version | ||
var preview, revision string | ||
|
||
parts := strings.SplitN(v, "+p", maxParts) | ||
mainVersion := parts[0] | ||
|
||
if len(parts) > 1 { | ||
if parts[1] == "" { | ||
return nil, fmt.Errorf("invalid preview format") | ||
} | ||
previewParts := strings.SplitN(parts[1], ".", maxParts) | ||
preview = previewParts[0] | ||
if len(previewParts) > 1 { | ||
if previewParts[1] == "" { | ||
return nil, fmt.Errorf("invalid revision format") | ||
} | ||
revision = previewParts[1] | ||
} | ||
} | ||
|
||
if _, err := fmt.Sscanf(mainVersion, "%d.%d.%d", &ver.Major, &ver.Minor, &ver.Patch); err != nil { | ||
return nil, fmt.Errorf("parsing version: %w", err) | ||
} | ||
|
||
if preview != "" { | ||
if _, err := fmt.Sscanf(preview, "%d", &ver.Preview); err != nil { | ||
return nil, fmt.Errorf("parsing preview version: %w", err) | ||
} | ||
} | ||
|
||
if revision != "" { | ||
if _, err := fmt.Sscanf(revision, "%d", &ver.Revision); err != nil { | ||
return nil, fmt.Errorf("parsing revision: %w", err) | ||
} | ||
} | ||
|
||
return &ver, nil | ||
} | ||
|
||
func (v *Version) String() string { | ||
base := fmt.Sprintf("%d.%d.%d", v.Major, v.Minor, v.Patch) | ||
if v.Preview > 0 { | ||
if v.Revision > 0 { | ||
return fmt.Sprintf("%s+p%d.%d", base, v.Preview, v.Revision) | ||
} | ||
return fmt.Sprintf("%s+p%d", base, v.Preview) | ||
} | ||
return base | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need the ability to extend this version based on the decision of going with option 2 in this adr.
#1677
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/opentdf/platform/pull/1805/files#diff-e4ef1c45819a3bdf9ccddb7d496711ecc1275b3c2ee9155c6273597283f74cc1R1496 - will handle the option 2