Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b152359706 | ||
| a844f6cc30 | |||
|
|
8e6b5a9bab | ||
|
|
cd4695ee68 | ||
|
|
5bd7958f09 | ||
| 8fc9170c9c |
3
Makefile
3
Makefile
@@ -11,6 +11,9 @@ OS_ARCH=windows_amd64
|
||||
|
||||
default: install
|
||||
|
||||
lint:
|
||||
golangci-lint run --timeout 600s
|
||||
|
||||
build:
|
||||
go build -o ${BINARY} ${MAINPATH}
|
||||
release:
|
||||
|
||||
@@ -31,7 +31,7 @@ Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
|
||||
|
||||
package image
|
||||
|
||||
const imageCreateAPI = "/restmachine/cloudapi/image/createImage"
|
||||
const imageCreateAPI = "/restmachine/cloudapi/image/create"
|
||||
const imageCreateVirtualAPI = "/restmachine/cloudapi/image/createVirtual"
|
||||
const imageGetAPI = "/restmachine/cloudapi/image/get"
|
||||
const imageListGetAPI = "/restmachine/cloudapi/image/list"
|
||||
|
||||
@@ -33,6 +33,7 @@ package image
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/url"
|
||||
"strconv"
|
||||
|
||||
@@ -52,7 +53,7 @@ func resourceImageCreate(ctx context.Context, d *schema.ResourceData, m interfac
|
||||
urlValues.Add("url", d.Get("url").(string))
|
||||
urlValues.Add("gid", strconv.Itoa(d.Get("gid").(int)))
|
||||
urlValues.Add("boottype", d.Get("boot_type").(string))
|
||||
urlValues.Add("imagetype", d.Get("image_type").(string))
|
||||
urlValues.Add("imagetype", d.Get("type").(string))
|
||||
|
||||
tstr := d.Get("drivers").([]interface{})
|
||||
temp := ""
|
||||
@@ -94,11 +95,25 @@ func resourceImageCreate(ctx context.Context, d *schema.ResourceData, m interfac
|
||||
if architecture, ok := d.GetOk("architecture"); ok {
|
||||
urlValues.Add("architecture", architecture.(string))
|
||||
}
|
||||
|
||||
/* uncomment then OK
|
||||
imageId, err := c.DecortAPICall(ctx, "POST", imageCreateAPI, urlValues)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
*/
|
||||
//innovation
|
||||
res, err := c.DecortAPICall(ctx, "POST", imageCreateAPI, urlValues)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
i := make([]interface{}, 0)
|
||||
err = json.Unmarshal([]byte(res), &i)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
imageId := strconv.Itoa(int(i[1].(float64)))
|
||||
// end innovation
|
||||
|
||||
d.SetId(imageId)
|
||||
d.Set("image_id", imageId)
|
||||
|
||||
@@ -139,7 +139,11 @@ func flattenCompute(d *schema.ResourceData, compFacts string) error {
|
||||
d.Set("cpu", model.Cpu)
|
||||
d.Set("ram", model.Ram)
|
||||
// d.Set("boot_disk_size", model.BootDiskSize) - bootdiskSize key in API compute/get is always zero, so we set boot_disk_size in another way
|
||||
d.Set("image_id", model.ImageID)
|
||||
if model.VirtualImageID != 0 {
|
||||
d.Set("image_id", model.VirtualImageID)
|
||||
} else {
|
||||
d.Set("image_id", model.ImageID)
|
||||
}
|
||||
d.Set("description", model.Desc)
|
||||
d.Set("cloud_init", "applied") // NOTE: for existing compute we hard-code this value as an indicator for DiffSuppress fucntion
|
||||
// d.Set("status", model.Status)
|
||||
|
||||
Reference in New Issue
Block a user