package executor import ( "fmt" schemepkg "git.buran.team/main/cep/scheme" fw "git.buran.team/main/fairwind" ) type ConditionBash struct { global *Global ticket *Ticket container Container id string timeout int command string result *Result } func NewConditionBash(global *Global, ticket *Ticket, container Container, conditionScheme schemepkg.Condition) (*ConditionBash, error) { result, err := NewResult(conditionScheme.KindBash.Result) if err != nil { return nil, fmt.Errorf("can't create bash condition: %w", err) } return &ConditionBash{ global: global, ticket: ticket, container: container, id: conditionScheme.ID, timeout: conditionScheme.Timeout, command: conditionScheme.KindBash.Command, result: result, }, nil } func (this *ConditionBash) ID() string { return this.id } func (this *ConditionBash) Check() bool { this.global.Log.Debug("checking bash condition", fw.LogValue("uuid", this.ticket.UUID)) defer this.global.Log.Debug("bash condition checked", fw.LogValue("uuid", this.ticket.UUID)) result := this.container.Execute(this.timeout, this.command) if result.Error != nil { return false } return this.result.Check(result.Code, result.Stdout, result.Stderr) }