Skip to content
Snippets Groups Projects
Unverified Commit b7190321 authored by priyawadhwa's avatar priyawadhwa Committed by GitHub
Browse files

Change TreeID to be of type `string` instead of `int64` (#712)

When printing the TreeID with rekor-cli loginfo, if the output is parsed through jq
then the TreeID gets rounded down as an int because it is bigger than JSON allows Numbers to be.

This is how jq works and is mentioned in the FAQ: https://github.com/stedolan/jq/wiki/FAQ#numbers



Switching this to a string will preserve the actual Tree ID.

Signed-off-by: default avatarPriya Wadhwa <priya@chainguard.dev>
parent 8cb2ceba
No related branches found
No related tags found
No related merge requests found
......@@ -44,7 +44,7 @@ type logInfoCmdOutput struct {
TreeSize int64
RootHash string
TimestampNanos uint64
TreeID int64
TreeID string
}
func (l *logInfoCmdOutput) String() string {
......@@ -55,7 +55,7 @@ func (l *logInfoCmdOutput) String() string {
Tree Size: %v
Root Hash: %s
Timestamp: %s
TreeID: %v
TreeID: %s
`, l.TreeSize, l.RootHash, ts, l.TreeID)
}
......
......@@ -582,8 +582,9 @@ definitions:
format: signedCheckpoint
description: The current signed tree head
treeID:
type: integer
type: string
description: The current treeID
pattern: '^[0-9]+$'
required:
- rootHash
- treeSize
......
......@@ -76,12 +76,16 @@ func GetLogInfoHandler(params tlog.GetLogInfoParams) middleware.Responder {
RootHash: &hashString,
TreeSize: &treeSize,
SignedTreeHead: &scString,
TreeID: &tc.logID,
TreeID: stringPointer(fmt.Sprintf("%d", tc.logID)),
}
return tlog.NewGetLogInfoOK().WithPayload(&logInfo)
}
func stringPointer(s string) *string {
return &s
}
// GetLogProofHandler returns information required to compute a consistency proof between two snapshots of log
func GetLogProofHandler(params tlog.GetLogProofParams) middleware.Responder {
if *params.FirstSize > params.LastSize {
......
......@@ -46,7 +46,8 @@ type LogInfo struct {
// The current treeID
// Required: true
TreeID *int64 `json:"treeID"`
// Pattern: ^[0-9]+$
TreeID *string `json:"treeID"`
// The current number of nodes in the merkle tree
// Required: true
......@@ -108,6 +109,10 @@ func (m *LogInfo) validateTreeID(formats strfmt.Registry) error {
return err
}
if err := validate.Pattern("treeID", "body", *m.TreeID, `^[0-9]+$`); err != nil {
return err
}
return nil
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment