func (c *GardenCollector) Detect(ctx context.Context, out chan<- []*TagInfo) (CollectionMode, error) {
	if !config.IsFeaturePresent(config.CloudFoundry) {
		return NoCollection, nil
	}

	// Detect if we're on a compute VM by trying to connect to the local garden API
	var err error
	c.gardenUtil, err = cloudfoundry.GetGardenUtil()
	if err != nil {
		if retry.IsErrWillRetry(err) {
			return NoCollection, err
		}
		return NoCollection, err
	}

	// if DCA is enabled and can't communicate with the DCA, let the tagger retry.
	var errDCA error
	if config.Datadog.GetBool("cluster_agent.enabled") {
		c.clusterAgentEnabled = false
		c.dcaClient, errDCA = clusteragent.GetClusterAgentClient()
		if errDCA != nil {
			log.Errorf("Could not initialise the communication with the cluster agent: %s", errDCA.Error())
			// continue to retry while we can
			if retry.IsErrPermaFail(errDCA) {
				log.Error("Permanent failure in communication with the cluster agent")
			}
			return NoCollection, errDCA
		}
		c.clusterAgentEnabled = true
	}

	c.infoOut = out
	return PullCollection, nil
}
// Detect tries to connect to the Garden API and the cluster agent
Detect tries to connect to the Garden API and the cluster agent
// Detect tries to connect to the Garden API and the cluster agent
func (c *GardenCollector) Detect(ctx context.Context, out chan<- []*TagInfo) (CollectionMode, error) {
	if !config.IsFeaturePresent(config.CloudFoundry) {
		return NoCollection, nil
	}
	var err error
	c.gardenUtil, err = cloudfoundry.GetGardenUtil()
	if err != nil {
		if retry.IsErrWillRetry(err) {
			return NoCollection, err
		}
		return NoCollection, err
	}
	var errDCA error
	if config.Datadog.GetBool("cluster_agent.enabled") {
		c.clusterAgentEnabled = false
		c.dcaClient, errDCA = clusteragent.GetClusterAgentClient()
		if errDCA != nil {
			log.Errorf("Could not initialise the communication with the cluster agent: %s", errDCA.Error())
			if retry.IsErrPermaFail(errDCA) {
				log.Error("Permanent failure in communication with the cluster agent")
			}
			return NoCollection, errDCA
		}
		c.clusterAgentEnabled = true
	}
	c.infoOut = out
	return PullCollection, nil
}
func ( c * GardenCollector ) Detect ( ctx context . Context , out chan <- [ ] * TagInfo ) ( CollectionMode , error ) { if ! config . IsFeaturePresent ( config . CloudFoundry ) { return NoCollection , nil } var err error c . gardenUtil , err = cloudfoundry . GetGardenUtil ( ) if err != nil { if retry . IsErrWillRetry ( err ) { return NoCollection , err } return NoCollection , err } var errDCA error if config . Datadog . GetBool ( " " ) { c . clusterAgentEnabled = false c . dcaClient , errDCA = clusteragent . GetClusterAgentClient ( ) if errDCA != nil { log . Errorf ( " " , errDCA . Error ( ) ) if retry . IsErrPermaFail ( errDCA ) { log . Error ( " " ) } return NoCollection , errDCA } c . clusterAgentEnabled = true } c . infoOut = out return PullCollection , nil }
Detect tries to connect to the Garden API and the cluster agent
Detect tries to connect to the Garden API and the cluster agent
// Detect if we're on a compute VM by trying to connect to the local garden API // if DCA is enabled and can't communicate with the DCA, let the tagger retry. // continue to retry while we can