Skip to content

Commit

Permalink
Update API based on logRangesFlag
Browse files Browse the repository at this point in the history
Signed-off-by: Lily Sturmann <lsturman@redhat.com>
  • Loading branch information
lkatalin committed Feb 22, 2022
1 parent 9f1a5cb commit 25b2ac8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cmd/rekor-server/app/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func init() {
rootCmd.PersistentFlags().String("trillian_log_server.address", "127.0.0.1", "Trillian log server address")
rootCmd.PersistentFlags().Uint16("trillian_log_server.port", 8090, "Trillian log server port")
rootCmd.PersistentFlags().Uint("trillian_log_server.tlog_id", 0, "Trillian tree id")
rootCmd.PersistentFlags().Var(&logRangeMap, "trillian_log_server.log_id_ranges", "ordered list of tree ids and ranges")
rootCmd.PersistentFlags().String("trillian_log_server.log_id_ranges", "", "ordered list of tree ids and ranges")

rootCmd.PersistentFlags().String("rekor_server.hostname", "rekor.sigstore.dev", "public hostname of instance")
rootCmd.PersistentFlags().String("rekor_server.address", "127.0.0.1", "Address to bind to")
Expand Down
8 changes: 8 additions & 0 deletions cmd/rekor-server/app/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,14 @@ var serveCmd = &cobra.Command{
server.Port = int(viper.GetUint("port"))
server.EnabledListeners = []string{"http"}

// Update logRangeMap if flag was passed in
rangeMap := viper.GetString("trillian_log_server.log_id_ranges")
if rangeMap != "" {
if err := logRangeMap.Set(rangeMap); err != nil {
log.Logger.Fatal("unable to set logRangeMap from flag: %v", err)
}
}

api.ConfigureAPI(logRangeMap.Ranges)
server.ConfigureAPI()

Expand Down
6 changes: 6 additions & 0 deletions pkg/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ func NewAPI(ranges sharding.LogRanges) (*API, error) {
return nil, errors.Wrap(err, "create and init tree")
}
tLogID = t.TreeId
log.Logger.Infof("Creating new tree with ID: %v", t.TreeId)
// append the newly created treeID to the API's logRangeMap for lookups
ranges.Ranges = append(ranges.Ranges, sharding.LogRange{TreeID: t.TreeId})
} else {
// append the manually specified treeID to the API's logRangeMap for lookups
ranges.Ranges = append(ranges.Ranges, sharding.LogRange{TreeID: tLogID})
}

rekorSigner, err := signer.New(ctx, viper.GetString("rekor_server.signer"))
Expand Down

0 comments on commit 25b2ac8

Please sign in to comment.