github.com/vmware/govmomi@v0.51.0/cli/vm/check/config.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 check
     6  
     7  import (
     8  	"context"
     9  	"flag"
    10  
    11  	"github.com/vmware/govmomi/cli"
    12  	"github.com/vmware/govmomi/vim25/types"
    13  )
    14  
    15  type config struct {
    16  	checkFlag
    17  }
    18  
    19  func init() {
    20  	cli.Register("vm.check.config", &config{}, true)
    21  }
    22  
    23  func (cmd *config) Description() string {
    24  	return `Check if VM config spec can be applied.
    25  
    26  Examples:
    27    govc vm.create -spec ... | govc vm.check.config -pool $pool`
    28  }
    29  
    30  func (cmd *config) Run(ctx context.Context, f *flag.FlagSet) error {
    31  	var spec types.VirtualMachineConfigSpec
    32  
    33  	if err := cmd.Spec(&spec); err != nil {
    34  		return err
    35  	}
    36  
    37  	checker, err := cmd.compatChecker()
    38  	if err != nil {
    39  		return err
    40  	}
    41  
    42  	res, err := checker.CheckVmConfig(ctx, spec, cmd.Machine, cmd.Host, cmd.Pool, cmd.testTypes...)
    43  	if err != nil {
    44  		return err
    45  	}
    46  
    47  	return cmd.result(ctx, res)
    48  }