diff --git a/internal/source/ai-brain/assistant.go b/internal/source/ai-brain/assistant.go index ea8207b..a4c09ed 100644 --- a/internal/source/ai-brain/assistant.go +++ b/internal/source/ai-brain/assistant.go @@ -66,7 +66,7 @@ func newAssistant(cfg *Config, log logrus.FieldLogger, out chan source.Event, ku tracer := otel.Tracer(serviceName) kcRunner := NewKubectlRunner(kubeConfigPath, tracer) - bkRunner, err := NewBotkubeRunner(kcRunner, tracer) + bkRunner, err := NewBotkubeRunner(tracer) if err != nil { return nil, fmt.Errorf("while creating Botkube runner: %w", err) } @@ -92,7 +92,6 @@ func newAssistant(cfg *Config, log logrus.FieldLogger, out chan source.Event, ku "kubectlTopNodes": kcRunner.TopNodes, "kubectlLogs": kcRunner.Logs, "botkubeGetStartupAgentConfiguration": bkRunner.GetStartupAgentConfiguration, - "botkubeGetCloudAgentConfiguration": bkRunner.GetCloudAgentConfiguration, // TODO: do we need that? "botkubeGetAgentStatus": bkRunner.GetAgentStatus, }, }, nil diff --git a/internal/source/ai-brain/botkube_tools.go b/internal/source/ai-brain/botkube_tools.go index 4eb2a42..c090721 100644 --- a/internal/source/ai-brain/botkube_tools.go +++ b/internal/source/ai-brain/botkube_tools.go @@ -27,16 +27,17 @@ type BotkubeRunner struct { httpCli *http.Client rawStartupConfig string startupConfig *ConfigWithDetails - logGetter LogGetter } -// LogGetter provides ability to get logs. -type LogGetter interface { - Logs(ctx context.Context, rawArgs []byte, _ *Payload) (string, error) +// ConfigWithDetails represents Botkube configuration with additional details. +type ConfigWithDetails struct { + *config.Config `yaml:",inline"` + LoaderValidationWarnings string `yaml:"loaderValidationWarnings"` + IncomingRequestPrompt string `yaml:"incomingRequestPrompt,omitempty"` } // NewBotkubeRunner creates new runner instance. -func NewBotkubeRunner(logGetter LogGetter, tracer trace.Tracer) (*BotkubeRunner, error) { +func NewBotkubeRunner(tracer trace.Tracer) (*BotkubeRunner, error) { cfg, ok := remote.GetConfig() if !ok { return nil, fmt.Errorf("cannot get Botkube cloud related environment variables") @@ -46,7 +47,6 @@ func NewBotkubeRunner(logGetter LogGetter, tracer trace.Tracer) (*BotkubeRunner, tracer: tracer, deployCli: remote.NewDeploymentClient(cfg), httpCli: httpx.NewHTTPClient(), - logGetter: logGetter, } err := r.initStartupConfig() @@ -56,18 +56,6 @@ func NewBotkubeRunner(logGetter LogGetter, tracer trace.Tracer) (*BotkubeRunner, return r, nil } -type ConfigWithDetails struct { - *config.Config `yaml:",inline"` - LoaderValidationWarnings string `yaml:"loaderValidationWarnings"` - IncomingRequestPrompt string `yaml:"incomingRequestPrompt,omitempty"` -} - -// TODO: to remove? -func (r *BotkubeRunner) GetCloudAgentConfiguration(ctx context.Context, _ []byte, _ *Payload) (string, error) { - rawCfg, _, err := r.fetchConfig(ctx) - return rawCfg, err -} - // GetStartupAgentConfiguration returns Botkube startup configuration. func (r *BotkubeRunner) GetStartupAgentConfiguration(ctx context.Context, _ []byte, p *Payload) (string, error) { _, span := r.tracer.Start(ctx, "aibrain.BotkubeRunner.GetStartupAgentConfiguration") @@ -91,6 +79,7 @@ func (r *BotkubeRunner) GetStartupAgentConfiguration(ctx context.Context, _ []by return string(raw), nil } +// GetAgentStatus returns Botkube Agent health status. func (r *BotkubeRunner) GetAgentStatus(ctx context.Context, _ []byte, _ *Payload) (string, error) { _, span := r.tracer.Start(ctx, "aibrain.BotkubeRunner.GetAgentStatus") defer span.End()