@@ -20,6 +20,7 @@ import (
2020 "os"
2121 "reflect"
2222 "strconv"
23+ "strings"
2324
2425 appsv1 "k8s.io/api/apps/v1"
2526 corev1 "k8s.io/api/core/v1"
@@ -329,6 +330,18 @@ func buildAgentContainerEnv(cr *argoproj.ArgoCD) []corev1.EnvVar {
329330 Name : EnvArgoCDAgentEnableResourceProxy ,
330331 Value : "true" ,
331332 },
333+ {
334+ Name : EnvArgoCDAgentDestinationBasedMap ,
335+ Value : getAgentDestinationBasedMapping (cr ),
336+ },
337+ {
338+ Name : EnvArgoCDAgentCreateNamespace ,
339+ Value : getAgentCreateNamespace (cr ),
340+ },
341+ {
342+ Name : EnvArgoCDAgentAllowedNamespaces ,
343+ Value : getAgentAllowedNamespaces (cr ),
344+ },
332345 {
333346 Name : EnvRedisPassword ,
334347 ValueFrom : & corev1.EnvVarSource {
@@ -373,6 +386,9 @@ const (
373386 EnvRedisPassword = "REDIS_PASSWORD"
374387 AgentRedisPasswordKey = "admin.password"
375388 AgentRedisSecretnameSuffix = "redis-initial-password" // #nosec G101
389+ EnvArgoCDAgentDestinationBasedMap = "ARGOCD_AGENT_DESTINATION_BASED_MAPPING"
390+ EnvArgoCDAgentCreateNamespace = "ARGOCD_AGENT_CREATE_NAMESPACE"
391+ EnvArgoCDAgentAllowedNamespaces = "ARGOCD_AGENT_ALLOWED_NAMESPACES"
376392)
377393
378394// Logging Configuration
@@ -383,6 +399,33 @@ func getAgentLogLevel(cr *argoproj.ArgoCD) string {
383399 return "info"
384400}
385401
402+ func getAgentDestinationBasedMapping (cr * argoproj.ArgoCD ) string {
403+ if hasAgent (cr ) {
404+ dm := cr .Spec .ArgoCDAgent .Agent .DestinationBasedMapping
405+ if dm != nil && dm .IsEnabled () {
406+ return "true"
407+ }
408+ }
409+ return "false"
410+ }
411+
412+ func getAgentCreateNamespace (cr * argoproj.ArgoCD ) string {
413+ if hasAgent (cr ) {
414+ dm := cr .Spec .ArgoCDAgent .Agent .DestinationBasedMapping
415+ if dm != nil && dm .IsCreateNamespaceEnabled () {
416+ return "true"
417+ }
418+ }
419+ return "false"
420+ }
421+
422+ func getAgentAllowedNamespaces (cr * argoproj.ArgoCD ) string {
423+ if hasAgent (cr ) && len (cr .Spec .ArgoCDAgent .Agent .AllowedNamespaces ) > 0 {
424+ return strings .Join (cr .Spec .ArgoCDAgent .Agent .AllowedNamespaces , "," )
425+ }
426+ return ""
427+ }
428+
386429func getAgentLogFormat (cr * argoproj.ArgoCD ) string {
387430 if hasAgent (cr ) && cr .Spec .ArgoCDAgent .Agent .LogFormat != "" {
388431 return cr .Spec .ArgoCDAgent .Agent .LogFormat
0 commit comments