plugin

package
v0.0.0-...-cc10910 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2024 License: Apache-2.0 Imports: 7 Imported by: 1

Documentation

Index

Constants

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

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

	ModTypeCLI Mod = "cli"

	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 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 Entrypoint

type Entrypoint struct {
	Shell  string
	Script string
}

type Evaluator

type Evaluator struct {
	FilePath string `yaml:"filepath"`
	Selector string `yaml:"selector,omitempty"`
}

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"`

	AssetParsers           map[ParserType][]Evaluator `yaml:"asset_parsers,omitempty"`
	DestinationURNTemplate string                     `yaml:"destination_urn_template,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 Mod

type Mod string

func (Mod) String

func (m Mod) String() string

type Options

type Options struct {
	DryRun bool
}

type ParserType

type ParserType string
const (
	BQParser ParserType = "bq"
)

type Plugin

type Plugin struct {
	// Mods apply multiple modifications to existing registered plugins which
	// can be used in different circumstances
	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