refactor: interfaces and data types into the model package (#642)
## Checklist - [x] I have read the [contribution guidelines](https://github.com/ooni/probe-cli/blob/master/CONTRIBUTING.md) - [x] reference issue for this pull request: https://github.com/ooni/probe/issues/1885 - [x] related ooni/spec pull request: N/A Location of the issue tracker: https://github.com/ooni/probe ## Description This PR contains a set of changes to move important interfaces and data types into the `./internal/model` package. The criteria for including an interface or data type in here is roughly that the type should be important and used by several packages. We are especially interested to move more interfaces here to increase modularity. An additional side effect is that, by reading this package, one should be able to understand more quickly how different parts of the codebase interact with each other. This is what I want to move in `internal/model`: - [x] most important interfaces from `internal/netxlite` - [x] everything that was previously part of `internal/engine/model` - [x] mocks from `internal/netxlite/mocks` should also be moved in here as a subpackage
This commit is contained in:
@@ -7,14 +7,10 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/google/shlex"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
"golang.org/x/sys/execabs"
|
||||
)
|
||||
|
||||
// Logger is the logger expected by this package.
|
||||
type Logger interface {
|
||||
Infof(format string, v ...interface{})
|
||||
}
|
||||
|
||||
// runconfig is the configuration for run.
|
||||
type runconfig struct {
|
||||
// args contains the command line arguments.
|
||||
@@ -48,7 +44,7 @@ func run(config runconfig) error {
|
||||
}
|
||||
|
||||
// Run executes the specified command with the specified args.
|
||||
func Run(logger Logger, name string, arg ...string) error {
|
||||
func Run(logger model.InfoLogger, name string, arg ...string) error {
|
||||
return run(runconfig{
|
||||
args: arg,
|
||||
command: name,
|
||||
@@ -76,7 +72,7 @@ func RunQuiet(name string, arg ...string) error {
|
||||
var ErrNoCommandToExecute = errors.New("shellx: no command to execute")
|
||||
|
||||
// RunCommandline executes the given command line.
|
||||
func RunCommandline(logger Logger, cmdline string) error {
|
||||
func RunCommandline(logger model.InfoLogger, cmdline string) error {
|
||||
args, err := shlex.Split(cmdline)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user