-
Notifications
You must be signed in to change notification settings - Fork 874
fix: set preset parameters in the API rather than the frontend #17403
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
Conversation
coderd/wsbuilder/wsbuilder_test.go
Outdated
@@ -960,6 +961,12 @@ func withInactiveVersion(params []database.TemplateVersionParameter) func(mTx *d | |||
} | |||
} | |||
|
|||
func withTemplateVersionPreset(presetID uuid.UUID) func(mTx *dbmock.MockStore) { | |||
return func(mTx *dbmock.MockStore) { | |||
mTx.EXPECT().GetPresetParametersByPresetID(gomock.Any(), presetID).Return(nil, nil) |
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.
I don't understand the value of returning nil, nil
here; this won't execute your new codepath in findNewBuildParameterValue
. Can you help me understand pls?
name: "Single Preset - No Preset Parameters But With Template Parameters", | ||
presets: []*proto.Preset{emptyPreset}, | ||
templateVersionParameters: templateVersionParameters, | ||
selectedPresetIndex: ptr.Ref(0), |
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.
What about instead just doing something like this?
selectedPresetIndex: ptr.Ref(0), | |
selectedPreset: &emptyPreset, |
coderd/workspaces_test.go
Outdated
presets: []*proto.Preset{}, | ||
templateVersionParameters: []*proto.RichParameter{}, | ||
selectedPresetIndex: -1, | ||
templateVersionParameters: templateVersionParameters, |
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.
Implementation doesn't seem to match the name
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.
Tests read much better now, thanks 👍
|
||
// Test Utility variables | ||
templateVersionParameters := []*proto.RichParameter{ | ||
{Name: "param1", Type: "string", Required: false}, |
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.
Only testing with unrequired params might introduce interesting blindspots, no?
Please update the referenced PR in the description |
Follow-up from a previous Pull Request required some additional testing of Presets from the API perspective.
In the process of adding the new tests, I updated the API to enforce preset parameter values based on the selected preset instead of trusting whichever frontend makes the request. This avoids errors scenarios in prebuilds where a prebuild might expect a certain preset but find a different set of actual parameter values.