Skip to content

chore: modify parameter dynamic immutability behavior #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 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 11 commits into from
Jul 9, 2025

Conversation

Emyrk
Copy link
Member

@Emyrk Emyrk commented Jun 25, 2025

Parameter mutablity is determined by the current state. So a previously immutable parameter can become mutable.

Terraform:

data "coder_parameter" "isimmutable" {
  name   = "isimmutable"
  type    = "bool"
  mutable = true
  default = "true"
}

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

Trivial Case:

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

Immutability source from the past

  1. Workspace built with isimmutable = true & immutable = "bar"
  2. Workspace updates immutable = foo & isimmutable = false
    1. This works because at validation time, mutable = true

Why ignore the previous parameter state?

Ignoring previous state is vastly simplier and more intuitive. If the previous parameter mutability affected the current build, then questions such as, "What if the last build failed? Do we take the last successful build?", etc.

@github-actions github-actions bot added the stale This issue is like stale bread. label Jul 3, 2025
@github-actions github-actions bot closed this Jul 6, 2025
@Emyrk Emyrk reopened this Jul 7, 2025
@Emyrk Emyrk force-pushed the stevenmasley/immutable_original branch from b12a492 to 7e4ef44 Compare July 7, 2025 15:41
@Emyrk Emyrk marked this pull request as ready for review July 7, 2025 16:56
@Emyrk Emyrk changed the title feat: test parameter immutability validation chore: parameter dynamic immutability behavior Jul 7, 2025
@Emyrk Emyrk changed the title chore: parameter dynamic immutability behavior chore: modify parameter dynamic immutability behavior Jul 7, 2025
@Emyrk Emyrk requested a review from Copilot July 7, 2025 17:06
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR updates dynamic parameter immutability so that a parameter’s mutability is determined solely by its current state rather than its prior state.

  • Adds a Terraform test scenario for dynamic immutability in testdata.
  • Introduces two new integration tests (PreviouslyImmutable, PreviouslyMutable) and a unit test (BecameImmutable) to capture dynamic behavior.
  • Refactors ResolveParameters to drop the old originalValues map and use previousValuesMap directly when validating immutability.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
enterprise/coderd/testdata/parameters/dynamicimmutable/main.tf Adds Terraform snippet for dynamic immutability testing.
enterprise/coderd/dynamicparameters_test.go Adds integration tests covering parameters that flip mutability.
coderd/dynamicparameters/resolver_test.go Adds a unit test for a parameter transitioning from mutable to immutable.
coderd/dynamicparameters/resolver.go Removes the originalValues cache and uses previousValuesMap for immutability checks.

@Emyrk Emyrk requested a review from aslilac July 7, 2025 17:10
@Emyrk Emyrk marked this pull request as draft July 7, 2025 17:17
@Emyrk Emyrk removed the request for review from aslilac July 7, 2025 17:17
@github-actions github-actions bot removed the stale This issue is like stale bread. label Jul 8, 2025
@Emyrk Emyrk marked this pull request as ready for review July 8, 2025 15:26
@Emyrk Emyrk requested a review from aslilac July 8, 2025 15:27
@Emyrk Emyrk merged commit 00ba027 into main Jul 9, 2025
36 checks passed
@Emyrk Emyrk deleted the stevenmasley/immutable_original branch July 9, 2025 14:45
@github-actions github-actions bot locked and limited conversation to collaborators Jul 9, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants