@cto.ai/ops-rc v1.20.0-rc.1

ops
💻 CTO.ai Ops - The CLI built for Teams 🚀
Usage
$ npm install -g @cto.ai/ops-rc
$ ops COMMAND
running command...
$ ops (-v|--version|version)
@cto.ai/ops-rc/1.20.0-rc.1 linux-x64 node-v18.19.0
$ ops --help [COMMAND]
USAGE
$ ops COMMAND
...Commands
ops account:resetops account:signinops account:signoutops account:signupops account:supportops add [OPNAME]ops build [PATH]ops certs CERTIFICATETYPE NAMEORPATHops cleanup [WORKFLOW]ops configs:deleteops configs:listops configs:setops generate:tokenops help [COMMAND]ops init [NAME]ops listops publish PATHops remove WORKFLOWops run [NAMEORPATH]ops search [FILTER]ops secrets:deleteops secrets:listops secrets:registerops secrets:setops secrets:unregisterops start [NAMEORPATH]ops statusops stop [RUNID]ops team:createops team:infoops team:inviteops team:joinops team:leaveops team:listops team:remove [MEMBER]ops team:switch [TEAMNAME]ops updateops whoami
ops account:reset
Reset your password.
USAGE
$ ops account:resetops account:signin
Log in to your account.
USAGE
$ ops account:signin
OPTIONS
-h, --help show CLI help
-i, --interactive Interactive Mode
-p, --password=password Password
-t, --team=team Team Name
-u, --user=user Username or emailops account:signout
Log out from your account.
USAGE
$ ops account:signout
OPTIONS
-h, --help show CLI helpops account:signup
Creates an account to use with ops CLI.
USAGE
$ ops account:signup
OPTIONS
-h, --help show CLI helpops account:support
Contact our support team with questions.
USAGE
$ ops account:support
OPTIONS
-h, --help show CLI helpops add [OPNAME]
Add a workflow to your team.
USAGE
$ ops add [OPNAME]
ARGUMENTS
OPNAME Name of the public workflow to be added to your team. It should be of the format -
@teamname/workflowName:versionName
OPTIONS
-h, --help show CLI helpops build [PATH]
Build your workflow for sharing.
USAGE
$ ops build [PATH]
ARGUMENTS
PATH Path to the workflow you want to build.
OPTIONS
-h, --help show CLI help
--nocache Do not use cache when building the image
--ops=workflows List of workflows from ops.yml you want to build. example:
ops build ./ops.yml --ops commandName serviceName pipelineNameops certs CERTIFICATETYPE NAMEORPATH
Save an SSL certificate and key for your service
USAGE
$ ops certs CERTIFICATETYPE NAMEORPATH
ARGUMENTS
CERTIFICATETYPE (ssl) The type of certificate to store
NAMEORPATH Name or path of the service to save SSL for.
OPTIONS
-h, --help Show help screen
--cert-file=cert-file Path to your certificate file
--key-file=key-file Path to your key fileops cleanup [WORKFLOW]
Clean up locally cached docker images.
USAGE
$ ops cleanup [WORKFLOW]
ARGUMENTS
WORKFLOW Name of the workflow to be cleaned up
OPTIONS
-h, --help show CLI helpops configs:delete
Delete a config stored for the active team
USAGE
$ ops configs:delete
OPTIONS
-h, --help show CLI help
-k, --key=key Secret Key Nameops configs:list
List all the configs that are stored for the active team
USAGE
$ ops configs:list
OPTIONS
-h, --help show CLI helpops configs:set
Add a new config key & value
USAGE
$ ops configs:set
OPTIONS
-f, --from-file=from-file path to a file containing the value of the config to set
-k, --key=key the key of the config to set
-v, --value=value the value of the config to setops generate:token
Generate a long live access token.
USAGE
$ ops generate:token
OPTIONS
-h, --help show CLI helpops help [COMMAND]
display help for ops
USAGE
$ ops help [COMMAND]
ARGUMENTS
COMMAND command to show help for
OPTIONS
--all see all commands in CLISee code: @oclif/plugin-help
ops init [NAME]
Create a new Workflow
USAGE
$ ops init [NAME]
ARGUMENTS
NAME provide a name or pass a github url to a template
OPTIONS
-h, --help show CLI help
-j, --jobs generate local template files for pipeline jobs
-k, --kind=kind the kind of Application to create (command, pipeline, etc.)
-t, --template=template the name of the template to useops list
Lists the Workflows you have in your team.
USAGE
$ ops list
OPTIONS
-h, --help show CLI helpops publish PATH
Publish a workflow to your team.
USAGE
$ ops publish PATH
ARGUMENTS
PATH Path to the workflow you want to publish.
OPTIONS
-c, --changelog=changelog Provide a publish changelog
-h, --help show CLI help
-o, --ops=workflows Provide the list of workflows that you want to publish.
--nocache Do not use cache when building the imageops remove WORKFLOW
Remove a workflow from your team.
USAGE
$ ops remove WORKFLOW
ARGUMENTS
WORKFLOW The name and version of the workflow you want to remove. E.g. my-workflow:0.1.0
Don't include team name or version if using the --all flag
OPTIONS
-h, --help show CLI help
--all Allows you to remove all versions of a workflow on your current team.ops run [NAMEORPATH]
Run a workflow from your team or the registry.
USAGE
$ ops run [NAMEORPATH]
ARGUMENTS
NAMEORPATH Name or path of the workflow you want to run.
OPTIONS
-B, --batch Runs the workflow in non-interactive batch mode.
-b, --build Builds the workflow before running. Must provide a path to the workflow.
-h, --help show CLI help
--nocache Do not use cache when building the imageops search [FILTER]
Search for workflows in our registry.
USAGE
$ ops search [FILTER]
ARGUMENTS
FILTER Filter results by workflow name or description.
OPTIONS
-h, --help show CLI helpops secrets:delete
Delete a secret stored for the active team
USAGE
$ ops secrets:delete
OPTIONS
-h, --help show CLI help
-k, --key=key Secret Key Nameops secrets:list
List all the keys that are stored for the active team
USAGE
$ ops secrets:list
OPTIONS
-h, --help show CLI helpops secrets:register
Register a secrets provider for a team
USAGE
$ ops secrets:registerops secrets:set
Add a key & value
USAGE
$ ops secrets:set
OPTIONS
-f, --from-file=from-file path to a file containing the value of the secret to set
-k, --key=key the key of the secret to set
-v, --value=value the value of the secret to setops secrets:unregister
Unregister a secrets provider for a team
USAGE
$ ops secrets:unregisterops start [NAMEORPATH]
Start a service, pipeline or command on our cloud.
USAGE
$ ops start [NAMEORPATH]
ARGUMENTS
NAMEORPATH Name or path of the workflow you want to run.
OPTIONS
-h, --help show CLI helpops status
See the status of currently running cloud services
USAGE
$ ops status
OPTIONS
-h, --help show CLI helpops stop [RUNID]
Stop a service, pipeline or command running in The Ops Cloud
USAGE
$ ops stop [RUNID]
ARGUMENTS
RUNID Run ID of the service, pipeline or command to stop
OPTIONS
-h, --help show CLI helpops team:create
Create your team.
USAGE
$ ops team:create
OPTIONS
-h, --help show CLI help
-n, --name=nameops team:info
Shows basic team information for the team you are currently on.
USAGE
$ ops team:info
OPTIONS
-h, --help show CLI helpops team:invite
Invite your team members.
USAGE
$ ops team:invite
OPTIONS
-h, --help show CLI help
-i, --invitees=invitees A comma-separated string of usernames/emails we want to invite. E.g. ("user1,
user2@gmail.com, user3@something")ops team:join
Accept an invite to join a team.
USAGE
$ ops team:joinops team:leave
Leave current team.
USAGE
$ ops team:leave
OPTIONS
-h, --help show CLI helpops team:list
Shows the list of your teams.
USAGE
$ ops team:list
OPTIONS
-h, --help show CLI helpops team:remove [MEMBER]
Remove your team members.
USAGE
$ ops team:remove [MEMBER]
ARGUMENTS
MEMBER The username of the team member you want to remove from the team.
OPTIONS
-h, --help show CLI helpops team:switch [TEAMNAME]
Switch your currently active team.
USAGE
$ ops team:switch [TEAMNAME]
ARGUMENTS
TEAMNAME Team Name
OPTIONS
-h, --help show CLI helpops update
Update The Ops CLI.
USAGE
$ ops update
OPTIONS
-h, --help show CLI helpops whoami
Display your user information
USAGE
$ ops whoami
OPTIONS
-h, --help show CLI helpOClif Source Repo
Useful reference for writing tests:
- https://github.com/oclif/command/blob/master/src/command.ts
- https://github.com/oclif/config/blob/master/src/plugin.ts
Testing
Isolate tests (run only specific tests in that file):
test.only('it should run only tests suffixed with .only', async () => {Unit Tests (test directory)
How to run Unit Tests
npm testornpm t
Tips
Run a single unit test, or filter them by filename:
npx jest --testPathPattern=keycloakE2E Tests (test_e2e directory)
The CLI has a number of robused E2E tests that are hosted inside of CTO.ai's private CI/CD infra.
We 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.
How to run E2E tests locally
The 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.
Run tests against staging (as part of the CTO.ai platform developer workflow):
- Run
npm run configdevto point the ops binary at the development Typescript app (instead of the production Javascript bundle) - Ensure you have a
.env.stagingfile (you can generate one by running scripts/make-env.sh) - Set your
NODE_ENVto 'staging':export NODE_ENV=staging npm run test:e2e
Run tests against Minikube (as part of the CTO.ai platform developer workflow):
- Create a user in Keycloak with the following credentials:
- username: 'existing_user'
- email: 'e2e_existing_user1@cto.ai'
- password: 'password'- Change the userID in
test_e2e/utils/constants.ts EXISTING_USER_IDto Step 1's userID - Create
existing_userteam in Database if haven't already - Change the teamID in
teste2e/utils/constants.ts EXISTING_TEAM_IDto step 3's teamID - Create a
cto.aiteam in Database if haven't already - Publish this following command:
- Team: ‘cto.ai’
- name: ‘github’
- version: ‘latest’
- public: true- Publish the
write_a_file_opcommand found intest_e2e/sample_ops/write_a_file_op - Publish the
echo_message_workflowworkflow found intest_e2e/sample_ops/echo_message_workflow - Add the
ops-cli-confidentialclient to Keycloak. Theops-cli-confidential.jsonfile can be found in Keybase - Run
npm run configdevto point the ops binary at the development Typescript app (instead of the production Javascript bundle) - Ensure you have a
.env.testfile (you can generate one by running scripts/make-env.sh) - Modify the vars in
.env.testto match your minikube IP - Set your
NODE_ENVto 'test':export NODE_ENV=test npm run test:e2e
Tips 1
Run a single E2E test, or filter test files by filename:
npm run test:e2e --testPathPattern=signinReleases
This CLI application is distributed via public Node Package Manager registry. Any non-trivial changes should be tested by first releasing to the Release Candidate package https://www.npmjs.com/package/@cto.ai/ops-rc before releasing to the official https://www.npmjs.com/package/@cto.ai/ops
Release Candidate Checklist
- Switch to the branch containing the changes to be released (it should not yet be merged to
master) - Ensure the code passes all tests by running
npm run test - Edit
package.jsonand updatenameto@cto.ai/ops-rcandversionto the next successive version (e.g. if the current publishedopsversion is1.20.3, the next rc version should be set to1.20.4-rc.0,1.20.4-rc.1, etc for each successive release candidate publish targeting the next official version to be eventually released toops) - Run
npm ito integrate above changes intopackage-lock.json - Log in to NPM (
npm login) with your NPM credentials. Make sure your user is part of theops-rcteam. If not, your user can be added by logging in with thecto.ai-adminaccount (credentials in LastPass) - Publish the package to
@cto.ai/ops-rcby runningnpm publish - Confirm the updated version appears on https://www.npmjs.com/package/@cto.ai/ops-rc
- You can now test the published package by installing it:
npm i -g @cto.ai/ops-rc(it is recommended you first remove existingopsby running:
npm uninstall -g @cto.ai/opsrm -rf $(which ops)
- Note that there will be a message stating that an update is available because the CLI code internally checks against the published version of
ops(notops-rc) - Point the installed binary CLI to STAGING by sourcing the
.env.stagingfile as follows:
source .env.stagingexport $(cut -d= -f1 .env.staging)- Running
ops account:signinshould now sign you into staging
- Once all code changes have been tested and confirmed to work on staging, you can switch the CLI to point to PRODUCTION by running:
unset $(cut -d= -f1 .env.staging)- Running
ops account:signinshould sign you into production
- Once all code changes have been tested and confirmed to work in production, the package may be deployed to the
opspackage (see next section).
Release Production Checklist
Releases are now handled by .gitlab/workflows/release.yml, which is triggered via a pushed tag that matches v*. This workflow will run npm publish and publish the current semantic version in the package.json. To simplify things, we've added the tag push command as a post hook to the npm version script. Steps to trigger a successful release:
1. Ensure that name in package.json has been set to ops
2. Run npm version v{package_version}
(this will version package.json and update README.md to reflect that version and then create and push the tag to GitHub)
2 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago