Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 4 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,21 @@

## Features
- **Modes**: The runner can be started in different modes which either offer full functionality or just be a standby listener for incoming alerts
- **Plugins**: Develop your own plugins or use our existing ones to extend the functionality of this runner and alertflow / exflow to your needs
- **Plugins**: Develop your own plugins or use our existing ones to extend the functionality of this Runner and JustFlow to your needs

## Configuration

To conntect an runner to exFlow or AlertFlow you first have to set them up and copy the runner_id and or the api key from the created project. As an Admin you can copy the Global Share Runner token from the admin view.
To conntect an runner to JustFlow you first have to set them up and copy the runner_id and or the api key from the created project. As an Admin you can copy the Global Share Runner token from the admin view.

```yaml
---

log_level: info
mode: master

alertflow:
justflow:
enabled: true
url: https://alertflow.org
runner_id: null
api_key: null

exflow:
enabled: true
url: https://exflow.org
url: https://justflow.app
runner_id: null
api_key: null

Expand Down
20 changes: 10 additions & 10 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ type ConfigurationManager struct {
type Config struct {
LogLevel string `mapstructure:"log_level" validate:"required,oneof=debug info warn error"`
Mode string `mapstructure:"mode" validate:"required,oneof=master worker"`
ExFlow exflowConfig `mapstructure:"exflow" validate:"required"`
JustFlow justflowConfig `mapstructure:"justflow" validate:"required"`
ApiEndpoint ApiEndpointConfig `mapstructure:"api_endpoint" validate:"required"`
WorkspaceDir string `mapstructure:"workspace_dir" validate:"dir"`
PluginDir string `mapstructure:"plugin_dir" validate:"dir"`
Plugins []PluginConfig `mapstructure:"plugins"`
Runner RunnerConf `mapstructure:"runner"`
}

type exflowConfig struct {
type justflowConfig struct {
URL string `mapstructure:"url" validate:"required,url"`
RunnerID string `mapstructure:"runner_id"`
APIKey string `mapstructure:"api_key"`
Expand Down Expand Up @@ -161,11 +161,11 @@ func (cm *ConfigurationManager) setDefaults(config *Config) {
}

func (cm *ConfigurationManager) validateConfig(config *Config) error {
if config.ExFlow.APIKey == "" && config.Runner.SharedRunnerSecret == "" {
return fmt.Errorf("exflow.api_key or runner.shared_runner_secret is required")
if config.JustFlow.APIKey == "" && config.Runner.SharedRunnerSecret == "" {
return fmt.Errorf("justflow.api_key or runner.shared_runner_secret is required")
}
if config.ExFlow.URL == "" {
return fmt.Errorf("exflow URL is required")
if config.JustFlow.URL == "" {
return fmt.Errorf("justflow URL is required")
}

return nil
Expand All @@ -182,28 +182,28 @@ func (cm *ConfigurationManager) GetConfig() *Config {
func (cm *ConfigurationManager) UpdateRunnerID(id string) {
cm.mu.Lock()
defer cm.mu.Unlock()
cm.config.ExFlow.RunnerID = id
cm.config.JustFlow.RunnerID = id
}

// UpdateRunnerApiKey updates the runner api_key in the configuration for both Alertflow and ExFlow
func (cm *ConfigurationManager) UpdateRunnerApiKey(apiKey string) {
cm.mu.Lock()
defer cm.mu.Unlock()
cm.config.ExFlow.APIKey = apiKey
cm.config.JustFlow.APIKey = apiKey
}

// GetRunnerIDs returns the current runner IDs for both Alertflow and ExFlow
func (cm *ConfigurationManager) GetRunnerID() string {
cm.mu.RLock()
defer cm.mu.RUnlock()
return cm.config.ExFlow.RunnerID
return cm.config.JustFlow.RunnerID
}

// GetRunnerIDs returns the current runner apiKey for both Alertflow and ExFlow
func (cm *ConfigurationManager) GetRunnerApiKey() string {
cm.mu.RLock()
defer cm.mu.RUnlock()
return cm.config.ExFlow.APIKey
return cm.config.JustFlow.APIKey
}

// ReloadConfig reloads the configuration from the file
Expand Down
4 changes: 2 additions & 2 deletions internal/executions/start_processing.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
jf_models "github.com/JustLABv1/justflow/services/backend/pkg/models"
"github.com/google/uuid"
"github.com/v1Flows/runner/config"
internal_exflow "github.com/v1Flows/runner/internal/exflow"
internal_justflow "github.com/v1Flows/runner/internal/justflow"
"github.com/v1Flows/runner/internal/runner"
"github.com/v1Flows/runner/pkg/executions"
"github.com/v1Flows/runner/pkg/plugins"
Expand Down Expand Up @@ -67,7 +67,7 @@ func startProcessing(actions []jf_models.Action, loadedPlugins map[string]plugin

// send initial step
var initialSteps []jf_models.ExecutionSteps
initialSteps, err = internal_exflow.SendInitialSteps(cfg, actions, execution)
initialSteps, err = internal_justflow.SendInitialSteps(cfg, actions, execution)
if err != nil {
executions.EndWithError(nil, execution)
// Stop heartbeats and finish processing
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package internal_exflow
package internal_justflow

import (
"time"
Expand Down
4 changes: 2 additions & 2 deletions pkg/alerts/get_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ func GetData(cfg *config.Config, alertID string) (models.Alerts, error) {
},
}

url := cfg.ExFlow.URL + "/api/v1/alerts/" + alertID
url := cfg.JustFlow.URL + "/api/v1/alerts/" + alertID
req, err := http.NewRequest("GET", url, nil)
if err != nil {
log.Errorf("Failed to create request: %v", err)
return models.Alerts{}, err
}
req.Header.Set("Authorization", cfg.ExFlow.APIKey)
req.Header.Set("Authorization", cfg.JustFlow.APIKey)
resp, err := client.Do(req)
if err != nil {
log.Error(err)
Expand Down
4 changes: 2 additions & 2 deletions pkg/alerts/get_grouped_alerts.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ func GetGroupedAlerts(cfg *config.Config, flowID string, groupKeyIdentifier stri
payloadBuf := new(bytes.Buffer)
json.NewEncoder(payloadBuf).Encode(request)

url := cfg.ExFlow.URL + "/api/v1/alerts/grouped"
url := cfg.JustFlow.URL + "/api/v1/alerts/grouped"
req, err := http.NewRequest("GET", url, payloadBuf)
if err != nil {
log.Errorf("Failed to create request: %v", err)
return []models.Alerts{}, err
}
req.Header.Set("Authorization", cfg.ExFlow.APIKey)
req.Header.Set("Authorization", cfg.JustFlow.APIKey)
resp, err := client.Do(req)
if err != nil {
log.Error(err)
Expand Down
4 changes: 2 additions & 2 deletions pkg/alerts/send_alert.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ func SendAlert(cfg *config.Config, alert models.Alerts) (err error) {
}

// Add authorization
req, err := http.NewRequest("POST", cfg.ExFlow.URL+"/api/v1/alerts/", bytes.NewReader(jsonPayload))
req, err := http.NewRequest("POST", cfg.JustFlow.URL+"/api/v1/alerts/", bytes.NewReader(jsonPayload))
if err != nil {
log.Error(err)
return
}
req.Header.Set("Authorization", cfg.ExFlow.APIKey)
req.Header.Set("Authorization", cfg.JustFlow.APIKey)

client := &http.Client{}
res, err := client.Do(req)
Expand Down
4 changes: 2 additions & 2 deletions pkg/alerts/update_alert.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ func UpdateAlert(cfg *config.Config, alert models.Alerts) {
}

// Add authorization
req, err := http.NewRequest("PUT", cfg.ExFlow.URL+"/api/v1/alerts/"+alert.ID.String(), bytes.NewReader(jsonPayload))
req, err := http.NewRequest("PUT", cfg.JustFlow.URL+"/api/v1/alerts/"+alert.ID.String(), bytes.NewReader(jsonPayload))
if err != nil {
log.Error(err)
return
}
req.Header.Set("Authorization", cfg.ExFlow.APIKey)
req.Header.Set("Authorization", cfg.JustFlow.APIKey)

client := &http.Client{}
res, err := client.Do(req)
Expand Down
4 changes: 2 additions & 2 deletions pkg/platform/platform.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ func GetPlatformConfig(cfg *config.Config) (string, string, string) {
cfg = configManager.GetConfig()
}

return cfg.ExFlow.URL, cfg.ExFlow.APIKey, cfg.ExFlow.RunnerID
return cfg.JustFlow.URL, cfg.JustFlow.APIKey, cfg.JustFlow.RunnerID
}

func GetPlatformConfigPlain(cfg *config.Config) (string, string) {
Expand All @@ -21,5 +21,5 @@ func GetPlatformConfigPlain(cfg *config.Config) (string, string) {
cfg = configManager.GetConfig()
}

return cfg.ExFlow.URL, cfg.ExFlow.APIKey
return cfg.JustFlow.URL, cfg.JustFlow.APIKey
}