mirror of
https://github.com/bpg/terraform-provider-proxmox.git
synced 2025-07-01 19:12:59 +00:00
Provide correct outputs from stopped VM (#106)
Outputs 'ipv4_addresses', 'ipv6_addresses', 'network_interface_names' of stopped VM are empty and break plans - e.g. search for "eth0" in empty list. On update, mark them 'Computed' if there is planned change in 'started' or 'network_device' of the VM. This makes it possible to depend on e.g. 'network_interface_names' of VM which is not running at the time of 'terraform plan', but which will be started during 'terraform apply'.
This commit is contained in:
parent
442b60c8f9
commit
3392d8e5c0
@ -9,6 +9,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff"
|
||||||
"sort"
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@ -1057,6 +1058,17 @@ func resourceVirtualEnvironmentVM() *schema.Resource {
|
|||||||
ReadContext: resourceVirtualEnvironmentVMRead,
|
ReadContext: resourceVirtualEnvironmentVMRead,
|
||||||
UpdateContext: resourceVirtualEnvironmentVMUpdate,
|
UpdateContext: resourceVirtualEnvironmentVMUpdate,
|
||||||
DeleteContext: resourceVirtualEnvironmentVMDelete,
|
DeleteContext: resourceVirtualEnvironmentVMDelete,
|
||||||
|
CustomizeDiff: customdiff.All(
|
||||||
|
customdiff.ComputedIf(mkResourceVirtualEnvironmentVMIPv4Addresses, func(ctx context.Context, d *schema.ResourceDiff, meta interface{}) bool {
|
||||||
|
return d.HasChange(mkResourceVirtualEnvironmentVMStarted) || d.HasChange(mkResourceVirtualEnvironmentVMNetworkDevice)
|
||||||
|
}),
|
||||||
|
customdiff.ComputedIf(mkResourceVirtualEnvironmentVMIPv6Addresses, func(ctx context.Context, d *schema.ResourceDiff, meta interface{}) bool {
|
||||||
|
return d.HasChange(mkResourceVirtualEnvironmentVMStarted) || d.HasChange(mkResourceVirtualEnvironmentVMNetworkDevice)
|
||||||
|
}),
|
||||||
|
customdiff.ComputedIf(mkResourceVirtualEnvironmentVMNetworkInterfaceNames, func(ctx context.Context, d *schema.ResourceDiff, meta interface{}) bool {
|
||||||
|
return d.HasChange(mkResourceVirtualEnvironmentVMStarted) || d.HasChange(mkResourceVirtualEnvironmentVMNetworkDevice)
|
||||||
|
}),
|
||||||
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user