Skip to content

Commit

Permalink
add logging plugin to test environment
Browse files Browse the repository at this point in the history
  • Loading branch information
kralicky committed Oct 4, 2022
1 parent 9ed471c commit 4b2f0f8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
14 changes: 13 additions & 1 deletion pkg/test/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import (
"github.com/rancher/opni/pkg/plugins/meta"
"github.com/rancher/opni/plugins/alerting/pkg/alerting"
"github.com/rancher/opni/plugins/example/pkg/example"
logging_agent "github.com/rancher/opni/plugins/logging/pkg/agent"
logging_gateway "github.com/rancher/opni/plugins/logging/pkg/gateway"
metrics_agent "github.com/rancher/opni/plugins/metrics/pkg/agent"
metrics_gateway "github.com/rancher/opni/plugins/metrics/pkg/gateway"
"github.com/rancher/opni/plugins/slo/pkg/slo"
Expand Down Expand Up @@ -81,15 +83,17 @@ type testPlugin struct {
}

func LoadPlugins(loader *plugins.PluginLoader, mode meta.PluginMode) int {
var metricsPluginScheme meta.Scheme
var metricsPluginScheme, loggingPluginScheme meta.Scheme
var scheme meta.Scheme
switch mode {
case meta.ModeGateway:
scheme = plugins.GatewayScheme
metricsPluginScheme = metrics_gateway.Scheme(context.Background())
loggingPluginScheme = logging_gateway.Scheme(context.Background())
case meta.ModeAgent:
scheme = plugins.AgentScheme
metricsPluginScheme = metrics_agent.Scheme(context.Background())
loggingPluginScheme = logging_agent.Scheme(context.Background())
default:
panic("unknown plugin mode: " + mode)
}
Expand All @@ -103,6 +107,14 @@ func LoadPlugins(loader *plugins.PluginLoader, mode meta.PluginMode) int {
Module: "github.com/rancher/opni/plugins/metrics",
},
},
{
Scheme: loggingPluginScheme,
Metadata: meta.PluginMeta{
BinaryPath: "plugin_logging",
GoVersion: runtime.Version(),
Module: "github.com/rancher/opni/plugins/logging",
},
},
{
Scheme: example.Scheme(context.Background()),
Metadata: meta.PluginMeta{
Expand Down
2 changes: 1 addition & 1 deletion plugins/logging/pkg/gateway/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ func Scheme(ctx context.Context) meta.Scheme {
p.manageFlag = p.featureOverride
}

if !p.manageFlag.IsEnabled() {
if p.manageFlag != nil && !p.manageFlag.IsEnabled() {
go p.setOpensearchClient()
}

Expand Down

0 comments on commit 4b2f0f8

Please sign in to comment.