-
Notifications
You must be signed in to change notification settings - Fork 10
fix: consistent status message for unchanged resources #1402
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
base: master
Are you sure you want to change the base?
Conversation
4914112 to
ed1ca9f
Compare
ceee328 to
6faac35
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces a significant and valuable refactoring by changing numerous struct fields from value types to pointer types. This change allows for better handling of default values and distinguishing between unset fields and those explicitly set to their zero value, which is crucial for consistent behavior, especially in status messages for unchanged resources. The introduction of the adapter package to centralize default value population is a great step towards better maintainability. My review focuses on ensuring the consistency of these changes. I've found a few minor inconsistencies in JSON tags where omitempty is missing for new pointer fields, which could lead to null values in the JSON output instead of omitting the field. Overall, this is a solid improvement to the API models.
| // +kubebuilder:validation:Optional (default: true) | ||
| KeepAlive *bool `json:"keepAlive"` | ||
| // +kubebuilder:validation:Optional | ||
| // +kubebuilder:default:=true | ||
| KeepAlive bool `json:"keepAlive"` | ||
| // +kubebuilder:validation:Optional | ||
| // +kubebuilder:default:=30000 | ||
| // Should keep alive be used for the HTTP connection ? | ||
| KeepAliveTimeout uint64 `json:"keepAliveTimeout"` | ||
| // Should keep alive be used for the HTTP connection ? (default: 30000) | ||
| KeepAliveTimeout *uint64 `json:"keepAliveTimeout"` | ||
| // Read timeout | ||
| // +kubebuilder:validation:Optional | ||
| ReadTimeout *uint64 `json:"readTimeout,omitempty"` | ||
| // +kubebuilder:default:=false | ||
| // Should HTTP/1.1 pipelining be used for the connection or not ? | ||
| Pipelining bool `json:"pipelining"` | ||
| // Should HTTP/1.1 pipelining be used for the connection or not ? (default: false) | ||
| Pipelining *bool `json:"pipelining"` | ||
| // HTTP max concurrent connections | ||
| // +kubebuilder:validation:Optional | ||
| MaxConcurrentConnections *int `json:"maxConcurrentConnections,omitempty"` | ||
| // +kubebuilder:default:=false | ||
| // Should compression be used or not ? | ||
| UseCompression bool `json:"useCompression"` | ||
| // Should compression be used or not ? (default: false) | ||
| UseCompression *bool `json:"useCompression"` | ||
| // +kubebuilder:validation:Optional | ||
| // +kubebuilder:default:=false | ||
| // Propagate Client Accept-Encoding header | ||
| PropagateClientAcceptEncoding bool `json:"propagateClientAcceptEncoding"` | ||
| // +kubebuilder:default:=false | ||
| // Propagate Client Accept-Encoding header (default: false) | ||
| PropagateClientAcceptEncoding *bool `json:"propagateClientAcceptEncoding"` | ||
| // Should HTTP redirects be followed or not ? | ||
| FollowRedirects bool `json:"followRedirects"` | ||
| // +kubebuilder:validation:Optional | ||
| // +kubebuilder:default:=true | ||
| // Should HTTP/2 clear text upgrade be used or not ? | ||
| ClearTextUpgrade bool `json:"clearTextUpgrade"` | ||
| // +kubebuilder:default:=HTTP_1_1 | ||
| // HTTP Protocol Version (Possible values Http1 or Http2) | ||
| ProtocolVersion ProtocolVersion `json:"version,omitempty"` | ||
| FollowRedirects *bool `json:"followRedirects"` | ||
| // +kubebuilder:validation:Optional | ||
| // Should HTTP/2 clear text upgrade be used or not ? (default: true) | ||
| ClearTextUpgrade *bool `json:"clearTextUpgrade"` | ||
| // HTTP Protocol Version (Possible values Http1 or Http2) (default: HTTP_1_1) | ||
| ProtocolVersion *ProtocolVersion `json:"version,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To ensure consistency and avoid sending null values in the JSON output for unset fields, the omitempty option should be added to the json tag for all new pointer fields in this struct. This applies to KeepAlive, KeepAliveTimeout, Pipelining, UseCompression, PropagateClientAcceptEncoding, FollowRedirects, and ClearTextUpgrade.
// +kubebuilder:validation:Optional (default: true)
KeepAlive *bool `json:"keepAlive,omitempty"`
// +kubebuilder:validation:Optional
// Should keep alive be used for the HTTP connection ? (default: 30000)
KeepAliveTimeout *uint64 `json:"keepAliveTimeout,omitempty"`
// Read timeout
// +kubebuilder:validation:Optional
ReadTimeout *uint64 `json:"readTimeout,omitempty"`
// Should HTTP/1.1 pipelining be used for the connection or not ? (default: false)
Pipelining *bool `json:"pipelining,omitempty"`
// HTTP max concurrent connections
// +kubebuilder:validation:Optional
MaxConcurrentConnections *int `json:"maxConcurrentConnections,omitempty"`
// Should compression be used or not ? (default: false)
UseCompression *bool `json:"useCompression,omitempty"`
// +kubebuilder:validation:Optional
// Propagate Client Accept-Encoding header (default: false)
PropagateClientAcceptEncoding *bool `json:"propagateClientAcceptEncoding,omitempty"`
// Should HTTP redirects be followed or not ?
FollowRedirects *bool `json:"followRedirects,omitempty"`
// +kubebuilder:validation:Optional
// Should HTTP/2 clear text upgrade be used or not ? (default: true)
ClearTextUpgrade *bool `json:"clearTextUpgrade,omitempty"`
// HTTP Protocol Version (Possible values Http1 or Http2) (default: HTTP_1_1)
ProtocolVersion *ProtocolVersion `json:"version,omitempty"`| // Is resource enabled or not? | ||
| Enabled bool `json:"enabled"` | ||
| // Is resource enabled or not? (default: true) | ||
| Enabled *bool `json:"enabled"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // Indicate if this flow is enabled or disabled | ||
| Enabled bool `json:"enabled"` | ||
| // Indicate if this flow is enabled or disabled (default: true) | ||
| Enabled *bool `json:"enabled"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // Is service enabled or not? | ||
| Enabled bool `json:"enabled"` | ||
| // Is service enabled or not? (default: false) | ||
| Enabled *bool `json:"enabled"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
6faac35 to
22d10b4
Compare
|



see https://gravitee.atlassian.net/browse/GKO-1530