@@ -16,6 +16,7 @@ package agent
16
16
17
17
import (
18
18
"github.com/argoproj-labs/argocd-agent/internal/event"
19
+ "github.com/argoproj-labs/argocd-agent/internal/logging/logfields"
19
20
"github.com/argoproj-labs/argocd-agent/internal/resources"
20
21
"github.com/argoproj-labs/argocd-agent/pkg/types"
21
22
"github.com/argoproj/argo-cd/v3/pkg/apis/application/v1alpha1"
@@ -26,7 +27,7 @@ import (
26
27
// addAppCreationToQueue processes a new application event originating from the
27
28
// AppInformer and puts it in the send queue.
28
29
func (a * Agent ) addAppCreationToQueue (app * v1alpha1.Application ) {
29
- logCtx := log ().WithField ("event" , "NewApp" ).WithField ("application" , app .QualifiedName ())
30
+ logCtx := log ().WithField (logfields . Event , "NewApp" ).WithField (logfields . Application , app .QualifiedName ())
30
31
logCtx .Debugf ("New app event" )
31
32
32
33
a .resources .Add (resources .NewResourceKeyFromApp (app ))
@@ -55,13 +56,13 @@ func (a *Agent) addAppCreationToQueue(app *v1alpha1.Application) {
55
56
}
56
57
57
58
q .Add (a .emitter .ApplicationEvent (event .Create , app ))
58
- logCtx .WithField ("sendq_len" , q .Len ()).WithField ("sendq_name" , defaultQueueName ).Debugf ("Added app create event to send queue" )
59
+ logCtx .WithField (logfields . SendQueueLen , q .Len ()).WithField (logfields . SendQueueName , defaultQueueName ).Debugf ("Added app create event to send queue" )
59
60
}
60
61
61
62
// addAppUpdateToQueue processes an application update event originating from
62
63
// the AppInformer and puts it in the agent's send queue.
63
64
func (a * Agent ) addAppUpdateToQueue (old * v1alpha1.Application , new * v1alpha1.Application ) {
64
- logCtx := log ().WithField ("event" , "UpdateApp" ).WithField ("application" , old .QualifiedName ())
65
+ logCtx := log ().WithField (logfields . Event , "UpdateApp" ).WithField (logfields . Application , old .QualifiedName ())
65
66
a .watchLock .Lock ()
66
67
defer a .watchLock .Unlock ()
67
68
if a .appManager .IsChangeIgnored (new .QualifiedName (), new .ResourceVersion ) {
@@ -101,15 +102,15 @@ func (a *Agent) addAppUpdateToQueue(old *v1alpha1.Application, new *v1alpha1.App
101
102
q .Add (a .emitter .ApplicationEvent (eventType , new ))
102
103
// q.Add(ev)
103
104
logCtx .
104
- WithField ("sendq_len" , q .Len ()).
105
- WithField ("sendq_name" , defaultQueueName ).
105
+ WithField (logfields . SendQueueLen , q .Len ()).
106
+ WithField (logfields . SendQueueName , defaultQueueName ).
106
107
Debugf ("Added event of type %s to send queue" , eventType )
107
108
}
108
109
109
110
// addAppDeletionToQueue processes an application delete event originating from
110
111
// the AppInformer and puts it in the send queue.
111
112
func (a * Agent ) addAppDeletionToQueue (app * v1alpha1.Application ) {
112
- logCtx := log ().WithField ("event" , "DeleteApp" ).WithField ("application" , app .QualifiedName ())
113
+ logCtx := log ().WithField (logfields . Event , "DeleteApp" ).WithField (logfields . Application , app .QualifiedName ())
113
114
logCtx .Debugf ("Delete app event" )
114
115
115
116
a .resources .Remove (resources .NewResourceKeyFromApp (app ))
@@ -128,13 +129,13 @@ func (a *Agent) addAppDeletionToQueue(app *v1alpha1.Application) {
128
129
}
129
130
130
131
q .Add (a .emitter .ApplicationEvent (event .Delete , app ))
131
- logCtx .WithField ("sendq_len" , q .Len ()).Debugf ("Added app delete event to send queue" )
132
+ logCtx .WithField (logfields . SendQueueLen , q .Len ()).Debugf ("Added app delete event to send queue" )
132
133
}
133
134
134
135
// deleteNamespaceCallback is called when the user deletes the agent namespace.
135
136
// Since there is no namespace we can remove the queue associated with this agent.
136
137
func (a * Agent ) deleteNamespaceCallback (outbound * corev1.Namespace ) {
137
- logCtx := log ().WithField ("event" , "DeleteNamespace" ).WithField ("agent" , outbound .Name )
138
+ logCtx := log ().WithField (logfields . Event , "DeleteNamespace" ).WithField (logfields . Agent , outbound .Name )
138
139
139
140
if ! a .queues .HasQueuePair (outbound .Name ) {
140
141
return
@@ -185,7 +186,7 @@ func (a *Agent) addAppProjectCreationToQueue(appProject *v1alpha1.AppProject) {
185
186
}
186
187
187
188
q .Add (a .emitter .AppProjectEvent (event .Create , appProject ))
188
- logCtx .WithField ("sendq_len" , q .Len ()).Debugf ("Added appProject create event to send queue" )
189
+ logCtx .WithField (logfields . SendQueueLen , q .Len ()).Debugf ("Added appProject create event to send queue" )
189
190
}
190
191
191
192
// addAppProjectUpdateToQueue processes an appProject update event originating from the
@@ -223,7 +224,7 @@ func (a *Agent) addAppProjectUpdateToQueue(old *v1alpha1.AppProject, new *v1alph
223
224
}
224
225
225
226
q .Add (a .emitter .AppProjectEvent (event .SpecUpdate , new ))
226
- logCtx .WithField ("sendq_len" , q .Len ()).Debugf ("Added appProject spec update event to send queue" )
227
+ logCtx .WithField (logfields . SendQueueLen , q .Len ()).Debugf ("Added appProject spec update event to send queue" )
227
228
}
228
229
229
230
// addAppProjectDeletionToQueue processes an appProject delete event originating from the
@@ -258,5 +259,5 @@ func (a *Agent) addAppProjectDeletionToQueue(appProject *v1alpha1.AppProject) {
258
259
}
259
260
260
261
q .Add (a .emitter .AppProjectEvent (event .Delete , appProject ))
261
- logCtx .WithField ("sendq_len" , q .Len ()).Debugf ("Added appProject delete event to send queue" )
262
+ logCtx .WithField (logfields . SendQueueLen , q .Len ()).Debugf ("Added appProject delete event to send queue" )
262
263
}
0 commit comments