package executor import ( "fmt" schemepkg "git.buran.team/main/cep/scheme" ) type ExecutionResult struct { Code int Stdout []byte Stderr []byte Error error } type Container interface { ID() string Start() *ContainerResult Stop() *ContainerResult Execute(timeout int, command string) ExecutionResult Read(timeout int, path string) ([]byte, error) } func NewContainer(global *Global, ticket *Ticket, network *Network, containerIndex int, containerScheme schemepkg.Container) (Container, error) { switch containerScheme.Kind { case schemepkg.CONTAINER_KIND_ONESHOT: return NewOneshotContainer(global, ticket, network, containerIndex, containerScheme) case schemepkg.CONTAINER_KIND_CONTINIOUS: return NewContiniousContainer(global, ticket, network, containerIndex, containerScheme) } return nil, ErrKindUnknown } func containerName(networkIndex int, containerIndex int) string { return fmt.Sprintf("container-%d-%d", networkIndex, containerIndex) } func containerIP(networkIndex int, containerIndex int) string { return fmt.Sprintf("172.16.%d.%d", networkIndex, containerIndex+2) }