Skip to content

Commit

Permalink
Change TreeID to be of type string instead of int64
Browse files Browse the repository at this point in the history
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: Priya Wadhwa <priya@chainguard.dev>
  • Loading branch information
priyawadhwa committed Mar 7, 2022
1 parent c3a7f89 commit 0d867c1
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
4 changes: 2 additions & 2 deletions cmd/rekor-cli/app/log_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ type logInfoCmdOutput struct {
TreeSize int64
RootHash string
TimestampNanos uint64
TreeID int64
TreeID string
}

func (l *logInfoCmdOutput) String() string {
Expand All @@ -53,7 +53,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)
}

Expand Down
2 changes: 1 addition & 1 deletion openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ definitions:
format: signedCheckpoint
description: The current signed tree head
treeID:
type: integer
type: string
description: The current treeID
required:
- rootHash
Expand Down
6 changes: 5 additions & 1 deletion pkg/api/tlog.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion pkg/generated/models/log_info.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0d867c1

Please sign in to comment.