Skip to content

Commit 014f614

Browse files
committed
refactor: folder name change from workers to hooks
1 parent 852f8ea commit 014f614

8 files changed

Lines changed: 16 additions & 16 deletions

File tree

cmd/bootstrapper.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"github.com/chen-keinan/kube-knark/internal/startup"
1111
"github.com/chen-keinan/kube-knark/internal/tracer/kexec"
1212
"github.com/chen-keinan/kube-knark/internal/tracer/khttp"
13-
"github.com/chen-keinan/kube-knark/internal/workers"
13+
"github.com/chen-keinan/kube-knark/internal/hooks"
1414
"github.com/chen-keinan/kube-knark/pkg/model"
1515
"github.com/chen-keinan/kube-knark/pkg/model/execevent"
1616
"github.com/chen-keinan/kube-knark/pkg/model/netevent"
@@ -49,13 +49,13 @@ func StartKnark() {
4949
fx.Provide(ui.NewKubeKnarkUI),
5050
fx.Provide(numOfWorkers),
5151
fx.Provide(matchCmdChan),
52-
fx.Provide(workers.NewCommandMatchesWorker),
52+
fx.Provide(hooks.NewCommandMatchesWorker),
5353
// init packet workers
5454
fx.Provide(matchNetChan),
55-
fx.Provide(workers.NewPacketMatchesWorker),
56-
fx.Provide(workers.NewPacketMatchData),
55+
fx.Provide(hooks.NewPacketMatchesWorker),
56+
fx.Provide(hooks.NewPacketMatchData),
5757
fx.Provide(matches.NewFSMatches),
58-
fx.Provide(workers.NewCommandMatchesData),
58+
fx.Provide(hooks.NewCommandMatchesData),
5959
fx.Provide(ui.NewFilesystemEvtChan),
6060
fx.Invoke(runKnarkService),
6161
)
@@ -71,8 +71,8 @@ func runKnarkService(lifecycle fx.Lifecycle,
7171
files []utils.FilesInfo,
7272
NetEventChan chan *netevent.HTTPNetData,
7373
cmdEventChan chan *execevent.KprobeEvent,
74-
cm *workers.CommandMatchesWorker,
75-
pm *workers.PacketMatchesWorker) {
74+
cm *hooks.CommandMatchesWorker,
75+
pm *hooks.PacketMatchesWorker) {
7676

7777
lifecycle.Append(fx.Hook{OnStart: func(context.Context) error {
7878
quitChan := make(chan bool)
@@ -255,7 +255,7 @@ func getDataFileContent() ([]string, error) {
255255
}
256256

257257
//LoadAPICallPluginSymbols load API call plugin symbols
258-
func LoadAPICallPluginSymbols(log *zap.Logger) workers.K8sAPICallHook {
258+
func LoadAPICallPluginSymbols(log *zap.Logger) hooks.K8sAPICallHook {
259259
fm := utils.NewKFolder()
260260
sourceFolder, err := utils.GetPluginSourceSubFolder(fm)
261261
if err != nil {
@@ -271,7 +271,7 @@ func LoadAPICallPluginSymbols(log *zap.Logger) workers.K8sAPICallHook {
271271
if err != nil {
272272
panic(fmt.Sprintf("failed to get plugin compiled plugins %s", err.Error()))
273273
}
274-
apiPlugin := workers.K8sAPICallHook{Plugins: make([]plugin.Symbol, 0), Plug: pl}
274+
apiPlugin := hooks.K8sAPICallHook{Plugins: make([]plugin.Symbol, 0), Plug: pl}
275275
for _, name := range names {
276276
sym, err := pl.Load(name, common.OnK8sAPICallHook)
277277
if err != nil {
@@ -284,7 +284,7 @@ func LoadAPICallPluginSymbols(log *zap.Logger) workers.K8sAPICallHook {
284284
}
285285

286286
//LoadFileChangePluginSymbols load config file change plugin symbols
287-
func LoadFileChangePluginSymbols(log *zap.Logger) workers.K8sFileConfigChangeHook {
287+
func LoadFileChangePluginSymbols(log *zap.Logger) hooks.K8sFileConfigChangeHook {
288288
fm := utils.NewKFolder()
289289
sourceFolder, err := utils.GetPluginSourceSubFolder(fm)
290290
if err != nil {
@@ -300,7 +300,7 @@ func LoadFileChangePluginSymbols(log *zap.Logger) workers.K8sFileConfigChangeHoo
300300
if err != nil {
301301
panic(fmt.Sprintf("failed to get plugin compiled plugins %s", err.Error()))
302302
}
303-
filePlugin := workers.K8sFileConfigChangeHook{Plugins: make([]plugin.Symbol, 0), Plug: pl}
303+
filePlugin := hooks.K8sFileConfigChangeHook{Plugins: make([]plugin.Symbol, 0), Plug: pl}
304304
for _, name := range names {
305305
sym, err := pl.Load(name, common.OnK8sFileConfigChangeHook)
306306
if err != nil {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package workers
1+
package hooks
22

33
import (
44
"bytes"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package workers
1+
package hooks
22

33
import (
44
"fmt"
File renamed without changes.

internal/kplugin/fixtures/on_k8s_file_config_change_hook.go renamed to internal/hooks/fixtures/on_k8s_file_config_change_hook.go

File renamed without changes.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package workers
1+
package hooks
22

33
import (
44
"fmt"
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package workers
1+
package hooks
22

33
import (
44
"fmt"
@@ -123,7 +123,7 @@ func pluginSetUp(fileName string) (*uplugin.PluginLoader, error) {
123123
if err != nil {
124124
return nil, err
125125
}
126-
f, err := os.Open(fmt.Sprintf("./../kplugin/fixtures/%s", fileName))
126+
f, err := os.Open(fmt.Sprintf("./fixtures/%s", fileName))
127127
if err != nil {
128128
return nil, err
129129
}

0 commit comments

Comments
 (0)