Repository navigation
Add missing fields to SpecReport JSON marshalling, and add unit test - #1687
Merged
Merged
Conversation
pohly
approved these changes
Oct 8, 2026
Comment on lines
+390
to
+392
| for i := range reportType.NumField() { | ||
| if reportVal.Field(i).IsZero() { | ||
| missingFields = append(missingFields, reportType.Field(i).Name) |
Contributor
There was a problem hiding this comment.
Nit:
Suggested change
| for i := range reportType.NumField() { | |
| if reportVal.Field(i).IsZero() { | |
| missingFields = append(missingFields, reportType.Field(i).Name) | |
| for field := range reportType.Fields() { | |
| if field.IsZero() { | |
| missingFields = append(missingFields, field.Name) |
Contributor
Author
There was a problem hiding this comment.
No, that's trying to call a reflect.Value method on a reflect.Type. As far as I could tell, if you want both .Name and .IsZero(), you need to iterate both objects together.
Contributor
There was a problem hiding this comment.
Ah, I see now - I missed the part about needing info from both.
Owner
|
looks great thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Trying to do something with kubernetes's
e2e.test --spec-dumpand discovered that it wasn't dumpingLeafNodeComponentSemVerConstraints. It was an easy fix, but then when I updated the unit test to try to make sure we didn't miss out on any other fields in the future, I discovered that we were already missing a bunch of other fields...If the goal is just "don't output an empty
Failure" there's probably a better way to write this... but for now, this at least adds all the missing fields, and makes sure we don't miss any more in the future.