Templates
Define and share common Tasks with your team.
#
IntroductionTemplates are pre-defined Tasks stored in a Git repository. These special Tasks have variables defined in their scripts.
When creating a Task using a Template, you have to provide only the variables. A regular Task will be created using the Template script filled with the parameters you provide.
You can run a Task from Slack providing the parameters to the Runops bot, get reviews, and get result logs; all without touching a single line of code or command-line. But you can also use the Runops CLI.
#
Create a TemplateLet's create a Template for querying DynamoDB.
We will create a Template using Python with AWS's boto3 library. After creating the script, we commit it to the main
branch of the Runops Templates repository.
pro-tip
Open the Templates repository for everyone at your company to contribute with scripts they already have.
Here is our template, lets save it to a file and commit it to the main
branch of a Github repository.
This template has 5 parameters which are indicated by double curly braces:
{{pk}}
- the name of the Partition Key
{{pk_value}}
- the value of the Partition Key
{{sk}}
- the name of the Sort Key
{{sk_value}}
- the value of the Sort Key
{{table}}
- the name of the DynamoDB table
#
Connect Runops to GithubTo connect Runops to your Templates repository, add the Github user runopsbot
as a read-only collaborator to the repository.
You will soon be able to connect using OAuth from the Runops web app.
#
Check available templatesNow we can see the template available. Listing the Templates will read all the files in the main
branch of the Github repository:
To verify specific details about a template, like its params:
#
Use a TemplateCreate a Task from the Template
#
Use Templates in SlackTo run templates from Slack, run /runops templates
anywhere in your Slack workspace:
#
WorkflowA powerful workflow for Templates is having a central Git repository with scripts certified by stakeholders of a Target.
Engineers from multiple teams could submit Pull Requests to this repository. After testing, the Template gets merged into the main
branch and becomes available to everyone to everyone in the company.
#
Ignoring filesA .runopsignore
file specifies intentionally untracked files that runops should ignore when listing templates.
#
Pattern Format- A blank line matches no files
- A line starting with
#
serves as a comment - Trailing spaces are ignored
- The slash / is used as the directory separator
- Using the slash / in the beginning, has a special meaning to indicate matching files in the root of the folder.
- An asterisk
*
matches anything
#
Examples- The pattern
hello.*
matches any file or directory whose name begins with hello. If one wants to restrict this only to the directory and not in its subdirectories, one can prepend the pattern with a slash, i.e./hello.*
; the pattern now matcheshello.txt
,hello.c
but nota/hello.java
. - The pattern
doc/frotz
and/doc/frotz
have the same effect in any .runopsignore file. In other words, a leading slash is not relevant if there is already a middle slash in the pattern. - The pattern
foo/*
, matchesfoo/test.json
(a regular file),foo/bar
(a directory), and all contents in the subdirectories also, likefoo/bar/test.sql
.
#
Parameters ValidationWe have a way to create validations for each parameter and this will provide security for your template at the form level. Each parameter could receive any validations following these specifications:
pro-tip
We are using parts of the same types and atributes from the HTML element input, you can find more informations here.
#
Creating the file for validationThese validations are stored in a JSON file with the same name of their template file and with the .config extension instead.
For other-template.sql
Use other-template.config
You can use as example this file: