4.3.0
This commit is contained in:
@@ -49,6 +49,7 @@ func dataSourceLBListRead(ctx context.Context, d *schema.ResourceData, m interfa
|
||||
id := uuid.New()
|
||||
d.SetId(id.String())
|
||||
d.Set("items", flattenLBList(lbList))
|
||||
d.Set("entry_count", lbList.EntryCount)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -49,6 +49,7 @@ func dataSourceLBListDeletedRead(ctx context.Context, d *schema.ResourceData, m
|
||||
id := uuid.New()
|
||||
d.SetId(id.String())
|
||||
d.Set("items", flattenLBList(lbList))
|
||||
d.Set("entry_count", lbList.EntryCount)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -241,9 +241,9 @@ func flattenLBBackends(backends []lb.ItemBackend) []map[string]interface{} {
|
||||
return temp
|
||||
}
|
||||
|
||||
func flattenLBList(lbl lb.ListLB) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0, len(lbl))
|
||||
for _, lb := range lbl {
|
||||
func flattenLBList(lbl *lb.ListLB) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0, len(lbl.Data))
|
||||
for _, lb := range lbl.Data {
|
||||
temp := map[string]interface{}{
|
||||
"ha_mode": lb.HAMode,
|
||||
"backends": flattenLBBackends(lb.Backends),
|
||||
|
||||
@@ -45,6 +45,41 @@ func dsLBSchemaMake() map[string]*schema.Schema {
|
||||
|
||||
func dsLBListDeletedSchemaMake() map[string]*schema.Schema {
|
||||
return map[string]*schema.Schema{
|
||||
"by_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Filter by ID",
|
||||
},
|
||||
"name": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Filter by name",
|
||||
},
|
||||
"account_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Filter by Account ID",
|
||||
},
|
||||
"rg_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Filter by RG ID",
|
||||
},
|
||||
"tech_status": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Filter by TechStatus",
|
||||
},
|
||||
"front_ip": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Filter by FrontIP",
|
||||
},
|
||||
"back_ip": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Filter by BackIP",
|
||||
},
|
||||
"page": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
@@ -62,11 +97,55 @@ func dsLBListDeletedSchemaMake() map[string]*schema.Schema {
|
||||
Schema: dsLBItemSchemaMake(),
|
||||
},
|
||||
},
|
||||
"entry_count": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func dsLBListSchemaMake() map[string]*schema.Schema {
|
||||
return map[string]*schema.Schema{
|
||||
"by_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Filter by ID",
|
||||
},
|
||||
"name": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Filter by name",
|
||||
},
|
||||
"account_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Filter by Account ID",
|
||||
},
|
||||
"rg_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Filter by RG ID",
|
||||
},
|
||||
"tech_status": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Filter by TechStatus",
|
||||
},
|
||||
"status": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Filter by Status",
|
||||
},
|
||||
"front_ip": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Filter by FrontIP",
|
||||
},
|
||||
"back_ip": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Filter by BackIP",
|
||||
},
|
||||
"includedeleted": {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
@@ -89,6 +168,10 @@ func dsLBListSchemaMake() map[string]*schema.Schema {
|
||||
Schema: dsLBItemSchemaMake(),
|
||||
},
|
||||
},
|
||||
"entry_count": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ func existLBID(ctx context.Context, d *schema.ResourceData, m interface{}) (bool
|
||||
return false, err
|
||||
}
|
||||
|
||||
return len(lbList.FilterByID(lbId)) != 0, nil
|
||||
return len(lbList.FilterByID(lbId).Data) != 0, nil
|
||||
}
|
||||
|
||||
func existRGID(ctx context.Context, d *schema.ResourceData, m interface{}) (bool, error) {
|
||||
@@ -36,7 +36,7 @@ func existRGID(ctx context.Context, d *schema.ResourceData, m interface{}) (bool
|
||||
return false, err
|
||||
}
|
||||
|
||||
return len(rgList.FilterByID(rgId)) != 0, nil
|
||||
return len(rgList.FilterByID(rgId).Data) != 0, nil
|
||||
}
|
||||
|
||||
func existExtNetID(ctx context.Context, d *schema.ResourceData, m interface{}) (bool, error) {
|
||||
@@ -50,7 +50,7 @@ func existExtNetID(ctx context.Context, d *schema.ResourceData, m interface{}) (
|
||||
return false, err
|
||||
}
|
||||
|
||||
return len(extNetList.FilterByID(extNetID)) != 0, nil
|
||||
return len(extNetList.FilterByID(extNetID).Data) != 0, nil
|
||||
}
|
||||
|
||||
func existViNSID(ctx context.Context, d *schema.ResourceData, m interface{}) (bool, error) {
|
||||
@@ -64,5 +64,5 @@ func existViNSID(ctx context.Context, d *schema.ResourceData, m interface{}) (bo
|
||||
return false, err
|
||||
}
|
||||
|
||||
return len(vinsList.FilterByID(vinsID)) != 0, nil
|
||||
return len(vinsList.FilterByID(vinsID).Data) != 0, nil
|
||||
}
|
||||
|
||||
@@ -198,8 +198,6 @@ func resourceLBBackendUpdate(ctx context.Context, d *schema.ResourceData, m inte
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
//TODO: перенести servers сюда
|
||||
|
||||
return resourceLBBackendRead(ctx, d, m)
|
||||
}
|
||||
|
||||
|
||||
@@ -120,9 +120,6 @@ func resourceLBFrontendDelete(ctx context.Context, d *schema.ResourceData, m int
|
||||
}
|
||||
|
||||
func resourceLBFrontendEdit(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
|
||||
//TODO: перенести bindings сюда
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -42,10 +42,42 @@ import (
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
)
|
||||
|
||||
func utilityLBListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (lb.ListLB, error) {
|
||||
func utilityLBListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*lb.ListLB, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
req := lb.ListRequest{}
|
||||
|
||||
if by_id, ok := d.GetOk("by_id"); ok {
|
||||
req.ByID = uint64(by_id.(int))
|
||||
}
|
||||
|
||||
if name, ok := d.GetOk("name"); ok {
|
||||
req.Name = name.(string)
|
||||
}
|
||||
|
||||
if account_id, ok := d.GetOk("account_id"); ok {
|
||||
req.AccountID = uint64(account_id.(int))
|
||||
}
|
||||
|
||||
if rg_id, ok := d.GetOk("rg_id"); ok {
|
||||
req.RGID = uint64(rg_id.(int))
|
||||
}
|
||||
|
||||
if tech_status, ok := d.GetOk("tech_status"); ok {
|
||||
req.TechStatus = tech_status.(string)
|
||||
}
|
||||
|
||||
if status, ok := d.GetOk("status"); ok {
|
||||
req.Status = status.(string)
|
||||
}
|
||||
|
||||
if front_ip, ok := d.GetOk("front_ip"); ok {
|
||||
req.FrontIP = front_ip.(string)
|
||||
}
|
||||
|
||||
if back_ip, ok := d.GetOk("back_ip"); ok {
|
||||
req.BackIP = back_ip.(string)
|
||||
}
|
||||
|
||||
if includedeleted, ok := d.GetOk("includedeleted"); ok {
|
||||
req.IncludeDeleted = includedeleted.(bool)
|
||||
}
|
||||
|
||||
@@ -42,10 +42,38 @@ import (
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
)
|
||||
|
||||
func utilityLBListDeletedCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (lb.ListLB, error) {
|
||||
func utilityLBListDeletedCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*lb.ListLB, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
req := lb.ListDeletedRequest{}
|
||||
|
||||
if by_id, ok := d.GetOk("by_id"); ok {
|
||||
req.ByID = uint64(by_id.(int))
|
||||
}
|
||||
|
||||
if name, ok := d.GetOk("name"); ok {
|
||||
req.Name = name.(string)
|
||||
}
|
||||
|
||||
if account_id, ok := d.GetOk("account_id"); ok {
|
||||
req.AccountID = uint64(account_id.(int))
|
||||
}
|
||||
|
||||
if rg_id, ok := d.GetOk("rg_id"); ok {
|
||||
req.RGID = uint64(rg_id.(int))
|
||||
}
|
||||
|
||||
if tech_status, ok := d.GetOk("tech_status"); ok {
|
||||
req.TechStatus = tech_status.(string)
|
||||
}
|
||||
|
||||
if front_ip, ok := d.GetOk("front_ip"); ok {
|
||||
req.FrontIP = front_ip.(string)
|
||||
}
|
||||
|
||||
if back_ip, ok := d.GetOk("back_ip"); ok {
|
||||
req.BackIP = back_ip.(string)
|
||||
}
|
||||
|
||||
if page, ok := d.GetOk("page"); ok {
|
||||
req.Page = uint64(page.(int))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user