diff --git a/admission/rules/v1/helpers.go b/admission/rules/v1/helpers.go index 6536e32..e278be2 100644 --- a/admission/rules/v1/helpers.go +++ b/admission/rules/v1/helpers.go @@ -85,19 +85,3 @@ func GetContainerNameFromExecToPodEvent(event admission.Attributes) string { } return "" } - -// GetContainerNameFromPortForwardEvent returns the container name from the admission event for port-forward operations. -func GetContainerNameFromPortForwardEvent(event admission.Attributes) string { - if event.GetSubresource() == "portforward" { - if obj := event.GetObject(); obj != nil { - if unstructuredObj, ok := obj.(*unstructured.Unstructured); ok { - if object, ok := unstructuredObj.Object["object"].(map[string]interface{}); ok { - if containerName, ok := object["container"].(string); ok { - return containerName - } - } - } - } - } - return "" -} diff --git a/admission/rules/v1/r2001_portforward.go b/admission/rules/v1/r2001_portforward.go index 93e6953..c723eee 100644 --- a/admission/rules/v1/r2001_portforward.go +++ b/admission/rules/v1/r2001_portforward.go @@ -76,8 +76,6 @@ func (rule *R2001PortForward) ProcessEvent(event admission.Attributes, access in logger.L().Error("Failed to get parent workload details", helpers.Error(err)) return nil } - containerName := GetContainerNameFromPortForwardEvent(event) - ruleFailure := GenericRuleFailure{ BaseRuntimeAlert: apitypes.BaseRuntimeAlert{ AlertName: rule.Name(), @@ -114,7 +112,6 @@ func (rule *R2001PortForward) ProcessEvent(event admission.Attributes, access in WorkloadNamespace: workloadNamespace, WorkloadKind: workloadKind, NodeName: nodeName, - ContainerName: containerName, }, RuleID: R2001ID, }