UNPKG

11.9 kBMarkdownView Raw
1![](https://cto.ai/static/sdk-banner.png)
2
3# ops
4
5💻 CTO.ai Ops - The CLI built for Teams 🚀
6
7[![oclif](https://img.shields.io/badge/cli-oclif-brightgreen.svg)](https://oclif.io)
8[![Version](https://img.shields.io/npm/v/ops.svg)](https://npmjs.org/package/ops)
9[![Downloads/week](https://img.shields.io/npm/dw/ops.svg)](https://npmjs.org/package/ops)
10[![License](https://img.shields.io/npm/l/ops.svg)](https://github.com/cto.ai/ops/blob/master/package.json)
11
12<!-- toc -->
13* [ops](#ops)
14* [Usage](#usage)
15* [Commands](#commands)
16* [Testing](#testing)
17<!-- tocstop -->
18
19# Usage
20
21<!-- usage -->
22```sh-session
23$ npm install -g @cto.ai/ops
24$ ops COMMAND
25running command...
26$ ops (-v|--version|version)
27@cto.ai/ops/1.13.3 darwin-x64 node-v12.18.4
28$ ops --help [COMMAND]
29USAGE
30 $ ops COMMAND
31...
32```
33<!-- usagestop -->
34
35# Commands
36
37<!-- commands -->
38* [`ops account:reset`](#ops-accountreset)
39* [`ops account:signin`](#ops-accountsignin)
40* [`ops account:signout`](#ops-accountsignout)
41* [`ops account:signup`](#ops-accountsignup)
42* [`ops account:support`](#ops-accountsupport)
43* [`ops add [OPNAME]`](#ops-add-opname)
44* [`ops build [PATH]`](#ops-build-path)
45* [`ops cleanup [OPNAME]`](#ops-cleanup-opname)
46* [`ops configs:delete`](#ops-configsdelete)
47* [`ops configs:list`](#ops-configslist)
48* [`ops configs:set`](#ops-configsset)
49* [`ops generate:token`](#ops-generatetoken)
50* [`ops help [COMMAND]`](#ops-help-command)
51* [`ops init [NAME]`](#ops-init-name)
52* [`ops list`](#ops-list)
53* [`ops publish PATH`](#ops-publish-path)
54* [`ops remove OP`](#ops-remove-op)
55* [`ops run [NAMEORPATH]`](#ops-run-nameorpath)
56* [`ops search [FILTER]`](#ops-search-filter)
57* [`ops secrets:delete`](#ops-secretsdelete)
58* [`ops secrets:list`](#ops-secretslist)
59* [`ops secrets:register`](#ops-secretsregister)
60* [`ops secrets:set`](#ops-secretsset)
61* [`ops secrets:unregister`](#ops-secretsunregister)
62* [`ops start [NAMEORPATH]`](#ops-start-nameorpath)
63* [`ops status`](#ops-status)
64* [`ops stop [RUNID]`](#ops-stop-runid)
65* [`ops team:create`](#ops-teamcreate)
66* [`ops team:info`](#ops-teaminfo)
67* [`ops team:invite`](#ops-teaminvite)
68* [`ops team:join`](#ops-teamjoin)
69* [`ops team:list`](#ops-teamlist)
70* [`ops team:remove [MEMBER]`](#ops-teamremove-member)
71* [`ops team:switch`](#ops-teamswitch)
72* [`ops update`](#ops-update)
73* [`ops whoami`](#ops-whoami)
74
75## `ops account:reset`
76
77Reset your password.
78
79```
80USAGE
81 $ ops account:reset
82```
83
84## `ops account:signin`
85
86Log in to your account.
87
88```
89USAGE
90 $ ops account:signin
91
92OPTIONS
93 -h, --help show CLI help
94 -i, --interactive Interactive Mode
95 -p, --password=password Password
96 -u, --user=user Username or email
97```
98
99## `ops account:signout`
100
101Log out from your account.
102
103```
104USAGE
105 $ ops account:signout
106
107OPTIONS
108 -h, --help show CLI help
109```
110
111## `ops account:signup`
112
113Creates an account to use with ops CLI.
114
115```
116USAGE
117 $ ops account:signup
118
119OPTIONS
120 -h, --help show CLI help
121```
122
123## `ops account:support`
124
125Contact our support team with questions.
126
127```
128USAGE
129 $ ops account:support
130
131OPTIONS
132 -h, --help show CLI help
133```
134
135## `ops add [OPNAME]`
136
137Add an op to your team.
138
139```
140USAGE
141 $ ops add [OPNAME]
142
143ARGUMENTS
144 OPNAME Name of the public op to be added to your team. It should be of the format - @teamname/opName:versionName
145
146OPTIONS
147 -h, --help show CLI help
148```
149
150## `ops build [PATH]`
151
152Build your op for sharing.
153
154```
155USAGE
156 $ ops build [PATH]
157
158ARGUMENTS
159 PATH Path to the op you want to build.
160
161OPTIONS
162 -h, --help show CLI help
163```
164
165## `ops cleanup [OPNAME]`
166
167Clean up locally cached docker images.
168
169```
170USAGE
171 $ ops cleanup [OPNAME]
172
173ARGUMENTS
174 OPNAME Name of the op to be cleaned up
175
176OPTIONS
177 -h, --help show CLI help
178```
179
180## `ops configs:delete`
181
182Delete a config stored for the active team
183
184```
185USAGE
186 $ ops configs:delete
187
188OPTIONS
189 -h, --help show CLI help
190 -k, --key=key Secret Key Name
191```
192
193## `ops configs:list`
194
195List all the configs that are stored for the active team
196
197```
198USAGE
199 $ ops configs:list
200
201OPTIONS
202 -h, --help show CLI help
203```
204
205## `ops configs:set`
206
207Add a new config key & value
208
209```
210USAGE
211 $ ops configs:set
212
213OPTIONS
214 -f, --from-file=from-file path to a file containing the value of the config to set
215 -k, --key=key the key of the config to set
216 -v, --value=value the value of the config to set
217```
218
219## `ops generate:token`
220
221Generate a long live access token.
222
223```
224USAGE
225 $ ops generate:token
226
227OPTIONS
228 -h, --help show CLI help
229```
230
231## `ops help [COMMAND]`
232
233display help for ops
234
235```
236USAGE
237 $ ops help [COMMAND]
238
239ARGUMENTS
240 COMMAND command to show help for
241
242OPTIONS
243 --all see all commands in CLI
244```
245
246_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v2.2.3/src/commands/help.ts)_
247
248## `ops init [NAME]`
249
250Create a new op
251
252```
253USAGE
254 $ ops init [NAME]
255
256ARGUMENTS
257 NAME the name of the op to create
258
259OPTIONS
260 -h, --help show CLI help
261 -k, --kind=kind the kind of op to create (command, pipeline, etc.)
262 -t, --template=template the name of the template to use
263```
264
265## `ops list`
266
267Lists the Ops you have in your team.
268
269```
270USAGE
271 $ ops list
272
273OPTIONS
274 -h, --help show CLI help
275```
276
277## `ops publish PATH`
278
279Publish an Op to your team.
280
281```
282USAGE
283 $ ops publish PATH
284
285ARGUMENTS
286 PATH Path to the op you want to publish.
287
288OPTIONS
289 -h, --help show CLI help
290```
291
292## `ops remove OP`
293
294Remove an Op from your team.
295
296```
297USAGE
298 $ ops remove OP
299
300ARGUMENTS
301 OP The name and version of the command or workflow you want to remove. E.g. my-command:0.1.0
302
303OPTIONS
304 -h, --help show CLI help
305```
306
307## `ops run [NAMEORPATH]`
308
309Run an Op from your team or the registry.
310
311```
312USAGE
313 $ ops run [NAMEORPATH]
314
315ARGUMENTS
316 NAMEORPATH Name or path of the Op you want to run.
317
318OPTIONS
319 -B, --batch Runs the op in non-interactive batch mode.
320 -b, --build Builds the op before running. Must provide a path to the op.
321 -h, --help show CLI help
322```
323
324## `ops search [FILTER]`
325
326Search for ops in your workspaces.
327
328```
329USAGE
330 $ ops search [FILTER]
331
332ARGUMENTS
333 FILTER Filters Op results which include filter text in Op name or description.
334
335OPTIONS
336 -h, --help show CLI help
337```
338
339## `ops secrets:delete`
340
341Delete a secret stored for the active team
342
343```
344USAGE
345 $ ops secrets:delete
346
347OPTIONS
348 -h, --help show CLI help
349 -k, --key=key Secret Key Name
350```
351
352## `ops secrets:list`
353
354List all the keys that are stored for the active team
355
356```
357USAGE
358 $ ops secrets:list
359
360OPTIONS
361 -h, --help show CLI help
362```
363
364## `ops secrets:register`
365
366Register a secrets provider for a team
367
368```
369USAGE
370 $ ops secrets:register
371```
372
373## `ops secrets:set`
374
375Add a key & value
376
377```
378USAGE
379 $ ops secrets:set
380
381OPTIONS
382 -f, --from-file=from-file path to a file containing the value of the secret to set
383 -k, --key=key the key of the secret to set
384 -v, --value=value the value of the secret to set
385```
386
387## `ops secrets:unregister`
388
389Unregister a secrets provider for a team
390
391```
392USAGE
393 $ ops secrets:unregister
394```
395
396## `ops start [NAMEORPATH]`
397
398Run a Pipeline remotely in the Ops Cloud.
399
400```
401USAGE
402 $ ops start [NAMEORPATH]
403
404ARGUMENTS
405 NAMEORPATH Name or path of the Op you want to run.
406
407OPTIONS
408 -h, --help show CLI help
409```
410
411## `ops status`
412
413See the status of currently running Ops (currently only services)
414
415```
416USAGE
417 $ ops status
418
419OPTIONS
420 -h, --help show CLI help
421```
422
423## `ops stop [RUNID]`
424
425Stop a service running in the Ops Cloud
426
427```
428USAGE
429 $ ops stop [RUNID]
430
431ARGUMENTS
432 RUNID Run ID of the service to stop
433
434OPTIONS
435 -h, --help show CLI help
436```
437
438## `ops team:create`
439
440Create your team.
441
442```
443USAGE
444 $ ops team:create
445
446OPTIONS
447 -h, --help show CLI help
448 -n, --name=name
449```
450
451## `ops team:info`
452
453Shows basic team information for the team you are currently on.
454
455```
456USAGE
457 $ ops team:info
458
459OPTIONS
460 -h, --help show CLI help
461```
462
463## `ops team:invite`
464
465Invite your team members.
466
467```
468USAGE
469 $ ops team:invite
470
471OPTIONS
472 -h, --help show CLI help
473
474 -i, --invitees=invitees A comma-separated string of usernames/emails we want to invite. E.g. ("user1,
475 user2@gmail.com, user3@something")
476```
477
478## `ops team:join`
479
480Accept an invite to join a team.
481
482```
483USAGE
484 $ ops team:join
485```
486
487## `ops team:list`
488
489Shows the list of your teams.
490
491```
492USAGE
493 $ ops team:list
494
495OPTIONS
496 -h, --help show CLI help
497```
498
499## `ops team:remove [MEMBER]`
500
501Remove your team members.
502
503```
504USAGE
505 $ ops team:remove [MEMBER]
506
507ARGUMENTS
508 MEMBER The username of the team member you want to remove from the team.
509
510OPTIONS
511 -h, --help show CLI help
512```
513
514## `ops team:switch`
515
516Switch your currently active team.
517
518```
519USAGE
520 $ ops team:switch
521
522OPTIONS
523 -h, --help show CLI help
524```
525
526## `ops update`
527
528Update the Ops CLI.
529
530```
531USAGE
532 $ ops update
533
534OPTIONS
535 -h, --help show CLI help
536```
537
538## `ops whoami`
539
540Display your user information
541
542```
543USAGE
544 $ ops whoami
545
546OPTIONS
547 -h, --help show CLI help
548```
549<!-- commandsstop -->
550
551
552
553### OClif Source Repo
554
555Useful reference for writing tests:
556
557 * https://github.com/oclif/command/blob/master/src/command.ts
558 * https://github.com/oclif/config/blob/master/src/plugin.ts
559
560
561# Testing
562
563Isolate tests (run only specific tests in that file):
564
565 test.only('it should run only tests suffixed with .only', async () => {
566
567## Unit Tests (`test` directory)
568
569### How to run Unit Tests
570
571 1. `npm test` or `npm t`
572
573### Tips
574
575Run a single unit test, or filter them by filename:
576
577 npx jest --testPathPattern=keycloak
578
579## E2E Tests (`test_e2e` directory)
580
581The CLI has a number of robused E2E tests that are hosted inside of CTO.ai's private CI/CD infra.
582
583We are planning to expose this system via Github Actions in the future, but for now, a CTO.ai team member will review your PR and test coverage.
584
585### How to run E2E tests locally
586
587The default test server is staging, but you can override this by passing in your own `OPS_REGISTRY_HOST` and `OPS_API_HOST` values from your shell config.
588
589Run tests against staging (as part of the CTO.ai platform developer workflow):
590
591 1. Run `npm run configdev` to point the ops binary at the development Typescript app (instead of the production Javascript bundle)
592 2. Ensure you have a `.env.staging` file (you can generate one by running scripts/make-env.sh)
593 3. Set your `NODE_ENV` to 'staging': `export NODE_ENV=staging`
594 4. `npm run test:e2e`
595
596Run tests against Minikube (as part of the CTO.ai platform developer workflow):
597
598 1. Create a user in Keycloak with the following credentials:
599
600```
601- username: 'existing_user'
602- email: 'e2e_existing_user1@cto.ai'
603- password: 'password'
604```
605
606 2. Change the userID in `test_e2e/utils/constants.ts EXISTING_USER_ID` to Step 1's userID
607 3. Create `existing_user` team in Database if haven't already
608 4. Change the teamID in `teste2e/utils/constants.ts EXISTING_TEAM_ID` to step 3's teamID
609 5. Create a `cto.ai` team in Database if haven't already
610 6. Publish this following command:
611
612```
613- Team: ‘cto.ai’
614- name: ‘github’
615- version: ‘latest’
616- public: true
617```
618
619 7. Publish the `write_a_file_op` command found in `test_e2e/sample_ops/write_a_file_op`
620 8. Publish the `echo_message_workflow` workflow found in `test_e2e/sample_ops/echo_message_workflow`
621 9. Add the `ops-cli-confidential` client to Keycloak. The `ops-cli-confidential.json` file can be found in Keybase
622 10. Run `npm run configdev` to point the ops binary at the development Typescript app (instead of the production Javascript bundle)
623 11. Ensure you have a `.env.test` file (you can generate one by running scripts/make-env.sh)
624 12. Modify the vars in `.env.test` to match your minikube IP
625 13. Set your `NODE_ENV` to 'test': `export NODE_ENV=test`
626 14. `npm run test:e2e`
627
628### Tips
629
630Run a single E2E test, or filter test files by filename:
631
632 npm run test:e2e --testPathPattern=signin