-
Notifications
You must be signed in to change notification settings - Fork 392
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tracing: allow configuring policy mode via options
Example: ``` apiVersion: cilium.io/v1alpha1 kind: TracingPolicyNamespaced metadata: name: "enforce-test" namespace: "pizza" spec: options: - name: "policy-mode" value: "enforce" kprobes: ... ``` Signed-off-by: Kornilios Kourtis <kornilios@isovalent.com>
- Loading branch information
Showing
4 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// Copyright Authors of Tetragon | ||
|
||
package tracingpolicy | ||
|
||
import "fmt" | ||
|
||
type Mode uint8 | ||
|
||
const ( | ||
InvalidMode Mode = Mode(^uint8(0)) | ||
// NB: values below should match the ones in bpf/lib/policy_conf.h | ||
EnforceMode Mode = 0 | ||
MonitorMode Mode = 1 | ||
) | ||
|
||
func ParseMode(s string) (Mode, error) { | ||
switch s { | ||
case "enforce": | ||
return EnforceMode, nil | ||
case "monitor": | ||
return MonitorMode, nil | ||
} | ||
|
||
return InvalidMode, fmt.Errorf("invalid mode: %q", s) | ||
} |