Skip to content

Commit

Permalink
Merge pull request #54 from AlertFlow/release/v0.19.0-beta
Browse files Browse the repository at this point in the history
Release v0.19.0 beta
  • Loading branch information
JustNZ authored Jan 6, 2025
2 parents 37a1d37 + c0750f9 commit 1bc6d53
Show file tree
Hide file tree
Showing 11 changed files with 315 additions and 220 deletions.
31 changes: 31 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# If you prefer the allow list template instead of the deny list, see community template:
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
#
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib

# Test binary, built with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Dependency directories (remove the comment below to include it)
vendor/

# Go workspace file
go.work

# hide firebase account key
serviceAccountKey.json

.envrc
alertflow-runner
config*.yaml
./plugins
./plugins_temp
.versions
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ serviceAccountKey.json
.envrc
alertflow-runner
config*.yaml
plugins/
temp/
./plugins
./plugins_temp
.versions
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ RUN CGO_ENABLED=1 GOOS=linux go build -o /alertflow-runner ./cmd/alertflow-runne

# Copy configuration files
RUN mkdir -p /app/config
RUN mkdir -p /app/plugins
COPY config/config.yaml /app/config/config.yaml

VOLUME [ "/runner/config" ]
VOLUME [ "/app/config", "/app/plugins" ]

EXPOSE 8081

Expand Down
58 changes: 5 additions & 53 deletions cmd/alertflow-runner/main.go
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
package main

import (
"os"
"path/filepath"
"strings"

"github.com/AlertFlow/runner/config"
"github.com/AlertFlow/runner/internal/common"
payloadendpoints "github.com/AlertFlow/runner/internal/payload_endpoints"
"github.com/AlertFlow/runner/internal/plugins"
"github.com/AlertFlow/runner/internal/runner"
"github.com/AlertFlow/runner/pkg/models"

"github.com/alecthomas/kingpin/v2"
log "github.com/sirupsen/logrus"
)

const version string = "0.18.0-beta"
const version string = "0.19.0-beta"

var (
configFile = kingpin.Flag("config", "Config File").Short('c').Default("config.yaml").String()
Expand Down Expand Up @@ -53,57 +50,12 @@ func main() {

logging(config.LogLevel)

pluginReposDir := "./temp/rawPlugins"
pluginDir := "./plugins"
os.MkdirAll(pluginReposDir, os.ModePerm)
os.MkdirAll(pluginDir, os.ModePerm)

for _, plugin := range config.Plugins {
pluginPath := filepath.Join(pluginReposDir, plugin.Name)
if _, err := os.Stat(pluginPath); os.IsNotExist(err) {
log.Infof("Cloning and building plugin: %s", plugin.Name)
err := plugins.CloneAndBuildPlugin(plugin.Url, pluginDir, pluginPath, plugin.Name, plugin.Version)
if err != nil {
log.Fatalf("Failed to clone and build plugin %s: %v", plugin.Name, err)
}
}
}

// cleanup the temp directory
err = os.RemoveAll(pluginReposDir)
if err != nil {
log.Errorf("Failed to remove temp directory: %v", err)
}

plugins, err := plugins.LoadPlugins(pluginDir)
if err != nil {
log.Fatal(err)
}

pluginsMap := []models.Plugin{}
actionsSlice := make([]models.ActionDetails, 0)
payloadEndpointsSlice := make([]models.PayloadEndpoint, 0)
for _, plugin := range plugins {
p := plugin.Init()

pluginsMap = append(pluginsMap, p)

if p.Type == "action" {
action := plugin.Details()
actionsSlice = append(actionsSlice, action.Action)
log.Infof("Loaded action plugin: %s", action.Action.Name)
}
if p.Type == "payload_endpoint" {
payloadEndpoint := plugin.Details()
payloadEndpointsSlice = append(payloadEndpointsSlice, payloadEndpoint.Payload)
log.Infof("Loaded payload endpoint plugin: %s", payloadEndpoint.Payload.Name)
}
}
plugins, pluginsMap, actions, payloadEndpoints := plugins.Init()

common.RegisterActions(actionsSlice)
go payloadendpoints.InitPayloadRouter(config.PayloadEndpoints.Port, plugins, payloadEndpointsSlice)
common.RegisterActions(actions)
go payloadendpoints.InitPayloadRouter(config.PayloadEndpoints.Port, plugins, payloadEndpoints)

runner.RegisterAtAPI(version, pluginsMap, actionsSlice, payloadEndpointsSlice)
runner.RegisterAtAPI(version, pluginsMap, actions, payloadEndpoints)
go runner.SendHeartbeat()

Init()
Expand Down
23 changes: 7 additions & 16 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,53 +12,45 @@ require (
github.com/bytedance/sonic/loader v0.2.0 // indirect
github.com/cloudwego/base64x v0.1.4 // indirect
github.com/cloudwego/iasm v0.2.0 // indirect
github.com/fatih/color v1.17.0 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.5 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.22.0 // indirect
github.com/goccy/go-json v0.10.3 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/cpuid/v2 v2.2.8 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
github.com/prometheus-community/pro-bing v0.5.0 // indirect
github.com/rogpeppe/go-internal v1.11.0 // indirect
github.com/sagikazarmark/locafero v0.4.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spaolacci/murmur3 v1.1.0 // indirect
github.com/spf13/afero v1.11.0 // indirect
github.com/spf13/cast v1.6.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/stretchr/testify v1.10.0 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/tidwall/gjson v1.18.0 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.12 // indirect
go.opentelemetry.io/otel v1.29.0 // indirect
go.opentelemetry.io/otel/trace v1.29.0 // indirect
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/automaxprocs v1.5.3 // indirect
go.uber.org/multierr v1.9.0 // indirect
golang.org/x/arch v0.9.0 // indirect
golang.org/x/crypto v0.29.0 // indirect
golang.org/x/crypto v0.31.0 // indirect
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect
golang.org/x/net v0.31.0 // indirect
golang.org/x/text v0.20.0 // indirect
google.golang.org/protobuf v1.34.2 // indirect
golang.org/x/net v0.33.0 // indirect
golang.org/x/text v0.21.0 // indirect
google.golang.org/protobuf v1.36.1 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

Expand All @@ -68,6 +60,5 @@ require (
github.com/google/uuid v1.6.0
github.com/spf13/viper v1.19.0
github.com/xhit/go-str2duration/v2 v2.1.0 // indirect
github.com/zeromicro/go-zero v1.7.0
golang.org/x/sys v0.27.0 // indirect
golang.org/x/sys v0.28.0 // indirect
)
Loading

0 comments on commit 1bc6d53

Please sign in to comment.