@@ -87,6 +87,9 @@ func NewAgentRunCommand() *cobra.Command {
8787 // Destination-based mapping options
8888 createNamespace bool
8989 destinationBasedMapping bool
90+
91+ // Allowed namespaces for filtering applications
92+ allowedNamespaces []string
9093 )
9194 command := & cobra.Command {
9295 Use : "agent" ,
@@ -238,6 +241,7 @@ func NewAgentRunCommand() *cobra.Command {
238241 agentOpts = append (agentOpts , agent .WithHeartbeatInterval (heartbeatInterval ))
239242 agentOpts = append (agentOpts , agent .WithCreateNamespace (createNamespace ))
240243 agentOpts = append (agentOpts , agent .WithDestinationBasedMapping (destinationBasedMapping ))
244+ agentOpts = append (agentOpts , agent .WithAllowedNamespaces (allowedNamespaces ... ))
241245
242246 if metricsPort > 0 {
243247 agentOpts = append (agentOpts , agent .WithMetricsPort (metricsPort ))
@@ -362,6 +366,9 @@ func NewAgentRunCommand() *cobra.Command {
362366 command .Flags ().BoolVar (& createNamespace , "create-namespace" ,
363367 env .BoolWithDefault ("ARGOCD_AGENT_CREATE_NAMESPACE" , false ),
364368 "Create target namespace if it doesn't exist when syncing applications (used with destination-based-mapping)" )
369+ command .Flags ().StringSliceVar (& allowedNamespaces , "allowed-namespaces" ,
370+ env .StringSliceWithDefault ("ARGOCD_AGENT_ALLOWED_NAMESPACES" , nil , []string {}),
371+ "List of additional namespaces the agent is allowed to manage applications in" )
365372
366373 command .Flags ().StringVar (& kubeConfig , "kubeconfig" , "" , "Path to a kubeconfig file to use" )
367374 command .Flags ().StringVar (& kubeContext , "kubecontext" , "" , "Override the default kube context" )
0 commit comments