Skip to content

Commit

Permalink
better output
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Labarussias <issif+github@gadz.org>
  • Loading branch information
Issif committed Jan 24, 2024
1 parent 87cb896 commit 8a5c8ac
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions actionners/kubernetes/networkpolicy/networkpolicy.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,14 +187,14 @@ var NetworkPolicy = func(rule *rules.Rule, action *rules.Action, event *events.E
payload.Spec.Egress = []networkingv1.NetworkPolicyEgressRule{*np}
}

var status string
var output string
_, err = client.NetworkingV1().NetworkPolicies(namespace).Get(context.Background(), owner, metav1.GetOptions{})
if errorsv1.IsNotFound(err) {
_, err = client.NetworkingV1().NetworkPolicies(namespace).Create(context.Background(), &payload, metav1.CreateOptions{})
status = fmt.Sprintf("The NetworkPolicy '%v' in the namespace '%v' has been created", owner, namespace)
output = fmt.Sprintf("The NetworkPolicy '%v' in the Namespace '%v' has been created", owner, namespace)
} else {
_, err = client.NetworkingV1().NetworkPolicies(namespace).Update(context.Background(), &payload, metav1.UpdateOptions{})
status = fmt.Sprintf("The NetworkPolicy '%v' in the namespace '%v' has been updated", owner, namespace)
output = fmt.Sprintf("The NetworkPolicy '%v' in the Namespace '%v' has been updated", owner, namespace)
}
if err != nil {
return utils.LogLine{
Expand All @@ -207,7 +207,7 @@ var NetworkPolicy = func(rule *rules.Rule, action *rules.Action, event *events.E
objects["NetworkPolicy"] = owner
return utils.LogLine{
Objects: objects,
Output: status,
Output: output,
Status: "success",
},
nil
Expand Down

0 comments on commit 8a5c8ac

Please sign in to comment.