-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
47 lines (42 loc) · 1.1 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package main
import (
"fmt"
"path/filepath"
"plugin"
"os"
"github.com/marguerite/util/dir"
"github.com/marguerite/util/slice"
"github.com/openSUSE/sauria/commit"
"github.com/openSUSE/sauria/configuration"
)
func main() {
cwd, _ := os.Getwd()
configs := configuration.ParseJson()
plugins, err := dir.Ls("./plugins/*.so")
if err != nil || len(plugins) == 0 {
fmt.Println("Can not find any plugin in plugins directory. Forgot to build them first?")
os.Exit(1)
}
for _, c := range configs {
plug := c.StringAttr("plugin")
p := filepath.Join(cwd, "plugins", plug+".so")
if ok, err := slice.Contains(plugins, p); ok && err == nil {
plug, err := plugin.Open(p)
if err != nil {
fmt.Printf("Can not open plugin %s\n", p)
os.Exit(1)
}
fetch, err := plug.Lookup("FetchNewVersion")
if err != nil {
fmt.Printf("Can not find function FetchNewVersion in plugin %s\n", p)
os.Exit(1)
}
fn := fetch.(func(*configuration.Configuration) (commit.Commit, error))
release, err := fn(c)
if err != nil {
panic(err)
}
fmt.Println(release.UnstableVersion())
}
}
}