yadw

command module
v0.0.0-...-8192ee4 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2020 License: Unlicense Imports: 4 Imported by: 0

README

Yet Another Docker Workflow

WIP, bookmark this repo and come back later.

Example:
package main

import (
	"context"
	"log"

	"github.com/docker/docker/client"
	"github.com/yitsushi/yadw/workflow"
)

func main() {
	cli, err := client.NewEnvClient()
	if err != nil {
		log.Println(err)
	}

	wfl := workflow.NewWorkflow(cli)
	wfl.AddJob(&workflow.Job{
		Name:  "Check",
		Image: "alpine:latest",
		Commands: [][]string{
			{"touch", "/asdasd"},
			{"ls", "-la"},
		},
		Environment: []string{},
		StopOnError: true,
		Result:      nil,
	})
	wfl.AddJob(&workflow.Job{
		Name:  "Ping",
		Image: "alpine:latest",
		Commands: [][]string{
			{"ping", "-c", "3", "github.com"},
		},
		Environment: []string{},
		StopOnError: true,
		Result:      nil,
	})

	wfl.Execute(context.Background())

	for _, job := range wfl.Jobs {
		if job.Result.Error != nil {
			log.Printf("Job level error on %s: %s", job.Name, job.Result.Error.Error())
		}

		for _, command := range job.Result.Commands {
			if command.Error != nil {
				log.Printf("Command level error on %s: %s", command.Command, command.Error.Error())
			}

			log.Printf("Stdout:\n%s", command.StdOut.String())
		}
	}
}

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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