Skip to content

Commit

Permalink
Fix functions
Browse files Browse the repository at this point in the history
Signed-off-by: jnathangreeg <[email protected]>
  • Loading branch information
jnathangreeg committed Aug 25, 2024
1 parent 2193a1f commit b9e6834
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
9 changes: 4 additions & 5 deletions admission/rules/v1/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ func resolveJob(ownerRef metav1.OwnerReference, namespace string, clientset kube
return "Job", ownerRef.Name, namespace
}

// getContainerNameFromExecToPodEvent returns the container name from the admission event for exec operations.
func getContainerNameFromExecToPodEvent(event admission.Attributes) string {
// GetContainerNameFromExecToPodEvent returns the container name from the admission event for exec operations.
func GetContainerNameFromExecToPodEvent(event admission.Attributes) string {
if event.GetSubresource() == "exec" {
if obj := event.GetObject(); obj != nil {
if unstructuredObj, ok := obj.(*unstructured.Unstructured); ok {
Expand All @@ -86,8 +86,8 @@ 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 {
// 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 {
Expand All @@ -101,4 +101,3 @@ func getContainerNameFromPortForwardEvent(event admission.Attributes) string {
}
return ""
}

2 changes: 1 addition & 1 deletion admission/rules/v1/r2000_exec_to_pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func (rule *R2000ExecToPod) ProcessEvent(event admission.Attributes, access inte
return nil
}

containerName := getContainerNameFromExecToPodEvent(event)
containerName := GetContainerNameFromExecToPodEvent(event)

ruleFailure := GenericRuleFailure{
BaseRuntimeAlert: apitypes.BaseRuntimeAlert{
Expand Down
2 changes: 1 addition & 1 deletion admission/rules/v1/r2001_portforward.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ 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)
containerName := GetContainerNameFromPortForwardEvent(event)

ruleFailure := GenericRuleFailure{
BaseRuntimeAlert: apitypes.BaseRuntimeAlert{
Expand Down

0 comments on commit b9e6834

Please sign in to comment.