forked from TykTechnologies/tyk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TT-4354 Go plugins to support multiple Tyk versions (TykTechnologies#…
…3873) * started to build new plugin path based on gwVersion+os+architecture * added test coverage.Small refactor to load go plugin * if goarch and goos are present then build the plugin name using those values * receive params via terminal * rename the plugin name and not the path * fix naming of the plugin format * build the plugin considering os and arch params * enable cross compiling * set CGO_ENABLE=1 * enable cgo only when its not linux Co-authored-by: Tomas Buchaillot <[email protected]>
- Loading branch information
1 parent
74664bd
commit e60c6f2
Showing
7 changed files
with
109 additions
and
10 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
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
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,37 @@ | ||
package gateway | ||
|
||
import ( | ||
"fmt" | ||
"runtime" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestGoPluginFromTykVersion(t *testing.T) { | ||
m := GoPluginMiddleware{ | ||
BaseMiddleware: BaseMiddleware{}, | ||
Path: "", | ||
SymbolName: "test-symbol", | ||
} | ||
|
||
type testCase struct { | ||
userDefinedName, inferredName string | ||
} | ||
os := runtime.GOOS | ||
arch := runtime.GOARCH | ||
|
||
matrix := []testCase{ | ||
{"plugin.so", fmt.Sprintf("./plugin_%v_%v_%v.so", VERSION, os, arch)}, | ||
{"/some/path/plugin.so", fmt.Sprintf("/some/path/plugin_%v_%v_%v.so", VERSION, os, arch)}, | ||
{"/some/path/plugin", fmt.Sprintf("/some/path/plugin_%v_%v_%v.so", VERSION, os, arch)}, | ||
{"./plugin.so", fmt.Sprintf("./plugin_%v_%v_%v.so", VERSION, os, arch)}, | ||
{"", ""}, | ||
} | ||
|
||
for _, v := range matrix { | ||
m.Path = v.userDefinedName | ||
newPluginPath := m.goPluginFromTykVersion() | ||
assert.Equal(t, v.inferredName, newPluginPath) | ||
} | ||
} |
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
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