Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(metrics-operator): remove omitempty tags to get complete representation of AnalysisResult #2078

Merged
merged 2 commits into from
Sep 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion metrics-operator/controllers/analysis/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func TestAnalysisReconciler_Reconcile_BasicControlLoop(t *testing.T) {
client: fake2.NewClient(&analysis, &analysisDef, &template),
want: controllerruntime.Result{},
wantErr: false,
status: &metricsapi.AnalysisStatus{Raw: "{\"pass\":true}", Pass: true},
status: &metricsapi.AnalysisStatus{Raw: "{\"objectiveResults\":null,\"totalScore\":0,\"maximumScore\":0,\"pass\":true,\"warning\":false}", Pass: true},
res: metricstypes.AnalysisResult{Pass: true},
},
}
Expand Down
28 changes: 14 additions & 14 deletions metrics-operator/controllers/common/analysis/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ type ProviderRequest struct {
}

type TargetResult struct {
FailResult OperatorResult `json:"failResult,omitempty"`
WarnResult OperatorResult `json:"warnResult,omitempty"`
Warning bool `json:"warning,omitempty"`
Pass bool `json:"pass,omitempty"`
FailResult OperatorResult `json:"failResult"`
WarnResult OperatorResult `json:"warnResult"`
Warning bool `json:"warning"`
Pass bool `json:"pass"`
}

func (t *TargetResult) IsFail() bool {
Expand All @@ -26,14 +26,14 @@ func (t *TargetResult) IsWarn() bool {
}

type OperatorResult struct {
Operator v1alpha3.Operator `json:"operator,omitempty"`
Fulfilled bool `json:"fulfilled,omitempty"`
Operator v1alpha3.Operator `json:"operator"`
Fulfilled bool `json:"fulfilled"`
}

type ObjectiveResult struct {
Result TargetResult `json:"result,omitempty"`
Value float64 `json:"value,omitempty"`
Score float64 `json:"score,omitempty"`
Result TargetResult `json:"result"`
Value float64 `json:"value"`
Score float64 `json:"score"`
Error error `json:"error,omitempty"`
}

Expand All @@ -50,11 +50,11 @@ func (o *ObjectiveResult) IsWarn() bool {
}

type AnalysisResult struct {
ObjectiveResults []ObjectiveResult `json:"objectiveResults,omitempty"`
TotalScore float64 `json:"totalScore,omitempty"`
MaximumScore float64 `json:"maximumScore,omitempty"`
Pass bool `json:"pass,omitempty"`
Warning bool `json:"warning,omitempty"`
ObjectiveResults []ObjectiveResult `json:"objectiveResults"`
TotalScore float64 `json:"totalScore"`
MaximumScore float64 `json:"maximumScore"`
Pass bool `json:"pass"`
Warning bool `json:"warning"`
}

func (a *AnalysisResult) GetAchievedPercentage() float64 {
Expand Down
2 changes: 1 addition & 1 deletion test/integration/analysis-controller/01-assert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ spec:
status:
pass: true
# yamllint disable-line rule:line-length
raw: '{"objectiveResults":[{"result":{"failResult":{"operator":{"lessThan":{"fixedValue":"2"}}},"warnResult":{"operator":{"lessThan":{"fixedValue":"3"}}},"pass":true},"value":4,"score":1}],"totalScore":1,"maximumScore":1,"pass":true}'
raw: '{"objectiveResults":[{"result":{"failResult":{"operator":{"lessThan":{"fixedValue":"2"}},"fulfilled":false},"warnResult":{"operator":{"lessThan":{"fixedValue":"3"}},"fulfilled":false},"warning":false,"pass":true},"value":4,"score":1}],"totalScore":1,"maximumScore":1,"pass":true,"warning":false}'
Loading