| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- package executor
- import (
- "fmt"
- schemepkg "git.buran.team/main/cep/scheme"
- fw "git.buran.team/main/fairwind"
- )
- type CheckBash struct {
- global *Global
- ticket *Ticket
- id string
- container Container
- timeout int
- command string
- result *Result
- }
- func NewCheckBash(global *Global, ticket *Ticket, container Container, checkScheme schemepkg.Check) (*CheckBash, error) {
- result, err := NewResult(checkScheme.KindBash.Result)
- if err != nil {
- return nil, fmt.Errorf("can't create bash check: %w", err)
- }
- return &CheckBash{
- global: global,
- ticket: ticket,
- id: checkScheme.ID,
- container: container,
- timeout: checkScheme.Timeout,
- command: checkScheme.KindBash.Command,
- result: result,
- }, nil
- }
- func (this *CheckBash) ID() string {
- return this.ID()
- }
- func (this *CheckBash) Check() CheckResult {
- this.global.Log.Debug("beginning bash check", fw.LogValue("uuid", this.ticket.UUID))
- result := this.container.Execute(this.timeout, this.command)
- if result.Error != nil {
- this.global.Log.Debug("bash check ended with error", fw.LogValue("uuid", this.ticket.UUID), fw.LogError(result.Error))
- return CheckResult{
- Success: false,
- Data: nil,
- }
- }
- this.global.Log.Debug("bash check ended successfully", fw.LogValue("uuid", this.ticket.UUID))
- return CheckResult{
- Success: this.result.Check(result.Code, result.Stdout, result.Stderr),
- Data: nil,
- }
- }
|