Skip to content

Commit c1d5a0f

Browse files
authored
fix: missed a few renames (raid -> plugin) (#52)
Signed-off-by: jmeridth <[email protected]>
1 parent 5adde6a commit c1d5a0f

File tree

4 files changed

+49
-49
lines changed

4 files changed

+49
-49
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ loglevel: Debug
7676
write-directory: sample_output
7777
services:
7878
my-cloud-service1:
79-
raid: example
80-
tactics:
79+
plugin: example
80+
test-suite:
8181
- tlp_red
8282
# - tlp_amber
8383
# - tlp_green

cmd/list.go

+25-25
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ var listCmd = &cobra.Command{
2020
Short: "Consult the Charts! List all plugins that have been installed.",
2121
Run: func(cmd *cobra.Command, args []string) {
2222
if viper.GetBool("all") {
23-
fmt.Fprintln(writer, "| Raid \t | Available \t| Requested \t|")
24-
for _, pluginPkg := range GetRaids() {
23+
fmt.Fprintln(writer, "| Plugin \t | Available \t| Requested \t|")
24+
for _, pluginPkg := range GetPlugins() {
2525
fmt.Fprintf(writer, "| %s \t | %t \t| %t \t|\n", pluginPkg.Name, pluginPkg.Available, pluginPkg.Requested)
2626
}
2727
} else {
2828
// list only the available plugins
29-
fmt.Fprintln(writer, "| Raid \t | Requested \t|")
30-
for _, pluginPkg := range GetRaids() {
29+
fmt.Fprintln(writer, "| Plugin \t | Requested \t|")
30+
for _, pluginPkg := range GetPlugins() {
3131
if pluginPkg.Available {
3232
fmt.Fprintf(writer, "| %s \t | %t \t|\n", pluginPkg.Name, pluginPkg.Requested)
3333
}
@@ -44,56 +44,56 @@ func init() {
4444
viper.BindPFlag("all", listCmd.PersistentFlags().Lookup("all"))
4545
}
4646

47-
// GetRequestedRaids returns a list of plugin names requested in the config
48-
func getRequestedRaids() (requestedRaidPackages []*RaidPkg) {
47+
// GetRequestedPlugins returns a list of plugin names requested in the config
48+
func getRequestedPlugins() (requestedPluginPackages []*PluginPkg) {
4949
services := viper.GetStringMap("services")
5050
for serviceName := range services {
5151
pluginName := viper.GetString("services." + serviceName + ".plugin")
52-
if pluginName != "" && !Contains(requestedRaidPackages, pluginName) {
53-
pluginPkg := NewRaidPkg(pluginName, serviceName)
52+
if pluginName != "" && !Contains(requestedPluginPackages, pluginName) {
53+
pluginPkg := NewPluginPkg(pluginName, serviceName)
5454
pluginPkg.Requested = true
55-
requestedRaidPackages = append(requestedRaidPackages, pluginPkg)
55+
requestedPluginPackages = append(requestedPluginPackages, pluginPkg)
5656
}
5757
}
58-
return requestedRaidPackages
58+
return requestedPluginPackages
5959
}
6060

61-
// GetAvailableRaids returns a list of plugins found in the binaries path
62-
func getAvailableRaids() (availableRaidPackages []*RaidPkg) {
61+
// GetAvailablePlugins returns a list of plugins found in the binaries path
62+
func getAvailablePlugins() (availablePluginPackages []*PluginPkg) {
6363
pluginPaths, _ := hcplugin.Discover("*", viper.GetString("binaries-path"))
6464
for _, pluginPath := range pluginPaths {
65-
pluginPkg := NewRaidPkg(path.Base(pluginPath), "")
65+
pluginPkg := NewPluginPkg(path.Base(pluginPath), "")
6666
pluginPkg.Available = true
67-
if strings.Contains(pluginPkg.Name, "privateer"){
67+
if strings.Contains(pluginPkg.Name, "privateer") {
6868
continue
6969
}
70-
availableRaidPackages = append(availableRaidPackages, pluginPkg)
70+
availablePluginPackages = append(availablePluginPackages, pluginPkg)
7171
}
72-
return availableRaidPackages
72+
return availablePluginPackages
7373
}
7474

75-
var allRaids []*RaidPkg
75+
var allPlugins []*PluginPkg
7676

77-
func GetRaids() []*RaidPkg {
78-
if allRaids != nil {
79-
return allRaids
77+
func GetPlugins() []*PluginPkg {
78+
if allPlugins != nil {
79+
return allPlugins
8080
}
81-
output := make([]*RaidPkg, 0)
82-
for _, plugin := range getRequestedRaids() {
83-
if Contains(getAvailableRaids(), plugin.Name) {
81+
output := make([]*PluginPkg, 0)
82+
for _, plugin := range getRequestedPlugins() {
83+
if Contains(getAvailablePlugins(), plugin.Name) {
8484
plugin.Available = true
8585
}
8686
output = append(output, plugin)
8787
}
88-
for _, plugin := range getAvailableRaids() {
88+
for _, plugin := range getAvailablePlugins() {
8989
if !Contains(output, plugin.Name) {
9090
output = append(output, plugin)
9191
}
9292
}
9393
return output
9494
}
9595

96-
func Contains(slice []*RaidPkg, search string) bool {
96+
func Contains(slice []*PluginPkg, search string) bool {
9797
for _, plugin := range slice {
9898
if plugin.Name == search {
9999
return true

cmd/objects.go

+13-13
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,23 @@ import (
1111
"github.com/spf13/viper"
1212
)
1313

14-
// RaidError retains an error object and the name of the pack that generated it
15-
type RaidError struct {
16-
Raid string
17-
Err error
14+
// PluginError retains an error object and the name of the pack that generated it
15+
type PluginError struct {
16+
Plugin string
17+
Err error
1818
}
1919

20-
// RaidErrors holds a list of errors and an Error() method
20+
// PluginErrors holds a list of errors and an Error() method
2121
// so it adheres to the standard Error interface
22-
type RaidErrors struct {
23-
Errors []RaidError
22+
type PluginErrors struct {
23+
Errors []PluginError
2424
}
2525

26-
func (e *RaidErrors) Error() string {
26+
func (e *PluginErrors) Error() string {
2727
return fmt.Sprintf("Service Pack Errors: %v", e.Errors)
2828
}
2929

30-
type RaidPkg struct {
30+
type PluginPkg struct {
3131
Name string
3232
Path string
3333
ServiceTarget string
@@ -40,7 +40,7 @@ type RaidPkg struct {
4040
Error error
4141
}
4242

43-
func (p *RaidPkg) getBinary() (binaryName string, err error) {
43+
func (p *PluginPkg) getBinary() (binaryName string, err error) {
4444
p.Name = filepath.Base(strings.ToLower(p.Name)) // in some cases a filepath may arrive here instead of the base name; overwrite if so
4545
if runtime.GOOS == "windows" && !strings.HasSuffix(p.Name, ".exe") {
4646
p.Name = fmt.Sprintf("%s.exe", p.Name)
@@ -55,7 +55,7 @@ func (p *RaidPkg) getBinary() (binaryName string, err error) {
5555
return
5656
}
5757

58-
func (p *RaidPkg) queueCmd() {
58+
func (p *PluginPkg) queueCmd() {
5959
cmd := exec.Command(p.Path)
6060
flags := []string{
6161
fmt.Sprintf("--config=%s", viper.GetString("config")),
@@ -68,8 +68,8 @@ func (p *RaidPkg) queueCmd() {
6868
}
6969
}
7070

71-
func NewRaidPkg(pluginName string, serviceName string) *RaidPkg {
72-
plugin := &RaidPkg{
71+
func NewPluginPkg(pluginName string, serviceName string) *PluginPkg {
72+
plugin := &PluginPkg{
7373
Name: pluginName,
7474
}
7575
path, err := plugin.getBinary()

cmd/run.go

+9-9
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,17 @@ func Run() (err error) {
4343
logger.Trace(fmt.Sprintf(
4444
"Using bin: %s", viper.GetString("binaries-path")))
4545

46-
plugins := GetRaids()
46+
plugins := GetPlugins()
4747
if len(plugins) == 0 {
4848
logger.Error("no requested plugins were found in " + viper.GetString("binaries-path"))
4949
return
5050
}
5151

5252
// Run all plugins
5353
for serviceName := range viper.GetStringMap("services") {
54-
serviceRaidName := viper.GetString(fmt.Sprintf("services.%s.plugin", serviceName))
54+
servicePluginName := viper.GetString(fmt.Sprintf("services.%s.plugin", serviceName))
5555
for _, pluginPkg := range plugins {
56-
if pluginPkg.Name == serviceRaidName {
56+
if pluginPkg.Name == servicePluginName {
5757
if !pluginPkg.Available {
5858
logger.Error("Requested plugin that is not installed: " + pluginPkg.Name)
5959
continue
@@ -68,16 +68,16 @@ func Run() (err error) {
6868
return err
6969
}
7070
// Request the plugin
71-
var rawRaid interface{}
72-
rawRaid, err = rpcClient.Dispense(shared.PluginName)
71+
var rawPlugin interface{}
72+
rawPlugin, err = rpcClient.Dispense(shared.PluginName)
7373
if err != nil {
7474
logger.Error(err.Error())
7575
}
7676
// Execute plugin
77-
plugin := rawRaid.(shared.Pluginer)
77+
plugin := rawPlugin.(shared.Pluginer)
7878

7979
// Execute
80-
logger.Trace("Starting Raid: " + pluginPkg.Name)
80+
logger.Trace("Starting Plugin: " + pluginPkg.Name)
8181
response := plugin.Start()
8282
if response != nil {
8383
pluginPkg.Error = fmt.Errorf("Error running plugin for %s: %v", serviceName, response)
@@ -90,9 +90,9 @@ func Run() (err error) {
9090
return
9191
}
9292

93-
func closeClient(pluginPkg *RaidPkg, client *hcplugin.Client) {
93+
func closeClient(pluginPkg *PluginPkg, client *hcplugin.Client) {
9494
if pluginPkg.Successful {
95-
logger.Info(fmt.Sprintf("Raid %s completed successfully", pluginPkg.Name))
95+
logger.Info(fmt.Sprintf("Plugin %s completed successfully", pluginPkg.Name))
9696
} else if pluginPkg.Error != nil {
9797
logger.Error(pluginPkg.Error.Error())
9898
} else {

0 commit comments

Comments
 (0)