refactor(internal/ooni): Context => Probe (#170)

Closes https://github.com/ooni/probe/issues/939
This commit is contained in:
Simone Basso 2020-11-13 19:01:06 +01:00 committed by GitHub
commit 9e238c27dd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 90 additions and 90 deletions

View file

@ -17,7 +17,7 @@ var Cmd = kingpin.New("ooniprobe", "")
var Command = Cmd.Command
// Init should be called by all subcommand that care to have a ooni.Context instance
var Init func() (*ooni.Context, error)
var Init func() (*ooni.Probe, error)
func init() {
configPath := Cmd.Flag("config", "Set a custom config file path").Short('c').String()
@ -43,7 +43,7 @@ func init() {
log.Debugf("ooni version %s", version.Version)
}
Init = func() (*ooni.Context, error) {
Init = func() (*ooni.Probe, error) {
var err error
homePath, err := utils.GetOONIHome()
@ -51,16 +51,16 @@ func init() {
return nil, err
}
ctx := ooni.NewContext(*configPath, homePath)
err = ctx.Init(*softwareName, *softwareVersion)
probe := ooni.NewProbe(*configPath, homePath)
err = probe.Init(*softwareName, *softwareVersion)
if err != nil {
return nil, err
}
if *isBatch {
ctx.IsBatch = true
probe.IsBatch = true
}
return ctx, nil
return probe, nil
}
return nil