-
Notifications
You must be signed in to change notification settings - Fork 36
Support docker-compose variable substitution #17
Conversation
@seglo Thanks for the PR! When implementing this feature I think we should take advantage of the fact that the plugin pre-processes the compose file and uses a modified version of the original compose file when executing the So instead of having to modify a bunch of the code to pass the substitution variables around and how the processes are launched I think it would be easier to just replace the set of ''variablesForSubstitution' on the fly via RegEx in the
This would also allow the internal plugin that we use at Tapad (which derives from this plugin) to also use this feature when starting instances in our Mesos environment which doesn't use same "Process" starting code. The regex above could be made to be a little more robust but I think it handles the majority of cases. Let me know what you think. I can also make the modifications to your PR if you don't have the time. Just let me know. Thanks again! |
Hey @kurtkopchik . I was actually thinking the opposite: replacing the I wasn't aware that you had an internal version of this plugin that makes further use of the templating feature with your Mesos environment, or that it would break something more specifically. Would you be able to elaborate on that use case? Either way, I'm fine if you decide to use the internal logic. I can probably take a look at it later this week if you like. EDIT: "vice-versa" use case |
Hey @seglo. If you are just strictly using the environment variable substitution feature with the RegEx replacement implementation the same docker-compose file should work both with the plugin and without it. But if you are using some of the other plugin-specific substitutions tags such as Being able to do things like tag a specific set of images as For launching compose instances in Mesos we leverage docker-compose-executor which we would also likely need to modify in some way to to inject the environment variables into the Process instance. If they are substituted in the compose file itself then there is no modification needed. I hope that helps give a better explanation :) If you could take a look at using the internal logic version that would be awesome and much appreciated! |
OK cool, I get it. What if I supported both scenarios: substitution with traditional docker-compose variable substitution and your internal logic. A feature switch could be added with a default to your internal logic? |
I'd prefer to just have it use the internal logic version only for now to keep things simple. Also wanted to note, for future PR's, that any changes to the |
Cool. I updated the PR as you suggested. I reverted the changes to In regards to the |
* @param instanceData An optional parameter to specify additional information about the instance | ||
*/ | ||
case class RunningInstanceInfo(instanceName: String, composeServiceName: String, composeFilePath: String, | ||
servicesInfo: Iterable[ServiceInfo], instanceData: Option[Any] = None) | ||
servicesInfo: Iterable[ServiceInfo], variables: Vector[(String, String)] = Vector.empty, |
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.
You should now be able to remove the previously added variables
property and comment from RunningInstanceInfo
.
Thanks @seglo! I made a few comments and I'll merge the changes after the next set of updates. Your understanding of
|
I think we're in business now. What do you think? |
Looks good! Thank you for the contribution. I'll be getting another official release out soon with this change included. |
This PR will allow the user to programmatically define a
Map
of key value pairs that are passed as environment variables to the call todocker-compose
. A new setting has been addedvariablesForSubstitution
that accepts aMap[String,String]
to represent the variables.https://docs.docker.com/compose/compose-file/#variable-substitution