airplane

package module
v0.1.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 31, 2022 License: MIT Imports: 13 Imported by: 0

README

Airplane Go SDK Docs License CI status

Go SDK for writing Airplane.dev tasks.

Getting started

go get github.com/airplanedev/go-sdk

Usage

package main

import (
  "context"
  "fmt"

  airplane "github.com/airplanedev/go-sdk"
)

func main() {
  airplane.Run(func(ctx context.Context) error {
    var parameters struct {
      Name string `json:"name"`
    }
    if err := airplane.Parameters(&parameters); err != nil {
      return err
    }

    msg := fmt.Sprintf("Hello, %s!\n", parameters.Name)
    airplane.MustOutput(msg)

    return nil
  })
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendOutput added in v0.1.0

func AppendOutput(value interface{}, path ...interface{}) error

AppendOutput appends to the Airplane task output, writing it to stdout. Optionally can be provided a JSON path to only append to part of the output. Outputs are separated from your logs and are used to provide structured context to end-users of your task.

A JSON path should consist of multiple strings and/or integers. A string indicates the value associated with a key in a JSON object, and an integer indicates the index of an element in a (0-indexed) JSON array. For instance calling

AppendOutput(4, "test", 3)

would append a 4 to the array containing a 3 in the following JSON object:

{"test": [[0], [1], [2], [3]]}

Docs: https://docs.airplane.dev/reference/outputs

func MustAppendOutput added in v0.1.0

func MustAppendOutput(value interface{}, path ...interface{})

MustAppendOutput appends to the Airplane task output, writing it to stdout. Optionally can be provided a JSON path to only append to part of the output. Outputs are separated from your logs and are used to provide structured context to end-users of your task.

A JSON path should consist of multiple strings and/or integers. A string indicates the value associated with a key in a JSON object, and an integer indicates the index of an element in a (0-indexed) JSON array. For instance calling

MustAppendOutput(4, "test", 3)

would append a 4 to the array containing a 3 in the following JSON object:

{"test": [[0], [1], [2], [3]]}

If an error is produced, MustAppendOutput will panic.

Docs: https://docs.airplane.dev/reference/outputs

func MustNamedOutput deprecated

func MustNamedOutput(name string, value interface{})

MustNamedOutput writes `value` to stdout as an Airplane output. Outputs are separated from your logs and used to provide context structured context to end-users of your task. Unlike Output, NamedOutput accepts a `name` which will be used to group separate streams of outputs together.

If an error is produced, MustNamedOutput will panic.

Deprecated: Please use MustSetOutput or MustAppendOutput instead.

Docs: https://docs.airplane.dev/reference/outputs

func MustOutput deprecated

func MustOutput(value interface{})

MustOutput writes `value` to stdout as an Airplane output. Outputs are separated from your logs and used to provide context structured context to end-users of your task.

If an error is produced, MustOutput will panic.

Deprecated: Please use MustSetOutput or MustAppendOutput instead.

Docs: https://docs.airplane.dev/reference/outputs

func MustSetOutput added in v0.1.0

func MustSetOutput(value interface{}, path ...interface{})

MustSetOutput sets the Airplane task output, writing it to stdout. Optionally can be provided a JSON path to only set a part of the output. Outputs are separated from your logs and are used to provide structured context to end-users of your task.

A JSON path should consist of multiple strings and/or integers. A string indicates the value associated with a key in a JSON object, and an integer indicates the index of an element in a (0-indexed) JSON array. For instance calling

MustSetOutput(4, "test", 3)

would update the 3 to a 4 in the following JSON object:

{"test": [0, 1, 2, 3]}

If an error is produced, MustSetOutput will panic.

Docs: https://docs.airplane.dev/reference/outputs

func NamedOutput deprecated

func NamedOutput(name string, value interface{}) error

NamedOutput writes `value` to stdout as an Airplane output. Outputs are separated from your logs and used to provide context structured context to end-users of your task. Unlike Output, NamedOutput accepts a `name` which will be used to group separate streams of outputs together.

Deprecated: Please use SetOutput or AppendOutput instead.

Docs: https://docs.airplane.dev/reference/outputs

func Output deprecated

func Output(value interface{}) error

Output writes `value` as an Airplane output to stdout. Outputs are separated from your logs and used to provide context structured context to end-users of your task.

Deprecated: Please use SetOutput or AppendOutput instead.

Docs: https://docs.airplane.dev/reference/outputs

func Parameters

func Parameters(parameters interface{}) error

Parameters parses the CLI arguments provided to the task and sets them into `parameters` by matching JSON struct tags to parameter slugs.

This expects that the first CLI argument to your task is a JSON document containing parameter slugs mapped to parameter values. This is done by setting the `arguments` field of the task to `{{.JSON}}`.

Docs: https://docs.airplane.dev/reference/parameters

func Run

func Run(f func(ctx context.Context) error)

Run provides your task with context-cancellation and error-handling. Any errors returned, or bubbled up via a panic, will be logged as Airplane outputs.

func SetOutput added in v0.1.0

func SetOutput(value interface{}, path ...interface{}) error

Docs: https://docs.airplane.dev/reference/outputs

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL