@openupstream/cli 0.3.0 → 0.5.0

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.
package/README.md CHANGED
@@ -40,9 +40,60 @@ oup site deploy dist --bucket my-site
40
40
  find it, as git finds `.git`. It holds no secret and may be committed.
41
41
  `--project <name|id>`, or `OUP_PROJECT` in CI, names another Project for
42
42
  one command.
43
- - `oup pg create <name> [--memory <MB>] [--storage <GB>] [--site hetzner-fsn1|ovh-lim] [--max-storage <GB> | --no-auto-grow] [--no-wait]`:
44
- a Database with its primary in the Site (default `hetzner-fsn1`) and a
45
- standby in the other one, 256 MB and 1 GB unless told otherwise. Its
43
+ - `oup member list [--account <name|id>]`: the Members of your Account
44
+ with their roles (decision 138) and grants: an `owner` may do everything, the
45
+ Account's Members included; a `developer` every Project and everything
46
+ in it. With several Accounts, `--account` says which, as for every
47
+ `oup member` command.
48
+ - `oup member role <email> owner|developer|none`: gives a Member another
49
+ role, or none, which leaves them only their grants; their Postgres roles
50
+ beyond those are dropped. Owners only; an Account always keeps an owner.
51
+ - `oup member grant <email> read|write|owner --database <name> [--project <name|id>]`:
52
+ lets a Member use one Database of the linked Project at that level or
53
+ below (decision 139): they see it and its Project's name and open
54
+ `oup pg proxy`, nothing else of the Project. Run again with another
55
+ level to change it; a lower one drops their Postgres roles above it.
56
+ Owners only. A grant counts only while the Member has no role.
57
+ - `oup member revoke <email> --database <name> [--project <name|id>]`:
58
+ takes the grant away, and with it their Postgres roles there.
59
+ - `oup member remove <email>`: removes a Member, owners only. Their
60
+ Postgres roles from `oup pg proxy`, and those of their API keys, are
61
+ dropped from the Account's Databases (decision 143). Where they had
62
+ `owner`, every open `oup pg proxy` connection to that Project is closed
63
+ once, so theirs ends too; tools reconnect.
64
+ - `oup member leave`: leaves the Account; its last owner cannot. `oup
65
+ member` changes need `oup login`: an API key cannot change who is in an
66
+ Account.
67
+ - `oup token list [--account <name|id>]`: the Account's tokens (decision
68
+ 144), secrets of the Account rather than of a person, for CI, BI tools
69
+ and scripts: each with its role, expiry, last use and grants, never its
70
+ secret. Owners and developers see them.
71
+ - `oup token create <name> --expires <days|date> [--developer] [--account <name|id>]`:
72
+ a new token that expires after `90d` or on a date, at most a year away.
73
+ `--developer` gives it the developer role (every Project and everything
74
+ in it, never the Account itself); without it, it reaches only what
75
+ `oup token grant` gives. The secret (`oup_tok_…`) is printed alone on
76
+ stdout, only now, so it can go straight to where it is kept, e.g.
77
+ `oup token create ci --developer --expires 90d | gh secret set OUP_API_KEY`.
78
+ - `oup token grant <name> read|write|owner --database <name> [--project <name|id>]`
79
+ and `oup token revoke <name> --database <name>`: a token's access to one
80
+ Database of the linked Project, as for a Member, e.g. `read` for a BI
81
+ tool. A grant counts only while the token has no role.
82
+ - `oup token role <name> developer|none`: gives a token the developer role
83
+ or takes it; without it, its Postgres roles beyond its grants are
84
+ dropped.
85
+ - `oup token roll <name> --expires <days|date>`: a new secret with a new
86
+ expiry, printed like `create`'s; the old one keeps working for 24 hours,
87
+ so CI can be switched over. Its name, rights and Postgres roles stay, so
88
+ a BI tool's saved database login keeps working. It also brings back an
89
+ expired token.
90
+ - `oup token delete <name>`: revokes the token at once and drops its
91
+ Postgres roles. Changing tokens needs an owner with `oup login`; neither
92
+ an API key nor a token can.
93
+ - `oup pg create <name> [--memory <MB>] [--storage <GB>] [--site <site>] [--max-storage <GB> | --no-auto-grow] [--no-wait]`:
94
+ a Database with its primary in the Site (default: the installation's
95
+ default Site, see `oup sites`) and a standby in another one, 256 MB and
96
+ 1 GB unless told otherwise. Its
46
97
  storage grows by half once 90% full (decision 111), without a limit
47
98
  unless `--max-storage` sets one; `--no-auto-grow` leaves growing to
48
99
  `oup pg resize`. It waits
@@ -59,14 +110,31 @@ oup site deploy dist --bucket my-site
59
110
  oldest base backup and at least 5 minutes in the past (WAL reaches the
60
111
  archive up to that late).
61
112
  - `oup pg resize <name> [--memory <MB>] [--storage <GB>] [--max-storage <GB> | --no-max-storage] [--auto-grow | --no-auto-grow] [--no-wait]`:
62
- storage only grows, online; a new memory size restarts the two instances
63
- one after the other, the standby first (writes pause for seconds). Waits
113
+ storage only grows, online; more memory is given to the running
114
+ instances without a restart, less memory restarts the two instances
115
+ one after the other, the standby first (queries through the pooler wait
116
+ about 15 seconds). Waits
64
117
  until the Database is ready again, unless `--no-wait`; a change of the
65
118
  growth settings alone takes effect at once.
66
119
  - `oup pg list` (with each Database's growth: `auto`, `auto ≤ 40 GB` or
67
120
  `manual`), `oup pg show <name>` (JSON), `oup pg delete <name>`.
121
+ - `oup pg proxy <name> [--access read|write|owner] [--port <n>]`: the
122
+ Database on this machine while it runs (decision 126). It listens on
123
+ `127.0.0.1:5432`, or `--port`, and prints the URL to give `psql`, a
124
+ database GUI or a migration tool. You log in with a Postgres role of
125
+ your own, created the first time (the first start waits a minute or two
126
+ for it): `--access read`, the default, reads every table; `write` also
127
+ inserts, updates and deletes rows; `owner` acts as `app`, the role the
128
+ Project's Services use, so migrations work and what they create belongs
129
+ to `app`. `read` and `write` go through the Pooler like a Service;
130
+ `owner` goes to the primary, so migration tools' locks work, with at most
131
+ 5 connections at once, which end when the primary restarts. The same role
132
+ and password every time, on any machine. Connections travel through a
133
+ WebSocket on port 443; nothing else needs installing or opening. With
134
+ `OUP_API_KEY` (an API key needs `openupstream:write`), the key or the
135
+ Account token gets roles of its own.
68
136
  - `oup service deploy <name> --image <ref> [--port <n> | --no-port] [--replicas <n>]
69
- [--memory <MB>] [--cpu <millicores>] [--site hetzner-fsn1|ovh-lim]
137
+ [--memory <MB>] [--cpu <millicores>] [--site <site>]
70
138
  [--registry-user <user> --registry-password-stdin] [--no-wait]`: brings
71
139
  the Service to what the flags say (ARCHITECTURE.md, decision 94). A new
72
140
  one needs `--port`, or `--no-port` for a worker that serves no HTTP
@@ -88,7 +156,7 @@ oup site deploy dist --bucket my-site
88
156
  was replaced is gone.
89
157
  - `oup job deploy <name> --image <ref> [--schedule <cron> | --no-schedule]
90
158
  [--time-zone <IANA name>] [--timeout <seconds>] [--memory <MB>]
91
- [--cpu <millicores>] [--site hetzner-fsn1|ovh-lim] [--registry-user <user>
159
+ [--cpu <millicores>] [--site <site>] [--registry-user <user>
92
160
  --registry-password-stdin] [--no-wait] [--no-command | -- <command>
93
161
  <arg>…]`: brings the
94
162
  Job to what the flags say, as `oup service deploy` does for a Service
@@ -133,6 +201,33 @@ oup site deploy dist --bucket my-site
133
201
  but `BUCKET_NAME` by themselves; the AWS CLI also needs
134
202
  `aws configure set default.s3.addressing_style virtual`, since a Bucket
135
203
  is reached at its own hostname only.
204
+ - `oup domain list`, `oup domain add <hostname>`, `oup domain verify
205
+ <hostname>`, `oup domain delete <hostname>` (and its Routes). Every
206
+ Project has its default Domain. `add` claims a hostname of your own and
207
+ prints the two DNS records to publish: a TXT record that proves it is
208
+ yours, and a CNAME that brings its traffic here. `verify` looks the TXT
209
+ record up now. Publish the CNAME before the first Route: the Domain's
210
+ certificate is requested then, and a failed attempt is tried again only
211
+ after an hour.
212
+ - `oup route list`, `oup route add <address> --bucket <name> [--spa]`,
213
+ `oup route add <address> --service <name>`, `oup route delete <address>`.
214
+ A Route sends everything below a path of a Domain to a Bucket or to a
215
+ Service that has a port. The address is the hostname with the path, as in
216
+ `www.example.com/docs` (`www.example.com` alone is its `/`), or the path
217
+ alone, as in `/docs`, on the Project's default Domain. A Bucket gets the
218
+ path without the prefix, and with `--spa` a path without an object
219
+ serves `index.html`; a Service gets the path as it came. Deleting a Route
220
+ leaves what it went to.
221
+ - `oup usage [--instances] [--json]`: what the Project's Resources use
222
+ now of what they were given: CPU (the last two minutes' average), memory
223
+ and storage per Database, Service, Job and Bucket. `--instances` adds
224
+ every running copy below its Resource, with its Site, its state and its
225
+ restarts; `--json` prints what the API answers. This is the use right
226
+ now, not what is billed.
227
+ - `oup sites`: the compute Sites, where Databases, Services and Jobs run:
228
+ each Site's id (what `--site` takes), `default` for the one used when
229
+ `--site` is left out, and its name, as the installation's admins set it.
230
+ Which Sites exist is the installation's (ADR-0007).
136
231
  - `oup site deploy <dir> --bucket <name> [--keep] [--force]`: makes the
137
232
  Bucket mirror the directory (decision 88): changed files only, `index.html`
138
233
  files last, then deletes what the directory no longer has, unless
@@ -141,13 +236,15 @@ oup site deploy dist --bucket my-site
141
236
  headers come from the name: hashed assets a year and immutable,
142
237
  `index.html` `no-cache`, the rest five minutes.
143
238
 
144
- In CI, set `OUP_API_KEY` to a madAuth API key instead of signing in, and
145
- `OUP_API_URL` for another API than `https://console.openupstream.com/api`.
239
+ In CI, set `OUP_API_KEY` instead of signing in: preferably to an Account
240
+ token (`oup token create`), which belongs to the Account and keeps working
241
+ when the person who made it leaves, or to a madAuth API key of your own.
242
+ `OUP_API_URL` names another API than `https://console.openupstream.com/api`.
146
243
 
147
244
  <!-- docs:end -->
148
245
 
149
246
  `src/oidc.ts` is the device grant and refresh, `src/session.ts` the token
150
- for each call, `src/deploy.ts` the site deploy (`planDeploy` is pure),
247
+ for each call, `src/proxy.ts` the database proxy, `src/deploy.ts` the site deploy (`planDeploy` is pure),
151
248
  `src/project.ts` the linked Project, `src/services.ts` the Service deploy
152
249
  (`planServiceDeploy` is pure), `src/jobs.ts` the Job deploy and runs
153
250
  (`planJobDeploy` is pure), `src/wait.ts` the polling both wait with and