-
Notifications
You must be signed in to change notification settings - Fork 384
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move tracing policy types to a separate file
Signed-off-by: Michi Mutsuzaki <michi@isovalent.com>
- Loading branch information
1 parent
0c4394b
commit 0de4662
Showing
4 changed files
with
244 additions
and
236 deletions.
There are no files selected for viewing
122 changes: 122 additions & 0 deletions
122
pkg/k8s/apis/cilium.io/v1alpha1/tracing_policy_types.go
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,122 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// Copyright Authors of Tetragon | ||
|
||
package v1alpha1 | ||
|
||
import ( | ||
"fmt" | ||
|
||
slimv1 "github.com/cilium/cilium/pkg/k8s/slim/k8s/apis/meta/v1" | ||
ciliumio "github.com/cilium/tetragon/pkg/k8s/apis/cilium.io" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
const ( | ||
// Tracing Policy (TP) | ||
|
||
// TPPluralName is the plural name of Cilium Tracing Policy | ||
TPPluralName = "tracingpolicies" | ||
|
||
// TPKindDefinition is the kind name of Cilium Tracing Policy | ||
TPKindDefinition = "TracingPolicy" | ||
|
||
// TPName is the full name of Cilium Egress NAT Policy | ||
TPName = TPPluralName + "." + ciliumio.GroupName | ||
|
||
// TPNamespacedPluralName is the plural name of Cilium Tracing Policy | ||
TPNamespacedPluralName = "tracingpoliciesnamespaced" | ||
|
||
// TPNamespacedName | ||
TPNamespacedName = TPNamespacedPluralName + "." + ciliumio.GroupName | ||
|
||
// TPKindDefinition is the kind name of Cilium Tracing Policy | ||
TPNamespacedKindDefinition = "TracingPolicyNamespaced" | ||
) | ||
|
||
// +genclient | ||
// +genclient:noStatus | ||
// +genclient:nonNamespaced | ||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object | ||
// +kubebuilder:resource:singular="tracingpolicy",path="tracingpolicies",scope="Cluster",shortName={} | ||
type TracingPolicy struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata"` | ||
// Tracing policy specification. | ||
Spec TracingPolicySpec `json:"spec"` | ||
} | ||
|
||
// +genclient | ||
// +genclient:noStatus | ||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object | ||
// +kubebuilder:resource:singular="tracingpolicynamespaced",path="tracingpoliciesnamespaced",scope="Namespaced",shortName={} | ||
type TracingPolicyNamespaced struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata"` | ||
// Tracing policy specification. | ||
Spec TracingPolicySpec `json:"spec"` | ||
} | ||
|
||
func (tp *TracingPolicyNamespaced) TpSpec() *TracingPolicySpec { | ||
return &tp.Spec | ||
} | ||
|
||
func (tp *TracingPolicyNamespaced) TpInfo() string { | ||
return fmt.Sprintf("%s (object:%d/%s) (type:%s/%s)", tp.ObjectMeta.Name, tp.ObjectMeta.Generation, tp.ObjectMeta.UID, tp.TypeMeta.Kind, tp.TypeMeta.APIVersion) | ||
} | ||
|
||
func (tp *TracingPolicyNamespaced) TpName() string { | ||
return tp.ObjectMeta.Name | ||
} | ||
|
||
func (tp *TracingPolicyNamespaced) TpNamespace() string { | ||
return tp.ObjectMeta.Namespace | ||
} | ||
|
||
type TracingPolicySpec struct { | ||
// +kubebuilder:validation:Optional | ||
// A list of kprobe specs. | ||
KProbes []KProbeSpec `json:"kprobes,omitempty"` | ||
// +kubebuilder:validation:Optional | ||
// A list of tracepoint specs. | ||
Tracepoints []TracepointSpec `json:"tracepoints,omitempty"` | ||
// +kubebuilder:validation:Optional | ||
// Enable loader events | ||
Loader bool `json:"loader,omitempty"` | ||
// +kubebuilder:validation:Optional | ||
// A list of uprobe specs. | ||
UProbes []UProbeSpec `json:"uprobes,omitempty"` | ||
|
||
// +kubebuilder:validation:Optional | ||
// PodSelector selects pods that this policy applies to | ||
PodSelector *slimv1.LabelSelector `json:"podSelector,omitempty"` | ||
|
||
// +kubebuilder:validation:Optional | ||
// A list of list specs. | ||
Lists []ListSpec `json:"lists,omitempty"` | ||
} | ||
|
||
func (tp *TracingPolicy) TpName() string { | ||
return tp.ObjectMeta.Name | ||
} | ||
|
||
func (tp *TracingPolicy) TpSpec() *TracingPolicySpec { | ||
return &tp.Spec | ||
} | ||
|
||
func (tp *TracingPolicy) TpInfo() string { | ||
return fmt.Sprintf("%s (object:%d/%s) (type:%s/%s)", tp.ObjectMeta.Name, tp.ObjectMeta.Generation, tp.ObjectMeta.UID, tp.TypeMeta.Kind, tp.TypeMeta.APIVersion) | ||
} | ||
|
||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object | ||
type TracingPolicyList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata"` | ||
Items []TracingPolicy `json:"items"` | ||
} | ||
|
||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object | ||
type TracingPolicyNamespacedList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata"` | ||
Items []TracingPolicyNamespaced `json:"items"` | ||
} |
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
122 changes: 122 additions & 0 deletions
122
vendor/github.com/cilium/tetragon/pkg/k8s/apis/cilium.io/v1alpha1/tracing_policy_types.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.