Skip to content

Commit

Permalink
Add undeletetree command (#2638)
Browse files Browse the repository at this point in the history
* Add undeletetree command

* Move undelete_tree flag into deletetree binary

* Address presubmit lint warning

Co-authored-by: Phil Porada <[email protected]>
  • Loading branch information
mhutchinson and pgporada authored Nov 29, 2021
1 parent 081150f commit 57e4a52
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions cmd/deletetree/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
var (
adminServerAddr = flag.String("admin_server", "", "Address of the gRPC Trillian Admin Server (host:port)")
logID = flag.Int64("log_id", 0, "Trillian LogID to delete")
undeleteTree = flag.Bool("undelete_tree", false, "Undelete the specified Trillian LogID (bool)")
)

func main() {
Expand All @@ -50,8 +51,15 @@ func main() {
defer conn.Close()

a := trillian.NewTrillianAdminClient(conn)
_, err = a.DeleteTree(context.Background(), &trillian.DeleteTreeRequest{TreeId: *logID})
if err != nil {
glog.Exitf("Delete failed: %v", err)
if !*undeleteTree {
_, err = a.DeleteTree(context.Background(), &trillian.DeleteTreeRequest{TreeId: *logID})
if err != nil {
glog.Exitf("Delete failed: %v", err)
}
} else {
_, err = a.UndeleteTree(context.Background(), &trillian.UndeleteTreeRequest{TreeId: *logID})
if err != nil {
glog.Exitf("Undelete failed: %v", err)
}
}
}

0 comments on commit 57e4a52

Please sign in to comment.