feat: add merge_strategy attribute to coder_env resource#489
Merged
Conversation
46c9e05 to
df73de5
Compare
Member
deansheather
left a comment
There was a problem hiding this comment.
Implementation seems fine but I worry about how the order for prepending/appending is going to be determined if there are multiple
Add an optional merge_strategy attribute that controls how environment variables are combined when multiple coder_env resources define the same name. Valid values: replace (default), append, prepend, error. - Default 'replace' preserves backward compatibility - ForceNew: true ensures strategy changes recreate the resource - Validated with StringInSlice matching existing codebase patterns - Added tests for default value, all valid values, and invalid rejection - Updated docs with merge_strategy description and PATH append example
df73de5 to
979b8e0
Compare
kacpersaw
commented
Mar 13, 2026
Contributor
Author
kacpersaw
left a comment
There was a problem hiding this comment.
Good point! The ordering for append/prepend is determined server-side in Coder's provisioner — resources are processed in alphabetical order by Terraform resource address (per the determinism fix in coder/coder). The provider itself just stores the merge_strategy value; it doesn't perform the merging.
I've added a note to the schema description to make this explicit: "When multiple resources append or prepend to the same name, they are applied in alphabetical order by Terraform resource address."
johnstcn
approved these changes
Mar 13, 2026
deansheather
approved these changes
Mar 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add an optional
merge_strategyattribute to thecoder_envresource that controls how environment variables are combined when multiplecoder_envresources define the same name.Relates to coder/coder#21885
Valid values
replace(default)append:separatorprepend:separatorerrorcoder_envdefines the same nameExample
Changes
provider/env.go— Addedmerge_strategyschema field withStringInSlicevalidationprovider/env_test.go— Tests for default value, all valid values, and invalid rejectiondocs/resources/env.md— Updated with new attribute docs and PATH append exampleDesign notes
replacepreserves backward compatibilityForceNew: true— changing strategy recreates the resource:(PATH-style); future enhancement could add custom separator