diff --git a/castai/resource_eviction_config.go b/castai/resource_eviction_config.go index 17ca458e..ad716d87 100644 --- a/castai/resource_eviction_config.go +++ b/castai/resource_eviction_config.go @@ -214,9 +214,9 @@ func upsertEvictionConfigs(ctx context.Context, data *schema.ResourceData, meta "application/json", bytes.NewReader(evictorAdvancedConfigJson), ) - if err != nil || resp.JSON200 == nil { + if checkErr := sdk.CheckOKResponse(resp, err); checkErr != nil { log.Printf("[ERROR] Failed to upsert evictor advanced config: %v", err) - return err + return checkErr } err = data.Set(FieldEvictorAdvancedConfig, flattenEvictionConfig(resp.JSON200.EvictionConfig)) if err != nil { @@ -421,6 +421,10 @@ func toPodSelector(in interface{}) (*sdk.CastaiEvictorV1PodSelector, error) { return nil, err } + if mls == nil || len(mls.AdditionalProperties) == 0 { + continue + } + if out.LabelSelector == nil { out.LabelSelector = &sdk.CastaiEvictorV1LabelSelector{} } diff --git a/castai/resource_rebalancing_job.go b/castai/resource_rebalancing_job.go index 5bee32b1..19c098dd 100644 --- a/castai/resource_rebalancing_job.go +++ b/castai/resource_rebalancing_job.go @@ -189,7 +189,7 @@ func getRebalancingJobByScheduleName(ctx context.Context, client *sdk.ClientWith return nil, fmt.Errorf("getting schedule: %w", err) } - resp, err := client.ScheduledRebalancingAPIListRebalancingJobsWithResponse(ctx, clusterID) + resp, err := client.ScheduledRebalancingAPIListRebalancingJobsWithResponse(ctx, clusterID, &sdk.ScheduledRebalancingAPIListRebalancingJobsParams{}) if checkErr := sdk.CheckOKResponse(resp, err); checkErr != nil { return nil, checkErr } diff --git a/castai/sdk/api.gen.go b/castai/sdk/api.gen.go index 1b9b4ac1..32704aff 100644 --- a/castai/sdk/api.gen.go +++ b/castai/sdk/api.gen.go @@ -2617,6 +2617,11 @@ type NodeTemplatesAPIUpdateNodeTemplateJSONBody = NodetemplatesV1UpdateNodeTempl // PoliciesAPIUpsertClusterPoliciesJSONBody defines parameters for PoliciesAPIUpsertClusterPolicies. type PoliciesAPIUpsertClusterPoliciesJSONBody = PoliciesV1Policies +// ScheduledRebalancingAPIListRebalancingJobsParams defines parameters for ScheduledRebalancingAPIListRebalancingJobs. +type ScheduledRebalancingAPIListRebalancingJobsParams struct { + RebalancingScheduleId *string `form:"rebalancingScheduleId,omitempty" json:"rebalancingScheduleId,omitempty"` +} + // ScheduledRebalancingAPICreateRebalancingJobJSONBody defines parameters for ScheduledRebalancingAPICreateRebalancingJob. type ScheduledRebalancingAPICreateRebalancingJobJSONBody = ScheduledrebalancingV1RebalancingJob diff --git a/castai/sdk/client.gen.go b/castai/sdk/client.gen.go index 158c367d..a9f8f23a 100644 --- a/castai/sdk/client.gen.go +++ b/castai/sdk/client.gen.go @@ -194,7 +194,7 @@ type ClientInterface interface { PoliciesAPIUpsertClusterPolicies(ctx context.Context, clusterId string, body PoliciesAPIUpsertClusterPoliciesJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) // ScheduledRebalancingAPIListRebalancingJobs request - ScheduledRebalancingAPIListRebalancingJobs(ctx context.Context, clusterId string, reqEditors ...RequestEditorFn) (*http.Response, error) + ScheduledRebalancingAPIListRebalancingJobs(ctx context.Context, clusterId string, params *ScheduledRebalancingAPIListRebalancingJobsParams, reqEditors ...RequestEditorFn) (*http.Response, error) // ScheduledRebalancingAPICreateRebalancingJob request with any body ScheduledRebalancingAPICreateRebalancingJobWithBody(ctx context.Context, clusterId string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -872,8 +872,8 @@ func (c *Client) PoliciesAPIUpsertClusterPolicies(ctx context.Context, clusterId return c.Client.Do(req) } -func (c *Client) ScheduledRebalancingAPIListRebalancingJobs(ctx context.Context, clusterId string, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewScheduledRebalancingAPIListRebalancingJobsRequest(c.Server, clusterId) +func (c *Client) ScheduledRebalancingAPIListRebalancingJobs(ctx context.Context, clusterId string, params *ScheduledRebalancingAPIListRebalancingJobsParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewScheduledRebalancingAPIListRebalancingJobsRequest(c.Server, clusterId, params) if err != nil { return nil, err } @@ -3012,7 +3012,7 @@ func NewPoliciesAPIUpsertClusterPoliciesRequestWithBody(server string, clusterId } // NewScheduledRebalancingAPIListRebalancingJobsRequest generates requests for ScheduledRebalancingAPIListRebalancingJobs -func NewScheduledRebalancingAPIListRebalancingJobsRequest(server string, clusterId string) (*http.Request, error) { +func NewScheduledRebalancingAPIListRebalancingJobsRequest(server string, clusterId string, params *ScheduledRebalancingAPIListRebalancingJobsParams) (*http.Request, error) { var err error var pathParam0 string @@ -3037,6 +3037,26 @@ func NewScheduledRebalancingAPIListRebalancingJobsRequest(server string, cluster return nil, err } + queryValues := queryURL.Query() + + if params.RebalancingScheduleId != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "rebalancingScheduleId", runtime.ParamLocationQuery, *params.RebalancingScheduleId); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + queryURL.RawQuery = queryValues.Encode() + req, err := http.NewRequest("GET", queryURL.String(), nil) if err != nil { return nil, err @@ -5643,7 +5663,7 @@ type ClientWithResponsesInterface interface { PoliciesAPIUpsertClusterPoliciesWithResponse(ctx context.Context, clusterId string, body PoliciesAPIUpsertClusterPoliciesJSONRequestBody) (*PoliciesAPIUpsertClusterPoliciesResponse, error) // ScheduledRebalancingAPIListRebalancingJobs request - ScheduledRebalancingAPIListRebalancingJobsWithResponse(ctx context.Context, clusterId string) (*ScheduledRebalancingAPIListRebalancingJobsResponse, error) + ScheduledRebalancingAPIListRebalancingJobsWithResponse(ctx context.Context, clusterId string, params *ScheduledRebalancingAPIListRebalancingJobsParams) (*ScheduledRebalancingAPIListRebalancingJobsResponse, error) // ScheduledRebalancingAPICreateRebalancingJob request with any body ScheduledRebalancingAPICreateRebalancingJobWithBodyWithResponse(ctx context.Context, clusterId string, contentType string, body io.Reader) (*ScheduledRebalancingAPICreateRebalancingJobResponse, error) @@ -8813,8 +8833,8 @@ func (c *ClientWithResponses) PoliciesAPIUpsertClusterPoliciesWithResponse(ctx c } // ScheduledRebalancingAPIListRebalancingJobsWithResponse request returning *ScheduledRebalancingAPIListRebalancingJobsResponse -func (c *ClientWithResponses) ScheduledRebalancingAPIListRebalancingJobsWithResponse(ctx context.Context, clusterId string) (*ScheduledRebalancingAPIListRebalancingJobsResponse, error) { - rsp, err := c.ScheduledRebalancingAPIListRebalancingJobs(ctx, clusterId) +func (c *ClientWithResponses) ScheduledRebalancingAPIListRebalancingJobsWithResponse(ctx context.Context, clusterId string, params *ScheduledRebalancingAPIListRebalancingJobsParams) (*ScheduledRebalancingAPIListRebalancingJobsResponse, error) { + rsp, err := c.ScheduledRebalancingAPIListRebalancingJobs(ctx, clusterId, params) if err != nil { return nil, err } diff --git a/castai/sdk/mock/client.go b/castai/sdk/mock/client.go index a134930f..1a1fa6c9 100644 --- a/castai/sdk/mock/client.go +++ b/castai/sdk/mock/client.go @@ -1856,9 +1856,9 @@ func (mr *MockClientInterfaceMockRecorder) ScheduledRebalancingAPIListAvailableR } // ScheduledRebalancingAPIListRebalancingJobs mocks base method. -func (m *MockClientInterface) ScheduledRebalancingAPIListRebalancingJobs(ctx context.Context, clusterId string, reqEditors ...sdk.RequestEditorFn) (*http.Response, error) { +func (m *MockClientInterface) ScheduledRebalancingAPIListRebalancingJobs(ctx context.Context, clusterId string, params *sdk.ScheduledRebalancingAPIListRebalancingJobsParams, reqEditors ...sdk.RequestEditorFn) (*http.Response, error) { m.ctrl.T.Helper() - varargs := []interface{}{ctx, clusterId} + varargs := []interface{}{ctx, clusterId, params} for _, a := range reqEditors { varargs = append(varargs, a) } @@ -1869,9 +1869,9 @@ func (m *MockClientInterface) ScheduledRebalancingAPIListRebalancingJobs(ctx con } // ScheduledRebalancingAPIListRebalancingJobs indicates an expected call of ScheduledRebalancingAPIListRebalancingJobs. -func (mr *MockClientInterfaceMockRecorder) ScheduledRebalancingAPIListRebalancingJobs(ctx, clusterId interface{}, reqEditors ...interface{}) *gomock.Call { +func (mr *MockClientInterfaceMockRecorder) ScheduledRebalancingAPIListRebalancingJobs(ctx, clusterId, params interface{}, reqEditors ...interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{ctx, clusterId}, reqEditors...) + varargs := append([]interface{}{ctx, clusterId, params}, reqEditors...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ScheduledRebalancingAPIListRebalancingJobs", reflect.TypeOf((*MockClientInterface)(nil).ScheduledRebalancingAPIListRebalancingJobs), varargs...) } @@ -3814,18 +3814,18 @@ func (mr *MockClientWithResponsesInterfaceMockRecorder) ScheduledRebalancingAPIL } // ScheduledRebalancingAPIListRebalancingJobsWithResponse mocks base method. -func (m *MockClientWithResponsesInterface) ScheduledRebalancingAPIListRebalancingJobsWithResponse(ctx context.Context, clusterId string) (*sdk.ScheduledRebalancingAPIListRebalancingJobsResponse, error) { +func (m *MockClientWithResponsesInterface) ScheduledRebalancingAPIListRebalancingJobsWithResponse(ctx context.Context, clusterId string, params *sdk.ScheduledRebalancingAPIListRebalancingJobsParams) (*sdk.ScheduledRebalancingAPIListRebalancingJobsResponse, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "ScheduledRebalancingAPIListRebalancingJobsWithResponse", ctx, clusterId) + ret := m.ctrl.Call(m, "ScheduledRebalancingAPIListRebalancingJobsWithResponse", ctx, clusterId, params) ret0, _ := ret[0].(*sdk.ScheduledRebalancingAPIListRebalancingJobsResponse) ret1, _ := ret[1].(error) return ret0, ret1 } // ScheduledRebalancingAPIListRebalancingJobsWithResponse indicates an expected call of ScheduledRebalancingAPIListRebalancingJobsWithResponse. -func (mr *MockClientWithResponsesInterfaceMockRecorder) ScheduledRebalancingAPIListRebalancingJobsWithResponse(ctx, clusterId interface{}) *gomock.Call { +func (mr *MockClientWithResponsesInterfaceMockRecorder) ScheduledRebalancingAPIListRebalancingJobsWithResponse(ctx, clusterId, params interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ScheduledRebalancingAPIListRebalancingJobsWithResponse", reflect.TypeOf((*MockClientWithResponsesInterface)(nil).ScheduledRebalancingAPIListRebalancingJobsWithResponse), ctx, clusterId) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ScheduledRebalancingAPIListRebalancingJobsWithResponse", reflect.TypeOf((*MockClientWithResponsesInterface)(nil).ScheduledRebalancingAPIListRebalancingJobsWithResponse), ctx, clusterId, params) } // ScheduledRebalancingAPIListRebalancingSchedulesWithResponse mocks base method.