Uh oh!
There was an error while loading. Please reload this page.
Embed struct, not pointer in resources - #2829
Conversation
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
… commit message that captures the essence of the transformation: refactor: replace App pointer embedding with direct struct embedding
This commit resolves type mismatch errors in test files by converting `compute.ClusterSpec{}` to `&compute.ClusterSpec{}` to match the expected pointer type.
The changes affect multiple test files in the bundle configuration and deployment packages, ensuring consistent type usage for cluster specifications.This reverts commit 8bd4ddb.
a1add45 to
9fa0be8Compare
pietern
left a comment
There was a problem hiding this comment.
Thanks, great simplification!
| assert.Nil(t, b.Config.Resources.Volumes["nilVolume"]) | ||
| assert.Nil(t, b.Config.Resources.Volumes["emptyVolume"].CreateVolumeRequestContent) | ||
| // assert.Nil(t, b.Config.Resources.Volumes["emptyVolume"].CreateVolumeRequestContent) |
There was a problem hiding this comment.
Not a dup (second line used to check inner pointer), should have been cleaned up.
| ModelServingEndpoints: map[string]*resources.ModelServingEndpoint{ | ||
| "my_model_serving_endpoint": { | ||
| CreateServingEndpoint: &serving.CreateServingEndpoint{}, | ||
| CreateServingEndpoint: serving.CreateServingEndpoint{}, |
There was a problem hiding this comment.
FWIW, with these structs being zero-initialized, the assignment can be removed entirely.
There was a problem hiding this comment.
I agree. For context, most replacement were made with search-and-replace, so they look odd (AI tools were going back and forth on whether it should be a pointer or a struct, so I stopped using those for this).
I feel like there should be a linter to clean this up, but I could not find one.
## Changes - Embed struct by value not by pointer in all the resources. - Remove IsNil method from the resource interface and implementations (it's never true). ## Why - Prevents a class of crashes related to nil pointer, like #2776 and #1937 - Simplify user code, no need to check nilness as much. ## Tests Existing tests.
Changes
Why
Tests
Existing tests.