8000 Add explanation for findNewBuildParameterValue · coder/coder@8ecf5a6 · GitHub
[go: up one dir, main page]

Skip to content
10000

Commit 8ecf5a6

Browse files
committed
Add explanation for findNewBuildParameterValue
Signed-off-by: Danny Kopping <dannykopping@gmail.com>
1 parent 978a1ee commit 8ecf5a6

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

coderd/wsbuilder/wsbuilder.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,15 @@ func (b *Builder) getParameters() (names, values []string, err error) {
623623
}
624624

625625
func (b *Builder) findNewBuildParameterValue(name string) *codersdk.WorkspaceBuildParameter {
626+
// If a preset has been chosen during workspace creation, we must ensure that the parameters defined by the preset
627+
// are set *exactly* as they as defined. For example, if a preset is chosen but a different value for one of the
628+
// parameters (defined in that preset) are set explicitly, we need to ignore those values.
629+
//
630+
// If this were to occur, a workspace build's parameters and its associated preset's parameters would not match,
631+
// causing inconsistency, and would be especially problematic for prebuilds. When a prebuild is claimed, we assume
632+
// that the prebuild was built using *at least* the parameters defined in the selected preset.
633+
//
634+
// This should generally not happen, but this is added protection against that situation.
626635
for _, v := range b.templateVersionPresetParameterValues {
627636
if v.Name == name {
628637
return &codersdk.WorkspaceBuildParameter{

0 commit comments

Comments
 (0)
0