github.com/vmware/govmomi@v0.51.0/cli/disk/snapshot/rm.go (about) 1 // © Broadcom. All Rights Reserved. 2 // The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. 3 // SPDX-License-Identifier: Apache-2.0 4 5 package snapshot 6 7 import ( 8 "context" 9 "flag" 10 11 "github.com/vmware/govmomi/cli" 12 "github.com/vmware/govmomi/cli/disk" 13 "github.com/vmware/govmomi/cli/flags" 14 ) 15 16 type rm struct { 17 *flags.DatastoreFlag 18 } 19 20 func init() { 21 cli.Register("disk.snapshot.rm", &rm{}) 22 } 23 24 func (cmd *rm) Register(ctx context.Context, f *flag.FlagSet) { 25 cmd.DatastoreFlag, ctx = flags.NewDatastoreFlag(ctx) 26 cmd.DatastoreFlag.Register(ctx, f) 27 } 28 29 func (cmd *rm) Usage() string { 30 return "ID SID" 31 } 32 33 func (cmd *rm) Description() string { 34 return `Remove disk ID snapshot ID on DS. 35 36 Examples: 37 govc disk.snapshot.rm ffe6a398-eb8e-4eaa-9118-e1f16b8b8e3c ecbca542-0a25-4127-a585-82e4047750d6` 38 } 39 40 func (cmd *rm) Run(ctx context.Context, f *flag.FlagSet) error { 41 m, err := disk.NewManagerFromFlag(ctx, cmd.DatastoreFlag) 42 if err != nil { 43 return err 44 } 45 46 id := f.Arg(0) 47 sid := f.Arg(1) 48 49 return m.DeleteSnapshot(ctx, id, sid) 50 }