@@ -32,17 +32,19 @@ public class PodPatcher : IPodPatcher
3232 private readonly IClusterIdState _clusterIdState ;
3333 private readonly OperatorOptions _operatorOptions ;
3434 private readonly InitContainerOptions _initOptions ;
35+ private readonly TelemetryOptions _telemetryOptions ;
3536 private readonly IAgentInjectionTypeConverter _agentTypeConverter ;
3637
3738 public PodPatcher ( Func < IEnumerable < IAgentPatcher > > patchersFactory , IGlobMatcher globMatcher ,
3839 IClusterIdState clusterIdState , OperatorOptions operatorOptions , InitContainerOptions initOptions ,
39- IAgentInjectionTypeConverter agentTypeConverter )
40+ TelemetryOptions telemetryOptions , IAgentInjectionTypeConverter agentTypeConverter )
4041 {
4142 _patchersFactory = patchersFactory ;
4243 _globMatcher = globMatcher ;
4344 _clusterIdState = clusterIdState ;
4445 _operatorOptions = operatorOptions ;
4546 _initOptions = initOptions ;
47+ _telemetryOptions = telemetryOptions ;
4648 _agentTypeConverter = agentTypeConverter ;
4749 }
4850
@@ -316,6 +318,12 @@ private IEnumerable<V1EnvVar> GenerateEnvVars(PatchingContext context, V1Pod pod
316318 yield return new V1EnvVar { Name = "CONTRAST_MOUNT_AGENT_PATH" , Value = agentMountPath } ;
317319 yield return new V1EnvVar { Name = "CONTRAST_MOUNT_WRITABLE_PATH" , Value = writableMountPath } ;
318320
321+ //If opt-out is set on the operator we should opt-out the agents
322+ if ( _telemetryOptions . OptOut )
323+ {
324+ yield return new V1EnvVar { Name = "CONTRAST_AGENT_TELEMETRY_OPTOUT" , Value = "1" } ;
325+ }
326+
319327 if ( connection . TeamServerUri != null )
320328 {
321329 yield return new V1EnvVar { Name = "CONTRAST__API__URL" , Value = connection . TeamServerUri } ;
0 commit comments