Skip to content

Commit 577e1e8

Browse files
authored
Update executor contract, publish local dev server (#1385)
1 parent ea1de35 commit 577e1e8

File tree

13 files changed

+413
-208
lines changed

13 files changed

+413
-208
lines changed

CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ For faster development, you can also build and run Botkube outside K8s cluster.
162162
1. Start fake plugins server to serve binaries from [`dist`](dist) folder:
163163
164164
```bash
165-
go run test/helpers/plugin_server.go
165+
go run hack/target/serve-plugins/main.go
166166
```
167167
168168
> **Note**

hack/target/serve-plugins/main.go

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package main
2+
3+
import (
4+
"flag"
5+
"log"
6+
"os"
7+
"path/filepath"
8+
"strconv"
9+
10+
"github.com/kubeshop/botkube/pkg/loggerx"
11+
"github.com/kubeshop/botkube/pkg/plugin"
12+
)
13+
14+
func main() {
15+
pluginsDir := flag.String("plugins-dir", getEnv("PLUGINS_DIR", "plugin-dist"), "Plugins directory")
16+
host := flag.String("host", getEnv("PLUGIN_SERVER_HOST", "http://localhost"), "Local server host")
17+
port := flag.String("port", getEnv("PLUGIN_SERVER_PORT", "3010"), "Local server port")
18+
flag.Parse()
19+
20+
dir, err := os.Getwd()
21+
loggerx.ExitOnError(err, "while getting current directory")
22+
23+
portInt, err := strconv.Atoi(*port)
24+
loggerx.ExitOnError(err, "while casting server port value")
25+
26+
binDir := filepath.Join(dir, *pluginsDir)
27+
indexEndpoint, startServerFn := plugin.NewStaticPluginServer(plugin.StaticPluginServerConfig{
28+
BinariesDirectory: binDir,
29+
Host: *host,
30+
Port: portInt,
31+
})
32+
33+
log.Printf("Service plugin binaries from %s\n", binDir)
34+
log.Printf("Botkube repository index URL: %s", indexEndpoint)
35+
err = startServerFn()
36+
loggerx.ExitOnError(err, "while starting server")
37+
}
38+
39+
func getEnv(key, defaultValue string) string {
40+
value, exists := os.LookupEnv(key)
41+
if !exists {
42+
return defaultValue
43+
}
44+
return value
45+
}

0 commit comments

Comments
 (0)