@@ -2,9 +2,7 @@ package main
2
2
3
3
import (
4
4
"context"
5
- "errors"
6
5
"fmt"
7
- "runtime"
8
6
"time"
9
7
10
8
log "github.com/sirupsen/logrus"
@@ -25,24 +23,9 @@ func initAPIServer(ctx context.Context, cConfig *csconfig.Config) (*apiserver.AP
25
23
return nil , fmt .Errorf ("unable to run local API: %w" , err )
26
24
}
27
25
28
- if hasPlugins (cConfig .API .Server .Profiles ) {
29
- log .Info ("initiating plugin broker" )
30
- // On windows, the plugins are always run as medium-integrity processes, so we don't care about plugin_config
31
- if cConfig .PluginConfig == nil && runtime .GOOS != "windows" {
32
- return nil , errors .New ("plugins are enabled, but the plugin_config section is missing in the configuration" )
33
- }
34
-
35
- if cConfig .ConfigPaths .PluginDir == "" {
36
- return nil , errors .New ("plugins are enabled, but config_paths.plugin_dir is not defined" )
37
- }
38
-
39
- err = pluginBroker .Init (ctx , cConfig .PluginConfig , cConfig .API .Server .Profiles , cConfig .ConfigPaths )
40
- if err != nil {
41
- return nil , fmt .Errorf ("plugin broker: %w" , err )
42
- }
43
-
44
- log .Info ("initiated plugin broker" )
45
- apiServer .AttachPluginBroker (& pluginBroker )
26
+ err = apiServer .InitPlugins (ctx , cConfig , & pluginBroker )
27
+ if err != nil {
28
+ return nil , err
46
29
}
47
30
48
31
err = apiServer .InitController ()
@@ -81,13 +64,3 @@ func serveAPIServer(apiServer *apiserver.APIServer) {
81
64
})
82
65
<- apiReady
83
66
}
84
-
85
- func hasPlugins (profiles []* csconfig.ProfileCfg ) bool {
86
- for _ , profile := range profiles {
87
- if len (profile .Notifications ) != 0 {
88
- return true
89
- }
90
- }
91
-
92
- return false
93
- }
0 commit comments