Skip to content

chore: keep previous workspace build parameters for dynamic params #18059

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

Merged
merged 8 commits into from
May 28, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
better assertion in test
  • Loading branch information
Emyrk committed May 28, 2025
commit 28d14168945eea3ec7196a968e4f5979d02d65ca
14 changes: 3 additions & 11 deletions coderd/parameters_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package coderd_test
import (
"context"
"os"
"slices"
"testing"

"github.com/google/uuid"
Expand Down Expand Up @@ -281,17 +280,10 @@ func TestDynamicParametersWithTerraformValues(t *testing.T) {

latestParams, err := setup.client.WorkspaceBuildParameters(ctx, bld.ID)
require.NoError(t, err)

require.Len(t, latestParams, 2)
idx := slices.IndexFunc(latestParams, func(parameter codersdk.WorkspaceBuildParameter) bool {
return parameter.Name == "jetbrains_ide"
require.ElementsMatch(t, latestParams, []codersdk.WorkspaceBuildParameter{
{Name: "jetbrains_ide", Value: "GO"},
{Name: "foo", Value: fooVal},
})
require.Equal(t, "jetbrains_ide", latestParams[idx].Name)
require.Equal(t, "GO", latestParams[idx].Value)

fooIdx := (idx + 1) % 2
require.Equal(t, "foo", latestParams[fooIdx].Name)
require.Equal(t, fooVal, latestParams[fooIdx].Value)
}

// Restart the workspace, then delete. Asserting params on all builds.
Expand Down
2 changes: 1 addition & 1 deletion coderd/wsbuilder/wsbuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ func (b *Builder) getParameters() (names, values []string, err error) {
// conditional parameter existence, the static frame of reference
// is not sufficient. So assume the user is correct, or pull in the
// dynamic param code to find the actual parameters.
latestValues := make(map[string]string)
latestValues := make(map[string]string, len(b.richParameterValues))
for _, latest := range b.richParameterValues {
latestValues[latest.Name] = latest.Value
}
Expand Down