devnomads-cli 0.13.0__tar.gz → 0.15.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 (24) hide show
  1. {devnomads_cli-0.13.0 → devnomads_cli-0.15.0}/PKG-INFO +138 -13
  2. {devnomads_cli-0.13.0 → devnomads_cli-0.15.0}/README.md +137 -12
  3. {devnomads_cli-0.13.0 → devnomads_cli-0.15.0}/devnomads_cli.egg-info/PKG-INFO +138 -13
  4. {devnomads_cli-0.13.0 → devnomads_cli-0.15.0}/devnomads_cli.egg-info/SOURCES.txt +3 -0
  5. {devnomads_cli-0.13.0 → devnomads_cli-0.15.0}/dncli.py +3620 -219
  6. {devnomads_cli-0.13.0 → devnomads_cli-0.15.0}/pyproject.toml +1 -1
  7. devnomads_cli-0.15.0/tests/test_agent_features.py +483 -0
  8. {devnomads_cli-0.13.0 → devnomads_cli-0.15.0}/tests/test_cli.py +8 -8
  9. {devnomads_cli-0.13.0 → devnomads_cli-0.15.0}/tests/test_config.py +1 -1
  10. {devnomads_cli-0.13.0 → devnomads_cli-0.15.0}/tests/test_generate.py +100 -4
  11. {devnomads_cli-0.13.0 → devnomads_cli-0.15.0}/tests/test_generated_cli.py +21 -11
  12. devnomads_cli-0.15.0/tests/test_sites_publish.py +619 -0
  13. devnomads_cli-0.15.0/tests/test_sites_ssh.py +149 -0
  14. {devnomads_cli-0.13.0 → devnomads_cli-0.15.0}/tests/test_transfer.py +1 -1
  15. {devnomads_cli-0.13.0 → devnomads_cli-0.15.0}/LICENSE +0 -0
  16. {devnomads_cli-0.13.0 → devnomads_cli-0.15.0}/devnomads_cli.egg-info/dependency_links.txt +0 -0
  17. {devnomads_cli-0.13.0 → devnomads_cli-0.15.0}/devnomads_cli.egg-info/entry_points.txt +0 -0
  18. {devnomads_cli-0.13.0 → devnomads_cli-0.15.0}/devnomads_cli.egg-info/requires.txt +0 -0
  19. {devnomads_cli-0.13.0 → devnomads_cli-0.15.0}/devnomads_cli.egg-info/top_level.txt +0 -0
  20. {devnomads_cli-0.13.0 → devnomads_cli-0.15.0}/setup.cfg +0 -0
  21. {devnomads_cli-0.13.0 → devnomads_cli-0.15.0}/tests/test_cert.py +0 -0
  22. {devnomads_cli-0.13.0 → devnomads_cli-0.15.0}/tests/test_helpers.py +0 -0
  23. {devnomads_cli-0.13.0 → devnomads_cli-0.15.0}/tests/test_hook.py +0 -0
  24. {devnomads_cli-0.13.0 → devnomads_cli-0.15.0}/tests/test_versions.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: devnomads-cli
3
- Version: 0.13.0
3
+ Version: 0.15.0
4
4
  Summary: Manage your DevNomads services from the command line
5
5
  Author-email: DevNomads <support@devnomads.nl>
6
6
  License: MIT
@@ -98,8 +98,103 @@ Every DevNomads product has its own command group - `apps`,
98
98
  your SSH keys and `jobs` for background work. Explore with
99
99
  `dncli --help` and `dncli <group> --help`.
100
100
 
101
- Commands accept any unambiguous prefix: `dncli e l` is `dncli emails
102
- list`. An ambiguous prefix lists the candidates.
101
+ In a terminal, commands accept any unambiguous prefix: `dncli e l` is
102
+ `dncli emails list`. An ambiguous prefix lists the candidates. Scripts
103
+ (no terminal on stdin) must spell commands out, so a truncated name can
104
+ never run a different command; dncli then names the command you meant.
105
+
106
+ `dncli commands` lists every command with its options, and marks the
107
+ ones that change something, ask for confirmation, run in the
108
+ background or start billing. `dncli commands --out json sites` gives
109
+ the full detail for one group, for scripts and AI agents.
110
+
111
+ ## Logging in to a site
112
+
113
+ `dncli sites ssh` opens an SSH session as the site's system user,
114
+ `site<service_id>`, so you don't need to know that name:
115
+
116
+ ```sh
117
+ dncli sites ssh example.com
118
+ dncli sites ssh example.com -- ls -la # run one command
119
+ dncli sites ssh example.com --dry-run # print the ssh command
120
+ ```
121
+
122
+ dncli logs in on the host the API lists for the site. A site that runs
123
+ on several hosts (an HA cluster) asks which one; pick it with `--host`
124
+ to skip the question, for example in a script. Anything after `--`
125
+ goes to ssh: extra options (`-- -p 2222`) or a remote command.
126
+
127
+ ssh logs in with your SSH key when the site has it (`dncli sites keys
128
+ attach`); otherwise ssh itself asks for the site's password. dncli never
129
+ sees or stores that password. Scripts and other runs without a terminal
130
+ cannot answer a password prompt, so they need key login.
131
+
132
+ ## Publishing a site
133
+
134
+ `dncli sites publish` uploads a folder (the current one by default) to
135
+ a site with rsync, over the same SSH login as `dncli sites ssh`:
136
+
137
+ ```sh
138
+ dncli sites publish example.com ./dist --dry-run # show what would change
139
+ dncli sites publish example.com ./dist # new and changed files
140
+ dncli sites publish example.com ./dist --delete # also remove files not in ./dist
141
+ ```
142
+
143
+ Files go to `/home/site<service_id>/domains/<domain>/public_html`. `.git/`
144
+ is never uploaded; `--exclude` leaves out more (repeat it). You need
145
+ rsync locally and on the server.
146
+
147
+ **Release mode.** `--release` switches a site to versioned uploads:
148
+ each publish goes into `public_html/releases/<timestamp>/` (unchanged
149
+ files are hard links to the previous release, so only changes are
150
+ transferred) and the `public_html/current` symlink switches to it in
151
+ one step, so visitors never see a half-finished upload. dncli points
152
+ the site's document root into `current` through the API, e.g. `/public`
153
+ becomes `/current/public`. After that every publish makes a release;
154
+ `--keep` (default 5) sets how many stay.
155
+
156
+ ```sh
157
+ dncli sites publish example.com ./dist --release # switch, asks first
158
+ dncli sites releases example.com # list releases
159
+ dncli sites rollback example.com # back to the previous one
160
+ dncli sites publish example.com ./dist --no-release # back to plain mode
161
+ ```
162
+
163
+ Every release starts from your folder alone: files the site writes
164
+ into its own folder (uploads, caches) are not carried over. Switching
165
+ mode changes the live site, so dncli asks first (`--yes` skips the
166
+ question); the old mode's files stay on the server, no longer served.
167
+
168
+ **Commands after the upload.** `--run` runs a command on the server in
169
+ the uploaded folder, such as `composer install`; repeat it for more, they
170
+ run in the order given. In release mode the commands run in the new
171
+ release before it goes live, so a failing command stops the publish and
172
+ the site keeps serving the previous release. `--run-once` is for what
173
+ must happen only once, like a database migration: on a site with several
174
+ hosts it runs on the first host only, after all `--run` commands:
175
+
176
+ ```sh
177
+ dncli sites publish example.com . --exclude vendor/ \
178
+ --run 'composer install --no-dev --optimize-autoloader' \
179
+ --run-once 'php artisan migrate --force'
180
+ ```
181
+
182
+ **Sites on several hosts.** A site that runs on several hosts (an HA
183
+ cluster) gets every publish on all of them: dncli uploads to and runs
184
+ the commands on every host first, and only then switches them, so the
185
+ hosts serve different releases only for the moment the switches take.
186
+ `rollback` switches every host too. `--host` limits a command to one
187
+ of them.
188
+
189
+ **From a CI pipeline.** A pipeline has no terminal, so ssh cannot ask
190
+ for a password or whether to trust a host it has not seen before. Give
191
+ the pipeline an SSH key that is attached to the site (`dncli sites keys
192
+ attach`), the hosts' keys in `known_hosts` and the API key in `DN_API_KEY`:
193
+
194
+ ```sh
195
+ mkdir -p ~/.ssh && ssh-keyscan web01.example.com >> ~/.ssh/known_hosts
196
+ dncli sites publish example.com . --run 'composer install --no-dev'
197
+ ```
103
198
 
104
199
  ## Managing DNS
105
200
 
@@ -184,23 +279,53 @@ fields, and reports an error on an unknown column name.
184
279
 
185
280
  Commands that take a service id also accept a unique entity name and
186
281
  resolve it for you, so `dncli domains show example.com` works as well
187
- as `dncli domains show 1234`. Names match regardless of case. A purely
188
- numeric value is always treated as an id; an entity that matches more
189
- than one service is rejected, so pass the id when an entity is not
190
- unique. Other references, such as cluster, key or user ids, take the
191
- numeric id only.
282
+ as `dncli domains show 1234`. Clients, SSH keys, clusters, hypervisors,
283
+ database users and volumes take a name too, as an argument or an
284
+ option: `dncli databases permissions create stelling_bg25 --user-id stelling`. The
285
+ help of each such option says which field it matches. Names match
286
+ regardless of case. A purely numeric value is always treated as an id;
287
+ a name that matches more than one entity is rejected, so pass the id
288
+ when a name is not unique.
289
+
290
+ Every command that changes something takes `--dry-run`: it resolves
291
+ names to ids and prints the request it would send, without sending it
292
+ (secrets masked).
293
+
294
+ Passwords stay off the command line with `--password -`, which reads
295
+ the password from stdin, or `--generate-password`, which creates a
296
+ strong one and prints it once on stderr.
297
+
298
+ List options on update commands (`--alias`, `--backend`) replace the
299
+ whole list; `--add-alias` and `--remove-alias` change one entry and
300
+ keep the rest.
192
301
 
193
302
  Some changes run in the background: creating a site, server, proxy or
194
303
  domain, for example, queues one or more jobs in a batch. Such a command
195
304
  prints the queued jobs and returns right away; add `--wait` to follow
196
305
  the batch until every job has finished and see how each one ended.
197
- With `--wait` the exit status is 0 only when every job completed. You
306
+ With `--wait` the exit status is 0 only when every job completed (1
307
+ when a job failed, 7 when `--timeout` ran out). You
198
308
  can look a batch up later with `dncli jobs batches show <batch_id>`.
199
309
 
200
- The exit status is 0 when the API accepted the request and 1 for any
201
- error response, so `dncli ... && next-step` is safe in scripts. Every
202
- command takes `--timeout <seconds>` (default 300) for how long to wait
203
- for the API, including the time spent waiting on `--wait`.
310
+ The exit status is 0 when the API accepted the request, so `dncli ...
311
+ && next-step` is safe in scripts. A failure says what kind it is:
312
+
313
+ | Exit | Meaning |
314
+ |---|---|
315
+ | 1 | other errors, e.g. a background job failed |
316
+ | 2 | wrong command, option or value, or `--yes` needed |
317
+ | 3 | not found (404, or no entity with that name) |
318
+ | 4 | API key missing or rejected, or no permission |
319
+ | 5 | the API rejected the request (validation), or a name is ambiguous |
320
+ | 6 | rate limited, server error or network failure: retry later |
321
+ | 7 | `--wait` timed out; the jobs keep running |
322
+
323
+ When output is JSON and stderr is not a terminal, the error is one
324
+ JSON line on stderr, e.g. `{"error": {"message": "...", "kind":
325
+ "invalid", "exit": 5, "status": 422}}`; option parsing errors (exit 2)
326
+ stay plain text. Every command takes `--timeout
327
+ <seconds>` (default 300) for how long to wait for the API, including
328
+ the time spent waiting on `--wait`.
204
329
 
205
330
  In CI and pipelines, skip the credentials file and pass the key via
206
331
  the environment:
@@ -82,8 +82,103 @@ Every DevNomads product has its own command group - `apps`,
82
82
  your SSH keys and `jobs` for background work. Explore with
83
83
  `dncli --help` and `dncli <group> --help`.
84
84
 
85
- Commands accept any unambiguous prefix: `dncli e l` is `dncli emails
86
- list`. An ambiguous prefix lists the candidates.
85
+ In a terminal, commands accept any unambiguous prefix: `dncli e l` is
86
+ `dncli emails list`. An ambiguous prefix lists the candidates. Scripts
87
+ (no terminal on stdin) must spell commands out, so a truncated name can
88
+ never run a different command; dncli then names the command you meant.
89
+
90
+ `dncli commands` lists every command with its options, and marks the
91
+ ones that change something, ask for confirmation, run in the
92
+ background or start billing. `dncli commands --out json sites` gives
93
+ the full detail for one group, for scripts and AI agents.
94
+
95
+ ## Logging in to a site
96
+
97
+ `dncli sites ssh` opens an SSH session as the site's system user,
98
+ `site<service_id>`, so you don't need to know that name:
99
+
100
+ ```sh
101
+ dncli sites ssh example.com
102
+ dncli sites ssh example.com -- ls -la # run one command
103
+ dncli sites ssh example.com --dry-run # print the ssh command
104
+ ```
105
+
106
+ dncli logs in on the host the API lists for the site. A site that runs
107
+ on several hosts (an HA cluster) asks which one; pick it with `--host`
108
+ to skip the question, for example in a script. Anything after `--`
109
+ goes to ssh: extra options (`-- -p 2222`) or a remote command.
110
+
111
+ ssh logs in with your SSH key when the site has it (`dncli sites keys
112
+ attach`); otherwise ssh itself asks for the site's password. dncli never
113
+ sees or stores that password. Scripts and other runs without a terminal
114
+ cannot answer a password prompt, so they need key login.
115
+
116
+ ## Publishing a site
117
+
118
+ `dncli sites publish` uploads a folder (the current one by default) to
119
+ a site with rsync, over the same SSH login as `dncli sites ssh`:
120
+
121
+ ```sh
122
+ dncli sites publish example.com ./dist --dry-run # show what would change
123
+ dncli sites publish example.com ./dist # new and changed files
124
+ dncli sites publish example.com ./dist --delete # also remove files not in ./dist
125
+ ```
126
+
127
+ Files go to `/home/site<service_id>/domains/<domain>/public_html`. `.git/`
128
+ is never uploaded; `--exclude` leaves out more (repeat it). You need
129
+ rsync locally and on the server.
130
+
131
+ **Release mode.** `--release` switches a site to versioned uploads:
132
+ each publish goes into `public_html/releases/<timestamp>/` (unchanged
133
+ files are hard links to the previous release, so only changes are
134
+ transferred) and the `public_html/current` symlink switches to it in
135
+ one step, so visitors never see a half-finished upload. dncli points
136
+ the site's document root into `current` through the API, e.g. `/public`
137
+ becomes `/current/public`. After that every publish makes a release;
138
+ `--keep` (default 5) sets how many stay.
139
+
140
+ ```sh
141
+ dncli sites publish example.com ./dist --release # switch, asks first
142
+ dncli sites releases example.com # list releases
143
+ dncli sites rollback example.com # back to the previous one
144
+ dncli sites publish example.com ./dist --no-release # back to plain mode
145
+ ```
146
+
147
+ Every release starts from your folder alone: files the site writes
148
+ into its own folder (uploads, caches) are not carried over. Switching
149
+ mode changes the live site, so dncli asks first (`--yes` skips the
150
+ question); the old mode's files stay on the server, no longer served.
151
+
152
+ **Commands after the upload.** `--run` runs a command on the server in
153
+ the uploaded folder, such as `composer install`; repeat it for more, they
154
+ run in the order given. In release mode the commands run in the new
155
+ release before it goes live, so a failing command stops the publish and
156
+ the site keeps serving the previous release. `--run-once` is for what
157
+ must happen only once, like a database migration: on a site with several
158
+ hosts it runs on the first host only, after all `--run` commands:
159
+
160
+ ```sh
161
+ dncli sites publish example.com . --exclude vendor/ \
162
+ --run 'composer install --no-dev --optimize-autoloader' \
163
+ --run-once 'php artisan migrate --force'
164
+ ```
165
+
166
+ **Sites on several hosts.** A site that runs on several hosts (an HA
167
+ cluster) gets every publish on all of them: dncli uploads to and runs
168
+ the commands on every host first, and only then switches them, so the
169
+ hosts serve different releases only for the moment the switches take.
170
+ `rollback` switches every host too. `--host` limits a command to one
171
+ of them.
172
+
173
+ **From a CI pipeline.** A pipeline has no terminal, so ssh cannot ask
174
+ for a password or whether to trust a host it has not seen before. Give
175
+ the pipeline an SSH key that is attached to the site (`dncli sites keys
176
+ attach`), the hosts' keys in `known_hosts` and the API key in `DN_API_KEY`:
177
+
178
+ ```sh
179
+ mkdir -p ~/.ssh && ssh-keyscan web01.example.com >> ~/.ssh/known_hosts
180
+ dncli sites publish example.com . --run 'composer install --no-dev'
181
+ ```
87
182
 
88
183
  ## Managing DNS
89
184
 
@@ -168,23 +263,53 @@ fields, and reports an error on an unknown column name.
168
263
 
169
264
  Commands that take a service id also accept a unique entity name and
170
265
  resolve it for you, so `dncli domains show example.com` works as well
171
- as `dncli domains show 1234`. Names match regardless of case. A purely
172
- numeric value is always treated as an id; an entity that matches more
173
- than one service is rejected, so pass the id when an entity is not
174
- unique. Other references, such as cluster, key or user ids, take the
175
- numeric id only.
266
+ as `dncli domains show 1234`. Clients, SSH keys, clusters, hypervisors,
267
+ database users and volumes take a name too, as an argument or an
268
+ option: `dncli databases permissions create stelling_bg25 --user-id stelling`. The
269
+ help of each such option says which field it matches. Names match
270
+ regardless of case. A purely numeric value is always treated as an id;
271
+ a name that matches more than one entity is rejected, so pass the id
272
+ when a name is not unique.
273
+
274
+ Every command that changes something takes `--dry-run`: it resolves
275
+ names to ids and prints the request it would send, without sending it
276
+ (secrets masked).
277
+
278
+ Passwords stay off the command line with `--password -`, which reads
279
+ the password from stdin, or `--generate-password`, which creates a
280
+ strong one and prints it once on stderr.
281
+
282
+ List options on update commands (`--alias`, `--backend`) replace the
283
+ whole list; `--add-alias` and `--remove-alias` change one entry and
284
+ keep the rest.
176
285
 
177
286
  Some changes run in the background: creating a site, server, proxy or
178
287
  domain, for example, queues one or more jobs in a batch. Such a command
179
288
  prints the queued jobs and returns right away; add `--wait` to follow
180
289
  the batch until every job has finished and see how each one ended.
181
- With `--wait` the exit status is 0 only when every job completed. You
290
+ With `--wait` the exit status is 0 only when every job completed (1
291
+ when a job failed, 7 when `--timeout` ran out). You
182
292
  can look a batch up later with `dncli jobs batches show <batch_id>`.
183
293
 
184
- The exit status is 0 when the API accepted the request and 1 for any
185
- error response, so `dncli ... && next-step` is safe in scripts. Every
186
- command takes `--timeout <seconds>` (default 300) for how long to wait
187
- for the API, including the time spent waiting on `--wait`.
294
+ The exit status is 0 when the API accepted the request, so `dncli ...
295
+ && next-step` is safe in scripts. A failure says what kind it is:
296
+
297
+ | Exit | Meaning |
298
+ |---|---|
299
+ | 1 | other errors, e.g. a background job failed |
300
+ | 2 | wrong command, option or value, or `--yes` needed |
301
+ | 3 | not found (404, or no entity with that name) |
302
+ | 4 | API key missing or rejected, or no permission |
303
+ | 5 | the API rejected the request (validation), or a name is ambiguous |
304
+ | 6 | rate limited, server error or network failure: retry later |
305
+ | 7 | `--wait` timed out; the jobs keep running |
306
+
307
+ When output is JSON and stderr is not a terminal, the error is one
308
+ JSON line on stderr, e.g. `{"error": {"message": "...", "kind":
309
+ "invalid", "exit": 5, "status": 422}}`; option parsing errors (exit 2)
310
+ stay plain text. Every command takes `--timeout
311
+ <seconds>` (default 300) for how long to wait for the API, including
312
+ the time spent waiting on `--wait`.
188
313
 
189
314
  In CI and pipelines, skip the credentials file and pass the key via
190
315
  the environment:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: devnomads-cli
3
- Version: 0.13.0
3
+ Version: 0.15.0
4
4
  Summary: Manage your DevNomads services from the command line
5
5
  Author-email: DevNomads <support@devnomads.nl>
6
6
  License: MIT
@@ -98,8 +98,103 @@ Every DevNomads product has its own command group - `apps`,
98
98
  your SSH keys and `jobs` for background work. Explore with
99
99
  `dncli --help` and `dncli <group> --help`.
100
100
 
101
- Commands accept any unambiguous prefix: `dncli e l` is `dncli emails
102
- list`. An ambiguous prefix lists the candidates.
101
+ In a terminal, commands accept any unambiguous prefix: `dncli e l` is
102
+ `dncli emails list`. An ambiguous prefix lists the candidates. Scripts
103
+ (no terminal on stdin) must spell commands out, so a truncated name can
104
+ never run a different command; dncli then names the command you meant.
105
+
106
+ `dncli commands` lists every command with its options, and marks the
107
+ ones that change something, ask for confirmation, run in the
108
+ background or start billing. `dncli commands --out json sites` gives
109
+ the full detail for one group, for scripts and AI agents.
110
+
111
+ ## Logging in to a site
112
+
113
+ `dncli sites ssh` opens an SSH session as the site's system user,
114
+ `site<service_id>`, so you don't need to know that name:
115
+
116
+ ```sh
117
+ dncli sites ssh example.com
118
+ dncli sites ssh example.com -- ls -la # run one command
119
+ dncli sites ssh example.com --dry-run # print the ssh command
120
+ ```
121
+
122
+ dncli logs in on the host the API lists for the site. A site that runs
123
+ on several hosts (an HA cluster) asks which one; pick it with `--host`
124
+ to skip the question, for example in a script. Anything after `--`
125
+ goes to ssh: extra options (`-- -p 2222`) or a remote command.
126
+
127
+ ssh logs in with your SSH key when the site has it (`dncli sites keys
128
+ attach`); otherwise ssh itself asks for the site's password. dncli never
129
+ sees or stores that password. Scripts and other runs without a terminal
130
+ cannot answer a password prompt, so they need key login.
131
+
132
+ ## Publishing a site
133
+
134
+ `dncli sites publish` uploads a folder (the current one by default) to
135
+ a site with rsync, over the same SSH login as `dncli sites ssh`:
136
+
137
+ ```sh
138
+ dncli sites publish example.com ./dist --dry-run # show what would change
139
+ dncli sites publish example.com ./dist # new and changed files
140
+ dncli sites publish example.com ./dist --delete # also remove files not in ./dist
141
+ ```
142
+
143
+ Files go to `/home/site<service_id>/domains/<domain>/public_html`. `.git/`
144
+ is never uploaded; `--exclude` leaves out more (repeat it). You need
145
+ rsync locally and on the server.
146
+
147
+ **Release mode.** `--release` switches a site to versioned uploads:
148
+ each publish goes into `public_html/releases/<timestamp>/` (unchanged
149
+ files are hard links to the previous release, so only changes are
150
+ transferred) and the `public_html/current` symlink switches to it in
151
+ one step, so visitors never see a half-finished upload. dncli points
152
+ the site's document root into `current` through the API, e.g. `/public`
153
+ becomes `/current/public`. After that every publish makes a release;
154
+ `--keep` (default 5) sets how many stay.
155
+
156
+ ```sh
157
+ dncli sites publish example.com ./dist --release # switch, asks first
158
+ dncli sites releases example.com # list releases
159
+ dncli sites rollback example.com # back to the previous one
160
+ dncli sites publish example.com ./dist --no-release # back to plain mode
161
+ ```
162
+
163
+ Every release starts from your folder alone: files the site writes
164
+ into its own folder (uploads, caches) are not carried over. Switching
165
+ mode changes the live site, so dncli asks first (`--yes` skips the
166
+ question); the old mode's files stay on the server, no longer served.
167
+
168
+ **Commands after the upload.** `--run` runs a command on the server in
169
+ the uploaded folder, such as `composer install`; repeat it for more, they
170
+ run in the order given. In release mode the commands run in the new
171
+ release before it goes live, so a failing command stops the publish and
172
+ the site keeps serving the previous release. `--run-once` is for what
173
+ must happen only once, like a database migration: on a site with several
174
+ hosts it runs on the first host only, after all `--run` commands:
175
+
176
+ ```sh
177
+ dncli sites publish example.com . --exclude vendor/ \
178
+ --run 'composer install --no-dev --optimize-autoloader' \
179
+ --run-once 'php artisan migrate --force'
180
+ ```
181
+
182
+ **Sites on several hosts.** A site that runs on several hosts (an HA
183
+ cluster) gets every publish on all of them: dncli uploads to and runs
184
+ the commands on every host first, and only then switches them, so the
185
+ hosts serve different releases only for the moment the switches take.
186
+ `rollback` switches every host too. `--host` limits a command to one
187
+ of them.
188
+
189
+ **From a CI pipeline.** A pipeline has no terminal, so ssh cannot ask
190
+ for a password or whether to trust a host it has not seen before. Give
191
+ the pipeline an SSH key that is attached to the site (`dncli sites keys
192
+ attach`), the hosts' keys in `known_hosts` and the API key in `DN_API_KEY`:
193
+
194
+ ```sh
195
+ mkdir -p ~/.ssh && ssh-keyscan web01.example.com >> ~/.ssh/known_hosts
196
+ dncli sites publish example.com . --run 'composer install --no-dev'
197
+ ```
103
198
 
104
199
  ## Managing DNS
105
200
 
@@ -184,23 +279,53 @@ fields, and reports an error on an unknown column name.
184
279
 
185
280
  Commands that take a service id also accept a unique entity name and
186
281
  resolve it for you, so `dncli domains show example.com` works as well
187
- as `dncli domains show 1234`. Names match regardless of case. A purely
188
- numeric value is always treated as an id; an entity that matches more
189
- than one service is rejected, so pass the id when an entity is not
190
- unique. Other references, such as cluster, key or user ids, take the
191
- numeric id only.
282
+ as `dncli domains show 1234`. Clients, SSH keys, clusters, hypervisors,
283
+ database users and volumes take a name too, as an argument or an
284
+ option: `dncli databases permissions create stelling_bg25 --user-id stelling`. The
285
+ help of each such option says which field it matches. Names match
286
+ regardless of case. A purely numeric value is always treated as an id;
287
+ a name that matches more than one entity is rejected, so pass the id
288
+ when a name is not unique.
289
+
290
+ Every command that changes something takes `--dry-run`: it resolves
291
+ names to ids and prints the request it would send, without sending it
292
+ (secrets masked).
293
+
294
+ Passwords stay off the command line with `--password -`, which reads
295
+ the password from stdin, or `--generate-password`, which creates a
296
+ strong one and prints it once on stderr.
297
+
298
+ List options on update commands (`--alias`, `--backend`) replace the
299
+ whole list; `--add-alias` and `--remove-alias` change one entry and
300
+ keep the rest.
192
301
 
193
302
  Some changes run in the background: creating a site, server, proxy or
194
303
  domain, for example, queues one or more jobs in a batch. Such a command
195
304
  prints the queued jobs and returns right away; add `--wait` to follow
196
305
  the batch until every job has finished and see how each one ended.
197
- With `--wait` the exit status is 0 only when every job completed. You
306
+ With `--wait` the exit status is 0 only when every job completed (1
307
+ when a job failed, 7 when `--timeout` ran out). You
198
308
  can look a batch up later with `dncli jobs batches show <batch_id>`.
199
309
 
200
- The exit status is 0 when the API accepted the request and 1 for any
201
- error response, so `dncli ... && next-step` is safe in scripts. Every
202
- command takes `--timeout <seconds>` (default 300) for how long to wait
203
- for the API, including the time spent waiting on `--wait`.
310
+ The exit status is 0 when the API accepted the request, so `dncli ...
311
+ && next-step` is safe in scripts. A failure says what kind it is:
312
+
313
+ | Exit | Meaning |
314
+ |---|---|
315
+ | 1 | other errors, e.g. a background job failed |
316
+ | 2 | wrong command, option or value, or `--yes` needed |
317
+ | 3 | not found (404, or no entity with that name) |
318
+ | 4 | API key missing or rejected, or no permission |
319
+ | 5 | the API rejected the request (validation), or a name is ambiguous |
320
+ | 6 | rate limited, server error or network failure: retry later |
321
+ | 7 | `--wait` timed out; the jobs keep running |
322
+
323
+ When output is JSON and stderr is not a terminal, the error is one
324
+ JSON line on stderr, e.g. `{"error": {"message": "...", "kind":
325
+ "invalid", "exit": 5, "status": 422}}`; option parsing errors (exit 2)
326
+ stay plain text. Every command takes `--timeout
327
+ <seconds>` (default 300) for how long to wait for the API, including
328
+ the time spent waiting on `--wait`.
204
329
 
205
330
  In CI and pipelines, skip the credentials file and pass the key via
206
331
  the environment:
@@ -8,6 +8,7 @@ devnomads_cli.egg-info/dependency_links.txt
8
8
  devnomads_cli.egg-info/entry_points.txt
9
9
  devnomads_cli.egg-info/requires.txt
10
10
  devnomads_cli.egg-info/top_level.txt
11
+ tests/test_agent_features.py
11
12
  tests/test_cert.py
12
13
  tests/test_cli.py
13
14
  tests/test_config.py
@@ -15,5 +16,7 @@ tests/test_generate.py
15
16
  tests/test_generated_cli.py
16
17
  tests/test_helpers.py
17
18
  tests/test_hook.py
19
+ tests/test_sites_publish.py
20
+ tests/test_sites_ssh.py
18
21
  tests/test_transfer.py
19
22
  tests/test_versions.py