daisy

package module
v0.0.0-...-04ad9f0 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2022 License: Apache-2.0 Imports: 30 Imported by: 3

README

What is Daisy?

Daisy is a solution for running multi-step workflows on GCE.

GoDoc

The current Daisy stepset includes support for creating/deleting GCE resources, waiting for signals from GCE VMs, streaming GCE VM logs, uploading local files to GCE and GCE VMs, and more.

For example, Daisy is used to create Google Official Guest OS images. The workflow:

  1. Creates a Debian 8 disk and another empty disk.
  2. Creates and boots a VM with the two disks.
  3. Runs and waits for a script on the VM.
  4. Creates an image from the previously empty disk.
  5. Automatically cleans up the VM and disks.

Other use-case examples:

  • Workflows for importing external physical or virtual disks to GCE.
  • GCE environment deployment.
  • Ad hoc GCE testing environment deployment and test running.

Documentation

Daisy documentation can be found here.

Testing

Infrastructure has been set up to perform presubmit testing on PRs and periodic continuous integration tests against HEAD.

Presubmit checks unit tests, golint, go fmt, and go vet against PRs with changes to Daisy source code. Unit test coverage is reported to codecov.io, which posts coverage reports on the PR. Presubmit tests are gated by repo owners. Repo owners have the following commands available on a PR:

  • /go test: runs unit tests and reports coverage.
  • /golint: runs golint.
  • /go fmt: runs go fmt.
  • /go vet: runs go vet.
  • /ok-to-test: gives Prow the go-ahead to run the entire suite automatically.
  • /retest: reruns failed tests, only available after Prow reports failures.

Periodic tests run every 6 hours. Currently, periodic tests include the e2e tests here: ../test-infra/prow/config.yaml. You can see the test results for the e2e tests in testgrid: [https://k8s-testgrid.appspot.com/google-gce-compute-image-tools#ci-daisy-e2e].

Documentation

Overview

Package daisy describes a daisy workflow.

Index

Constants

This section is empty.

Variables

View Source
var SleepFn = time.Sleep

SleepFn function is mocked on testing.

Functions

func CombineGuestOSFeatures

func CombineGuestOSFeatures(features1 []*compute.GuestOsFeature,
	features2 ...string) []*compute.GuestOsFeature

CombineGuestOSFeatures merges two slices of Guest OS features and returns a new slice instance. Duplicates are removed.

func CombineGuestOSFeaturesBeta

func CombineGuestOSFeaturesBeta(features1 []*computeBeta.GuestOsFeature,
	features2 ...string) []*computeBeta.GuestOsFeature

CombineGuestOSFeaturesBeta merges two slices of Beta Guest OS features and returns a new slice instance. Duplicates are removed.

func JSONError

func JSONError(file string, data []byte, err error) error

JSONError turns an error from json.Unmarshal and returns a more user friendly error.

func NamedSubexp

func NamedSubexp(re *regexp.Regexp, s string) map[string]string

NamedSubexp extracts sub matches in the exp

func UpdateInstanceNoExternalIP

func UpdateInstanceNoExternalIP(step *Step)

UpdateInstanceNoExternalIP updates Create Instance step to operate when no external IP access is allowed by the VPC Daisy workflow is running in.

Types

type AttachDisk

type AttachDisk struct {
	compute.AttachedDisk

	// Instance to attach to.
	Instance string
	// contains filtered or unexported fields
}

AttachDisk is used to attach a GCE disk into an instance.

type AttachDisks

type AttachDisks []*AttachDisk

AttachDisks is a Daisy AttachDisks workflow step.

type CopyGCSObject

type CopyGCSObject struct {
	Source, Destination string
	ACLRules            []*storage.ACLRule `json:",omitempty"`
}

CopyGCSObject copies a GCS object from Source to Destination.

type CopyGCSObjects

type CopyGCSObjects []CopyGCSObject

CopyGCSObjects is a Daisy CopyGCSObject workflow step.

type CreateDisks

type CreateDisks []*Disk

CreateDisks is a Daisy CreateDisks workflow step.

type CreateFirewallRules

type CreateFirewallRules []*FirewallRule

CreateFirewallRules is a Daisy CreateFirewallRules workflow step.

type CreateForwardingRules

type CreateForwardingRules []*ForwardingRule

CreateForwardingRules is a Daisy CreateForwardingRules workflow step.

type CreateImages

type CreateImages struct {
	Images      []*Image
	ImagesAlpha []*ImageAlpha
	ImagesBeta  []*ImageBeta
}

CreateImages is a Daisy CreateImages workflow step.

func (*CreateImages) UnmarshalJSON

func (ci *CreateImages) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals Image.

type CreateInstances

type CreateInstances struct {
	Instances     []*Instance
	InstancesBeta []*InstanceBeta
}

CreateInstances is a Daisy CreateInstances workflow step.

func (*CreateInstances) UnmarshalJSON

func (ci *CreateInstances) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals Instance.

type CreateMachineImages

type CreateMachineImages []*MachineImage

CreateMachineImages is a Daisy workflow step for creating machine images.

type CreateNetworks

type CreateNetworks []*Network

CreateNetworks is a Daisy CreateNetwork workflow step.

type CreateSnapshots

type CreateSnapshots []*Snapshot

CreateSnapshots is a Daisy CreateSnapshots workflow step.

type CreateSubnetworks

type CreateSubnetworks []*Subnetwork

CreateSubnetworks is a Daisy CreateSubnetwork workflow step.

type CreateTargetInstances

type CreateTargetInstances []*TargetInstance

CreateTargetInstances is a Daisy CreateTargetInstances workflow step.

type DError

type DError interface {
	error

	AnonymizedErrs() []string
	CausedByErrType(t string) bool
	// contains filtered or unexported methods
}

DError is a Daisy external error type. It has: - optional error typing - multiple error aggregation - safe error messages in which privacy information is removed

Default implementation: The default DError implementation is flat, DError.add(anotherDErr) will merge the two dErrs into a single, flat DError instead of making anotherDErr a child to DError.

func Errf

func Errf(format string, a ...interface{}) DError

Errf returns a DError by constructing error message with given format.

func ToDError

func ToDError(e error) DError

ToDError returns a DError. ToDError is used to wrap another error as a DError. If e is already a DError, e is copied and returned. If e is a normal error, error message is reused as format. If e is nil, nil is returned.

type DeleteResources

type DeleteResources struct {
	Disks         []string `json:",omitempty"`
	Images        []string `json:",omitempty"`
	MachineImages []string `json:",omitempty"`
	Instances     []string `json:",omitempty"`
	Networks      []string `json:",omitempty"`
	Subnetworks   []string `json:",omitempty"`
	GCSPaths      []string `json:",omitempty"`
	Firewalls     []string `json:",omitempty"`
}

DeleteResources deletes GCE/GCS resources.

type DeprecateImage

type DeprecateImage struct {
	// Image to set deprecation status on.
	Image string
	// DeprecationStatus to set for image.
	DeprecationStatus compute.DeprecationStatus
	// DeprecationStatus to set for image.
	DeprecationStatusAlpha computeAlpha.DeprecationStatus
	// Project image is in, overrides workflow Project.
	Project string `json:",omitempty"`
}

DeprecateImage sets the deprecation status on a GCE image.

type DeprecateImages

type DeprecateImages []*DeprecateImage

DeprecateImages is a Daisy DeprecateImage workflow step.

type DetachDisk

type DetachDisk struct {
	// Instance to detach diskName.
	Instance   string
	DeviceName string
	// contains filtered or unexported fields
}

DetachDisk is used to detach a GCE disk from an instance.

type DetachDisks

type DetachDisks []*DetachDisk

DetachDisks is a Daisy DetachDisks workflow step.

type Disk

type Disk struct {
	compute.Disk
	Resource

	// Size of this disk.
	SizeGb string `json:"sizeGb,omitempty"`
}

Disk is used to create a GCE disk in a project.

func (*Disk) MarshalJSON

func (d *Disk) MarshalJSON() ([]byte, error)

MarshalJSON is a hacky workaround to prevent Disk from using compute.Disk's implementation.

type FailureMatches

type FailureMatches []string

FailureMatches is a list of matching failure strings.

func (*FailureMatches) UnmarshalJSON

func (fms *FailureMatches) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals FailureMatches.

type FirewallRule

type FirewallRule struct {
	compute.Firewall
	Resource
}

FirewallRule is used to create a GCE firewallRule.

func (*FirewallRule) MarshalJSON

func (fir *FirewallRule) MarshalJSON() ([]byte, error)

MarshalJSON is a hacky workaround to compute.Firewall's implementation.

type ForwardingRule

type ForwardingRule struct {
	compute.ForwardingRule
	Resource
}

ForwardingRule is used to create a GCE forwardingRule.

func (*ForwardingRule) MarshalJSON

func (fr *ForwardingRule) MarshalJSON() ([]byte, error)

MarshalJSON is a hacky workaround to compute.ForwardingRule's implementation.

type GCSLogger

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

GCSLogger is a logger that writes to a GCS object.

func NewGCSLogger

func NewGCSLogger(ctx context.Context, client *storage.Client, bucket, object string) *GCSLogger

NewGCSLogger creates a new GCSLogger.

func (*GCSLogger) Write

func (l *GCSLogger) Write(b []byte) (int, error)

type GuestAttribute

type GuestAttribute struct {
	KeyName      string `json:",omitempty"`
	SuccessValue string `json:",omitempty"`
}

GuestAttribute describes text signal strings that will be written to guest attributes. This step will not complete until the key exists and matches the value in SuccessValue (if specified and non empty). If SuccessValue is set, any other value in the key will cause the step to fail.

type Image

type Image struct {
	ImageBase
	compute.Image

	// GuestOsFeatures to set for the image.
	GuestOsFeatures guestOsFeatures `json:"guestOsFeatures,omitempty"`
}

Image is used to create a GCE image using GA API. Supported sources are a GCE disk or a RAW image listed in Workflow.Sources.

func (*Image) MarshalJSON

func (i *Image) MarshalJSON() ([]byte, error)

MarshalJSON is a hacky workaround to prevent Image from using compute.Image's implementation.

type ImageAlpha

type ImageAlpha struct {
	ImageBase
	computeAlpha.Image

	// GuestOsFeatures to set for the image.
	GuestOsFeatures guestOsFeatures `json:"guestOsFeatures,omitempty"`
}

ImageAlpha is used to create a GCE image using Alpha API. Supported sources are a GCE disk or a RAW image listed in Workflow.Sources.

type ImageBase

type ImageBase struct {
	Resource

	// Should an existing image of the same name be deleted, defaults to false
	// which will fail validation.
	OverWrite bool `json:",omitempty"`

	//Ignores license validation if 403/forbidden returned
	IgnoreLicenseValidationIfForbidden bool `json:",omitempty"`
}

ImageBase is a base struct for GA/Beta/Alpha images. It holds the shared properties between them.

type ImageBeta

type ImageBeta struct {
	ImageBase
	computeBeta.Image

	// GuestOsFeatures to set for the image.
	GuestOsFeatures guestOsFeatures `json:"guestOsFeatures,omitempty"`
}

ImageBeta is used to create a GCE image using Beta API. Supported sources are a GCE disk or a RAW image listed in Workflow.Sources.

type ImageInterface

type ImageInterface interface {
	// contains filtered or unexported methods
}

ImageInterface represent abstract Image across different API stages (Alpha, Beta, API)

type IncludeWorkflow

type IncludeWorkflow struct {
	Path     string
	Vars     map[string]string `json:",omitempty"`
	Workflow *Workflow         `json:",omitempty"`
}

IncludeWorkflow defines a Daisy workflow injection step. This step will 'include' the workflow found the path given into the parent workflow. Unlike a Subworkflow the included workflow will exist in the same namespace as the parent and have access to all its resources.

type Instance

type Instance struct {
	InstanceBase
	compute.Instance

	// Additional metadata to set for the instance.
	Metadata map[string]string `json:"metadata,omitempty"`
}

Instance is used to create a GCE instance using GA API. By default, output of serial port 1 will be streamed to the daisy logs directory.

func (*Instance) MarshalJSON

func (i *Instance) MarshalJSON() ([]byte, error)

MarshalJSON is a workaround to prevent Instance from using compute.Instance's implementation.

type InstanceBase

type InstanceBase struct {
	Resource

	// OAuth2 scopes to give the instance. If left unset
	// https://www.googleapis.com/auth/devstorage.read_only will be added.
	Scopes []string `json:",omitempty"`
	// StartupScript is the Sources path to a startup script to use in this step.
	// This will be automatically mapped to the appropriate metadata key.
	StartupScript string `json:",omitempty"`
	// RetryWhenExternalIPDenied indicates whether to retry CreateInstances when
	// it fails due to external IP denied by organization IP.
	RetryWhenExternalIPDenied bool `json:",omitempty"`
	// Should an existing instance of the same name be deleted, defaults to false
	// which will fail validation.
	OverWrite bool `json:",omitempty"`
	// Serial port to log to GCS bucket, defaults to 1
	SerialPortsToLog []int64 `json:",omitempty"`
}

InstanceBase is a base struct for GA/Beta instances. It holds the shared properties between the two.

type InstanceBeta

type InstanceBeta struct {
	InstanceBase
	computeBeta.Instance

	// Additional metadata to set for the instance.
	Metadata map[string]string `json:"metadata,omitempty"`
}

InstanceBeta is used to create a GCE instance using Beta API. By default, output of serial port 1 will be streamed to the daisy logs directory.

type InstanceInterface

type InstanceInterface interface {
	// contains filtered or unexported methods
}

InstanceInterface represent abstract Instance across different API stages (Alpha, Beta, API)

type InstanceSignal

type InstanceSignal struct {
	// Instance name to wait for.
	Name string
	// Interval to check for signal (default is 5s).
	// Must be parsable by https://golang.org/pkg/time/#ParseDuration.
	Interval string `json:",omitempty"`

	// Wait for the instance to stop.
	Stopped bool `json:",omitempty"`
	// Wait for a string match in the serial output.
	SerialOutput *SerialOutput `json:",omitempty"`
	// Wait for a key or value match in guest attributes.
	GuestAttribute *GuestAttribute `json:",omitempty"`
	// contains filtered or unexported fields
}

InstanceSignal waits for a signal from an instance.

type LogEntry

type LogEntry struct {
	LocalTimestamp time.Time `json:"localTimestamp"`
	WorkflowName   string    `json:"workflow"`
	StepName       string    `json:"stepName,omitempty"`
	StepType       string    `json:"stepType,omitempty"`
	SerialPort1    string    `json:"serialPort1,omitempty"`
	Message        string    `json:"message"`
	Type           string    `json:"type"`
}

LogEntry encapsulates a single log entry.

func (*LogEntry) String

func (e *LogEntry) String() string

type Logger

type Logger interface {
	WriteLogEntry(e *LogEntry)
	// AppendSerialPortLogs appends a portion of serial port logs for a GCE instance.
	AppendSerialPortLogs(w *Workflow, instance string, logs string)
	// WriteSerialPortLogsToCloudLogging writes all of the collected logs for instance to cloud logging.
	WriteSerialPortLogsToCloudLogging(w *Workflow, instance string)
	// ReadSerialPortLogs returns all collected serial port logs, with one entry per instance.
	ReadSerialPortLogs() []string
	Flush()
}

Logger is a helper that encapsulates the logging logic for Daisy.

type MachineImage

type MachineImage struct {
	compute.MachineImage
	Resource

	// Should an existing machine image of the same name be deleted.
	// Defaults to false which will fail validation if a machine image with the
	// same name exists in the project.
	OverWrite bool `json:",omitempty"`
}

MachineImage is used to create a GCE machine image.

func (*MachineImage) MarshalJSON

func (mi *MachineImage) MarshalJSON() ([]byte, error)

MarshalJSON is a workaround to prevent MachineImage from using computeBeta.MachineImage's implementation.

type Network

type Network struct {
	compute.Network
	AutoCreateSubnetworks *bool `json:"autoCreateSubnetworks,omitempty"`
	Resource
}

Network is used to create a GCE network.

func (*Network) MarshalJSON

func (n *Network) MarshalJSON() ([]byte, error)

MarshalJSON is a hacky workaround to compute.Network's implementation.

type ResizeDisk

type ResizeDisk struct {
	compute.DisksResizeRequest
	// Name of the disk to be resized
	Name   string
	SizeGb string "json:\"sizeGb,omitempty\""
}

ResizeDisk is used to resize a GCE disk.

type ResizeDisks

type ResizeDisks []*ResizeDisk

ResizeDisks is a Daisy ResizeDisks workflow step.

type Resource

type Resource struct {
	// If this is unset Workflow.Project is used.
	Project string `json:",omitempty"`
	// Should this resource be cleaned up after the workflow?
	NoCleanup bool `json:",omitempty"`
	// If set Daisy will use this as the resource name instead of generating a name. Mutually exclusive with ExactName.
	RealName string `json:",omitempty"`
	// If set, Daisy will use the exact name as specified by the user instead of generating a name. Mutually exclusive with RealName.
	ExactName bool `json:",omitempty"`
	// contains filtered or unexported fields
}

Resource is the base struct for Daisy representation structs for GCE resources. This base struct defines some common user-definable fields, as well as some Daisy bookkeeping fields.

type SerialOutput

type SerialOutput struct {
	Port         int64          `json:",omitempty"`
	SuccessMatch string         `json:",omitempty"`
	FailureMatch FailureMatches `json:"failureMatch,omitempty"`
	StatusMatch  string         `json:",omitempty"`
}

SerialOutput describes text signal strings that will be written to the serial port. A StatusMatch will print out the matching line from the StatusMatch onward. This step will not complete until a line in the serial output matches SuccessMatch or FailureMatch. A match with FailureMatch will cause the step to fail.

type Snapshot

type Snapshot struct {
	compute.Snapshot
	Resource
}

Snapshot is used to create a GCE disk in a project.

func (*Snapshot) MarshalJSON

func (ss *Snapshot) MarshalJSON() ([]byte, error)

MarshalJSON is a hacky workaround to prevent Snapshot from using compute.Snapshot's implementation.

type StartInstances

type StartInstances struct {
	Instances []string `json:",omitempty"`
}

StartInstances start GCE instances.

type Step

type Step struct {

	//Timeout description
	TimeoutDescription string `json:",omitempty"`
	// Time to wait for this step to complete (default 10m).
	// Must be parsable by https://golang.org/pkg/time/#ParseDuration.
	Timeout string `json:",omitempty"`

	// Only one of the below fields should exist for each instance of Step.
	AttachDisks               *AttachDisks               `json:",omitempty"`
	DetachDisks               *DetachDisks               `json:",omitempty"`
	CreateDisks               *CreateDisks               `json:",omitempty"`
	CreateForwardingRules     *CreateForwardingRules     `json:",omitempty"`
	CreateFirewallRules       *CreateFirewallRules       `json:",omitempty"`
	CreateImages              *CreateImages              `json:",omitempty"`
	CreateMachineImages       *CreateMachineImages       `json:",omitempty"`
	CreateInstances           *CreateInstances           `json:",omitempty"`
	CreateNetworks            *CreateNetworks            `json:",omitempty"`
	CreateSnapshots           *CreateSnapshots           `json:",omitempty"`
	CreateSubnetworks         *CreateSubnetworks         `json:",omitempty"`
	CreateTargetInstances     *CreateTargetInstances     `json:",omitempty"`
	CopyGCSObjects            *CopyGCSObjects            `json:",omitempty"`
	ResizeDisks               *ResizeDisks               `json:",omitempty"`
	StartInstances            *StartInstances            `json:",omitempty"`
	StopInstances             *StopInstances             `json:",omitempty"`
	DeleteResources           *DeleteResources           `json:",omitempty"`
	DeprecateImages           *DeprecateImages           `json:",omitempty"`
	IncludeWorkflow           *IncludeWorkflow           `json:",omitempty"`
	SubWorkflow               *SubWorkflow               `json:",omitempty"`
	WaitForInstancesSignal    *WaitForInstancesSignal    `json:",omitempty"`
	WaitForAnyInstancesSignal *WaitForAnyInstancesSignal `json:",omitempty"`
	UpdateInstancesMetadata   *UpdateInstancesMetadata   `json:",omitempty"`
	// contains filtered or unexported fields
}

Step is a single daisy workflow step.

func NewStep

func NewStep(name string, w *Workflow, timeout time.Duration) *Step

NewStep creates a Step with given name and timeout with the specified workflow. If timeout is less or equal to zero, defaultTimeout from the workflow will be used

func NewStepDefaultTimeout

func NewStepDefaultTimeout(name string, w *Workflow) *Step

NewStepDefaultTimeout creates a Step with given name using default timeout from the workflow

type StopInstances

type StopInstances struct {
	Instances []string `json:",omitempty"`
}

StopInstances stop GCE instances.

type SubWorkflow

type SubWorkflow struct {
	Path     string
	Vars     map[string]string `json:",omitempty"`
	Workflow *Workflow         `json:",omitempty"`
}

SubWorkflow defines a Daisy sub workflow.

type Subnetwork

type Subnetwork struct {
	compute.Subnetwork
	Resource
}

Subnetwork is used to create a GCE subnetwork.

func (*Subnetwork) MarshalJSON

func (sn *Subnetwork) MarshalJSON() ([]byte, error)

MarshalJSON is a hacky workaround to compute.Subnetwork's implementation.

type TargetInstance

type TargetInstance struct {
	compute.TargetInstance
	Resource
}

TargetInstance is used to create a GCE targetInstance.

func (*TargetInstance) MarshalJSON

func (ti *TargetInstance) MarshalJSON() ([]byte, error)

MarshalJSON is a hacky workaround to compute.TargetInstance's implementation.

type TimeRecord

type TimeRecord struct {
	Name      string
	StartTime time.Time
	EndTime   time.Time
}

TimeRecord is a type with info of a step execution time

type UpdateInstanceMetadata

type UpdateInstanceMetadata struct {
	// Metadata
	Metadata map[string]string `json:"metadata,omitempty"`

	// Instance to attach to.
	Instance string
	// contains filtered or unexported fields
}

UpdateInstanceMetadata is used to update an instance metadata.

type UpdateInstancesMetadata

type UpdateInstancesMetadata []*UpdateInstanceMetadata

UpdateInstancesMetadata is a Daisy UpdateInstancesMetadata workflow step.

type Var

type Var struct {
	Value       string
	Required    bool   `json:",omitempty"`
	Description string `json:",omitempty"`
}

Var is a type with a flexible JSON representation. A Var can be represented by either a string, or by this struct definition. A Var that is represented by a string will unmarshal into the struct: {Value: <string>, Required: false, Description: ""}.

func (*Var) UnmarshalJSON

func (v *Var) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals a Var.

type WaitForAnyInstancesSignal

type WaitForAnyInstancesSignal []*InstanceSignal

WaitForAnyInstancesSignal is a Daisy WaitForAnyInstancesSignal workflow step.

type WaitForInstancesSignal

type WaitForInstancesSignal []*InstanceSignal

WaitForInstancesSignal is a Daisy WaitForInstancesSignal workflow step.

type Workflow

type Workflow struct {
	// Populated on New() construction.
	Cancel chan struct{} `json:"-"`

	// Workflow template fields.
	// Workflow name.
	Name string `json:",omitempty"`
	// Project to run in.
	Project string `json:",omitempty"`
	// Zone to run in.
	Zone string `json:",omitempty"`
	// GCS Path to use for scratch data and write logs/results to.
	GCSPath string `json:",omitempty"`
	// Path to OAuth credentials file.
	OAuthPath string `json:",omitempty"`
	// Sources used by this workflow, map of destination to source.
	Sources map[string]string `json:",omitempty"`
	// Vars defines workflow variables, substitution is done at Workflow run time.
	Vars  map[string]Var   `json:",omitempty"`
	Steps map[string]*Step `json:",omitempty"`
	// Map of steps to their dependencies.
	Dependencies map[string][]string `json:",omitempty"`
	// Default timout for each step, defaults to 10m.
	// Must be parsable by https://golang.org/pkg/time/#ParseDuration.
	DefaultTimeout string `json:",omitempty"`

	Logger Logger `json:"-"`

	// Optional compute endpoint override.stepWait
	ComputeEndpoint string          `json:",omitempty"`
	ComputeClient   compute.Client  `json:"-"`
	StorageClient   *storage.Client `json:"-"`

	//Forces cleanup on error of all resources, including those marked with NoCleanup
	ForceCleanupOnError bool
	// contains filtered or unexported fields
}

Workflow is a single Daisy workflow workflow.

func New

func New() *Workflow

New instantiates a new workflow.

func NewFromFile

func NewFromFile(file string) (w *Workflow, err error)

NewFromFile reads and unmarshals a workflow file. Recursively reads sub and included steps as well, when the filenames for those workflows do not contain a variable. If they contain a variable, they will be read during their populate step.

func (*Workflow) AddDependency

func (w *Workflow) AddDependency(dependent *Step, dependencies ...*Step) error

AddDependency creates a dependency of dependent on each dependency. Returns an error if dependent or dependency are not steps in this workflow.

func (*Workflow) AddSerialConsoleOutputValue

func (w *Workflow) AddSerialConsoleOutputValue(k, v string)

AddSerialConsoleOutputValue adds an serial-output key-value pair to the Workflow.

func (*Workflow) AddVar

func (w *Workflow) AddVar(k, v string)

AddVar adds a variable set to the Workflow.

func (*Workflow) CancelWithReason

func (w *Workflow) CancelWithReason(reason string)

CancelWithReason cancels workflow with a specific reason. The specific reason replaces "is canceled" in the default error message. Multiple invocations will not cause an error, but only the first reason will be retained.

func (*Workflow) CancelWorkflow

func (w *Workflow) CancelWorkflow()

CancelWorkflow cancels the workflow. Safe to call multiple times. Prefer this to closing the w.Cancel channel, which will panic if it has already been closed.

func (*Workflow) DisableCloudLogging

func (w *Workflow) DisableCloudLogging()

DisableCloudLogging disables logging to Cloud Logging for this workflow.

func (*Workflow) DisableGCSLogging

func (w *Workflow) DisableGCSLogging()

DisableGCSLogging disables logging to GCS for this workflow.

func (*Workflow) DisableStdoutLogging

func (w *Workflow) DisableStdoutLogging()

DisableStdoutLogging disables logging to stdout for this workflow.

func (*Workflow) GetSerialConsoleOutputValue

func (w *Workflow) GetSerialConsoleOutputValue(k string) string

GetSerialConsoleOutputValue gets an serial-output value by key.

func (*Workflow) GetStepTimeRecords

func (w *Workflow) GetStepTimeRecords() []TimeRecord

GetStepTimeRecords returns time records of each steps

func (*Workflow) ID

func (w *Workflow) ID() string

ID is the unique identifyier for this Workflow.

func (*Workflow) IterateWorkflowSteps

func (w *Workflow) IterateWorkflowSteps(cb func(step *Step))

IterateWorkflowSteps iterates over all workflow steps, including included workflow steps, and calls cb callback function

func (*Workflow) LogStepInfo

func (w *Workflow) LogStepInfo(stepName, stepType, format string, a ...interface{})

LogStepInfo logs information for the workflow step.

func (*Workflow) LogWorkflowInfo

func (w *Workflow) LogWorkflowInfo(format string, a ...interface{})

LogWorkflowInfo logs information for the workflow.

func (*Workflow) NewIncludedWorkflowFromFile

func (w *Workflow) NewIncludedWorkflowFromFile(file string) (*Workflow, DError)

NewIncludedWorkflowFromFile reads and unmarshals a workflow with the same resources as the parent.

func (*Workflow) NewStep

func (w *Workflow) NewStep(name string) (*Step, error)

NewStep instantiates a new, typeless step for this workflow. The step type must be specified before running this workflow.

func (*Workflow) NewSubWorkflow

func (w *Workflow) NewSubWorkflow() *Workflow

NewSubWorkflow instantiates a new workflow as a child to this workflow.

func (*Workflow) NewSubWorkflowFromFile

func (w *Workflow) NewSubWorkflowFromFile(file string) (*Workflow, DError)

NewSubWorkflowFromFile reads and unmarshals a workflow as a child to this workflow.

func (*Workflow) PopulateClients

func (w *Workflow) PopulateClients(ctx context.Context, options ...option.ClientOption) error

PopulateClients populates the compute and storage clients for the workflow.

func (*Workflow) Print

func (w *Workflow) Print(ctx context.Context)

Print populates then pretty prints the workflow.

func (*Workflow) Run

func (w *Workflow) Run(ctx context.Context) (err DError)

Run runs a workflow.

func (*Workflow) SetLogProcessHook

func (w *Workflow) SetLogProcessHook(hook func(string) string)

SetLogProcessHook sets a hook function to process log string

func (*Workflow) Validate

func (w *Workflow) Validate(ctx context.Context) DError

Validate runs validation on the workflow.

type WorkflowModifier

type WorkflowModifier func(*Workflow)

WorkflowModifier is a function type for functions that can modify a Workflow object.

Directories

Path Synopsis
Daisy is a GCE workflow tool.
Daisy is a GCE workflow tool.
Package compute provides access to the Google Compute API.
Package compute provides access to the Google Compute API.
daisy_test_runner is a tool for testing using Daisy workflows.
daisy_test_runner is a tool for testing using Daisy workflows.

Jump to

Keyboard shortcuts

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