Skip to content

Commit

Permalink
Revert "add 'version' filter for k8scluster"
Browse files Browse the repository at this point in the history
This reverts commit 0d57cae.
  • Loading branch information
Sooyoung Kim committed Jun 3, 2024
1 parent d7b0e81 commit 8b07b57
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 25 deletions.
5 changes: 0 additions & 5 deletions src/core/mcir/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,6 @@ type FilterSpecsByRangeRequest struct {
EvaluationScore10 Range `json:"evaluationScore10"`
}

type FilterK8sClusterByRangeRequest struct {
FilterSpecsByRangeRequest
Version string `json:"version"`
}

// ConvertSpiderSpecToTumblebugSpec accepts an Spider spec object, converts to and returns an TB spec object
func ConvertSpiderSpecToTumblebugSpec(spiderSpec SpiderSpecInfo) (TbSpecInfo, error) {
if spiderSpec.Name == "" {
Expand Down
21 changes: 1 addition & 20 deletions src/core/mcis/recommendation.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ type FilterInfo struct {

// FilterCondition is struct for .
type FilterCondition struct {
Metric string `json:"metric" example:"vCPU" enums:"vCPU,memoryGiB,costPerHour,version"`
Metric string `json:"metric" example:"vCPU" enums:"vCPU,memoryGiB,costPerHour"`
Condition []Operation `json:"condition"`
}

Expand Down Expand Up @@ -86,25 +86,6 @@ func toUpperFirst(s string) string {
return string(r)
}

// applyK8sClusterFilterPolicies dynamically sets filters on the request based on the policies.
func applyK8sClusterFilterPolicies(request *mcir.FilterK8sClusterByRangeRequest, plan *DeploymentPlan) error {
val := reflect.ValueOf(request).Elem()

for _, policy := range plan.Filter.Policy {
for _, condition := range policy.Condition {
fieldName := toUpperFirst(policy.Metric) // Correctly capitalize the first letter
field := val.FieldByName(fieldName)
if !field.IsValid() {
return fmt.Errorf("invalid metric: %s", policy.Metric)
}
if err := setFieldCondition(field, condition); err != nil {
return fmt.Errorf("setting condition failed: %v", err)
}
}
}
return nil
}

// applyFilterPolicies dynamically sets filters on the request based on the policies.
func applyFilterPolicies(request *mcir.FilterSpecsByRangeRequest, plan *DeploymentPlan) error {
val := reflect.ValueOf(request).Elem()
Expand Down

0 comments on commit 8b07b57

Please sign in to comment.