Skip to content

Commit

Permalink
Update executor contract, publish local dev server (#1385)
Browse files Browse the repository at this point in the history
  • Loading branch information
mszostok authored Feb 19, 2024
1 parent ea1de35 commit 577e1e8
Show file tree
Hide file tree
Showing 13 changed files with 413 additions and 208 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ For faster development, you can also build and run Botkube outside K8s cluster.
1. Start fake plugins server to serve binaries from [`dist`](dist) folder:
```bash
go run test/helpers/plugin_server.go
go run hack/target/serve-plugins/main.go
```
> **Note**
Expand Down
45 changes: 45 additions & 0 deletions hack/target/serve-plugins/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package main

import (
"flag"
"log"
"os"
"path/filepath"
"strconv"

"github.com/kubeshop/botkube/pkg/loggerx"
"github.com/kubeshop/botkube/pkg/plugin"
)

func main() {
pluginsDir := flag.String("plugins-dir", getEnv("PLUGINS_DIR", "plugin-dist"), "Plugins directory")
host := flag.String("host", getEnv("PLUGIN_SERVER_HOST", "http://localhost"), "Local server host")
port := flag.String("port", getEnv("PLUGIN_SERVER_PORT", "3010"), "Local server port")
flag.Parse()

dir, err := os.Getwd()
loggerx.ExitOnError(err, "while getting current directory")

portInt, err := strconv.Atoi(*port)
loggerx.ExitOnError(err, "while casting server port value")

binDir := filepath.Join(dir, *pluginsDir)
indexEndpoint, startServerFn := plugin.NewStaticPluginServer(plugin.StaticPluginServerConfig{
BinariesDirectory: binDir,
Host: *host,
Port: portInt,
})

log.Printf("Service plugin binaries from %s\n", binDir)
log.Printf("Botkube repository index URL: %s", indexEndpoint)
err = startServerFn()
loggerx.ExitOnError(err, "while starting server")
}

func getEnv(key, defaultValue string) string {
value, exists := os.LookupEnv(key)
if !exists {
return defaultValue
}
return value
}
Loading

0 comments on commit 577e1e8

Please sign in to comment.