Skip to content

Commit e4acc56

Browse files
committed
feat: Add playground mode check to allow plugins to exit early based on environment variable.
1 parent dc93b2a commit e4acc56

File tree

10 files changed

+46
-0
lines changed

10 files changed

+46
-0
lines changed

plugins/aws/main.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"errors"
66
"fmt"
77
"net/http"
8+
"os"
89
"runtime"
910
"strings"
1011
"time"
@@ -38,6 +39,10 @@ var (
3839
)
3940

4041
func main() {
42+
if os.Getenv("PLAYGROUND") == "true" {
43+
return
44+
}
45+
4146
mode := plugins.GetCfg("plugin_com.utmstack.aws").Env.Mode
4247
if mode != "manager" {
4348
return

plugins/azure/main.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"errors"
77
"fmt"
88
"net/http"
9+
"os"
910
"runtime"
1011
"strings"
1112
"sync"
@@ -65,6 +66,10 @@ var SupportedClouds = []CloudEndpoints{
6566
}
6667

6768
func main() {
69+
if os.Getenv("PLAYGROUND") == "true" {
70+
return
71+
}
72+
6873
mode := plugins.GetCfg("plugin_com.utmstack.azure").Env.Mode
6974
if mode != "worker" {
7075
return

plugins/bitdefender/main.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package main
22

33
import (
4+
"os"
45
"runtime"
56

67
"github.com/threatwinds/go-sdk/plugins"
@@ -10,6 +11,10 @@ import (
1011
)
1112

1213
func main() {
14+
if os.Getenv("PLAYGROUND") == "true" {
15+
return
16+
}
17+
1318
mode := plugins.GetCfg("plugin_com.utmstack.bitdefender").Env.Mode
1419
if mode != "manager" {
1520
return

plugins/config/main.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,10 @@ func (f *Filter) FromVar(id int, name any, filter any) {
234234
}
235235

236236
func main() {
237+
if os.Getenv("PLAYGROUND") == "true" {
238+
return
239+
}
240+
237241
for {
238242
func() {
239243
db, err := connect()

plugins/crowdStrike/main.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"encoding/json"
66
"errors"
77
"fmt"
8+
"os"
89
"runtime"
910
"strings"
1011
"sync"
@@ -27,6 +28,10 @@ const (
2728
)
2829

2930
func main() {
31+
if os.Getenv("PLAYGROUND") == "true" {
32+
return
33+
}
34+
3035
mode := plugins.GetCfg("plugin_com.utmstack.crowdstrike").Env.Mode
3136
if mode != "manager" {
3237
return

plugins/gcp/main.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ type GroupModule struct {
2929
}
3030

3131
func main() {
32+
if os.Getenv("PLAYGROUND") == "true" {
33+
return
34+
}
35+
3236
mode := plugins.GetCfg("plugin_com.utmstack.gcp").Env.Mode
3337
if mode != "worker" {
3438
return

plugins/inputs/main.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ const defaultTenant string = "ce66672c-e36d-4761-a8c8-90058fee1a24"
1616
var localLogsChannel chan *plugins.Log
1717

1818
func main() {
19+
if os.Getenv("PLAYGROUND") == "true" {
20+
return
21+
}
22+
1923
mode := plugins.GetCfg("plugin_com.utmstack.inputs").Env.Mode
2024
if mode != "worker" {
2125
return

plugins/o365/main.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"fmt"
66
"net/http"
77
"net/url"
8+
"os"
89
"runtime"
910
"strings"
1011
"sync"
@@ -70,6 +71,10 @@ func GetCloudConfig(env CloudEnvironment) CloudConfig {
7071
}
7172

7273
func main() {
74+
if os.Getenv("PLAYGROUND") == "true" {
75+
return
76+
}
77+
7378
mode := plugins.GetCfg("plugin_com.utmstack.o365").Env.Mode
7479
if mode != "manager" {
7580
return

plugins/sophos/main.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"fmt"
66
"net/http"
77
"net/url"
8+
"os"
89
"runtime"
910
"strings"
1011
"sync"
@@ -32,6 +33,10 @@ var (
3233
)
3334

3435
func main() {
36+
if os.Getenv("PLAYGROUND") == "true" {
37+
return
38+
}
39+
3540
mode := plugins.GetCfg("plugin_com.utmstack.sophos").Env.Mode
3641
if mode != "manager" {
3742
return

plugins/threadwinds-ingestion/main.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ const (
1919
)
2020

2121
func main() {
22+
if os.Getenv("PLAYGROUND") == "true" {
23+
return
24+
}
25+
2226
mode := plugins.GetCfg("plugin_com.utmstack.threadwinds-ingestion").Env.Mode
2327
if mode != "manager" {
2428
return

0 commit comments

Comments
 (0)