Skip to content

Commit

Permalink
Added 'tactic' flag for sets of strikes in a raid
Browse files Browse the repository at this point in the history
Signed-off-by: Eddie Knight <[email protected]>
  • Loading branch information
eddie-knight committed Oct 17, 2023
1 parent 4277c0c commit 8c3498c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
3 changes: 3 additions & 0 deletions command/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ func SetBase(cmd *cobra.Command) {
cmd.PersistentFlags().StringP("config", "c", defaultConfigPath(), "Configuration File, JSON or YAML")
viper.BindPFlag("config", cmd.PersistentFlags().Lookup("config"))

cmd.PersistentFlags().StringP("tactic", "t", "default", "Named set of strikes to execute from the raid")
viper.BindPFlag("tactic", cmd.PersistentFlags().Lookup("tactic"))

cmd.PersistentFlags().BoolP("verbose", "v", false, "Louder now! Set log verbosity to INFO")
viper.BindPFlag("verbose", cmd.PersistentFlags().Lookup("verbose"))

Expand Down
11 changes: 6 additions & 5 deletions raidengine/raidengine.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,18 @@ var cleanup = func() error {
}

// Run is used to execute a list of strikes provided by a Raid and customize by user config
func Run(raidName string, strikeSet string, availableStrikes map[string][]Strike) error {
func Run(raidName string, tactic string, availableStrikes map[string][]Strike) error {
logger = GetLogger(raidName, false)
closeHandler()

var attempts int
var failures int
strikes := availableStrikes[strikeSet]
strikes := availableStrikes[tactic]

if len(strikes) == 0 {
logger.Info("No strikes were found for the provided strike set: %s", strikeSet)
return nil
message := fmt.Sprintf("No strikes were found for the provided strike set: %s", tactic)
logger.Error(message)
return errors.New(message)
}
raidResults := &RaidResults{
RaidName: raidName,
Expand All @@ -75,7 +76,7 @@ func Run(raidName string, strikeSet string, availableStrikes map[string][]Strike
failures += 1
logger.Error(strikeResult.Message)
}
logger.Info("%s result:", strikeResult.Message)
logger.Info(fmt.Sprintf("%s result:", strikeResult.Message))
raidResults.AddStrikeResult(name, strikeResult)
}
raidResults.EndTime = time.Now().String()
Expand Down

0 comments on commit 8c3498c

Please sign in to comment.