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
2 changes: 1 addition & 1 deletion inspektor-gadget/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func (p *InspektorGadgetPlugin) httpInvoke(operation string, handler func(contex
res, err := handler(r.Context(), sdk.InvokeCtx{
Operation: operation,
ParamsJSON: params,
ConfigItemID: sdk.ConfigItemIDFromContext(r.Context()),
ConfigItemID: configItemIDFromRequest(r),
Host: sdk.HostClientFromContext(r.Context()),
})
if err != nil {
Expand Down
16 changes: 16 additions & 0 deletions inspektor-gadget/http_test.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,30 @@
package main

import (
"context"
"net/http"
"net/http/httptest"

"github.com/flanksource/incident-commander/plugin/sdk"
ginkgo "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)

var _ = ginkgo.Describe("http", func() {
ginkgo.It("passes config_id query parameters into operation invoke context", func() {
plugin := newPlugin()
handler := plugin.httpInvoke("trace-list", func(_ context.Context, req sdk.InvokeCtx) (any, error) {
Expect(req.ConfigItemID).To(Equal("config-123"))
return map[string]string{"ok": "true"}, nil
})

rec := httptest.NewRecorder()
req := httptest.NewRequest(http.MethodPost, "/trace-list?config_id=config-123", nil)
handler.ServeHTTP(rec, req)

Expect(rec.Code).To(Equal(http.StatusOK))
})

ginkgo.It("exports buffered events as an attachment", func() {
plugin := newPlugin()
gadget, ok := gadgetByID("trace_exec", defaultIGTag)
Expand Down
12 changes: 6 additions & 6 deletions inspektor-gadget/ui-src/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,11 @@ function App() {
return () => window.clearInterval(timer);
}, []);

const activeSession = useMemo(
() => sessions.find((session) => session.id === selectedSession) || null,
[sessions, selectedSession]
);

useEffect(() => {
setEvents([]);
if (!selectedSession) return;
Expand All @@ -257,12 +262,7 @@ function App() {
return () => {
cancelled = true;
};
}, [selectedSession]);

const activeSession = useMemo(
() => sessions.find((session) => session.id === selectedSession) || null,
[sessions, selectedSession]
);
}, [selectedSession, activeSession?.state]);
const activeGadgetSpec = useMemo(
() => gadgets.find((gadget) => gadget.id === activeSession?.gadgetId) || null,
[gadgets, activeSession?.gadgetId]
Expand Down
Loading