exec

package
v0.11.36 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2021 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func HookCommand

func HookCommand(eventType hook.EventType, name string, arg ...string) func(*Hook)

HookCommand sets a new command that will be run on specified event type. Only one command can be configured for each event type.

func NewHook

func NewHook(commands ...func(*Hook)) hook.Hook

NewHook creates new exec hook with specified commands.

Example
package main

import (
	"log"
	"os"

	"github.com/allegro/mesos-executor/hook"
	"github.com/allegro/mesos-executor/hook/exec"
)

func main() {
	os.Setenv("TEST", "test")
	defer os.Unsetenv("TEST")

	h := exec.NewHook(exec.HookCommand(hook.AfterTaskHealthyEvent, "sh", "-c", "echo $TEST"))
	if _, err := h.HandleEvent(hook.Event{Type: hook.AfterTaskHealthyEvent}); err != nil {
		log.Fatal(err)
	}

}
Output:

test

Types

type Hook

type Hook struct {
	// contains filtered or unexported fields
}

Hook is an executor hook implementation that will call defined external commands on specified hook events.

func (*Hook) HandleEvent

func (h *Hook) HandleEvent(event hook.Event) (hook.Env, error)

HandleEvent calls configured external command (if it is specified) for given hook event.

Jump to

Keyboard shortcuts

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