From 14358320140b5854282bbc756ef87bfd949ab721 Mon Sep 17 00:00:00 2001 From: Artem Lifshits <55093318+artem-lifshits@users.noreply.github.com> Date: Tue, 23 Apr 2024 12:35:48 +0200 Subject: [PATCH] [FGS]:fix various methods (#650) [FGS]:fix various methods What this PR does / why we need it Different fixes for TF Acceptance tests === RUN TestFunctionGraphReservedLifecycle reserved_test.go:44: Attempting to UPDATE FUNCGRAPH RESERVED INSTANCES tools.go:72: { "tactics_config": null, "idle_mode": false, "count": 1 } --- PASS: TestFunctionGraphReservedLifecycle (1.48s) PASS Process finished with the exit code 0 === RUN TestFunctionGraphLifecycle --- PASS: TestFunctionGraphLifecycle (2.48s) PASS Process finished with the exit code 0 Reviewed-by: Anton Sidelnikov --- acceptance/openstack/fgs/v2/functiongraph_test.go | 2 +- acceptance/openstack/fgs/v2/reserved_test.go | 3 ++- openstack/fgs/v2/function/UpdateCode.go | 12 ++++++------ openstack/fgs/v2/function/UpdateMaxInstances.go | 2 +- openstack/fgs/v2/reserved/Update.go | 4 ++-- 5 files changed, 12 insertions(+), 11 deletions(-) diff --git a/acceptance/openstack/fgs/v2/functiongraph_test.go b/acceptance/openstack/fgs/v2/functiongraph_test.go index dc3c1b7b2..7f8d717d1 100644 --- a/acceptance/openstack/fgs/v2/functiongraph_test.go +++ b/acceptance/openstack/fgs/v2/functiongraph_test.go @@ -46,7 +46,7 @@ func TestFunctionGraphLifecycle(t *testing.T) { updateFuncOpts := function.UpdateFuncCodeOpts{ FuncUrn: funcUrn, CodeType: "inline", - FuncCode: function.FuncCode{ + FuncCode: &function.FuncCode{ File: base64.StdEncoding.EncodeToString([]byte(appCode)), }, } diff --git a/acceptance/openstack/fgs/v2/reserved_test.go b/acceptance/openstack/fgs/v2/reserved_test.go index a1b6fe3ff..d144a0ac1 100644 --- a/acceptance/openstack/fgs/v2/reserved_test.go +++ b/acceptance/openstack/fgs/v2/reserved_test.go @@ -7,6 +7,7 @@ import ( golangsdk "github.com/opentelekomcloud/gophertelekomcloud" "github.com/opentelekomcloud/gophertelekomcloud/acceptance/clients" "github.com/opentelekomcloud/gophertelekomcloud/acceptance/tools" + "github.com/opentelekomcloud/gophertelekomcloud/openstack/common/pointerto" "github.com/opentelekomcloud/gophertelekomcloud/openstack/fgs/v2/function" "github.com/opentelekomcloud/gophertelekomcloud/openstack/fgs/v2/reserved" th "github.com/opentelekomcloud/gophertelekomcloud/testhelper" @@ -43,7 +44,7 @@ func TestFunctionGraphReservedLifecycle(t *testing.T) { t.Logf("Attempting to UPDATE FUNCGRAPH RESERVED INSTANCES") updateResp, err := reserved.Update(client, reserved.UpdateOpts{ FuncUrn: funcUrn, - Count: 1, + Count: pointerto.Int(1), }) th.AssertNoErr(t, err) diff --git a/openstack/fgs/v2/function/UpdateCode.go b/openstack/fgs/v2/function/UpdateCode.go index 06de9b1e3..ef08b0eca 100644 --- a/openstack/fgs/v2/function/UpdateCode.go +++ b/openstack/fgs/v2/function/UpdateCode.go @@ -7,12 +7,12 @@ import ( ) type UpdateFuncCodeOpts struct { - FuncUrn string `json:"-"` - CodeType string `json:"code_type" required:"true"` - CodeURL string `json:"code_url,omitempty"` - CodeFilename string `json:"code_filename,omitempty"` - FuncCode FuncCode `json:"func_code" required:"true"` - DependVersionList []string `json:"depend_version_list,omitempty"` + FuncUrn string `json:"-"` + CodeType string `json:"code_type" required:"true"` + CodeURL string `json:"code_url,omitempty"` + CodeFilename string `json:"code_filename,omitempty"` + FuncCode *FuncCode `json:"func_code,omitempty"` + DependVersionList []string `json:"depend_version_list,omitempty"` } func UpdateFuncCode(client *golangsdk.ServiceClient, opts UpdateFuncCodeOpts) (*FuncGraphCode, error) { diff --git a/openstack/fgs/v2/function/UpdateMaxInstances.go b/openstack/fgs/v2/function/UpdateMaxInstances.go index 17bf0c17a..8ffb1e250 100644 --- a/openstack/fgs/v2/function/UpdateMaxInstances.go +++ b/openstack/fgs/v2/function/UpdateMaxInstances.go @@ -8,7 +8,7 @@ import ( type UpdateFuncInstancesOpts struct { FuncUrn string `json:"-"` - MaxInstanceNum int `json:"max_instance_num" required:"true"` + MaxInstanceNum int `json:"max_instance_num,omitempty"` } func UpdateMaxInstances(client *golangsdk.ServiceClient, opts UpdateFuncInstancesOpts) (*FuncGraph, error) { diff --git a/openstack/fgs/v2/reserved/Update.go b/openstack/fgs/v2/reserved/Update.go index 291e7e9fb..d2b72ec15 100644 --- a/openstack/fgs/v2/reserved/Update.go +++ b/openstack/fgs/v2/reserved/Update.go @@ -8,7 +8,7 @@ import ( type UpdateOpts struct { FuncUrn string `json:"-"` - Count int `json:"count" required:"true"` + Count *int `json:"count" required:"true"` IdleMode *bool `json:"idle_mode"` TacticsConfig *TacticsConfig `json:"tactics_config"` } @@ -19,7 +19,7 @@ type TacticsConfig struct { type CronConfig struct { Name string `json:"name,omitempty"` Cron string `json:"cron,omitempty"` - Count string `json:"count,omitempty"` + Count int `json:"count,omitempty"` StartTime int `json:"start_time,omitempty"` ExpiredTime int `json:"expired_time,omitempty"` }