Coder Social home page Coder Social logo

flyte-shell's Introduction

flyte-shell

Build Status Docker Stars Docker Pulls

Overview

The Shell pack can run an arbitrary bash script. If you can run it in a bash terminal then it'll run on this pack. The pack has bash, curl, jq and openssh installed on its container. If you need something more, feel free to make a pull request.

Build & Run

Command Line

To build and run from the command line:

  • Clone this repo
  • Run dep ensure (must have dep installed )
  • Run go build
  • Run FLYTE_API_URL=http://.../ ./flyte-shell, FLYTE_API_URL environment variable is required
  • User can set labels (optional) using FLYTE_LABELS env. variable. Example: FLYTE_LABELS='env=dev,user=root'

Docker

To build and run in docker:

  • Run docker build -t flyte-shell .
  • Run docker run -e FLYTE_API_URL=http://.../ flyte-shell
  • The The FLYTE_API_URL environment variable needs to be set
  • Pack labels (optional) can be set using FLYTE_LABELS env. variable

Commands

shell Command

Input

This command's input is the script to be run:

"input" : "echo -e 'world\nhello' | sort"

The script needs to be a one line bash command. Distinct commands should be separated by ;. While newlines are perfectly fine in the shell, they do make for invalid JSON and no escape expansion is performed, so stick with single lines. The whole script argument is passed to exec.Command(). To test your command on the command line run it using this: bash -c '$script'. Single quotes are only required when running this command on the command line, do not put single quotes around your script in the flow.

Output Events

There is one type of output event, it contains the stdout, stderr and exit code.

For example, the script: "echo -e 'world\nhello' | sort" would return the output:

"payload": {
    "stdout": "hello\nworld",
    "stderr": "",
    "exit_code": 0
}

While echo oh ; >&2 echo dear results in:

"payload: {
    "stdout": "oh",
    "stderr": "dear",
    "exit_code": 0
}

Flows

An example flow, listening for a slack message and executing a command when one is received:

{
  "name": "slackShell",
  "description": "Run script when message received",
  "steps": [
      "event": {
        "name": "ReceivedMessage",
        "packName": "Slack"
      }, 
      "command": {
        "name": "Shell",
        "packName": "Shell",
        "input": "echo 'received an event from the Slack pack'"
      }
  ]
}

An example flow listening to shell output:

{
  "name": "shellOutput",
  "description": "Send message to slack when script has been run",
  "steps": [
      "event": {
        "name": "Output",
        "packName": "Shell"
      }, 
      "command": {
        "name": "SendMessage",
        "packName": "Slack",
        "input": {
          "channelId": "12345",
          "message": "Shell pack executed command. Output is: {{ Event.Payload.stdout }}"
        }
      }
  ]
}

flyte-shell's People

Contributors

dangorst1066 avatar dvdthms avatar fooksca avatar jollinshead avatar pamelin avatar ukjasonwright avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.