github.com/letsencrypt/trillian@v1.1.2-0.20180615153820-ae375a99d36a/cmd/deletetree/main.go (about) 1 // Copyright 2018 Google Inc. All Rights Reserved. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 // Package main contains the implementation and entry point for the deletetree 16 // command. 17 // 18 // Example usage: 19 // $ ./deletetree --admin_server=host:port --log_id=logid 20 package main 21 22 import ( 23 "context" 24 "flag" 25 26 "github.com/golang/glog" 27 "github.com/google/trillian" 28 "google.golang.org/grpc" 29 ) 30 31 var ( 32 adminServerAddr = flag.String("admin_server", "", "Address of the gRPC Trillian Admin Server (host:port)") 33 logID = flag.Int64("log_id", 0, "Trillian LogID to delete") 34 ) 35 36 func main() { 37 flag.Parse() 38 defer glog.Flush() 39 40 conn, err := grpc.Dial(*adminServerAddr, grpc.WithInsecure()) 41 if err != nil { 42 glog.Exitf("failed to dial %v: %v", *adminServerAddr, err) 43 } 44 defer conn.Close() 45 46 a := trillian.NewTrillianAdminClient(conn) 47 _, err = a.DeleteTree(context.Background(), &trillian.DeleteTreeRequest{TreeId: *logID}) 48 if err != nil { 49 glog.Exitf("delete failed: %v", err) 50 } 51 }