mirror of
https://github.com/moghtech/komodo.git
synced 2026-03-09 07:13:36 -05:00
[Feature] Default environment variables #130
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @em411 on GitHub (Nov 15, 2024).
Description
Currently, when creating a new stack in Komodo, the Environment form section provides a basic placeholder format
# VARIABLE = value. While this is helpful for beginners, it's not so useful for advanced users who frequently use the same environment variables across different stacks.Suggested Solution
Add a "Default" checkbox option in the variables settings that allows users to:
Use Case
PUID,PGID, orTZcan be presetExample images
@mbecker20 commented on GitHub (Nov 16, 2024):
Reminds me of #28
@em411 commented on GitHub (Nov 16, 2024):
Default vars and global vars, while seemingly similar, serve distinct purposes and would complement each other rather than be interchangeable.
Default vars act as a template/preset for new stack initialization, where users expect to modify values per stack's specific needs. For example, having a default value for
DOMAINpointing to internal domain name is useful as a starting point, but some stacks will need to change it to external domain for public facing services. The main difference is that updating default vars doesn't affect existing stacks - it only applies to new ones, making it a simpler, more predictable feature.Global vars, on the other hand, should function (in my opinion) as a singleton that affects all stacks uniformly, both existing and new. When you update a global var, the change propagates automatically across all stacks, making it a more complex feature that requires proper state management and update handling. This behavior is essential for values that should remain consistent across your application, like API keys or base path for bind mount directory.
Another advantage of default vars is that they serve as documentation of common configuration patterns. Users can quickly understand the expected environment structure by looking at the default template, while still maintaining the freedom to adjust values as needed.
In essence, default vars focus on initialization convenience while preserving stack independence, whereas global vars emphasize unified configuration management across all stacks.
@mbecker20 commented on GitHub (Nov 17, 2024):
Yeah I understand. I realize there is an existing usage pattern available that should satisfy your use case and more, call it the template pattern.
You may have noticed every Resource in Komodo has a "Copy" button available, you just enter a new name and it keep the same config. You can leverage this by creating template resources thats only use is as the source resource with the Copy api.
For example, create a new Deployment just called "template", and add the environment variables you want as defaults there. When you want to create a new Deployment, just navigate to the template use the Copy button.
While it is slightly less convenient to have to navigate to the template before creation, I don't think this impact is big (it takes seconds using the Search). Additionally, this pattern has several advantages:
Network,Restart Mode, orLabels.You can also leverage the simple API available for all resources to create new resources from template resources for automations, for example can use this call in an Action:
Overall I think universal configurable defaults is not adding enough value to justify this feature in addition to the template pattern. Please try out this pattern for your use case and let me know any difficulties you come across, and we can re-asses how to make this process more straightforward.
Already I see one way, which I will implement: When you click "New ..." buttons, currently you input the Name and hit create. Right below the name, can have a selector allowing to choose from your resources to copy from. Can also mark a resource as default for the template. The flow of this solution should be very similar to what you are looking for.
@gitcatpeter commented on GitHub (Nov 17, 2024):
I'm replying to the above (not to hijack @em411 thread) as well as to mine - issue #183.
Easily created Stacks template using Copy, seems that that approach would work for me well.
Also what you proposed sounds good:
Already I see one way, which I will implement: When you click "New ..." buttons, currently you input the Name and hit create. Right below(...)Thanks!
@em411 commented on GitHub (Nov 18, 2024):
Thanks @mbecker20 for this great idea.
I'm currently in the process of migrating my numerous stacks from Dockge to Komodo. While the migration is progressing slowly but surely, I wanted to provide some constructive feedback about both the main pain points and what I believe are relatively simple improvements that could be implemented without too much effort.
Update
Copyworks like a charm. I was able to avoid most of the tedious work of migrating all my containers from Dockge.