diff --git a/cmd/deletetree/main.go b/cmd/deletetree/main.go index e5c9d75fd8..9f0e0f4924 100644 --- a/cmd/deletetree/main.go +++ b/cmd/deletetree/main.go @@ -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() { @@ -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) + } } }