github.com/vmware/govmomi@v0.43.0/govc/cluster/draft/rm.go (about) 1 /* 2 Copyright (c) 2024-2024 VMware, Inc. All Rights Reserved. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package draft 18 19 import ( 20 "context" 21 "flag" 22 23 "github.com/vmware/govmomi/govc/cli" 24 "github.com/vmware/govmomi/govc/flags" 25 "github.com/vmware/govmomi/vapi/esx/settings/clusters" 26 ) 27 28 type rm struct { 29 *flags.ClientFlag 30 31 clusterId string 32 draftId string 33 } 34 35 func init() { 36 cli.Register("cluster.draft.rm", &rm{}) 37 } 38 39 func (cmd *rm) Register(ctx context.Context, f *flag.FlagSet) { 40 cmd.ClientFlag, ctx = flags.NewClientFlag(ctx) 41 cmd.ClientFlag.Register(ctx, f) 42 43 f.StringVar(&cmd.clusterId, "cluster-id", "", "The identifier of the cluster.") 44 f.StringVar(&cmd.draftId, "draft-id", "", "The identifier of the software draft.") 45 } 46 47 func (cmd *rm) Process(ctx context.Context) error { 48 return cmd.ClientFlag.Process(ctx) 49 } 50 51 func (cmd *rm) Usage() string { 52 return "CLUSTER" 53 } 54 55 func (cmd *rm) Description() string { 56 return `Discards a software draft. 57 58 Examples: 59 govc cluster.draft.rm -cluster-id=domain-c21 -draft-id=13` 60 } 61 62 func (cmd *rm) Run(ctx context.Context, f *flag.FlagSet) error { 63 rc, err := cmd.RestClient() 64 65 if err != nil { 66 return err 67 } 68 69 dm := clusters.NewManager(rc) 70 71 return dm.DeleteSoftwareDraft(cmd.clusterId, cmd.draftId) 72 }