Skip to content

Commit

Permalink
feat(plugins): can now dynamically call plugins and not only aws name…
Browse files Browse the repository at this point in the history
…d plugins
  • Loading branch information
StanGirard committed Sep 11, 2022
1 parent 05fbda0 commit 36ac556
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
4 changes: 2 additions & 2 deletions plugins/commons/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,8 @@ func (c *Plugin) downloadToTempFile(asset *github.ReleaseAsset) (*os.File, error

ctx := context.Background()
client := newGitHubClient(ctx)
log.Printf("[DEBUG] Request to https://api.github.com/repos/%s/%s/releases/assets/%d", c.SourceOwner, c.SourceRepo, asset.GetID())

log.Printf("[DEBUG] Request to https://api.github.com/repos/%s/%s/releases/assets/%d", c.SourceOwner, c.SourceRepo, asset.GetID())
downloader, _, err := client.Repositories.DownloadReleaseAsset(ctx, c.SourceOwner, c.SourceRepo, asset.GetID(), http.DefaultClient)
if err != nil {
return nil, err
Expand Down
11 changes: 7 additions & 4 deletions plugins/manager/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"log"
"os"
"os/exec"
"strings"

hclog "github.com/hashicorp/go-hclog"
"github.com/hashicorp/go-plugin"
Expand All @@ -16,6 +17,12 @@ func RunPlugin(pluginInput commons.Plugin, c *commons.Config) []commons.Tests {
// Create an hclog.Logger
gob.Register(map[string]interface{}{})
gob.Register([]interface{}{})
pluginMap := make(map[string]plugin.Plugin)

for _, plugin := range c.Plugins {
pluginMap[strings.ToLower(plugin.Name)] = &commons.YatasPlugin{}
}

logger := hclog.New(&hclog.LoggerOptions{
Name: "plugin",
Output: os.Stdout,
Expand Down Expand Up @@ -62,7 +69,3 @@ var handshakeConfig = plugin.HandshakeConfig{
}

// pluginMap is the map of plugins we can dispense.

var pluginMap = map[string]plugin.Plugin{
"aws": &commons.YatasPlugin{},
}

0 comments on commit 36ac556

Please sign in to comment.