Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: remove propertiesBytes from AspectPlugin interface #148

Merged
merged 1 commit into from
Feb 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 5 additions & 16 deletions pkg/plugin/system/aspectplugins.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,10 @@ const (

// AspectPlugin represents a plugin entry in the plugins file.
type AspectPlugin struct {
Name string `yaml:"name"`
From string `yaml:"from"`
LogLevel string `yaml:"log_level"`
Properties map[string]interface{} `yaml:"properties"`
propertiesBytes []byte
Name string `yaml:"name"`
From string `yaml:"from"`
LogLevel string `yaml:"log_level"`
Properties map[string]interface{} `yaml:"properties"`
}

// Finder is the interface that wraps the simple Find method that performs the
Expand Down Expand Up @@ -118,15 +117,5 @@ func (p *parser) Parse(aspectpluginsPath string) ([]AspectPlugin, error) {
return nil, fmt.Errorf("failed to parse .aspectplugins: %w", err)
}

var processedPlugins []AspectPlugin
for _, plugin := range aspectplugins {
propertiesBytes, err := p.yamlMarshal(plugin.Properties)
if err != nil {
return nil, fmt.Errorf("failed to parse .aspectplugins: %w", err)
}
plugin.propertiesBytes = propertiesBytes
processedPlugins = append(processedPlugins, plugin)
}

return processedPlugins, nil
return aspectplugins, nil
}
7 changes: 6 additions & 1 deletion pkg/plugin/system/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import (
"reflect"
"time"

yaml "gopkg.in/yaml.v2"

hclog "github.com/hashicorp/go-hclog"
goplugin "github.com/hashicorp/go-plugin"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -104,7 +106,10 @@ func (ps *pluginSystem) Configure(streams ioutils.Streams) error {
return fmt.Errorf("failed to configure plugin system: %w", err)
}

propertiesBytes := aspectplugin.propertiesBytes
propertiesBytes, err := yaml.Marshal(aspectplugin.Properties)
if err != nil {
return fmt.Errorf("failed to configure plugin system: %w", err)
}

aspectplugin := rawplugin.(plugin.Plugin)
if err := aspectplugin.Setup(propertiesBytes); err != nil {
Expand Down