Skip to content

Commit

Permalink
feat(metrics-operator): remove omitempty tags to get complete represe…
Browse files Browse the repository at this point in the history
…ntation of AnalysisResult (#2078)

Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
  • Loading branch information
bacherfl authored Sep 14, 2023
1 parent 598fed3 commit a08b9ca
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
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}'

0 comments on commit a08b9ca

Please sign in to comment.