actions

package module
v1.5.5 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2021 License: MIT Imports: 19 Imported by: 3

README

simple-actions

This is based somewhat on https://github.com/kubernetes-sigs/kind/tree/93abedaa23f6d4639e0c1b83fc0eb7cacbf357e4/pkg/cluster/internal/create/actions though it is intended to be a little more flexible

  • Supports a Dry Run flag for all actions

Included actions

  • docker actions allow you to interact with docker in your actions without needing to call the docker cli directly
  • kubectl actions wrap kubectl call in an action interface

Documentation

Overview

Package actions contains the high level workflow actions

Index

Constants

This section is empty.

Variables

View Source
var AzureENVPrefix = "AZURE"

AzureENVPrefix docs nolint:gochecknoglobals

Functions

func DirExists

func DirExists(filename string) bool

DirExists returns true if the path exists and is a directory.

func FileExists

func FileExists(filename string) bool

FileExists returns true if the file exists and is not a directory.

func FormatDuration

func FormatDuration(duration time.Duration) string

FormatDuration format duration string.

Types

type Action

type Action interface {
	Execute(ctx ActionContext) error
}

Action documentation.

func NewArchivePathAction added in v1.5.0

func NewArchivePathAction(name string, files ...string) Action

NewArchivePathAction documentation.

func NewCLIAction added in v1.5.0

func NewCLIAction(msg, cmd string, args ...string) Action

NewCLIAction run a cli command as an action.

func NewCopyFileAction added in v1.2.0

func NewCopyFileAction(from, to string) Action

NewCopyFileAction documentation.

func NewCopyPathAction added in v1.5.0

func NewCopyPathAction(from, to string) Action

NewCopyPathAction documentation.

func NewCreateDirectoryAction

func NewCreateDirectoryAction(path string) Action

NewCreateDirectoryAction documentation.

func NewDeletePathAction added in v1.5.0

func NewDeletePathAction(path string) Action

NewDeletePathAction documentation.

func NewErrorAction

func NewErrorAction(err error, msg string) Action

NewErrorAction docs.

func NewFetchFileAction added in v1.5.0

func NewFetchFileAction(filePath, path string) Action

NewFetchFileAction will download a path to a local file. It's efficient because it will write as it downloads and not load the whole file into memory. accepted scheme are http/https and azure the azure schema is a special format `azure://<azure storage account>/<azure container name>/<azure path to blob> eg azure://example/my-container/some/file/path the http equivalent would be https://example.blob.core.windows.net/my-container/some/file/path

func NewFetchFileActionWithHTTPClient added in v1.5.0

func NewFetchFileActionWithHTTPClient(filePath, path string, client *http.Client) Action

NewFetchFileActionWithHTTPClient will download a path to a local file. It's efficient because it will write as it downloads and not load the whole file into memory. accepted scheme are http/https and azure the azure schema is a special format `azure://<azure storage account>/<azure container name>/<azure path to blob> eg azure://example/my-container/some/file/path the http equivalent would be https://example.blob.core.windows.net/my-container/some/file/path

func NewPrintAction

func NewPrintAction(msg string) Action

NewPrintAction documentation.

func NewRenamePathAction added in v1.5.0

func NewRenamePathAction(from, to string) Action

NewRenamePathAction documentation.

func NewSleepAction

func NewSleepAction(duration, msg string) Action

NewSleepAction docs.

func NewUnArchiveAction added in v1.5.0

func NewUnArchiveAction(name, path string) Action

NewUnArchiveAction documentation.

type ActionContext added in v1.0.1

type ActionContext interface {
	context.Context

	Logger() log.Logger
	Status() *term.Status
	IsDryRun() bool
	Data() interface{}

	// Builder functions
	WithCancel() (ActionContext, context.CancelFunc)
	WithDeadline(d time.Time) (ActionContext, context.CancelFunc)
	WithTimeout(timeout time.Duration) (ActionContext, context.CancelFunc)
	WithValue(key, val interface{}) ActionContext
}

ActionContext docs.

func NewDefaultActionContext added in v1.0.1

func NewDefaultActionContext(logger log.Logger, dryRun bool) ActionContext

NewDefaultActionContext generate a default action context with a nil return for Data().

type Actions

type Actions []Action

Actions list of action items.

func (Actions) Execute

func (a Actions) Execute(ctx ActionContext) (err error)

Execute executes all action items in the Actions list.

Directories

Path Synopsis
Package log same as https://github.com/kubernetes-sigs/kind/tree/master/pkg/log
Package log same as https://github.com/kubernetes-sigs/kind/tree/master/pkg/log
Package term same as https://github.com/kubernetes-sigs/kind/tree/master/pkg/internal/env
Package term same as https://github.com/kubernetes-sigs/kind/tree/master/pkg/internal/env

Jump to

Keyboard shortcuts

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