Comments (5)
Thanks @tortuetorche, this is a very good starting point.
Stack envvars are set in the deploy()
function. When a new stack is deployed it gets no envvars, and when an existing one is updated its envvars are reused (extracted from its stack definition into the stack_envvars
variable and set back again). For the first case it would be just a matter of loading the content of the envvars file and transform it into JSON using the command you provided, and set it as the stack_envvars
value. For the second case, though, the script should update the current stack envvars rather than setting them from scratch, keeping any value not previously set in the .env
file.
I would also make the environment variables file path customizable with a flag, like -g
(could be any of the remaining bfghijkmoqwxyz), and a script configuration envvar, like ENVIRONMENT_VARIABLES_FILE
.
from portainer-stack-utils.
Hi @greenled,
Any news on this issue?
I'll be very useful.
Have a good day,
Tortue Torche
from portainer-stack-utils.
Hi @tortuetorche,
I'm afraid I can not work on this in an immediate future. Too much work here and some health issues :(
Feel free to contribute a solution if you want to 💪 Have a good day too.
from portainer-stack-utils.
Hi @greenled,
Here a starting point:
Create a .env
file, which contains the Docker Stack environment variables:
HOSTNAME=bfaecdeb0cd2
HOME=/root
_BASH_VERSION=5.0
_BASH_PATCH_LEVEL=0
_BASH_LATEST_PATCH=7
TERM=xterm
foo=d=cc
Then execute this jq
command:
env -i $(cat .env) jq -n 'env | to_entries | map({name: .key, value: .value})'
This will output:
[
{
"name": "HOSTNAME",
"value": "bfaecdeb0cd2"
},
{
"name": "HOME",
"value": "/root"
},
{
"name": "_BASH_VERSION",
"value": "5.0"
},
{
"name": "_BASH_PATCH_LEVEL",
"value": "0"
},
{
"name": "_BASH_LATEST_PATCH",
"value": "7"
},
{
"name": "TERM",
"value": "xterm"
},
{
"name": "foo",
"value": "d=cc"
}
]
I hope you'll be better soon,
Tortue Torche
from portainer-stack-utils.
Hi @greenled ,
Thank you for your explanations.
Here some snippets to merge two environment variable JSON files with jq
:
jq -s 'add | unique_by(.name)' env_new.json env_old.json
Or:
jq -n '[inputs] | add | unique_by(.name)' env_new.json env_old.json
Have a good day,
Tortue Torche
from portainer-stack-utils.
Related Issues (20)
- Better flags HOT 8
- Action as an argument HOT 1
- Help included in the script HOT 2
- Branching model with better support for releases HOT 2
- Error while deploying: bad substitution HOT 7
- Project rebranding HOT 9
- How do you use Portainer Stack Utils? HOT 7
- Migration to GitLab HOT 9
- Stack deploy with configs failed `read /data/compose/3: is a directory` HOT 3
- Definition of "breaking change" HOT 1
- Use Portainer API data structures HOT 1
- Deploy stack with configs/secrets from file, manage configs/secrets HOT 13
- Version included in the script
- Endpoint's Docker API proxy HOT 1
- Proxy command doesn't handle websockets
- Continuous integration HOT 19
- Docker image docs HOT 1
- Script as entrypoint HOT 1
- Releases HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from portainer-stack-utils.