Skip to content

Commit 4e4a6e2

Browse files
committed
fix non debug output
Signed-off-by: Sylwester Piskozub <sylwesterpiskozub@gmail.com>
1 parent b8e9fa3 commit 4e4a6e2

2 files changed

Lines changed: 9 additions & 11 deletions

File tree

app/cli/cmd/policy_develop_eval.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,8 @@ evaluates the policy against the provided material or attestation.`,
6464
if err != nil {
6565
return err
6666
}
67-
if debug {
68-
return encodeJSON(result)
69-
}
7067

71-
return encodeJSON(result.Result)
68+
return encodeJSON(result)
7269
},
7370
}
7471

app/cli/internal/policydevel/eval.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ type EvalResult struct {
4646
}
4747

4848
type EvalSummary struct {
49-
Result EvalResult `json:"result"`
50-
DebugInfo EvalSummaryDebugInfo `json:"debug_info"`
49+
Result *EvalResult `json:"result"`
50+
DebugInfo *EvalSummaryDebugInfo `json:"debug_info,omitempty"`
5151
}
5252

5353
type EvalSummaryDebugInfo struct {
@@ -112,15 +112,11 @@ func verifyMaterial(schema *v1.CraftingSchema, material *v12.Attestation_Materia
112112
policyEv := policyEvs[0]
113113

114114
summary := &EvalSummary{
115-
Result: EvalResult{
115+
Result: &EvalResult{
116116
Skipped: policyEv.GetSkipped(),
117117
SkipReasons: policyEv.SkipReasons,
118118
Violations: make([]string, 0, len(policyEv.Violations)),
119119
},
120-
DebugInfo: EvalSummaryDebugInfo{
121-
Inputs: []map[string]interface{}{},
122-
RawResults: []map[string]interface{}{},
123-
},
124120
}
125121

126122
// Collect violation messages
@@ -130,6 +126,11 @@ func verifyMaterial(schema *v1.CraftingSchema, material *v12.Attestation_Materia
130126

131127
// Include raw debug info if requested
132128
if debug {
129+
summary.DebugInfo = &EvalSummaryDebugInfo{
130+
Inputs: []map[string]interface{}{},
131+
RawResults: []map[string]interface{}{},
132+
}
133+
133134
for _, rr := range apiRawResultsToEngineRawResults(policyEv.RawResults) {
134135
if in, ok := rr["input"].(map[string]interface{}); ok {
135136
// Take the first input found, as we only allow one material input

0 commit comments

Comments
 (0)