mirror of
https://github.com/hanzo-fi/payments.git
synced 2026-10-30 20:31:20 +00:00
* Rename engine/plugins package to avoid confusion with connector/plugins package * Update instances of plugins to be renamed to connectors * Use Load/Unload for Connectors Manager to avoid confusion with Plugin Registry actions * Add some unit tests for connectors.Manager * Add Config method to Plugin interface * Use validated config instead of raw config for insertion into DB * Update plugin template to include new Config command * Ensure plugin is not nil in workflow unit tests * Small adjustments to e2e test expectations to reflect change in json validation of config * Update codecoverage to exclude new generated files * Guard against nil map in combineConfigs * Update Plugin interface in CONTRIBUTING.md
64 lines
1.4 KiB
Go
64 lines
1.4 KiB
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"flag"
|
|
"log"
|
|
"os"
|
|
"path/filepath"
|
|
"regexp"
|
|
)
|
|
|
|
var (
|
|
connectorDirPath = flag.String("connector-dir-path", "", "Path where to create the new connector directory")
|
|
connectorName = flag.String("connector-name", "", "Name of the new connector")
|
|
|
|
packageNameRegex = regexp.MustCompile(`^[a-z][a-z0-9_]*$`)
|
|
)
|
|
|
|
func main() {
|
|
flag.Parse()
|
|
|
|
if *connectorDirPath == "" {
|
|
log.Fatal("connector-dir-path flag is required")
|
|
}
|
|
|
|
if *connectorName == "" {
|
|
log.Fatal("connector-name flag is required")
|
|
}
|
|
|
|
if !isValidPackageName(*connectorName) {
|
|
log.Fatalf("connector-name %q contains invalid characters: must be a valid package name", *connectorName)
|
|
}
|
|
|
|
connectorPath := filepath.Join(*connectorDirPath, *connectorName)
|
|
|
|
// Create the new connector's directory
|
|
if err := os.Mkdir(connectorPath, 0755); err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
|
|
// Create the new connector client's directory
|
|
if err := os.Mkdir(filepath.Join(connectorPath, "client"), 0755); err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
|
|
// Create the new connector's files
|
|
if err := createFiles(
|
|
context.Background(),
|
|
connectorPath,
|
|
map[string]interface{}{
|
|
"Connector": *connectorName,
|
|
},
|
|
); err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
}
|
|
|
|
func isValidPackageName(name string) bool {
|
|
if name == "go" || name == "main" || name == "internal" {
|
|
return false
|
|
}
|
|
return packageNameRegex.MatchString(name)
|
|
}
|