| sidebar | auto |
|---|
This document is aimed at those who whish to develop integrations that run in dashboards. An integration is a Docker image that runs as a container on a cluster when added to a dashboard. VisualBox enables developers to define their own Dockerfile, which makes it possible to write integration code in virtually any environment and programming language.
When you create a new integration you have the option to choose from a set of pre-defined environment templates. These templates provide a starting point for a Dockerfile and example code that shows how to communicate with the VisualBox service.
Each template makes use of the VisualBox Utility Docker Layer, which is a set of modules/bindings for different programming languages to enable seamless communication with the VisualBox service.
The Utility Docker Layer also contains a boot binary, which acts as a middleware between the integration process and VisualBox. This allows the container to read the standard output/error stream of the integration process and handle socket connections. Arguments supplied to the boot binary are executed as the integration process.
E.g. if you want to start your integration by running node index.js:
# Include Utility Docker Layer
FROM visualboxio/utils:latest as utils
# Integration image
FROM node:12-alpine
# Copy `boot` binary from Utility Docker Layer
COPY --from=utils /boot /visualbox/boot
# Run `node index.js` through the `boot` binary
ENTRYPOINT /visualbox/boot node index.js::: danger You must use the boot binary as the ENTRYPOINT in the Docker image, or the container will immediately terminate. :::
The entrypoint for the Node environment is an index.js file in the root folder. A package.json file can be used to automatically install additional required dependencies.
You must import the globally accessible visualbox module to access the configuration model as well as send data back to a VisualBox dashboard:
const visualbox = require('visualbox')The configuration model is accessible through the visualbox.MODEL variable:
// visualbox.MODEL.<name>
const myVariable = visualbox.MODEL.myVariable
// or: const { myVariable } = visualbox.MODELTo send data back to a VisualBox dashboard, use the visualbox.output() method:
visualbox.output({ myVariable })
// or: visualbox.output('a string')The visualbox.output() method will try to parse a JavaScript object into a JSON string.
The entrypoint for the Python 3 environment is a main.py file in the root folder. A requirements.txt file can be used to automatically install additional required dependencies.
You must import the globally accessible visualbox module to access the configuration model as well as send data back to a VisualBox dashboard:
import visualboxThe configuration model is accessible through the visualbox.MODEL dictionary:
# visualbox.MODEL["<name>"]
myVariable = visualbox.MODEL["myVariable"]To send data back to a VisualBox dashboard, use the visualbox.output() method:
visualbox.output(myVariable)
# or: visualbox.output("a string")The visualbox.output() method will try to parse a Python dictionary into a JSON string.
The entrypoint for the Go environment is a main.go file in the root folder. A glide.yaml file can be used to automatically install additional required dependencies.
You must import the globally accessible visualbox package to access the configuration model as well as send data back to a VisualBox dashboard:
import "visualbox"The configuration model is accessible through the visualbox.MODEL interface:
// visualbox.MODEL[<name>]
myVariable = visualbox.MODEL["myVariable"]To send data back to a VisualBox dashboard, use the visualbox.Output() method (with a capital "O"):
visualbox.Output(myVariable)
// or: visualbox.Output("a string")The visualbox.Output() method will try to parse a Go map into a JSON string.