-
Notifications
You must be signed in to change notification settings - Fork 2
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
Allow templating in config values #32
Conversation
@@ -92,21 +92,30 @@ def compact | |||
to_h.compact | |||
end | |||
|
|||
def as_args | |||
with_env.map { |key, value| arg(key, value) }.compact | |||
def as_args(context: {}) |
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.
starting to think the whole "args" logic should move from Config
and into Command
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.
I think that moving at least the ENV vars into the command section makes sense. At the moment understanding the priority order of the different ways to configure options is the most complex part of this library, it would be great to be able to simplify that, out of scope for this PR however.
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.
any chance you wanna make an issue for this and describe the desired outcome? I think you're on to something with ENV config not being merged into config within the config class, but instead the two being merged just-in-time when the command is formed.
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.
Nice, I like this work a lot. Agreed that it now looks like a good time to take a holistic look at how we manage options and see if there is a way we can simplify the layers there.
@@ -92,21 +92,30 @@ def compact | |||
to_h.compact | |||
end | |||
|
|||
def as_args | |||
with_env.map { |key, value| arg(key, value) }.compact | |||
def as_args(context: {}) |
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.
I think that moving at least the ENV vars into the command section makes sense. At the moment understanding the priority order of the different ways to configure options is the most complex part of this library, it would be great to be able to simplify that, out of scope for this PR however.
f3ce109
to
a03b7b4
Compare
Description
It's likely that users will want values for some configuration options that are unique per migration, or at least scoped to the table that's being migrated (for example: the flag files). This can now be solved by using ERB like:
Any configuration value can be templated into another config value, and additionally the following values are always available:
pid
: the current process IDtimestamp
: current seconds since epoch (as integer)unique_id
: random UUIDtable
: the table being migrateddatabase
: the database the migration is being run againstAddresses half of #23
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
New unit tests added to check functionality. Also tested with a demo rails application (ruby 2.7)
Checklist: