Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tetragon: Add map ownership #2945

Merged
merged 7 commits into from
Sep 30, 2024
Merged
Changes from 1 commit
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
27 changes: 27 additions & 0 deletions pkg/sensors/program/map.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,17 @@
// - map is local for program, not shared at all
//
// NOTE Please do not share MapTypeProgram maps, it brings confusion.
//
// Each map declares the ownership of the map. The map can be either
// owner of the map (via MapBuilder* helpers) or as an user (MapUser*
// helpers.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding the comments!

//
// Map owner object owns the pinned map and when loading it sets (and
// potentially overwrite) the map's spec and its max entries value.
//
// Map user object object is just using the pinned map and follows its
// setup and will fail if the pinned map differs in spec or configured
// max entries value.

package program

Expand Down Expand Up @@ -138,6 +149,22 @@ func MapBuilderOpts(name string, opts MapOpts, lds ...*Program) *Map {
return mapBuilder(name, opts.Type, opts.Owner, lds...)
}

func MapUser(name string, lds ...*Program) *Map {
return mapBuilder(name, MapTypeGlobal, false, lds...)
}

func MapUserProgram(name string, lds ...*Program) *Map {
return mapBuilder(name, MapTypeProgram, false, lds...)
}

func MapUserSensor(name string, lds ...*Program) *Map {
return mapBuilder(name, MapTypeSensor, false, lds...)
}

func MapUserPolicy(name string, lds ...*Program) *Map {
return mapBuilder(name, MapTypePolicy, false, lds...)
}

func PolicyMapPath(mapDir, policy, name string) string {
return filepath.Join(mapDir, policy, name)
}
Expand Down