mirror of
https://github.com/cirruslabs/orchard.git
synced 2026-09-30 03:51:43 +02:00
create vm: introduce --{os,arch,runtime} command-line arguments (#422)
* create vm: introduce --{os,arch,runtime} command-line arguments
* v1.VM: prevent unsupported fields for "vetu" runtime
This commit is contained in:
@@ -137,6 +137,33 @@ func (vm *VM) IsScheduled() bool {
|
||||
}
|
||||
}
|
||||
|
||||
func (vm *VM) Validate() error {
|
||||
unsupportedFieldError := func(field string) error {
|
||||
return fmt.Errorf("runtime %q does not support field %q", vm.Runtime, field)
|
||||
}
|
||||
|
||||
switch vm.Runtime {
|
||||
case RuntimeVetu:
|
||||
if vm.NetSoftnetDeprecated || vm.NetSoftnet {
|
||||
return unsupportedFieldError("netSoftnet")
|
||||
}
|
||||
if len(vm.NetSoftnetAllow) != 0 {
|
||||
return unsupportedFieldError("netSoftnetAllow")
|
||||
}
|
||||
if len(vm.NetSoftnetBlock) != 0 {
|
||||
return unsupportedFieldError("netSoftnetBlock")
|
||||
}
|
||||
if len(vm.HostDirs) != 0 {
|
||||
return unsupportedFieldError("hostDirs")
|
||||
}
|
||||
if vm.Suspendable {
|
||||
return unsupportedFieldError("suspendable")
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
type VMSpec struct {
|
||||
// OS defines the operating system used by a VM.
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user