1.3.0
This commit is contained in:
@@ -43,7 +43,6 @@ func RGDataSource(ctx context.Context, state *models.DataSourceRGModel, c *clien
|
||||
Name: types.StringValue(recordRG.Name),
|
||||
DefNetType: types.StringValue(recordRG.DefNetType),
|
||||
Description: types.StringValue(recordRG.Description),
|
||||
RegisterComputes: types.BoolValue(recordRG.RegisterComputes),
|
||||
AccountName: types.StringValue(recordRG.AccountName),
|
||||
ACL: flattenACL(ctx, &recordRG.ACL),
|
||||
CPUAllocationParameter: types.StringValue(recordRG.CPUAllocationParameter),
|
||||
|
||||
@@ -69,7 +69,6 @@ func RGListDataSource(ctx context.Context, state *models.DataSourceRGListModel,
|
||||
LockStatus: types.StringValue(rgItem.LockStatus),
|
||||
Milestones: types.Int64Value(int64(rgItem.Milestones)),
|
||||
Name: types.StringValue(rgItem.Name),
|
||||
RegisterComputes: types.BoolValue(rgItem.RegisterComputes),
|
||||
ResourceLimits: &models.ResourceLimitsModel{
|
||||
CUC: types.Float64Value(rgItem.ResourceLimits.CUC),
|
||||
CUD: types.Float64Value(rgItem.ResourceLimits.CUD),
|
||||
|
||||
@@ -68,7 +68,6 @@ func RGListDeletedDataSource(ctx context.Context, state *models.DataSourceRGList
|
||||
LockStatus: types.StringValue(rgItem.LockStatus),
|
||||
Milestones: types.Int64Value(int64(rgItem.Milestones)),
|
||||
Name: types.StringValue(rgItem.Name),
|
||||
RegisterComputes: types.BoolValue(rgItem.RegisterComputes),
|
||||
ResourceLimits: &models.ResourceLimitsModel{
|
||||
CUC: types.Float64Value(rgItem.ResourceLimits.CUC),
|
||||
CUD: types.Float64Value(rgItem.ResourceLimits.CUD),
|
||||
|
||||
@@ -41,21 +41,20 @@ func RGResource(ctx context.Context, plan *models.ResourceRGModel, c *client.Cli
|
||||
GID: types.Int64Value(int64(recordRG.GID)),
|
||||
Name: types.StringValue(recordRG.Name),
|
||||
|
||||
DefNetType: plan.DefNetType,
|
||||
IPCIDR: plan.IPCIDR,
|
||||
Quota: flattenQuota(ctx, &recordRG.ResourceLimits),
|
||||
ExtNetID: plan.ExtNetID,
|
||||
ExtIP: plan.ExtIP,
|
||||
Owner: plan.Owner,
|
||||
Access: plan.Access,
|
||||
DefNet: plan.DefNet,
|
||||
Description: plan.Description,
|
||||
Force: plan.Force,
|
||||
Permanently: plan.Permanently,
|
||||
RegisterComputes: plan.RegisterComputes,
|
||||
Restore: plan.Restore,
|
||||
Enable: plan.Enable,
|
||||
Timeouts: plan.Timeouts,
|
||||
DefNetType: plan.DefNetType,
|
||||
IPCIDR: plan.IPCIDR,
|
||||
Quota: flattenQuota(ctx, &recordRG.ResourceLimits),
|
||||
ExtNetID: plan.ExtNetID,
|
||||
ExtIP: plan.ExtIP,
|
||||
Owner: plan.Owner,
|
||||
Access: flattenAccess(ctx, &recordRG.ACL),
|
||||
DefNet: plan.DefNet,
|
||||
Description: types.StringValue(recordRG.Description),
|
||||
Force: plan.Force,
|
||||
Permanently: plan.Permanently,
|
||||
Restore: plan.Restore,
|
||||
Enable: types.BoolValue(recordRG.Status == "ENABLED"),
|
||||
Timeouts: plan.Timeouts,
|
||||
|
||||
RGID: types.Int64Value(int64(recordRG.ID)),
|
||||
LastUpdated: plan.LastUpdated,
|
||||
@@ -64,6 +63,8 @@ func RGResource(ctx context.Context, plan *models.ResourceRGModel, c *client.Cli
|
||||
CPUAllocationParameter: types.StringValue(recordRG.CPUAllocationParameter),
|
||||
CPUAllocationRatio: types.Float64Value(recordRG.CPUAllocationRatio),
|
||||
DefNetID: types.Int64Value(recordRG.DefNetID),
|
||||
CreatedBy: types.StringValue(recordRG.CreatedBy),
|
||||
CreatedTime: types.Int64Value(int64(recordRG.CreatedTime)),
|
||||
DeletedBy: types.StringValue(recordRG.DeletedBy),
|
||||
DeletedTime: types.Int64Value(int64(recordRG.DeletedTime)),
|
||||
Dirty: types.BoolValue(recordRG.Dirty),
|
||||
@@ -150,3 +151,43 @@ func flattenQuota(ctx context.Context, item *rg.ResourceLimits) types.Object {
|
||||
}
|
||||
return quota
|
||||
}
|
||||
|
||||
func flattenAccess(ctx context.Context, aclList *rg.ListACL) types.Set {
|
||||
tflog.Info(ctx, "Start flattenAccess")
|
||||
tempSlice := make([]types.Object, 0, len(*aclList)-1)
|
||||
for i, item := range *aclList {
|
||||
if i == 0 {
|
||||
continue
|
||||
}
|
||||
temp := models.AccessModel{
|
||||
Right: types.StringValue(item.Right),
|
||||
User: types.StringValue(item.UserGroupID),
|
||||
}
|
||||
obj, diags := types.ObjectValueFrom(ctx, models.ItemAccess, temp)
|
||||
if diags != nil {
|
||||
tflog.Error(ctx, fmt.Sprint("Error flattenAccess struct to obj", diags))
|
||||
}
|
||||
tempSlice = append(tempSlice, obj)
|
||||
}
|
||||
|
||||
res, diags := types.SetValueFrom(ctx, types.ObjectType{AttrTypes: models.ItemAccess}, tempSlice)
|
||||
if diags != nil {
|
||||
tflog.Error(ctx, fmt.Sprint("Error flattenAccess", diags))
|
||||
}
|
||||
|
||||
tflog.Info(ctx, "End flattenAccess")
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenDefNet(ctx context.Context, dnType string, dnId int64) types.Object {
|
||||
tflog.Info(ctx, "Start flattenDefNet")
|
||||
tempStruct := models.DefNetModel{
|
||||
NetType: types.StringValue(dnType),
|
||||
NetId: types.Int64Value(int64(dnId)),
|
||||
}
|
||||
quota, diags := types.ObjectValueFrom(ctx, models.ItemDefNet, tempStruct)
|
||||
if diags != nil {
|
||||
tflog.Error(ctx, fmt.Sprint("Error flattenDefNet", diags))
|
||||
}
|
||||
return quota
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user