Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@smarchone
Copy link
Member

@smarchone smarchone commented Jul 20, 2022

Below are powered via YAML instead of binaries:

  1. Survey questions for job_create & job_adhook
  2. Plugin Info
  3. feat : cli syncs yaml plugins from server #530

Changes include:

  • model Plugin to contain YamlMod reference to PluginSpec which implements CommandLineMod Interface.
// representation of a yaml plugin
type AutoGenerated struct {
	Name          string `yaml:"name"`
	Description   string `yaml:"description"`
	Plugintype    string `yaml:"plugintype"`
	Pluginversion string `yaml:"pluginversion"`
	Image         string `yaml:"image"`
	Secretpath    string `yaml:"secretpath"`
	Questions     []struct {
		Name            string `yaml:"name"`
		Prompt          string `yaml:"prompt"`
		Help            string `yaml:"help"`
		Regexp          string `yaml:"regexp"`
		Validationerror string `yaml:"validationerror"`
		Minlength       int    `yaml:"minlength"`
		Maxlength       int    `yaml:"maxlength,omitempty"`
	} `yaml:"questions"`
	Defaultassets []struct {
		Name  string `yaml:"name"`
		Value string `yaml:"value"`
	} `yaml:"defaultassets"`
	Defaultconfig []struct {
		Name  string `yaml:"name"`
		Value string `yaml:"value"`
	} `yaml:"defaultconfig"`
}

// to enforce yaml plugin implementation
type YamlMod interface {
	BasePlugin
	CommandLineMod
}

// discuss issue 
// plugin is not an interface
// plugin is a struct that has attributes that refers to impl. of interfaces
type Plugin struct {
	Base          BasePlugin
	CLIMod        CommandLineMod
	DependencyMod DependencyResolverMod
	YamlMod       YamlMod
}


type PluginRepository interface {
	AddYaml(YamlMod) error                                            // yaml plugin 
	Add(BasePlugin, CommandLineMod, DependencyResolverMod) error       // binary plugin 
	
        // more..
}
  • Plugin discovery:
    • load binary plugins first
    • then load yaml implementations and merge if plugin already present else create
  • Plugin.YamlMod to drive survey (job create & add hook); if it's present else Plugin.CliMod will drive survey.
  • Sorting Plugins listing
  • Add yaml plugin validation (strict)
    optimus plugin validate --path {{file || dir}}

@smarchone smarchone marked this pull request as draft July 20, 2022 09:16
@coveralls
Copy link

coveralls commented Jul 20, 2022

Pull Request Test Coverage Report for Build 2999216758

  • 156 of 169 (92.31%) changed or added relevant lines in 2 files are covered.
  • 215 unchanged lines in 5 files lost coverage.
  • Overall coverage increased (+1.4%) to 77.223%

Changes Missing Coverage Covered Lines Changed/Added Lines %
plugin/yaml/plugin.go 84 88 95.45%
models/plugin.go 72 81 88.89%
Files with Coverage Reduction New Missed Lines %
models/plugin.go 1 52.68%
api/handler/v1beta1/job_spec.go 15 71.43%
models/job.go 23 46.91%
ext/scheduler/airflow2/airflow.go 41 83.22%
job/service.go 135 55.15%
Totals Coverage Status
Change from base Build 2918369205: 1.4%
Covered Lines: 7615
Relevant Lines: 9861

💛 - Coveralls

@smarchone smarchone marked this pull request as ready for review August 8, 2022 02:12

type PluginSpec struct {
models.PluginInfoResponse `yaml:",inline"`
models.GetQuestionsResponse `yaml:",inline"` // PluginQuestion has extra attrs related to validation
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove the comment

models/plugin.go Outdated

func (p *Plugin) Info() *PluginInfoResponse {
resp, _ := p.Base.PluginInfo()
if p.Base != nil {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use IsYamlPlugin() instead

@smarchone smarchone requested a review from sbchaos August 17, 2022 11:59
schema := tasks.Info()
v.logger.Info(fmt.Sprintf("\n%d. %s", taskIdx+1, schema.Name))
if tasks.YamlMod != nil {
v.logger.Info(fmt.Sprintf("\n%d. %s (%s)", taskIdx+1, schema.Name, "yaml"))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this required ?

@smarchone smarchone requested a review from sbchaos August 25, 2022 19:24
* refactor cmd/plugin

* add client sync feature; refactor plugin manager to plugin pkg

* fix lint; sync&cleanup issue

* make plugin discovery static (both client and server)

* fix : feedback

* fix : feedback

* fix : url formatting for downloading plugins
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support Yaml Plugins in Optimus which demand just a simple Command Line Experience

5 participants