util

package
v0.0.0-...-4f670de Latest Latest
Warning

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

Go to latest
Published: May 14, 2020 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// LabelKeyScheduledWorkflowEnabled is a label on a ScheduledWorkflow.
	// It captures whether the ScheduledWorkflow is enabled.
	LabelKeyScheduledWorkflowEnabled = constants.FullName + "/enabled"
	// LabelKeyScheduledWorkflowStatus is a label on a ScheduledWorkflow.
	// It captures the status of the scheduled workflow.
	LabelKeyScheduledWorkflowStatus = constants.FullName + "/status"

	// The maximum byte sizes of the parameter column in package/pipeline DB.
	MaxParameterBytes = 10000

	// LabelKeyWorkflowEpoch is a label on a Workflow.
	// It captures the epoch at which the workflow was scheduled.
	LabelKeyWorkflowEpoch = constants.FullName + "/workflowEpoch"
	// LabelKeyWorkflowIndex is a label on a Workflow.
	// It captures the index of creation the workflow by the ScheduledWorkflow.
	LabelKeyWorkflowIndex = constants.FullName + "/workflowIndex"
	// LabelKeyWorkflowIsOwnedByScheduledWorkflow is a label on a Workflow.
	// It captures whether the workflow is owned by a ScheduledWorkflow.
	LabelKeyWorkflowIsOwnedByScheduledWorkflow = constants.FullName + "/isOwnedByScheduledWorkflow"
	// LabelKeyWorkflowScheduledWorkflowName is a label on a Workflow.
	// It captures whether the name of the owning ScheduledWorkflow.
	LabelKeyWorkflowScheduledWorkflowName = constants.FullName + "/scheduledWorkflowName"

	LabelKeyWorkflowRunId               = "pipeline/runid"
	LabelKeyWorkflowPersistedFinalState = "pipeline/persistedFinalState"

	// LabelKeyWorkflowEpoch is a Workflow annotation key.
	// It captures the the name of the Run.
	AnnotationKeyRunName = "pipelines.kubeflow.org/run_name"

	AnnotationKeyIstioSidecarInject           = "sidecar.istio.io/inject"
	AnnotationValueIstioSidecarInjectEnabled  = "true"
	AnnotationValueIstioSidecarInjectDisabled = "false"

	// LabelKeyCacheEnabled is a workflow label key.
	// It captures whether this step will be selected by cache service.
	// To disable/enable cache for a single run, this label needs to be added in every step under a run.
	LabelKeyCacheEnabled = "pipelines.kubeflow.org/cache_enabled"
)
View Source
const (
	API_CODE_NOT_FOUND = 404
)

Variables

This section is empty.

Functions

func ArchiveTgz

func ArchiveTgz(files map[string]string) (string, error)

ArchiveTgz takes a map of files with name as key and content as value and tar and gzip it to a tgz content string. Nested files and directories are not supported.

func BoolNilOrValue

func BoolNilOrValue(b *bool) string

func BoolPointer

func BoolPointer(b bool) *bool

func BooleanPointer

func BooleanPointer(b bool) *bool

BooleanPointer converts a bool to a bool pointer.

func DateTimePointer

func DateTimePointer(t strfmt.DateTime) *strfmt.DateTime

func ExtractErrorForCLI

func ExtractErrorForCLI(err error, isDebugMode bool) error

func ExtractMasterIPAndPort

func ExtractMasterIPAndPort(config *rest.Config) string

func ExtractTgz

func ExtractTgz(tgzContent string) (map[string]string, error)

ExtractTgz extracts a list of files from a tgz content. The output is a map with file name as key and content as value. Nested files and directories are not supported.

func FormatInt64ForLabel

func FormatInt64ForLabel(epoch int64) string

func FormatTimeForLogging

func FormatTimeForLogging(epoch int64) string

FormatTimeForLogging formats an epoch for logging purposes.

func GetKubernetesClientFromClientConfig

func GetKubernetesClientFromClientConfig(clientConfig clientcmd.ClientConfig) (
	*kubernetes.Clientset, *rest.Config, string, error)

func GetParameters

func GetParameters(template []byte) (string, error)

func GetRpcConnection

func GetRpcConnection(address string) (*grpc.ClientConn, error)

func HasCustomCode

func HasCustomCode(err error, code CustomCode) bool

func Int32Pointer

func Int32Pointer(i int32) *int32

func Int64NilOrValue

func Int64NilOrValue(i *int64) string

func Int64Pointer

func Int64Pointer(i int64) *int64

func IsNotFound

func IsNotFound(err error) bool

IsNotFound returns whether an error indicates that a resource was "not found".

func IsUserErrorCodeMatch

func IsUserErrorCodeMatch(err error, code codes.Code) bool

IsUserErrorCodeMatch returns whether the error is a user error with specified code.

func LogError

func LogError(err error)

func MarshalJsonOrFail

func MarshalJsonOrFail(v interface{}) []byte

func MetaV1TimePointer

func MetaV1TimePointer(t metav1.Time) *metav1.Time

func Metav1TimePointer

func Metav1TimePointer(t metav1.Time) *metav1.Time

Metav1TimePointer converts a metav1.Time to a pointer.

func ParseTimeOrFatal

func ParseTimeOrFatal(value string) time.Time

func RetrieveInt64FromLabel

func RetrieveInt64FromLabel(epoch string) (int64, error)

RetrieveInt64FromLabel converts a string label value into an epoch.

func StringNilOrValue

func StringNilOrValue(s *string) string

func StringPointer

func StringPointer(s string) *string

func TerminateIfError

func TerminateIfError(err error)

TerminateIfError Check if error is nil. Terminate if not.

func TimePointer

func TimePointer(t time.Time) *time.Time

func TimestampPointer

func TimestampPointer(t timestamp.Timestamp) *timestamp.Timestamp

func ToGRPCError

func ToGRPCError(err error) error

func ToInt64Pointer

func ToInt64Pointer(t *metav1.Time) *int64

func Truncate

func Truncate(s string, size float64) string

Truncate the provided string up to provided size

func UInt32Pointer

func UInt32Pointer(i uint32) *uint32

func UnmarshalJsonOrFail

func UnmarshalJsonOrFail(data string, v interface{})

func ValidateWorkflow

func ValidateWorkflow(template []byte) (*v1alpha1.Workflow, error)

func WaitForAPIAvailable

func WaitForAPIAvailable(initializeTimeout time.Duration, basePath string, apiAddress string) error

func Wrap

func Wrap(err error, message string) error

func Wrapf

func Wrapf(err error, format string, args ...interface{}) error

Types

type APICode

type APICode int

type CustomCode

type CustomCode uint32
const (
	CUSTOM_CODE_TRANSIENT CustomCode = 0
	CUSTOM_CODE_PERMANENT CustomCode = 1
	CUSTOM_CODE_NOT_FOUND CustomCode = 2
	CUSTOM_CODE_GENERIC   CustomCode = 3
)

type CustomError

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

func NewCustomError

func NewCustomError(err error, code CustomCode, format string, a ...interface{}) *CustomError

func NewCustomErrorf

func NewCustomErrorf(code CustomCode, format string, a ...interface{}) *CustomError

func (*CustomError) Error

func (e *CustomError) Error() string

type FakeTime

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

func (*FakeTime) Now

func (f *FakeTime) Now() time.Time

type FakeUUIDGenerator

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

FakeUUIDGenerator is a fake implementation of the UUIDGeneratorInterface used for testing. It always generates the UUID and error provided during instantiation.

func (*FakeUUIDGenerator) NewRandom

func (f *FakeUUIDGenerator) NewRandom() (uuid.UUID, error)

type RealTime

type RealTime struct {
}

func (*RealTime) Now

func (r *RealTime) Now() time.Time

type ScheduledWorkflow

type ScheduledWorkflow struct {
	*swfapi.ScheduledWorkflow
}

ScheduledWorkflow is a type to help manipulate ScheduledWorkflow objects.

func NewScheduledWorkflow

func NewScheduledWorkflow(swf *swfapi.ScheduledWorkflow) *ScheduledWorkflow

NewScheduledWorkflow creates an instance of ScheduledWorkflow.

func (*ScheduledWorkflow) ConditionSummary

func (s *ScheduledWorkflow) ConditionSummary() string

func (*ScheduledWorkflow) CronOrEmpty

func (s *ScheduledWorkflow) CronOrEmpty() string

func (*ScheduledWorkflow) CronScheduleEndTimeInSecOrNull

func (s *ScheduledWorkflow) CronScheduleEndTimeInSecOrNull() *int64

func (*ScheduledWorkflow) CronScheduleStartTimeInSecOrNull

func (s *ScheduledWorkflow) CronScheduleStartTimeInSecOrNull() *int64

func (*ScheduledWorkflow) Get

Get converts this object to a swfapi.ScheduledWorkflow.

func (*ScheduledWorkflow) IntervalSecondOr0

func (s *ScheduledWorkflow) IntervalSecondOr0() int64

func (*ScheduledWorkflow) MaxConcurrencyOr0

func (s *ScheduledWorkflow) MaxConcurrencyOr0() int64

func (*ScheduledWorkflow) NoCatchupOrFalse

func (s *ScheduledWorkflow) NoCatchupOrFalse() bool

func (*ScheduledWorkflow) ParametersAsString

func (s *ScheduledWorkflow) ParametersAsString() (string, error)

func (*ScheduledWorkflow) PeriodicScheduleEndTimeInSecOrNull

func (s *ScheduledWorkflow) PeriodicScheduleEndTimeInSecOrNull() *int64

func (*ScheduledWorkflow) PeriodicScheduleStartTimeInSecOrNull

func (s *ScheduledWorkflow) PeriodicScheduleStartTimeInSecOrNull() *int64

func (*ScheduledWorkflow) ToStringForStore

func (s *ScheduledWorkflow) ToStringForStore() string

type TimeInterface

type TimeInterface interface {
	Now() time.Time
}

func NewFakeTime

func NewFakeTime(now time.Time) TimeInterface

func NewFakeTimeForEpoch

func NewFakeTimeForEpoch() TimeInterface

func NewRealTime

func NewRealTime() TimeInterface

type UUIDGenerator

type UUIDGenerator struct {
}

UUIDGenerator is the concrete implementation of the UUIDGeneratorInterface used to generate UUIDs in production deployments.

func NewUUIDGenerator

func NewUUIDGenerator() *UUIDGenerator

func (*UUIDGenerator) NewRandom

func (r *UUIDGenerator) NewRandom() (uuid.UUID, error)

type UUIDGeneratorInterface

type UUIDGeneratorInterface interface {
	NewRandom() (uuid.UUID, error)
}

func NewFakeUUIDGeneratorOrFatal

func NewFakeUUIDGeneratorOrFatal(uuidStringToReturn string, errToReturn error) UUIDGeneratorInterface

NewFakeUUIDGeneratorOrFatal creates a UUIDGenerator that always returns the UUID and error provided as parameters.

type UserError

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

func NewAlreadyExistError

func NewAlreadyExistError(messageFormat string, a ...interface{}) *UserError

func NewBadRequestError

func NewBadRequestError(err error, externalFormat string, a ...interface{}) *UserError

func NewInternalServerError

func NewInternalServerError(err error, internalMessageFormat string,
	a ...interface{}) *UserError

func NewInvalidInputError

func NewInvalidInputError(messageFormat string, a ...interface{}) *UserError

func NewInvalidInputErrorWithDetails

func NewInvalidInputErrorWithDetails(err error, externalMessage string) *UserError

func NewResourceNotFoundError

func NewResourceNotFoundError(resourceType string, resourceName string) *UserError

func NewResourcesNotFoundError

func NewResourcesNotFoundError(resourceTypesFormat string, resourceNames ...interface{}) *UserError

func NewUserError

func NewUserError(err error, internalMessage string, externalMessage string) *UserError

func NewUserErrorWithSingleMessage

func NewUserErrorWithSingleMessage(err error, message string) *UserError

func (*UserError) Error

func (e *UserError) Error() string

func (*UserError) ExternalMessage

func (e *UserError) ExternalMessage() string

func (*UserError) ExternalStatusCode

func (e *UserError) ExternalStatusCode() codes.Code

func (*UserError) Log

func (e *UserError) Log()

func (*UserError) String

func (e *UserError) String() string

type Workflow

type Workflow struct {
	*workflowapi.Workflow
}

Workflow is a type to help manipulate Workflow objects.

func NewWorkflow

func NewWorkflow(workflow *workflowapi.Workflow) *Workflow

NewWorkflow creates a Workflow.

func (*Workflow) Condition

func (w *Workflow) Condition() string

func (*Workflow) FindObjectStoreArtifactKeyOrEmpty

func (w *Workflow) FindObjectStoreArtifactKeyOrEmpty(nodeID string, artifactName string) string

FindObjectStoreArtifactKeyOrEmpty loops through all node running statuses and look up the first S3 artifact with the specified nodeID and artifactName. Returns empty if nothing is found.

func (*Workflow) FinishedAt

func (w *Workflow) FinishedAt() int64

func (*Workflow) Get

func (w *Workflow) Get() *workflowapi.Workflow

Get converts this object to a workflowapi.Workflow.

func (*Workflow) GetWorkflowSpec

func (w *Workflow) GetWorkflowSpec() *Workflow

func (*Workflow) HasScheduledWorkflowAsParent

func (w *Workflow) HasScheduledWorkflowAsParent() bool

func (*Workflow) IsInFinalState

func (w *Workflow) IsInFinalState() bool

IsInFinalState whether the workflow is in a final state.

func (*Workflow) OverrideName

func (w *Workflow) OverrideName(name string)

OverrideName sets the name of a Workflow.

func (*Workflow) OverrideParameters

func (w *Workflow) OverrideParameters(desiredParams map[string]string)

OverrideParameters overrides some of the parameters of a Workflow.

func (*Workflow) PersistedFinalState

func (w *Workflow) PersistedFinalState() bool

PersistedFinalState whether the workflow final state has being persisted.

func (*Workflow) ReplaceUID

func (w *Workflow) ReplaceUID(id string) error

func (*Workflow) ScheduledAtInSecOr0

func (w *Workflow) ScheduledAtInSecOr0() int64

func (*Workflow) ScheduledWorkflowUUIDAsStringOrEmpty

func (w *Workflow) ScheduledWorkflowUUIDAsStringOrEmpty() string

func (*Workflow) SetAnnotations

func (w *Workflow) SetAnnotations(key string, value string)

func (*Workflow) SetAnnotationsToAllTemplates

func (w *Workflow) SetAnnotationsToAllTemplates(key string, value string)

SetAnnotations sets annotations on all templates in a Workflow

func (*Workflow) SetCannonicalLabels

func (w *Workflow) SetCannonicalLabels(name string, nextScheduledEpoch int64, index int64)

func (*Workflow) SetLabels

func (w *Workflow) SetLabels(key string, value string)

func (*Workflow) SetLabelsToAllTemplates

func (w *Workflow) SetLabelsToAllTemplates(key string, value string)

SetLabels sets labels on all templates in a Workflow

func (*Workflow) SetOwnerReferences

func (w *Workflow) SetOwnerReferences(schedule *swfapi.ScheduledWorkflow)

SetOwnerReferences sets owner references on a Workflow.

func (*Workflow) SetServiceAccount

func (w *Workflow) SetServiceAccount(serviceAccount string)

SetServiceAccount Set the service account to run the workflow.

func (*Workflow) ToStringForStore

func (w *Workflow) ToStringForStore() string

func (*Workflow) VerifyParameters

func (w *Workflow) VerifyParameters(desiredParams map[string]string) error

type WorkflowFormatter

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

func NewWorkflowFormatter

func NewWorkflowFormatter(uuid UUIDGeneratorInterface, scheduledAtInSec int64,
	nowInSec int64) *WorkflowFormatter

func (*WorkflowFormatter) Format

func (p *WorkflowFormatter) Format(workflow *v1alpha1.Workflow) error

Jump to

Keyboard shortcuts

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