From 0d867c1f3a6b06e9e7118296ebf6772b27d09747 Mon Sep 17 00:00:00 2001 From: Priya Wadhwa Date: Mon, 7 Mar 2022 15:52:39 +0000 Subject: [PATCH] Change TreeID to be of type `string` instead of `int64` 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 --- cmd/rekor-cli/app/log_info.go | 4 ++-- openapi.yaml | 2 +- pkg/api/tlog.go | 6 +++++- pkg/generated/models/log_info.go | 2 +- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/cmd/rekor-cli/app/log_info.go b/cmd/rekor-cli/app/log_info.go index 53fcfac89..028ebe234 100644 --- a/cmd/rekor-cli/app/log_info.go +++ b/cmd/rekor-cli/app/log_info.go @@ -43,7 +43,7 @@ type logInfoCmdOutput struct { TreeSize int64 RootHash string TimestampNanos uint64 - TreeID int64 + TreeID string } func (l *logInfoCmdOutput) String() string { @@ -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) } diff --git a/openapi.yaml b/openapi.yaml index 28ab38c3d..1a824bc7b 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -582,7 +582,7 @@ definitions: format: signedCheckpoint description: The current signed tree head treeID: - type: integer + type: string description: The current treeID required: - rootHash diff --git a/pkg/api/tlog.go b/pkg/api/tlog.go index 6ad2fe813..36c7f66b9 100644 --- a/pkg/api/tlog.go +++ b/pkg/api/tlog.go @@ -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 { diff --git a/pkg/generated/models/log_info.go b/pkg/generated/models/log_info.go index 15eae37fe..f5b0588be 100644 --- a/pkg/generated/models/log_info.go +++ b/pkg/generated/models/log_info.go @@ -46,7 +46,7 @@ type LogInfo struct { // The current treeID // Required: true - TreeID *int64 `json:"treeID"` + TreeID *string `json:"treeID"` // The current number of nodes in the merkle tree // Required: true