docker-stack 0.3.1__tar.gz → 2.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. {docker_stack-0.3.1 → docker_stack-2.0.0}/PKG-INFO +151 -12
  2. docker_stack-2.0.0/README.md +231 -0
  3. {docker_stack-0.3.1 → docker_stack-2.0.0}/docker_stack/__init__.py +6 -1
  4. docker_stack-2.0.0/docker_stack/cli.py +1191 -0
  5. docker_stack-2.0.0/docker_stack/command_runner.py +56 -0
  6. {docker_stack-0.3.1 → docker_stack-2.0.0}/docker_stack/envsubst.py +7 -4
  7. {docker_stack-0.3.1 → docker_stack-2.0.0}/docker_stack/helpers.py +37 -19
  8. docker_stack-2.0.0/docker_stack/login.py +838 -0
  9. docker_stack-2.0.0/docker_stack/manager_api.py +354 -0
  10. {docker_stack-0.3.1 → docker_stack-2.0.0}/docker_stack/registry.py +9 -26
  11. {docker_stack-0.3.1 → docker_stack-2.0.0}/docker_stack.egg-info/PKG-INFO +151 -12
  12. {docker_stack-0.3.1 → docker_stack-2.0.0}/docker_stack.egg-info/SOURCES.txt +7 -1
  13. docker_stack-2.0.0/docker_stack.egg-info/requires.txt +4 -0
  14. {docker_stack-0.3.1 → docker_stack-2.0.0}/pyproject.toml +4 -0
  15. {docker_stack-0.3.1 → docker_stack-2.0.0}/setup.py +4 -1
  16. docker_stack-2.0.0/tests/test_docker_stack.py +491 -0
  17. docker_stack-2.0.0/tests/test_load_env.py +154 -0
  18. docker_stack-2.0.0/tests/test_login.py +557 -0
  19. docker_stack-2.0.0/tests/test_node_ls.py +77 -0
  20. docker_stack-0.3.1/README.md +0 -95
  21. docker_stack-0.3.1/docker_stack/cli.py +0 -490
  22. docker_stack-0.3.1/docker_stack.egg-info/requires.txt +0 -1
  23. docker_stack-0.3.1/tests/test_docker_stack.py +0 -7
  24. {docker_stack-0.3.1 → docker_stack-2.0.0}/docker_stack/compose.py +0 -0
  25. {docker_stack-0.3.1 → docker_stack-2.0.0}/docker_stack/docker_objects.py +0 -0
  26. {docker_stack-0.3.1 → docker_stack-2.0.0}/docker_stack/envsubst_merge.py +0 -0
  27. {docker_stack-0.3.1 → docker_stack-2.0.0}/docker_stack/markers.py +0 -0
  28. {docker_stack-0.3.1 → docker_stack-2.0.0}/docker_stack/merge_conf.py +0 -0
  29. {docker_stack-0.3.1 → docker_stack-2.0.0}/docker_stack/url_parser.py +0 -0
  30. {docker_stack-0.3.1 → docker_stack-2.0.0}/docker_stack.egg-info/dependency_links.txt +0 -0
  31. {docker_stack-0.3.1 → docker_stack-2.0.0}/docker_stack.egg-info/entry_points.txt +0 -0
  32. {docker_stack-0.3.1 → docker_stack-2.0.0}/docker_stack.egg-info/top_level.txt +0 -0
  33. {docker_stack-0.3.1 → docker_stack-2.0.0}/setup.cfg +0 -0
  34. {docker_stack-0.3.1 → docker_stack-2.0.0}/tests/test_docker_objects.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: docker-stack
3
- Version: 0.3.1
3
+ Version: 2.0.0
4
4
  Summary: CLI for deploying and managing Docker stacks.
5
5
  Home-page: https://github.com/mesudip/docker-stack
6
6
  Author: Sudip Bhattarai
@@ -11,21 +11,96 @@ Classifier: Operating System :: OS Independent
11
11
  Requires-Python: >=3.6
12
12
  Description-Content-Type: text/markdown
13
13
  Requires-Dist: PyYAML
14
+ Provides-Extra: dev
15
+ Requires-Dist: pytest<9,>=8; extra == "dev"
14
16
  Dynamic: author
15
17
  Dynamic: author-email
16
18
  Dynamic: classifier
17
19
  Dynamic: description
18
20
  Dynamic: description-content-type
19
21
  Dynamic: home-page
22
+ Dynamic: provides-extra
20
23
  Dynamic: requires-dist
21
24
  Dynamic: requires-python
22
25
  Dynamic: summary
23
26
 
24
27
  # Docker Stack CLI Utility
25
28
 
26
- A powerful command-line utility designed to enhance Docker Swarm stack deployments by providing advanced features for managing Docker configs and secrets. This tool aims to simplify complex deployment scenarios and offer capabilities beyond vanilla Docker Stack.
29
+ A command-line tool for advanced Docker Swarm stack deployments on plain Docker daemons. `docker-stack` extends vanilla `docker stack deploy` with generated secrets, templated configs, versioned stack state, safer rollbacks, and better day-to-day stack workflows.
27
30
 
28
- ## Features
31
+ ## Installation
32
+
33
+ Install or upgrade `docker-stack` with:
34
+
35
+ ```bash
36
+ pip install docker-stack --upgrade --break-system-packages
37
+ ```
38
+
39
+ ## Quick Start
40
+
41
+ ### Plain Docker Daemon
42
+
43
+ If you already have a Docker Swarm daemon or Docker context, you can use the advanced stack features directly against it.
44
+
45
+ Typical daemon-only workflow:
46
+
47
+ ```bash
48
+ docker-stack deploy my-stack docker-compose.yml
49
+ docker-stack ls
50
+ docker-stack versions my-stack
51
+ docker-stack cat my-stack
52
+ docker-stack checkout my-stack v2
53
+ docker-stack node ls
54
+ ```
55
+
56
+ What this gives you on a raw Docker daemon:
57
+
58
+ - richer secret and config handling in Compose
59
+ - generated secrets without external scripts
60
+ - template expansion from env vars and files
61
+ - versioned stack config history
62
+ - stack version inspection and checkout
63
+ - raw daemon compatibility without extra infrastructure
64
+
65
+ ### GitHub Actions
66
+
67
+ If you want to use `docker-stack` directly in a workflow, install the package explicitly:
68
+
69
+ ```yaml
70
+ steps:
71
+ - uses: actions/checkout@v4
72
+ - uses: actions/setup-python@v6
73
+ with:
74
+ python-version: '3.x'
75
+ - run: python3 -m pip install --upgrade docker-stack
76
+ - run: docker-stack deploy my-stack docker-compose.yml
77
+ ```
78
+
79
+ ## Core Capabilities
80
+
81
+ - **Advanced Deployments on Plain Docker Daemons:**
82
+ `docker-stack` works directly against a raw Docker daemon and adds capabilities that standard `docker stack deploy` does not provide out of the box:
83
+ - generated secrets
84
+ - inline configs and secrets
85
+ - template rendering from environment variables and files
86
+ - versioned config and secret history
87
+ - version lookup, checkout, and rollback-oriented workflows
88
+ - more ergonomic stack and node inspection output
89
+
90
+ - **Docker Stack Versioning and Config Backup for Rollback:**
91
+ The utility automatically versions your Docker configs and secrets, allowing for easy tracking of changes and seamless rollbacks to previous states. This provides a safety net for your deployments, ensuring you can always revert to a stable configuration.
92
+
93
+ ## Why Use It?
94
+
95
+ Vanilla Docker Stack deployments can sometimes lack the flexibility needed for dynamic environments or robust secret management. This utility bridges those gaps by:
96
+
97
+ - **Automating Secret Management:** No more manual secret generation or complex external scripts.
98
+ - **Simplifying Configuration:** Define configs and secrets directly in your compose files or use templates.
99
+ - **Enhancing Security:** Generate strong, random secrets on the fly.
100
+ - **Enabling Rollbacks:** Versioning ensures you can always revert to a known good state.
101
+ - **Improving Raw Daemon Workflows:** Works directly with a plain Docker Swarm daemon.
102
+
103
+ ## Advanced Compose Features
29
104
 
30
105
  - **Docker Config and Secret Management with Extended Options:**
31
106
  This utility significantly extends Docker's native config and secret management by introducing `x-` prefixed directives in your `docker-compose.yml` files. These directives allow for dynamic content generation, templating, and file inclusion, making your deployments more flexible and secure.
@@ -67,6 +142,33 @@ A powerful command-line utility designed to enhance Docker Swarm stack deploymen
67
142
  ### `x-generate`: Dynamic Secret Generation (Secrets Only)
68
143
  This powerful feature allows you to automatically generate random secrets based on specified criteria, eliminating the need to manually create and manage them. This is particularly useful for passwords, API keys, and other sensitive data.
69
144
 
145
+ Supported `x-generate` forms:
146
+
147
+ - `true`
148
+ Generate a secret with default options.
149
+ - integer
150
+ Generate a secret with the requested length.
151
+ - object
152
+ Generate a secret with explicit generation flags.
153
+
154
+ Supported object flags:
155
+
156
+ - `length`
157
+ Exact secret length.
158
+ - `numbers`
159
+ Include digits `0-9`.
160
+ - `special`
161
+ Include special characters.
162
+ - `uppercase`
163
+ Include uppercase letters `A-Z`.
164
+
165
+ Behavior notes:
166
+
167
+ - Generated values are created at deploy time.
168
+ - Generated secrets are versioned like other managed secrets.
169
+ - Newly generated values can be shown after deploy when `--show-generated` is enabled.
170
+ - `x-generate` is for secrets only; configs should use `x-content`, `x-template`, or `x-template-file`.
171
+
70
172
  - **Simple Generation (12-20 characters, default options):**
71
173
  ```yaml
72
174
  secrets:
@@ -104,15 +206,52 @@ A powerful command-line utility designed to enhance Docker Swarm stack deploymen
104
206
  uppercase: false
105
207
  ```
106
208
 
107
- - **Docker Stack Versioning and Config Backup for Rollback:**
108
- The utility automatically versions your Docker configs and secrets, allowing for easy tracking of changes and seamless rollbacks to previous states. This provides a safety net for your deployments, ensuring you can always revert to a stable configuration.
209
+ - **Database Password Style Secret:**
210
+ Generates a strong password with uppercase letters, lowercase letters, numbers, and special characters.
211
+ ```yaml
212
+ secrets:
213
+ db_password:
214
+ x-generate:
215
+ length: 32
216
+ numbers: true
217
+ special: false
218
+ uppercase: true
219
+ ```
220
+
221
+ - **Application Token Without Special Characters:**
222
+ Useful when the target application rejects punctuation in credentials or tokens.
223
+ ```yaml
224
+ secrets:
225
+ app_token:
226
+ x-generate:
227
+ length: 40
228
+ numbers: true
229
+ special: false
230
+ uppercase: true
231
+ ```
232
+
233
+ - **Lowercase Alphanumeric Secret:**
234
+ Useful for systems that want URL-safe or copy-friendly generated values.
235
+ ```yaml
236
+ secrets:
237
+ compact_secret:
238
+ x-generate:
239
+ length: 24
240
+ numbers: true
241
+ special: false
242
+ uppercase: false
243
+ ```
109
244
 
110
- ## Why use Docker Stack CLI Utility?
245
+ ## Development
111
246
 
112
- Vanilla Docker Stack deployments can sometimes lack the flexibility needed for dynamic environments or robust secret management. This utility bridges those gaps by:
113
- - **Automating Secret Management:** No more manual secret generation or complex external scripts.
114
- - **Simplifying Configuration:** Define configs and secrets directly in your compose files or use templates.
115
- - **Enhancing Security:** Generate strong, random secrets on the fly.
116
- - **Enabling Rollbacks:** Versioning ensures you can always revert to a known good state.
247
+ Install runtime and test dependencies with either:
248
+
249
+ ```bash
250
+ python3 -m pip install -r requirements-dev.txt
251
+ ```
252
+
253
+ or:
117
254
 
118
- Get started today and streamline your Docker Swarm deployments!
255
+ ```bash
256
+ python3 -m pip install -e '.[dev]'
257
+ ```
@@ -0,0 +1,231 @@
1
+ # Docker Stack CLI Utility
2
+
3
+ A command-line tool for advanced Docker Swarm stack deployments on plain Docker daemons. `docker-stack` extends vanilla `docker stack deploy` with generated secrets, templated configs, versioned stack state, safer rollbacks, and better day-to-day stack workflows.
4
+
5
+ ## Installation
6
+
7
+ Install or upgrade `docker-stack` with:
8
+
9
+ ```bash
10
+ pip install docker-stack --upgrade --break-system-packages
11
+ ```
12
+
13
+ ## Quick Start
14
+
15
+ ### Plain Docker Daemon
16
+
17
+ If you already have a Docker Swarm daemon or Docker context, you can use the advanced stack features directly against it.
18
+
19
+ Typical daemon-only workflow:
20
+
21
+ ```bash
22
+ docker-stack deploy my-stack docker-compose.yml
23
+ docker-stack ls
24
+ docker-stack versions my-stack
25
+ docker-stack cat my-stack
26
+ docker-stack checkout my-stack v2
27
+ docker-stack node ls
28
+ ```
29
+
30
+ What this gives you on a raw Docker daemon:
31
+
32
+ - richer secret and config handling in Compose
33
+ - generated secrets without external scripts
34
+ - template expansion from env vars and files
35
+ - versioned stack config history
36
+ - stack version inspection and checkout
37
+ - raw daemon compatibility without extra infrastructure
38
+
39
+ ### GitHub Actions
40
+
41
+ If you want to use `docker-stack` directly in a workflow, install the package explicitly:
42
+
43
+ ```yaml
44
+ steps:
45
+ - uses: actions/checkout@v4
46
+ - uses: actions/setup-python@v6
47
+ with:
48
+ python-version: '3.x'
49
+ - run: python3 -m pip install --upgrade docker-stack
50
+ - run: docker-stack deploy my-stack docker-compose.yml
51
+ ```
52
+
53
+ ## Core Capabilities
54
+
55
+ - **Advanced Deployments on Plain Docker Daemons:**
56
+ `docker-stack` works directly against a raw Docker daemon and adds capabilities that standard `docker stack deploy` does not provide out of the box:
57
+ - generated secrets
58
+ - inline configs and secrets
59
+ - template rendering from environment variables and files
60
+ - versioned config and secret history
61
+ - version lookup, checkout, and rollback-oriented workflows
62
+ - more ergonomic stack and node inspection output
63
+
64
+ - **Docker Stack Versioning and Config Backup for Rollback:**
65
+ The utility automatically versions your Docker configs and secrets, allowing for easy tracking of changes and seamless rollbacks to previous states. This provides a safety net for your deployments, ensuring you can always revert to a stable configuration.
66
+
67
+ ## Why Use It?
68
+
69
+ Vanilla Docker Stack deployments can sometimes lack the flexibility needed for dynamic environments or robust secret management. This utility bridges those gaps by:
70
+
71
+ - **Automating Secret Management:** No more manual secret generation or complex external scripts.
72
+ - **Simplifying Configuration:** Define configs and secrets directly in your compose files or use templates.
73
+ - **Enhancing Security:** Generate strong, random secrets on the fly.
74
+ - **Enabling Rollbacks:** Versioning ensures you can always revert to a known good state.
75
+ - **Improving Raw Daemon Workflows:** Works directly with a plain Docker Swarm daemon.
76
+
77
+ ## Advanced Compose Features
78
+
79
+ - **Docker Config and Secret Management with Extended Options:**
80
+ This utility significantly extends Docker's native config and secret management by introducing `x-` prefixed directives in your `docker-compose.yml` files. These directives allow for dynamic content generation, templating, and file inclusion, making your deployments more flexible and secure.
81
+
82
+ ### `x-content`: Inline Content for Configs and Secrets
83
+ Allows you to define the content of a Docker config or secret directly within your `docker-compose.yml`.
84
+
85
+ ```yaml
86
+ secrets:
87
+ my_inline_secret:
88
+ x-content: "This is my secret content defined inline."
89
+
90
+ configs:
91
+ my_inline_config:
92
+ x-content: |
93
+ key=value
94
+ another_key=another_value
95
+ ```
96
+
97
+ ### `x-template`: Environment Variable Templating
98
+ Enables the use of environment variables within your config or secret content, which are substituted at deployment time.
99
+
100
+ ```yaml
101
+ secrets:
102
+ my_templated_secret:
103
+ x-template: "I can create composite secret with template. ${API_KEY_NAME}:${MY_API_KEY}"
104
+ ```
105
+
106
+ ### `x-template-file`: External Template Files
107
+ Reference an external file whose content will be treated as a template and processed with environment variables.
108
+
109
+ ```yaml
110
+ configs:
111
+ my_config_from_template_file:
112
+ x-template-file: "./templates/my_config.tpl"
113
+ ```
114
+ *(Content of `./templates/my_config.tpl` might be: `DB_HOST=${DATABASE_HOST}`)*
115
+
116
+ ### `x-generate`: Dynamic Secret Generation (Secrets Only)
117
+ This powerful feature allows you to automatically generate random secrets based on specified criteria, eliminating the need to manually create and manage them. This is particularly useful for passwords, API keys, and other sensitive data.
118
+
119
+ Supported `x-generate` forms:
120
+
121
+ - `true`
122
+ Generate a secret with default options.
123
+ - integer
124
+ Generate a secret with the requested length.
125
+ - object
126
+ Generate a secret with explicit generation flags.
127
+
128
+ Supported object flags:
129
+
130
+ - `length`
131
+ Exact secret length.
132
+ - `numbers`
133
+ Include digits `0-9`.
134
+ - `special`
135
+ Include special characters.
136
+ - `uppercase`
137
+ Include uppercase letters `A-Z`.
138
+
139
+ Behavior notes:
140
+
141
+ - Generated values are created at deploy time.
142
+ - Generated secrets are versioned like other managed secrets.
143
+ - Newly generated values can be shown after deploy when `--show-generated` is enabled.
144
+ - `x-generate` is for secrets only; configs should use `x-content`, `x-template`, or `x-template-file`.
145
+
146
+ - **Simple Generation (12-20 characters, default options):**
147
+ ```yaml
148
+ secrets:
149
+ my_simple_generated_secret:
150
+ x-generate: true
151
+ ```
152
+
153
+ - **Specify Length:**
154
+ ```yaml
155
+ secrets:
156
+ my_fixed_length_secret:
157
+ x-generate: 30 # Generates a 30-character secret
158
+ ```
159
+
160
+ - **Custom Generation Options:**
161
+ You can provide a dictionary to fine-tune the generation process:
162
+ - `length`: (integer, default: 12-20 random) Exact length of the secret.
163
+ - `numbers`: (boolean, default: `true`) Include numbers (0-9).
164
+ - `special`: (boolean, default: `true`) Include special characters (!@#$%^&*...).
165
+ - `uppercase`: (boolean, default: `true`) Include uppercase letters (A-Z).
166
+
167
+ ```yaml
168
+ secrets:
169
+ my_complex_generated_secret:
170
+ x-generate:
171
+ length: 25
172
+ numbers: false
173
+ special: true
174
+ uppercase: true
175
+ my_alphanumeric_secret:
176
+ x-generate:
177
+ length: 15
178
+ numbers: true
179
+ special: false
180
+ uppercase: false
181
+ ```
182
+
183
+ - **Database Password Style Secret:**
184
+ Generates a strong password with uppercase letters, lowercase letters, numbers, and special characters.
185
+ ```yaml
186
+ secrets:
187
+ db_password:
188
+ x-generate:
189
+ length: 32
190
+ numbers: true
191
+ special: false
192
+ uppercase: true
193
+ ```
194
+
195
+ - **Application Token Without Special Characters:**
196
+ Useful when the target application rejects punctuation in credentials or tokens.
197
+ ```yaml
198
+ secrets:
199
+ app_token:
200
+ x-generate:
201
+ length: 40
202
+ numbers: true
203
+ special: false
204
+ uppercase: true
205
+ ```
206
+
207
+ - **Lowercase Alphanumeric Secret:**
208
+ Useful for systems that want URL-safe or copy-friendly generated values.
209
+ ```yaml
210
+ secrets:
211
+ compact_secret:
212
+ x-generate:
213
+ length: 24
214
+ numbers: true
215
+ special: false
216
+ uppercase: false
217
+ ```
218
+
219
+ ## Development
220
+
221
+ Install runtime and test dependencies with either:
222
+
223
+ ```bash
224
+ python3 -m pip install -r requirements-dev.txt
225
+ ```
226
+
227
+ or:
228
+
229
+ ```bash
230
+ python3 -m pip install -e '.[dev]'
231
+ ```
@@ -1,7 +1,12 @@
1
1
  from .envsubst import envsubst, envsubst_load_file
2
2
  from .compose import read_compose_file
3
3
  from .docker_objects import DockerConfig, DockerSecret
4
- from .cli import main
4
+
5
+
6
+ def main(args=None):
7
+ from .cli import main as cli_main
8
+
9
+ return cli_main(args)
5
10
 
6
11
  """
7
12
  Functions: