This commit is contained in:
2023-07-26 13:32:39 +03:00
parent f731cf246f
commit 272e385318
167 changed files with 5194 additions and 890 deletions

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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),

View File

@@ -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,
},
}
}

View File

@@ -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
}

View File

@@ -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)
}

View File

@@ -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
}

View File

@@ -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)
}

View File

@@ -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))
}