Creating a "Hello, torero" Service

Every good software project has a "hello world" example. So torero is no different. We will walk through a typical workflow of creating a service and explain all the steps along the way. We will be using a python service to perform the example. This example is not for production but to get a feel on how to use the application.

All the code that we write and that we want to be executed with torero must be placed somewhere. Git allows operators to easily share, revision and collaboratively work on different services.

torero requires a git repository to obtain the script to be used in a service. In this example we will use:

https://github.com/torerodev/example-scripts

It is important that you use a real git repository for this to work.

To create the repository in torero, we will use the torero create repository command.

>_ torero create repository example-scripts-repo --description "Simple repository for quick start" --url https://github.com/torerodev/example-scripts.git --reference main

torero should return results that show that a repository has been created.

Output:

Successfully created the repository

Name:             example-scripts-repo
Description:      Simple repository for quick start
Url:              https://github.com/torerodev/example-scripts.git
Reference:        main
Tags:             
Private Key Name:

(Optional) Verify that the repository has been created

>_ torero get repositories
Output:

NAME                   DESCRIPTION                         URL                                                REFERENCE   TAGS    PRIVATE KEY NAME
example-scripts-repo   Simple repository for quick start   https://github.com/torerodev/example-scripts.git   main                 
>_ torero describe repository example-scripts-repo
Output:

Name:             example-scripts-repo
Description:      Simple repository for quick start
Url:              https://github.com/torerodev/example-scripts.git
Reference:        main
Tags:
Private Key Name:

For more information on repositories, see the repository command line documents

Create a Service

Once torero knows where the repository is that stores the automation scripts, a service can be created. First create the service and give the service the name of the repository and filename (if applicable) for the automation. Since we will be creating a python script we should write our script which we will call hello-torero.py. We can reference python service to understand more about the service.

Creating The Service

>_ torero create service python-script hello-torero --repository example-scripts-repo --filename hello-torero.py  --description "Quick Start Example" 
Output:

Successfully created the Python script

Name:        hello-torero
Repo Name:   example-scripts-repo
Working Dir:
File Name:   hello-torero.py
Decorator:
Description: Quick Start Example
Tags:

Run a Service

Now that torero has a registered service to run, any user with proper access rights may now run the service. It is important to pass inputs through the service you will need to use the --set command that takes in a key=value syntax. In our example we are passing the key and value of name and world to the python script.

>_ torero run python-script hello-torero
Output:

Start Time:   2024-01-01T12:00:00Z
End Time:     2024-01-01T12:00:01Z
Elapsed Time: 1.372672s
Return Code:  0
Stdout:
Hello, torero!
...

Stderr:

That's it!