Skip to content

Commit

Permalink
feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
engelmi committed May 30, 2022
1 parent 8777e15 commit 6b8ac42
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions internal/ovirt/resource_ovirt_vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ func (p *provider) vmCreate(
var diags diag.Diagnostics
params := ovirtclient.NewCreateVMParams()
for _, f := range []func(
ovirtclient.Client,
*schema.ResourceData,
ovirtclient.BuildableVMParameters,
diag.Diagnostics,
Expand All @@ -210,15 +211,14 @@ func (p *provider) vmCreate(
handleVMCPUParameters,
handleVMOSType,
handleVMInitialization,
handleVMPlacementPolicy,
handleTemplateDiskAttachmentOverride,
handleVMMemory,
handleVMMemoryPolicy,
handleVMSerialConsole,
} {
diags = f(data, params, diags)
diags = f(client, data, params, diags)
}

diags = handleVMPlacementPolicy(client, data, params, diags)
if diags.HasError() {
return diags
}
Expand All @@ -243,6 +243,7 @@ func (p *provider) vmCreate(
}

func handleVMSerialConsole(
_ ovirtclient.Client,
data *schema.ResourceData,
params ovirtclient.BuildableVMParameters,
diags diag.Diagnostics,
Expand All @@ -256,6 +257,7 @@ func handleVMSerialConsole(
}

func handleTemplateDiskAttachmentOverride(
_ ovirtclient.Client,
data *schema.ResourceData,
params ovirtclient.BuildableVMParameters,
diags diag.Diagnostics,
Expand Down Expand Up @@ -298,6 +300,7 @@ func handleTemplateDiskAttachmentOverride(
}

func handleVMMemoryPolicy(
_ ovirtclient.Client,
data *schema.ResourceData,
params ovirtclient.BuildableVMParameters,
diags diag.Diagnostics,
Expand Down Expand Up @@ -331,6 +334,7 @@ func handleVMMemoryPolicy(
}

func handleVMMemory(
_ ovirtclient.Client,
data *schema.ResourceData,
params ovirtclient.BuildableVMParameters,
diags diag.Diagnostics,
Expand Down Expand Up @@ -384,7 +388,12 @@ func handleVMPlacementPolicy(
}

if hasPlacementPolicy {
if isSupported, _ := client.SupportsFeature(ovirtclient.FeaturePlacementPolicy); !isSupported {
isSupported, err := client.SupportsFeature(ovirtclient.FeaturePlacementPolicy)
if err != nil {
diags = append(diags, errorToDiag("check feature support", err))
return diags
}
if !isSupported {
diags = append(diags, diag.Diagnostic{
Severity: diag.Error,
Summary: "Feature not supported",
Expand All @@ -398,6 +407,7 @@ func handleVMPlacementPolicy(
}

func handleVMOSType(
_ ovirtclient.Client,
data *schema.ResourceData,
params ovirtclient.BuildableVMParameters,
diags diag.Diagnostics,
Expand All @@ -413,6 +423,7 @@ func handleVMOSType(
}

func handleVMCPUParameters(
_ ovirtclient.Client,
data *schema.ResourceData,
params ovirtclient.BuildableVMParameters,
diags diag.Diagnostics,
Expand Down Expand Up @@ -461,6 +472,7 @@ func handleVMCPUParameters(
}

func handleVMComment(
_ ovirtclient.Client,
data *schema.ResourceData,
params ovirtclient.BuildableVMParameters,
diags diag.Diagnostics,
Expand All @@ -482,6 +494,7 @@ func handleVMComment(
}

func handleVMInitialization(
_ ovirtclient.Client,
data *schema.ResourceData,
params ovirtclient.BuildableVMParameters,
diags diag.Diagnostics,
Expand Down

0 comments on commit 6b8ac42

Please sign in to comment.