Skip to content

Commit

Permalink
Deprecated and remove user_data
Browse files Browse the repository at this point in the history
As per #150, the user_data is not working, so the field is marked as
deprecated until its fixed.

All references from the examples and docs have been removed to avoid
confusion.
  • Loading branch information
VoyTechnology committed Sep 2, 2022
1 parent 07382be commit f46fd1c
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 27 deletions.
1 change: 0 additions & 1 deletion examples/example.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ resource "virtualbox_vm" "node" {
image = "https://app.vagrantup.com/ubuntu/boxes/bionic64/versions/20180903.0.0/providers/virtualbox.box"
cpus = 2
memory = "512 mib"
user_data = file("${path.module}/user_data")

network_adapter {
type = "hostonly"
Expand Down
4 changes: 0 additions & 4 deletions examples/user_data

This file was deleted.

22 changes: 4 additions & 18 deletions virtualbox/resource_vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,10 @@ func resourceVM() *schema.Resource {
},

"user_data": {
Type: schema.TypeString,
Optional: true,
Default: "",
Deprecated: "user_data is not working and is temporarily deprecated while we figure out how to make it work",
Type: schema.TypeString,
Optional: true,
Default: "",
},

"checksum": {
Expand Down Expand Up @@ -418,17 +419,6 @@ func resourceVMRead(ctx context.Context, d *schema.ResourceData, meta any) diag.
return diag.Errorf("can't set memory: %v", err)
}

userData, err := vm.GetExtraData("user_data")
if err != nil {
return diag.Errorf("can't get user data: %v", err)
}
if userData != nil && *userData != "" {
err = d.Set("user_data", *userData)
if err != nil {
return diag.Errorf("can't set user_data: %v", err)
}
}

if err = netVboxToTf(vm, d); err != nil {
return diag.Errorf("can't convert vbox network to terraform data: %v", err)
}
Expand Down Expand Up @@ -554,10 +544,6 @@ func tfToVbox(d *schema.ResourceData, vm *vbox.Machine) error {
vbox.HWVIRTEX | vbox.NESTEDPAGING | vbox.LARGEPAGES | vbox.LONGMODE |
vbox.VTXVPID | vbox.VTXUX
vm.NICs, err = netTfToVbox(d)
userData := d.Get("user_data").(string)
if userData != "" {
err = vm.SetExtraData("user_data", userData)
}
vm.BootOrder = defaultBootOrder
for i, bootDev := range d.Get("boot_order").([]any) {
vm.BootOrder[i] = bootDev.(string)
Expand Down
3 changes: 1 addition & 2 deletions website/docs/index.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ terraform {
required_providers {
virtualbox = {
source = "terra-farm/virtualbox"
version = "0.2.1"
version = "<latest-tag>"
}
}
}
Expand All @@ -34,7 +34,6 @@ resource "virtualbox_vm" "node" {
image = "https://app.vagrantup.com/ubuntu/boxes/bionic64/versions/20180903.0.0/providers/virtualbox.box"
cpus = 2
memory = "512 mib"
user_data = file("${path.module}/user_data")
network_adapter {
type = "hostonly"
Expand Down
2 changes: 0 additions & 2 deletions website/docs/r/vm.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ resource "virtualbox_vm" "node" {
image = "https://app.vagrantup.com/ubuntu/boxes/bionic64/versions/20180903.0.0/providers/virtualbox.box"
cpus = 2
memory = "512 mib"
user_data = file("${path.module}/user_data")
network_adapter {
type = "hostonly"
Expand All @@ -40,7 +39,6 @@ The following arguments are supported:
- `cpus`, int, optional, default=2: The number of CPUs.
- `memory`, string, optional, default="512mib": The size of memory, allow human
friendly units like 'MB', 'MiB'.
- `user_data`, string, optional, default="": User defined data.
- `status`, string, optional, default="running": The status of the VM. This
value will be updated at runtime to reflect the real status of the VM,
and you can also specify it explicitly in config to manually control the
Expand Down

0 comments on commit f46fd1c

Please sign in to comment.