Skip to content

Commit

Permalink
Fix UT for eviciton config
Browse files Browse the repository at this point in the history
  • Loading branch information
apasyniuk committed Jan 18, 2024
1 parent 99a4709 commit 23e0b31
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions castai/resource_eviction_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,10 @@ func toPodSelector(in interface{}) (*sdk.CastaiEvictorV1PodSelector, error) {
if len(me) < 1 {
continue
}

if out.LabelSelector == nil {
out.LabelSelector = &sdk.CastaiEvictorV1LabelSelector{}
}
out.LabelSelector.MatchExpressions = &me
} else {
return nil, fmt.Errorf("mapping match_expressions expecting map[string]interface, got %T, %+v", v, v)
Expand All @@ -417,6 +421,9 @@ func toPodSelector(in interface{}) (*sdk.CastaiEvictorV1PodSelector, error) {
return nil, err
}

if out.LabelSelector == nil {
out.LabelSelector = &sdk.CastaiEvictorV1LabelSelector{}
}
out.LabelSelector.MatchLabels = mls
}
}
Expand Down
2 changes: 1 addition & 1 deletion castai/resource_eviction_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ func TestEvictionConfig_UpdateContext(t *testing.T) {
Settings: sdk.CastaiEvictorV1EvictionSettings{Aggressive: &sdk.CastaiEvictorV1EvictionSettingsSettingEnabled{Enabled: true}},
PodSelector: &sdk.CastaiEvictorV1PodSelector{
Kind: lo.ToPtr("Job"),
LabelSelector: sdk.CastaiEvictorV1LabelSelector{
LabelSelector: &sdk.CastaiEvictorV1LabelSelector{
MatchLabels: &sdk.CastaiEvictorV1LabelSelector_MatchLabels{AdditionalProperties: map[string]string{
"key1": "value1",
}}}}}
Expand Down

0 comments on commit 23e0b31

Please sign in to comment.