Skip to content

Commit fbb9475

Browse files
authored
Merge pull request #3 from privateerproj/tactic-bugfix
Bugfix: tactic config var target
2 parents 60dfec9 + e44eb1c commit fbb9475

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

cmd/debug.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"log"
55

66
"github.com/spf13/cobra"
7-
"github.com/spf13/viper"
87

98
"github.com/privateerproj/privateer-sdk/raidengine"
109
)
@@ -15,7 +14,7 @@ var (
1514
Use: "debug",
1615
Short: "Run the Raid in debug mode",
1716
Run: func(cmd *cobra.Command, args []string) {
18-
err := raidengine.Run(RaidName, viper.GetString("raids.wireframe.tactic"), getStrikes())
17+
err := raidengine.Run(RaidName, getStrikes())
1918
if err != nil {
2019
log.Fatal(err)
2120
}

cmd/root.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package cmd
22

33
import (
4+
"fmt"
45
"os"
56

67
"github.com/spf13/cobra"
@@ -72,22 +73,29 @@ func cleanupFunc() error {
7273
// Adding raidengine.SetupCloseHandler(cleanupFunc) will allow you to append custom cleanup behavior
7374
func (r *Raid) Start() error {
7475
raidengine.SetupCloseHandler(cleanupFunc)
75-
return raidengine.Run(RaidName, viper.GetString("tactic"), getStrikes()) // Return errors from strike executions
76+
return raidengine.Run(RaidName, getStrikes()) // Return errors from strike executions
7677
}
7778

7879
// GetStrikes returns a list of probe objects
79-
func getStrikes() map[string][]raidengine.Strike {
80+
func getStrikes() []raidengine.Strike {
8081
logger := raidengine.GetLogger(RaidName, false)
8182
a := &strikes.Antijokes{
8283
Log: logger,
8384
}
84-
return map[string][]raidengine.Strike{
85-
"PCI": {
85+
availableStrikes := map[string][]raidengine.Strike{
86+
"CCC-Taxonomy": {
8687
a.KnockKnock,
8788
},
8889
"CIS": {
8990
a.KnockKnock,
9091
a.ChickenCrossedRoad,
9192
},
9293
}
94+
tactic := viper.GetString("raids.wireframe.tactic")
95+
strikes := availableStrikes[tactic]
96+
if len(strikes) == 0 {
97+
message := fmt.Sprintf("No strikes were found for the provided strike set: %s", tactic)
98+
logger.Error(message)
99+
}
100+
return strikes
93101
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.14
44

55
require (
66
github.com/hashicorp/go-hclog v1.2.0
7-
github.com/privateerproj/privateer-sdk v0.0.3
7+
github.com/privateerproj/privateer-sdk v0.0.4
88
github.com/spf13/cobra v1.4.0
99
github.com/spf13/viper v1.15.0
1010
)

0 commit comments

Comments
 (0)