-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
for_lane, for_platform blocks in configurations #7859
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM but definitely think @KrauseFx should review as well
# Setting this variable to be true allows a one-time overwrite of a particular | ||
# configuration value. This is used by the override block methods to allow | ||
# giving a more specific config value for a particular circumstance | ||
@allow_overwite = false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops, this should be removed. Is leftover from my first try/approach 😦
# lane_name - Symbol representing a lane name. | ||
# block - Block to execute to override configuration values. | ||
# | ||
# Discussion If received lane name does not match the lane name available as environment variable, no changes will |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the Discussion block?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, this was from the original PR. I can make the comments look more like our usual documentation. 👍
# configuration for applying values, so that values can be overridden | ||
# (once) again. Those values are then merged into the surrounding | ||
# configuration as the block completes | ||
def with_a_clean_config_merged_when_complete |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great
@@ -119,6 +119,60 @@ | |||
end | |||
end) | |||
end | |||
|
|||
describe "for_lane and for_platform support" do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect, just new tests, without modifying any of the existing ones 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great @mfurtak 👍 I don't know for sure where we want to add this to the documentation, besides Advanced.md
. Do you have a better idea?
A continuation of work on #6549
This reconciles the new configuration blocks (
for_lane
,for_platform
) and their desire to be able to override configuration values, with the existing rules about "first assignment wins" for configurations.It does this by having the new configuration blocks create a fresh configuration context every time you enter one. This way, each block gets a fresh application of the "first assignment wins" rule. As each block exits, any values set during the block are merged with any configuration context that was present at the time the block started. Thus, we can override values in these blocks, but only once, and still build a single comprehensive configuration!
This is supported with new
push_values!
andpop_values!
methods onConfiguration
If we like the solution, we can always add documentation as a follow-up.
/cc @maschall