MCPcopy
hub / github.com/crowdsecurity/crowdsec / Execute

Method Execute

pkg/hubops/plan.go:215–252  ·  view source on GitHub ↗
(ctx context.Context, interactive bool, dryRun bool, alwaysShowPlan bool, verbose bool)

Source from the content-addressed store, hash-verified

213}
214
215func (p *ActionPlan) Execute(ctx context.Context, interactive bool, dryRun bool, alwaysShowPlan bool, verbose bool) error {
216 // interactive: show action plan, ask for confirm
217 // dry-run: show action plan, no prompt, no action
218 // alwaysShowPlan: print plan even if interactive and dry-run are false
219 // verbosePlan: plan summary is displaying each step in order
220 if len(p.commands) == 0 {
221 fmt.Fprintln(os.Stdout, "Nothing to install or remove.")
222 return nil
223 }
224
225 if interactive && !dryRun {
226 answer, err := p.Confirm(dryRun)
227 if err != nil {
228 return err
229 }
230
231 if !answer {
232 return ErrUserCanceled
233 }
234 } else {
235 if dryRun || alwaysShowPlan {
236 fmt.Fprintln(os.Stdout, "Action plan:\n"+p.Description(verbose))
237 }
238
239 if dryRun {
240 fmt.Fprintln(os.Stdout, "Dry run, no action taken.")
241 return nil
242 }
243 }
244
245 for _, c := range p.commands {
246 if err := c.Run(ctx, p); err != nil {
247 return err
248 }
249 }
250
251 return nil
252}

Callers 6

installMethod · 0.95
installMethod · 0.95
upgradeMethod · 0.95
testOneParserFunction · 0.45
FormatAlertsFunction · 0.45
testOneBucketFunction · 0.45

Calls 3

ConfirmMethod · 0.95
DescriptionMethod · 0.95
RunMethod · 0.65

Tested by 2

testOneParserFunction · 0.36
testOneBucketFunction · 0.36