Skip to content
This repository has been archived by the owner on Aug 13, 2024. It is now read-only.

feat: add detailed view and show logs #18

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 16 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
273 changes: 97 additions & 176 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ That's it!
## Features

| Feature | Status |
|------------------|---------------------|
| ---------------- | ------------------- |
| Self Service | WIP |
| Catalog Services | WIP |
| Auth | Not implemented yet |
Expand All @@ -34,19 +34,22 @@ That's it!

### Installation

#### Using Docker

Today you can run Torii using Docker Compose. In the future, we will provide a Helm chart to deploy Torii on Kubernetes.

It starts full environment with postgres instance.

```bash
docker-compose up
```

If you want to run it locally you will need to start Postgres DB, the backend and the frontend separately.

```bash
# Start Postgres
docker-compose -f docker-compose-dev.yaml up
# Alternatively, you can use tilt
# https://tilt.dev
tilt up
```

#### Locally

```bash
# Start the backend
cd backend
Expand Down Expand Up @@ -135,16 +138,16 @@ self_service:
- my-scripts/environment_management.py
- create
- --name
- {{name}} # this is a variable that will be replaced by the value of the field 'name'
- {{ name }} # this is a variable that will be replaced by the value of the field 'name'
delayed_command:
- command:
- python
- my-scripts/environment_management.py
- delete
- --name
- {{name}}
- {{ name }}
delay:
hours: {{ttl}} # this is a variable that will be replaced by the value of the field 'ttl'
hours: {{ ttl }} # this is a variable that will be replaced by the value of the field 'ttl'
```

In this example, we define a self-service section with a single action called `new-testing-environment`. This action has four fields:
Expand All @@ -158,171 +161,89 @@ When the developer fills the form and submits it, Torii will run the `post_valid
If the script exits with a non-zero exit code, the action will fail.
If the script exits with a zero exit code, Torii will run the `delayed_command` script after the specified delay.

[//]: # (### Advanced Configuration)

[//]: # ()

[//]: # (#### Autocomplete Fetcher)

[//]: # ()

[//]: # (An autocomplete fetcher is a script that must print a JSON on standard output. The JSON must contain a `results` key that contains a list of)

[//]: # (values.)

[//]: # ()

[//]: # (```json)

[//]: # ({)

[//]: # ( "results": [)

[//]: # ( "val 1",)

[//]: # ( "val 2",)

[//]: # ( "val 3")

[//]: # ( ])

[//]: # (})

[//]: # (```)

[//]: # ()

[//]: # (Example of autocomplete fetcher in python:)

[//]: # ()

[//]: # (```python)

[//]: # (import json)

[//]: # ()

[//]: # ()

[//]: # (def get_data_from_fake_api():)

[//]: # ( return [)

[//]: # ( 'val 1',)

[//]: # ( 'val 2',)

[//]: # ( 'val 3',)

[//]: # ( ])

[//]: # ()

[//]: # ()

[//]: # (if __name__ == '__main__':)

[//]: # ( # do your stuff here)

[//]: # ( results = get_data_from_fake_api())

[//]: # ()

[//]: # ( data = {'results': results})

[//]: # ()

[//]: # ( # print json on standard output)

[//]: # ( print(json.dumps(data)))

[//]: # (```)

[//]: # ()

[//]: # (#### Validation Script)

[//]: # ()

[//]: # (A validation script can be any kind of script. It can be a bash script, a python script, a terraform script, etc. The script must exit with)

[//]: # (a non-zero exit code if the validation fails.)

[//]: # ()

[//]: # (```bash)

[//]: # (#!/bin/bash)

[//]: # ()

[//]: # (set -e # exit on error)

[//]: # (# print error on standard error output)

[//]: # ()

[//]: # (# do your stuff here)

[//]: # (exit 0)

[//]: # (```)

[//]: # ()

[//]: # (#### Post Validation Script)

[//]: # ()

[//]: # (An post validation script can be any kind of script. It can be a bash script, a python script, a terraform script, etc.)

[//]: # ()

[//]: # (- The script must exit with a non-zero exit code if the validation fails.)

[//]: # (- The script must be idempotent. It can be executed multiple times without side effects.)

[//]: # (- The output of the script must be a JSON that contains the defined model keys with their values. (Torii will update the model with)

[//]: # ( the values returned by the script))

[//]: # ()

[//]: # (```json)

[//]: # ({)

[//]: # ( "status": "success",)

[//]: # ( "url": "https://my-service.com",)

[//]: # ( "username": "my-username",)

[//]: # ( "password": "my-password")

[//]: # (})

[//]: # (```)

[//]: # ()

[//]: # (```bash)

[//]: # (#!/bin/bash)

[//]: # ()

[//]: # (set -e # exit on error)

[//]: # (# print error on standard error output)

[//]: # ()

[//]: # (# do your stuff here)

[//]: # (exit 0)

[//]: # (```)
[//]: # "### Advanced Configuration"
[//]: #
[//]: # "#### Autocomplete Fetcher"
[//]: #
[//]: # "An autocomplete fetcher is a script that must print a JSON on standard output. The JSON must contain a `results` key that contains a list of"
[//]: # "values."
[//]: #
[//]: # "```json"
[//]: # "{"
[//]: # ' "results": ['
[//]: # ' "val 1",'
[//]: # ' "val 2",'
[//]: # ' "val 3"'
[//]: # " ]"
[//]: # "}"
[//]: # "```"
[//]: #
[//]: # "Example of autocomplete fetcher in python:"
[//]: #
[//]: # "```python"
[//]: # "import json"
[//]: #
[//]: #
[//]: # "def get_data_from_fake_api():"
[//]: # " return ["
[//]: # " 'val 1',"
[//]: # " 'val 2',"
[//]: # " 'val 3',"
[//]: # " ]"
[//]: #
[//]: #
[//]: # "if __name__ == '__main__':"
[//]: # " # do your stuff here"
[//]: # " results = get_data_from_fake_api()"
[//]: #
[//]: # " data = {'results': results}"
[//]: #
[//]: # " # print json on standard output"
[//]: # " print(json.dumps(data))"
[//]: # "```"
[//]: #
[//]: # "#### Validation Script"
[//]: #
[//]: # "A validation script can be any kind of script. It can be a bash script, a python script, a terraform script, etc. The script must exit with"
[//]: # "a non-zero exit code if the validation fails."
[//]: #
[//]: # "```bash"
[//]: # "#!/bin/bash"
[//]: #
[//]: # "set -e # exit on error"
[//]: # "# print error on standard error output"
[//]: #
[//]: # "# do your stuff here"
[//]: # "exit 0"
[//]: # "```"
[//]: #
[//]: # "#### Post Validation Script"
[//]: #
[//]: # "An post validation script can be any kind of script. It can be a bash script, a python script, a terraform script, etc."
[//]: #
[//]: # "- The script must exit with a non-zero exit code if the validation fails."
[//]: # "- The script must be idempotent. It can be executed multiple times without side effects."
[//]: # "- The output of the script must be a JSON that contains the defined model keys with their values. (Torii will update the model with"
[//]: # " the values returned by the script)"
[//]: #
[//]: # "```json"
[//]: # "{"
[//]: # ' "status": "success",'
[//]: # ' "url": "https://my-service.com",'
[//]: # ' "username": "my-username",'
[//]: # ' "password": "my-password"'
[//]: # "}"
[//]: # "```"
[//]: #
[//]: # "```bash"
[//]: # "#!/bin/bash"
[//]: #
[//]: # "set -e # exit on error"
[//]: # "# print error on standard error output"
[//]: #
[//]: # "# do your stuff here"
[//]: # "exit 0"
[//]: # "```"

## Design

Expand All @@ -347,7 +268,7 @@ Today you have the choice between three options to build your Internal Developer
Torii is a simple, powerful, and extensible open-source Internal Developer Portal that aims to be the best of all worlds. It's easy to
extend and customize, it's free, and you have control over the codebase.

---
---

Curious to understand in more detail the motivation behind Torii? Read these articles:

Expand Down
1 change: 1 addition & 0 deletions Tiltfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
docker_compose("docker-compose.yaml")
2 changes: 1 addition & 1 deletion backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM rust:1.77.2-bookworm as builder
FROM rust:1.79-bookworm as builder

WORKDIR /app

Expand Down
10 changes: 10 additions & 0 deletions backend/Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM rust:1.79-bookworm

WORKDIR /app

RUN apt update && \
apt install -y libssl-dev python3 nodejs && \
ln -s /usr/bin/python3 /usr/bin/python & \
cargo install cargo-watch

COPY . .
12 changes: 12 additions & 0 deletions backend/examples/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,18 @@ self_service:
- bash
- examples/dumb_script_ok.sh # AND then this one
output_model: string (optional) # model name
- slug: get-temperature-paris
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a POC with Node.js

name: Get current temperature in Paris
description: Script to detect and return the current tempearture in celsius in Paris
icon: sun
icon_color: rose
fields: []
post_validate:
- command:
- node
- examples/node_get_weather_paris.js
timeout: 5

models:
- name: string
description: string (optional)
Expand Down
12 changes: 12 additions & 0 deletions backend/examples/node_get_weather_paris.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
console.log('Executing script node get weather Paris');

for(let i = 0; i < 20; i++) {
console.error(`Log error ${i}`);
}

fetch('https://wttr.in/Paris?format=j1')
.then(res => res.json())
.then(data => {
console.log(`Currently it's ${data.current_condition.at(0).temp_C}Β°C in Paris.`);
console.log('Finished!');
});
1 change: 1 addition & 0 deletions backend/src/app_config.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 0 additions & 1 deletion backend/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@ pub struct CLI {
/// Torii configuration file
#[clap(short, long, value_name = "configuration file")]
pub config: PathBuf,

}
Loading
Loading