Skip to content
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

fix(code-server): set settings variable type to any #368

Merged
merged 3 commits into from
Dec 17, 2024

Conversation

phorcys420
Copy link
Member

@phorcys420 phorcys420 commented Dec 17, 2024

module "code-server" {
  source = "git::https://github.com/coder/modules.git//code-server?ref=phorcys/code-server-settings-fix"

  settings = {
    "workbench.colorTheme" = "Dracula",
    "test.test" = ["hi"],
    "test.test2" = {
      "hello" = "hi"
    }
  }

  agent_id                = coder_agent.dev.id
}

image

Closes #296

@matifali
Copy link
Member

@phorcys420 Can you also do it for vscode-web?

@phorcys420 phorcys420 marked this pull request as draft December 17, 2024 12:14
@phorcys420
Copy link
Member Author

@matifali yes, i will make a separate PR

@matifali matifali changed the title chore: set variable type to map(any) fix(code-server): set settings variable type to map(any) Dec 17, 2024
@phorcys420 phorcys420 force-pushed the phorcys/code-server-settings-fix branch from 92c7e18 to 432630c Compare December 17, 2024 12:43
@phorcys420
Copy link
Member Author

@phorcys420 phorcys420 changed the title fix(code-server): set settings variable type to map(any) fix(code-server): set settings variable type to any Dec 17, 2024
@phorcys420 phorcys420 self-assigned this Dec 17, 2024
@phorcys420 phorcys420 marked this pull request as ready for review December 17, 2024 13:03
@phorcys420 phorcys420 enabled auto-merge (squash) December 17, 2024 13:03
@phorcys420
Copy link
Member Author

@matifali we cannot set the type to map(any) because it does not allow different types in the same map, because of the following reason:

map(any) means "map of any single type". That is, you can use whatever type you like but all of the elements must have the same type. That is what the error message is trying to explain here.

hashicorp/terraform#21384 (comment)

so, as pointed out by @gjrtimmer in #296, we have to set the type to any.

but the issue with that is that it can introduce some confusion, because a string or number will match this type constraint, except that it won't work.
I am not sure how to address this additionnal confusion though.

@matifali
Copy link
Member

@phorcys420 Have you seen: https://developer.hashicorp.com/terraform/language/expressions/type-constraints#dynamic-types-the-any-constraint

I think it is fine to use any for this use case.

Copy link
Member

@matifali matifali left a comment

Choose a reason for hiding this comment

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

LGTM. Have you verified that it now solves the issue?

@phorcys420 phorcys420 merged commit 6d27391 into main Dec 17, 2024
2 checks passed
@phorcys420 phorcys420 deleted the phorcys/code-server-settings-fix branch December 17, 2024 14:31
@9techijcore
Copy link

Hello,
Latest release is still v1.0.25, is it possible for you to trigger a new release so we can use this ?
Thanks in advance !

@matifali
Copy link
Member

@9techijcore I am waiting for #369 and we will cut a release.

@matifali
Copy link
Member

v1.0.26 has been pushed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug(code-server): Inability to set object values in settings
3 participants