Skip to content

Commit 85acada

Browse files
authored
Merge pull request #646 from MalloZup/fix-error-when-volume-exist
Don't error when a volume exist already during apply
2 parents 05f2d9e + 295ffbe commit 85acada

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

libvirt/resource_libvirt_volume.go

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -106,18 +106,12 @@ func resourceLibvirtVolumeCreate(d *schema.ResourceData, meta interface{}) error
106106
return pool.Refresh(0)
107107
})
108108

109-
// Check whether the storage volume already exists. Its name needs to be
110-
// unique.
111-
if _, err := pool.LookupStorageVolByName(d.Get("name").(string)); err == nil {
112-
return fmt.Errorf("storage volume '%s' already exists", d.Get("name").(string))
113-
}
114-
115109
volumeDef := newDefVolume()
116-
volumeDef.Name = d.Get("name").(string)
110+
if name, ok := d.GetOk("name"); ok {
111+
volumeDef.Name = name.(string)
112+
}
117113

118-
var (
119-
img image
120-
)
114+
var img image
121115

122116
givenFormat, isFormatGiven := d.GetOk("format")
123117
if isFormatGiven {

0 commit comments

Comments
 (0)