github.com/vmware/govmomi@v0.43.0/govc/cluster/group/remove.go (about) 1 /* 2 Copyright (c) 2017 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 group 18 19 import ( 20 "context" 21 "flag" 22 23 "github.com/vmware/govmomi/govc/cli" 24 "github.com/vmware/govmomi/vim25/types" 25 ) 26 27 type remove struct { 28 *InfoFlag 29 } 30 31 func init() { 32 cli.Register("cluster.group.remove", &remove{}) 33 } 34 35 func (cmd *remove) Register(ctx context.Context, f *flag.FlagSet) { 36 cmd.InfoFlag, ctx = NewInfoFlag(ctx) 37 cmd.InfoFlag.Register(ctx, f) 38 } 39 40 func (cmd *remove) Process(ctx context.Context) error { 41 if cmd.name == "" { 42 return flag.ErrHelp 43 } 44 return cmd.InfoFlag.Process(ctx) 45 } 46 47 func (cmd *remove) Description() string { 48 return `Remove cluster group. 49 50 Examples: 51 govc cluster.group.remove -cluster my_cluster -name my_group` 52 } 53 54 func (cmd *remove) Run(ctx context.Context, f *flag.FlagSet) error { 55 update := types.ArrayUpdateSpec{ 56 Operation: types.ArrayUpdateOperationRemove, 57 RemoveKey: cmd.name, 58 } 59 60 return cmd.Apply(ctx, update, nil) 61 }