Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: test parameter immutability validation#18583

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
Emyrk wants to merge4 commits intomain
base:main
Choose a base branch
Loading
fromstevenmasley/immutable_original

Conversation

Emyrk
Copy link
Member

@EmyrkEmyrk commentedJun 25, 2025
edited
Loading

What should happen in this situation. A template where the parameterisimmutable sets the mutability ofimmutable.

Terraform:

data"coder_parameter""isimmutable" {name="isimmutable"type="bool"mutable=truedefault="true"}data"coder_parameter""immutable" {name="immutable"type="string"mutable=data.coder_parameter.isimmutable.value=="false"default="Hello World"}

Trivial Case:

  1. Workspace built withisimmutable = true &immutable = "bar"
  2. Workspace updatesimmutable = foo
    1. Breaks, because you cannot update an immutable value

Immutability source from the past

  1. Workspace built withisimmutable = true &immutable = "bar"
  2. Workspace updatesimmutable = foo &isimmutable = false

Either it:

  • Breaks becauseisimmutableWAS immutable on the previous build
    • (I think this one)
  • Works becauseisimmutable is nowmutable from the new param

Comment on lines +355 to +388
t.Run("ImmutableChangeValue", func(t *testing.T) {
// Ok this is a weird test to document how things are working.
// What if a parameter flips it's immutability based on a value?
// The current behavior is to source immutability from the previous build.
t.Parallel()

ctx := testutil.Context(t, testutil.WaitShort)
// Start with a new template that has 1 parameter that is immutable
immutable, _ := coderdtest.DynamicParameterTemplate(t, templateAdmin, orgID, coderdtest.DynamicParameterTemplateParams{
MainTF: string(must(os.ReadFile("testdata/parameters/dynamicimmutable/main.tf"))),
})

// Create the workspace with the immutable parameter
wrk, err := templateAdmin.CreateUserWorkspace(ctx, codersdk.Me, codersdk.CreateWorkspaceRequest{
TemplateID: immutable.ID,
Name: coderdtest.RandomUsername(t),
RichParameterValues: []codersdk.WorkspaceBuildParameter{
{Name: "isimmutable", Value: "true"},
{Name: "immutable", Value: "coder"},
},
})
require.NoError(t, err)
coderdtest.AwaitWorkspaceBuildJobCompleted(t, templateAdmin, wrk.LatestBuild.ID)

// Try new values
_, err = templateAdmin.CreateWorkspaceBuild(ctx, wrk.ID, codersdk.CreateWorkspaceBuildRequest{
Transition: codersdk.WorkspaceTransitionStart,
RichParameterValues: []codersdk.WorkspaceBuildParameter{
{Name: "isimmutable", Value: "false"},
{Name: "immutable", Value: "not-coder"},
},
})
require.ErrorContains(t, err, `Previously immutable parameter changed`)
})
Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

The test

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees

@EmyrkEmyrk

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

1 participant
@Emyrk

[8]ページ先頭

©2009-2025 Movatter.jp