-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4ea29ff
commit 4beba37
Showing
4 changed files
with
32 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Package experimentname contains code to manipulate experiment names. | ||
package experimentname | ||
|
||
import "github.com/ooni/probe-cli/v3/internal/strcasex" | ||
|
||
// Canonicalize allows code to provide experiment names | ||
// in a more flexible way, where we have aliases. | ||
// | ||
// Because we allow for uppercase experiment names for backwards | ||
// compatibility with MK, we need to add some exceptions here when | ||
// mapping (e.g., DNSCheck => dnscheck). | ||
func Canonicalize(name string) string { | ||
switch name = strcasex.ToSnake(name); name { | ||
case "ndt_7": | ||
name = "ndt" // since 2020-03-18, we use ndt7 to implement ndt by default | ||
case "dns_check": | ||
name = "dnscheck" | ||
case "stun_reachability": | ||
name = "stunreachability" | ||
case "web_connectivity@v_0_5": | ||
name = "[email protected]" | ||
default: | ||
} | ||
return name | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,8 +13,8 @@ import ( | |
"strconv" | ||
|
||
"github.com/ooni/probe-cli/v3/internal/checkincache" | ||
"github.com/ooni/probe-cli/v3/internal/experimentname" | ||
"github.com/ooni/probe-cli/v3/internal/model" | ||
"github.com/ooni/probe-cli/v3/internal/strcasex" | ||
"github.com/ooni/probe-cli/v3/internal/targetloading" | ||
) | ||
|
||
|
@@ -238,27 +238,6 @@ func (b *Factory) NewTargetLoader(config *model.ExperimentTargetLoaderConfig) mo | |
} | ||
} | ||
|
||
// CanonicalizeExperimentName allows code to provide experiment names | ||
// in a more flexible way, where we have aliases. | ||
// | ||
// Because we allow for uppercase experiment names for backwards | ||
// compatibility with MK, we need to add some exceptions here when | ||
// mapping (e.g., DNSCheck => dnscheck). | ||
func CanonicalizeExperimentName(name string) string { | ||
switch name = strcasex.ToSnake(name); name { | ||
case "ndt_7": | ||
name = "ndt" // since 2020-03-18, we use ndt7 to implement ndt by default | ||
case "dns_check": | ||
name = "dnscheck" | ||
case "stun_reachability": | ||
name = "stunreachability" | ||
case "web_connectivity@v_0_5": | ||
name = "[email protected]" | ||
default: | ||
} | ||
return name | ||
} | ||
|
||
// ErrNoSuchExperiment indicates a given experiment does not exist. | ||
var ErrNoSuchExperiment = errors.New("no such experiment") | ||
|
||
|
@@ -305,7 +284,7 @@ const OONI_FORCE_ENABLE_EXPERIMENT = "OONI_FORCE_ENABLE_EXPERIMENT" | |
func NewFactory(name string, kvStore model.KeyValueStore, logger model.Logger) (*Factory, error) { | ||
// Make sure we are deadling with the canonical experiment name. Historically MK used | ||
// names such as WebConnectivity and we want to continue supporting this use case. | ||
name = CanonicalizeExperimentName(name) | ||
name = experimentname.Canonicalize(name) | ||
|
||
// Handle A/B testing where we dynamically choose LTE for some users. The current policy | ||
// only relates to a few users to collect data. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters