Skip to content

Commit

Permalink
change config value to bool and reflect in package and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
joshblakeley committed May 7, 2019
1 parent a73afc8 commit 447fae2
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 9 deletions.
2 changes: 1 addition & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ type Config struct {
ControlAPIPort int `json:"control_api_port"`
EnableCustomDomains bool `json:"enable_custom_domains"`
EnableJSVM bool `json:"enable_jsvm"`
JSVM string `json:"jsvm"`
EnableV2JSVM bool `json:"enable_v2_jsvm"`
JSVMTimeout int `json:"jsvm_timeout"`
CoProcessOptions CoProcessConfig `json:"coprocess_options"`
HideGeneratorHeader bool `json:"hide_generator_header"`
Expand Down
6 changes: 2 additions & 4 deletions jsvm_goja.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,9 @@ type TykJSVM interface {
}

func InitJSVM() TykJSVM {

switch config.Global().JSVM {
case "goja":
if config.Global().EnableV2JSVM {
return &GojaJSVM{}
default:
} else {
return &OttoJSVM{}
}
}
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ func loadCustomMiddleware(spec *APISpec) ([]string, apidef.MiddlewareDefinition,
mwPostFuncs := []apidef.MiddlewareDefinition{}
mwPostKeyAuthFuncs := []apidef.MiddlewareDefinition{}
var mwDriver apidef.MiddlewareDriver
if config.Global().JSVM == "goja" {
if config.Global().EnableV2JSVM {
mwDriver = apidef.GojaDriver
} else {
mwDriver = apidef.OttoDriver
Expand Down
3 changes: 1 addition & 2 deletions mw_js_plugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,6 @@ leakMid.NewProcessRequest(function(request, session) {

func TestTykMakeHTTPRequestOtto(t *testing.T) {
globalConf := config.Global()
globalConf.JSVM = "otto"
config.SetGlobal(globalConf)
ts := newTykTestServer()
defer ts.Close()
Expand Down Expand Up @@ -800,7 +799,7 @@ func TestTykMakeHTTPRequestOtto(t *testing.T) {

func TestTykMakeHTTPRequestGoja(t *testing.T) {
globalConf := config.Global()
globalConf.JSVM = "goja"
globalConf.EnableV2JSVM = true
config.SetGlobal(globalConf)
ts := newTykTestServer()
defer ts.Close()
Expand Down
2 changes: 1 addition & 1 deletion mw_virtual_endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func TestVirtualEndpointOtto(t *testing.T) {

func TestVirtualEndpointGoja(t *testing.T) {
globalConf := config.Global()
globalConf.JSVM = "goja"
globalConf.EnableV2JSVM = true
config.SetGlobal(globalConf)
defer resetTestConfig()
ts := newTykTestServer()
Expand Down

0 comments on commit 447fae2

Please sign in to comment.