Skip to content
Snippets Groups Projects
Commit c9716e5d authored by Luke Hinds's avatar Luke Hinds
Browse files

LeafIndex not correctly handled (was blank)

parent 0742c3db
No related branches found
No related tags found
No related merge requests found
...@@ -39,7 +39,7 @@ type getLeafResponse struct { ...@@ -39,7 +39,7 @@ type getLeafResponse struct {
Key []byte Key []byte
} }
// type leafStruct struct { // type leafStructs struct {
// Leaf struct { // Leaf struct {
// Leaves []struct { // Leaves []struct {
// MerkleLeafHash string `json:"merkle_leaf_hash"` // MerkleLeafHash string `json:"merkle_leaf_hash"`
...@@ -72,7 +72,7 @@ var getleafCmd = &cobra.Command{ ...@@ -72,7 +72,7 @@ var getleafCmd = &cobra.Command{
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
log := log.Logger log := log.Logger
rekorServer := viper.GetString("rekor_server") rekorServer := viper.GetString("rekor_server")
leafIndex := viper.GetString("leafIndex") leafIndex, _ := cmd.PersistentFlags().GetInt64("index")
u := rekorServer + "/api/v1/getleaf" u := rekorServer + "/api/v1/getleaf"
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
...@@ -83,7 +83,7 @@ var getleafCmd = &cobra.Command{ ...@@ -83,7 +83,7 @@ var getleafCmd = &cobra.Command{
log.Fatal(err) log.Fatal(err)
} }
request.URL.RawQuery += fmt.Sprintf("leafindex=%s", leafIndex) request.URL.RawQuery += fmt.Sprintf("leafindex=%d", leafIndex)
client := &http.Client{} client := &http.Client{}
response, err := client.Do(request) response, err := client.Do(request)
...@@ -114,13 +114,12 @@ var getleafCmd = &cobra.Command{ ...@@ -114,13 +114,12 @@ var getleafCmd = &cobra.Command{
log.Fatal(err) log.Fatal(err)
} }
log.Info("Leaf content", resp.Leaf.Leaves) log.Info("Leaf content", resp.Leaf)
log.Info("Root: ", root.TreeSize) log.Info("Root: ", root.TreeSize)
}, },
} }
func init() { func init() {
rootCmd.AddCommand(getleafCmd) rootCmd.AddCommand(getleafCmd)
getleafCmd.PersistentFlags().String("index", "", "Leaf Index") getleafCmd.PersistentFlags().Int64("index", -1, "")
viper.BindPFlag("linkfile", getleafCmd.PersistentFlags().Lookup("index"))
} }
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