This commit is contained in:
2025-05-21 16:38:25 +03:00
parent 2c70109d2d
commit 9e68edb2b9
1034 changed files with 73925 additions and 3187 deletions

View File

@@ -41,7 +41,6 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/image"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/ic"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/status"
)
@@ -53,12 +52,6 @@ func resourceCDROMImageCreate(ctx context.Context, d *schema.ResourceData, m int
URL: d.Get("url").(string),
}
if err := ic.ExistGID(ctx, uint64(d.Get("gid").(int)), c); err != nil {
return diag.FromErr(err)
}
req.GID = uint64(d.Get("gid").(int))
drivers := []string{}
for _, driver := range d.Get("drivers").([]interface{}) {
drivers = append(drivers, driver.(string))

View File

@@ -354,41 +354,47 @@ func resourceImageChangeAccess(ctx context.Context, d *schema.ResourceData, m in
oldSet, newSet := d.GetChange("accounts")
revokeAccess := (oldSet.(*schema.Set).Difference(newSet.(*schema.Set))).List()
if len(revokeAccess) > 0 {
revokeAccounts := make([]uint64, 0, len(revokeAccess))
revokeAccounts := make([]int64, 0, len(revokeAccess))
if newSet.(*schema.Set).Len() == 0 {
revokeAccounts = append(revokeAccounts, -1)
} else if len(revokeAccess) > 0 {
for _, accountId := range revokeAccess {
revokeAccounts = append(revokeAccounts, uint64(accountId.(int)))
revokeAccounts = append(revokeAccounts, accountId.(int64))
}
req := image.RevokeAccessRequest{
ImageID: imageId,
AccountIDs: revokeAccounts,
}
}
_, err := c.CloudBroker().Image().RevokeAccess(ctx, req)
if err != nil {
return err
}
req := image.RevokeAccessRequest{
ImageID: imageId,
AccountIDs: revokeAccounts,
}
_, err := c.CloudBroker().Image().RevokeAccess(ctx, req)
if err != nil {
return err
}
addedAccess := (newSet.(*schema.Set).Difference(oldSet.(*schema.Set))).List()
if len(addedAccess) > 0 {
grantAccounts := make([]uint64, 0, len(addedAccess))
grantAccounts := make([]int64, 0, len(addedAccess))
if newSet.(*schema.Set).Len() == 0 {
grantAccounts = append(grantAccounts, -1)
} else if len(addedAccess) > 0 {
for _, accountId := range addedAccess {
grantAccounts = append(grantAccounts, uint64(accountId.(int)))
grantAccounts = append(grantAccounts, accountId.(int64))
}
req := image.GrantAccessRequest{
ImageID: imageId,
AccountIDs: grantAccounts,
}
_, err := c.CloudBroker().Image().GrantAccess(ctx, req)
if err != nil {
return err
}
}
// req := image.GrantAccessRequest{
// ImageID: imageId,
// AccountIDs: grantAccounts,
// }
// _, err := c.CloudBroker().Image().GrantAccess(ctx, req)
// if err != nil {
// return err
// }
return nil
}
@@ -399,9 +405,9 @@ func resourceImageSetAccess(ctx context.Context, d *schema.ResourceData, m inter
imageId, _ := strconv.ParseUint(d.Id(), 10, 64)
accounts := d.Get("accounts").([]interface{})
accountIDs := make([]uint64, 0, len(accounts))
accountIDs := make([]int64, 0, len(accounts))
for _, accountId := range accounts {
accountIDs = append(accountIDs, uint64(accountId.(int)))
accountIDs = append(accountIDs, accountId.(int64))
}
req := image.GrantAccessRequest{

View File

@@ -74,9 +74,6 @@ func resourceImageFromBlankComputeCreate(ctx context.Context, d *schema.Resource
if accountId, ok := d.GetOk("account_id"); ok {
req.AccountID = uint64(accountId.(int))
}
if sepId, ok := d.GetOk("sep_id"); ok {
req.SepID = uint64(sepId.(int))
}
if poolName, ok := d.GetOk("pool_name"); ok {
req.PoolName = poolName.(string)
}

View File

@@ -76,9 +76,6 @@ func resourceImageFromPlatformDiskCreate(ctx context.Context, d *schema.Resource
if accountId, ok := d.GetOk("account_id"); ok {
req.AccountID = uint64(accountId.(int))
}
if sepId, ok := d.GetOk("sep_id"); ok {
req.SepID = uint64(sepId.(int))
}
if poolName, ok := d.GetOk("pool_name"); ok {
req.PoolName = poolName.(string)
}

View File

@@ -574,7 +574,7 @@ func dataSourceImageListSchemaMake() map[string]*schema.Schema {
Description: "pool for image create",
},
"present_to": {
Type: schema.TypeList,
Type: schema.TypeMap,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
@@ -832,7 +832,7 @@ func dataSourceImageSchemaMake() map[string]*schema.Schema {
Description: "pool for image create",
},
"present_to": {
Type: schema.TypeList,
Type: schema.TypeMap,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
@@ -930,11 +930,6 @@ func resourceCDROMImageSchemaMake() map[string]*schema.Schema {
Required: true,
Description: "URL where to download ISO from",
},
"gid": {
Type: schema.TypeInt,
Required: true,
Description: "grid (platform) ID where this template should be create in",
},
"drivers": {
Type: schema.TypeList,
Optional: true,
@@ -1068,6 +1063,10 @@ func resourceCDROMImageSchemaMake() map[string]*schema.Schema {
Computed: true,
Description: "Boot type of image bios or uefi",
},
"gid": {
Type: schema.TypeInt,
Computed: true,
},
"guid": {
Type: schema.TypeInt,
Computed: true,
@@ -1128,7 +1127,7 @@ func resourceCDROMImageSchemaMake() map[string]*schema.Schema {
Computed: true,
},
"present_to": {
Type: schema.TypeList,
Type: schema.TypeMap,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
@@ -1200,11 +1199,6 @@ func resourceImageSchemaMake() map[string]*schema.Schema {
Optional: true,
Description: "path to image file",
},
"gid": {
Type: schema.TypeInt,
Required: true,
Description: "grid (platform) ID where this template should be create in",
},
"boot_type": {
Type: schema.TypeString,
Required: true,
@@ -1365,6 +1359,10 @@ func resourceImageSchemaMake() map[string]*schema.Schema {
},
},
},
"gid": {
Type: schema.TypeInt,
Computed: true,
},
"guid": {
Type: schema.TypeInt,
Computed: true,
@@ -1424,7 +1422,7 @@ func resourceImageSchemaMake() map[string]*schema.Schema {
Computed: true,
},
"present_to": {
Type: schema.TypeList,
Type: schema.TypeMap,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
@@ -1669,7 +1667,7 @@ func resourceVirtualImageSchemaMake() map[string]*schema.Schema {
Description: "pool for image create",
},
"present_to": {
Type: schema.TypeList,
Type: schema.TypeMap,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
@@ -1763,8 +1761,8 @@ func resourceImageFromBlankComputeSchemaMake() map[string]*schema.Schema {
"image_type": {
Type: schema.TypeString,
Required: true,
ValidateFunc: validation.StringInSlice([]string{"linux", "windows", "other"}, true),
Description: "Image type linux, windows or other",
ValidateFunc: validation.StringInSlice([]string{"linux", "windows", "unknown"}, true),
Description: "Image type linux, windows or unknown",
},
"username": {
@@ -1787,7 +1785,6 @@ func resourceImageFromBlankComputeSchemaMake() map[string]*schema.Schema {
},
"sep_id": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
Description: "storage endpoint provider ID",
},
@@ -1966,7 +1963,7 @@ func resourceImageFromBlankComputeSchemaMake() map[string]*schema.Schema {
Computed: true,
},
"present_to": {
Type: schema.TypeList,
Type: schema.TypeMap,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
@@ -2037,8 +2034,8 @@ func resourceImageFromPlatformDiskSchemaMake() map[string]*schema.Schema {
"image_type": {
Type: schema.TypeString,
Required: true,
ValidateFunc: validation.StringInSlice([]string{"linux", "windows", "other"}, true),
Description: "Image type linux, windows or other",
ValidateFunc: validation.StringInSlice([]string{"linux", "windows", "unknown"}, true),
Description: "Image type linux, windows or unknown",
},
"architecture": {
Type: schema.TypeString,
@@ -2067,7 +2064,6 @@ func resourceImageFromPlatformDiskSchemaMake() map[string]*schema.Schema {
},
"sep_id": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
Description: "storage endpoint provider ID",
},
@@ -2245,7 +2241,7 @@ func resourceImageFromPlatformDiskSchemaMake() map[string]*schema.Schema {
Computed: true,
},
"present_to": {
Type: schema.TypeList,
Type: schema.TypeMap,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,

View File

@@ -36,8 +36,6 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/image"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudbroker/ic"
)
func SyncCreateRequest(ctx context.Context, d *schema.ResourceData, m interface{}, url string) (image.SyncCreateRequest, error) {
@@ -100,14 +98,6 @@ func CreateRequest(ctx context.Context, d *schema.ResourceData, m interface{}, u
ImageType: d.Get("image_type").(string),
}
c := m.(*controller.ControllerCfg)
if err := ic.ExistGID(ctx, uint64(d.Get("gid").(int)), c); err != nil {
return req, err
}
req.GID = uint64(d.Get("gid").(int))
if _, ok := d.GetOk("drivers"); ok {
drivers := []string{}
for _, driver := range d.Get("drivers").([]interface{}) {