plugin

package
v0.0.0-...-5874457 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TypeTask Type = "task"
	TypeHook Type = "hook"

	HookTypePre  HookType = "pre"
	HookTypePost HookType = "post"
	HookTypeFail HookType = "fail"

	ModTypeCLI                Mod = "cli"
	ModTypeDependencyResolver Mod = "dependencyresolver"

	DestinationURNFormat = "%s://%s"
)

Variables

View Source
var ValidatorFactory = new(vFactory)

Functions

This section is empty.

Types

type Answer

type Answer struct {
	Question Question
	Value    string
}

type Answers

type Answers []Answer

func (Answers) Get

func (ans Answers) Get(name string) (Answer, bool)

type Asset

type Asset struct {
	Name  string
	Value string
}

type Assets

type Assets []Asset

func AssetsFromMap

func AssetsFromMap(assetsMap map[string]string) Assets

func (Assets) Get

func (a Assets) Get(name string) (Asset, bool)

func (Assets) ToMap

func (a Assets) ToMap() map[string]string

type CommandLineMod

type CommandLineMod interface {
	// GetQuestions list down all the cli inputs required to generate spec files
	// name used for question will be directly mapped to DefaultConfig() parameters
	GetQuestions(context.Context, GetQuestionsRequest) (*GetQuestionsResponse, error)
	ValidateQuestion(context.Context, ValidateQuestionRequest) (*ValidateQuestionResponse, error)

	// DefaultConfig will be passed down to execution unit as env vars
	// they will be generated based on results of AskQuestions
	// if DryRun is true in PluginOptions, should not throw error for missing inputs
	DefaultConfig(context.Context, DefaultConfigRequest) (*DefaultConfigResponse, error)

	// DefaultAssets will be passed down to execution unit as files
	// if DryRun is true in PluginOptions, should not throw error for missing inputs
	DefaultAssets(context.Context, DefaultAssetsRequest) (*DefaultAssetsResponse, error)
}

CommandLineMod needs to be implemented by plugins to interact with optimus CLI

type CompileAssetsRequest

type CompileAssetsRequest struct {
	Options

	// Task configs
	Config Configs

	// Job assets
	Assets Assets

	// the instance for which these assets are being compiled for
	InstanceData []JobRunSpecData
	StartTime    time.Time
	EndTime      time.Time
}

type CompileAssetsResponse

type CompileAssetsResponse struct {
	Assets Assets
}

type Config

type Config struct {
	Name  string
	Value string
}

type Configs

type Configs []Config

func ConfigsFromMap

func ConfigsFromMap(configMap map[string]string) Configs

func (Configs) Get

func (c Configs) Get(name string) (Config, bool)

type DefaultAssetsRequest

type DefaultAssetsRequest struct {
	Options

	Answers Answers
}

type DefaultAssetsResponse

type DefaultAssetsResponse struct {
	Assets Assets `yaml:"defaultassets,omitempty"`
}

type DefaultConfigRequest

type DefaultConfigRequest struct {
	Options

	Answers Answers
}

type DefaultConfigResponse

type DefaultConfigResponse struct {
	Config Configs `yaml:"defaultconfig,omitempty"`
}

type DependencyResolverMod

type DependencyResolverMod interface {
	// GetName returns name of the plugin
	GetName(context.Context) (string, error)

	// GenerateDestination derive destination from config and assets
	GenerateDestination(context.Context, GenerateDestinationRequest) (*GenerateDestinationResponse, error)

	// GenerateDependencies returns names of job destination on which this unit is dependent on
	GenerateDependencies(context.Context, GenerateDependenciesRequest) (*GenerateDependenciesResponse, error)

	// CompileAssets overrides default asset compilation
	CompileAssets(context.Context, CompileAssetsRequest) (*CompileAssetsResponse, error)
}

DependencyResolverMod needs to be implemented for automatic dependency resolution of tasks

type Entrypoint

type Entrypoint struct {
	Shell  string
	Script string
}

type GenerateDependenciesRequest

type GenerateDependenciesRequest struct {
	// Task configs
	Config Configs

	// Job assets
	Assets Assets

	Options
}

type GenerateDependenciesResponse

type GenerateDependenciesResponse struct {
	Dependencies []string
}

type GenerateDestinationRequest

type GenerateDestinationRequest struct {
	// Task configs
	Config Configs

	// Job assets
	Assets Assets

	Options
}

type GenerateDestinationResponse

type GenerateDestinationResponse struct {
	Destination string
	Type        string
}

func (GenerateDestinationResponse) URN

type GetQuestionsRequest

type GetQuestionsRequest struct {
	Options

	JobName string
}

type GetQuestionsResponse

type GetQuestionsResponse struct {
	Questions Questions `yaml:",omitempty"`
}

type HookType

type HookType string

func (HookType) String

func (ht HookType) String() string

type Info

type Info struct {
	// Name should as simple as possible with no special characters
	// should start with a character, better if all lowercase
	Name        string
	Description string
	PluginType  Type  `yaml:",omitempty"`
	PluginMods  []Mod `yaml:",omitempty"`

	PluginVersion string   `yaml:",omitempty"`
	APIVersion    []string `yaml:",omitempty"`

	// Image is the full path to docker container that will be scheduled for execution
	Image string

	// Entrypoint command which will be used to execute the plugin
	Entrypoint Entrypoint

	// DependsOn returns list of hooks this should be executed after
	DependsOn []string `yaml:",omitempty"`

	// PluginType provides the place of execution, could be before the transformation
	// after the transformation, etc
	HookType HookType `yaml:",omitempty"`
}

func (*Info) Validate

func (info *Info) Validate() error

type JobRunSpecData

type JobRunSpecData struct {
	Name  string
	Value string
	Type  string
}

type Mod

type Mod string

func (Mod) String

func (m Mod) String() string

type Options

type Options struct {
	DryRun bool
}

type Plugin

type Plugin struct {
	// Mods apply multiple modifications to existing registered plugins which
	// can be used in different circumstances
	DependencyMod DependencyResolverMod
	YamlMod       YamlMod
}

Plugin is an extensible module implemented outside the core optimus boundaries

func (*Plugin) GetSurveyMod

func (p *Plugin) GetSurveyMod() CommandLineMod

func (*Plugin) Info

func (p *Plugin) Info() *Info

func (*Plugin) IsYamlPlugin

func (p *Plugin) IsYamlPlugin() bool

type Question

type Question struct {
	Name        string   `yaml:",omitempty"`
	Prompt      string   `yaml:",omitempty"`
	Help        string   `yaml:",omitempty"`
	Default     string   `yaml:",omitempty"`
	Multiselect []string `yaml:",omitempty"`

	SubQuestions []SubQuestion `yaml:",omitempty"`

	Regexp          string `yaml:",omitempty"`
	ValidationError string `yaml:",omitempty"`
	MinLength       int    `yaml:",omitempty"`
	MaxLength       int    `yaml:",omitempty"`
	Required        bool   `yaml:",omitempty"`
}

func (*Question) IsValid

func (q *Question) IsValid(value string) error

type Questions

type Questions []Question

func (Questions) Get

func (q Questions) Get(name string) (Question, bool)

type SubQuestion

type SubQuestion struct {
	// IfValue is used as an if condition to match with user input
	// if user value matches this only then ask sub questions
	IfValue   string
	Questions Questions
}

type Type

type Type string

func (Type) String

func (t Type) String() string

type ValidateQuestionRequest

type ValidateQuestionRequest struct {
	Options

	Answer Answer
}

type ValidateQuestionResponse

type ValidateQuestionResponse struct {
	Success bool
	Error   string
}

type YamlMod

type YamlMod interface {
	PluginInfo() *Info
	CommandLineMod
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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