Skip to content

Commit

Permalink
refactor: remove propertiesBytes from AspectPlugin interface (#148)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbedard authored Feb 15, 2022
1 parent e4754dc commit 5942a80
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 17 deletions.
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

0 comments on commit 5942a80

Please sign in to comment.