Skip to content

Commit

Permalink
Sync namespace for Event to the Application namespace (#847)
Browse files Browse the repository at this point in the history
Signed-off-by: Jort Koopmans <[email protected]>
  • Loading branch information
jortkoopmans committed Sep 1, 2024
1 parent 8c9e269 commit fd60c85
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions pkg/kube/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,14 @@ func (client *KubernetesClient) GetSecretField(namespace string, secretName stri
}
}

// CreateApplicationevent creates a kubernetes event with a custom reason and message for an application.
// CreateApplicationEvent creates a kubernetes event with a custom reason and message for an application.
func (client *KubernetesClient) CreateApplicationEvent(app *appv1alpha1.Application, reason string, message string, annotations map[string]string) (*v1.Event, error) {
t := metav1.Time{Time: time.Now()}

event := v1.Event{
ObjectMeta: metav1.ObjectMeta{
Name: fmt.Sprintf("%v.%x", app.ObjectMeta.Name, t.UnixNano()),
Namespace: client.Namespace,
Namespace: app.ObjectMeta.Namespace,
Annotations: annotations,
},
Source: v1.EventSource{
Expand All @@ -125,7 +125,7 @@ func (client *KubernetesClient) CreateApplicationEvent(app *appv1alpha1.Applicat
Reason: reason,
}

result, err := client.Clientset.CoreV1().Events(client.Namespace).Create(client.Context, &event, metav1.CreateOptions{})
result, err := client.Clientset.CoreV1().Events(app.ObjectMeta.Namespace).Create(client.Context, &event, metav1.CreateOptions{})
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/kube/kubernetes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,6 @@ func Test_CreateApplicationEvent(t *testing.T) {
require.NoError(t, err)
require.NotNil(t, event)
assert.Equal(t, "ArgocdImageUpdater", event.Source.Component)
assert.Equal(t, "default", client.Namespace)
assert.Equal(t, "argocd", event.Namespace)
})
}

0 comments on commit fd60c85

Please sign in to comment.