grafana / synthetic-monitoring-agent

Synthetic Monitoring Agent
https://grafana.com/docs/grafana-cloud/how-do-i/synthetic-monitoring/
Apache License 2.0
155 stars 20 forks source link

k6runner: apply empty IP denylist even if it is empty #731

Closed roobre closed 2 weeks ago

roobre commented 2 weeks ago

Before this PR, withOpts checked if the IP denylist at opts.BlacklistedIP was empty, and if it was, it didn't override the default value (10.0.0.0/8). Unfortunately, this effectively prevented from clearning that default, as specifying --blocked-nets="" would cause opts.BlacklistedIP to become the empty string, which will not be applied over the default.

To prevent having two defaults (cli flag and in-constructor), with the constructor one being always ignored, this PR gets rid of the constructor default.

The changes here should not cause any functional change, as blocked-nets defaults to 10.0.0.0/8 either way in the CLI code: https://github.com/grafana/synthetic-monitoring-agent/blob/7123e22162573d5ff1b83649aca571dd7f0479b9/cmd/synthetic-monitoring-agent/main.go#L80

Additionally, this PR fixes a bug that made this change ineffective when WithLogger was called on the local runner, as doing so would not copy the IP denylist.

Finally, having a mixture of pointer and non-pointer returns for LocalRunner was making testing hard. This PR also uniforms to non-pointer runners everywhere.

Related to: https://github.com/grafana/synthetic-monitoring-agent/issues/730