mirror of
https://github.com/prometheus/prometheus.git
synced 2025-01-12 06:17:27 -08:00
Rename discovery/dockerswarm to discovery/moby (#8691)
This makes it clear that the dockerswarm package does more than docker swarm, but does also docker. I have picked moby as it is the upstream name: https://mobyproject.org/ There is no user-facing change, except in the case of a bad configuration. Previously, a user who would have a bad docker sd config would see an error like: > field xx not found in type dockerswarm.plain Now that error would be turned into: > field xx not found in type moby.plain While not perfect, it should at not be confusing between docker and dockerswarm. Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>
This commit is contained in:
parent
9781e51f59
commit
5bce801a09
|
@ -34,13 +34,13 @@ import (
|
||||||
"github.com/prometheus/prometheus/discovery/consul"
|
"github.com/prometheus/prometheus/discovery/consul"
|
||||||
"github.com/prometheus/prometheus/discovery/digitalocean"
|
"github.com/prometheus/prometheus/discovery/digitalocean"
|
||||||
"github.com/prometheus/prometheus/discovery/dns"
|
"github.com/prometheus/prometheus/discovery/dns"
|
||||||
"github.com/prometheus/prometheus/discovery/dockerswarm"
|
|
||||||
"github.com/prometheus/prometheus/discovery/ec2"
|
"github.com/prometheus/prometheus/discovery/ec2"
|
||||||
"github.com/prometheus/prometheus/discovery/eureka"
|
"github.com/prometheus/prometheus/discovery/eureka"
|
||||||
"github.com/prometheus/prometheus/discovery/file"
|
"github.com/prometheus/prometheus/discovery/file"
|
||||||
"github.com/prometheus/prometheus/discovery/hetzner"
|
"github.com/prometheus/prometheus/discovery/hetzner"
|
||||||
"github.com/prometheus/prometheus/discovery/kubernetes"
|
"github.com/prometheus/prometheus/discovery/kubernetes"
|
||||||
"github.com/prometheus/prometheus/discovery/marathon"
|
"github.com/prometheus/prometheus/discovery/marathon"
|
||||||
|
"github.com/prometheus/prometheus/discovery/moby"
|
||||||
"github.com/prometheus/prometheus/discovery/openstack"
|
"github.com/prometheus/prometheus/discovery/openstack"
|
||||||
"github.com/prometheus/prometheus/discovery/scaleway"
|
"github.com/prometheus/prometheus/discovery/scaleway"
|
||||||
"github.com/prometheus/prometheus/discovery/targetgroup"
|
"github.com/prometheus/prometheus/discovery/targetgroup"
|
||||||
|
@ -658,8 +658,8 @@ var expectedConf = &Config{
|
||||||
HTTPClientConfig: config.DefaultHTTPClientConfig,
|
HTTPClientConfig: config.DefaultHTTPClientConfig,
|
||||||
|
|
||||||
ServiceDiscoveryConfigs: discovery.Configs{
|
ServiceDiscoveryConfigs: discovery.Configs{
|
||||||
&dockerswarm.DockerSDConfig{
|
&moby.DockerSDConfig{
|
||||||
Filters: []dockerswarm.Filter{},
|
Filters: []moby.Filter{},
|
||||||
Host: "unix:///var/run/docker.sock",
|
Host: "unix:///var/run/docker.sock",
|
||||||
Port: 80,
|
Port: 80,
|
||||||
RefreshInterval: model.Duration(60 * time.Second),
|
RefreshInterval: model.Duration(60 * time.Second),
|
||||||
|
@ -679,8 +679,8 @@ var expectedConf = &Config{
|
||||||
HTTPClientConfig: config.DefaultHTTPClientConfig,
|
HTTPClientConfig: config.DefaultHTTPClientConfig,
|
||||||
|
|
||||||
ServiceDiscoveryConfigs: discovery.Configs{
|
ServiceDiscoveryConfigs: discovery.Configs{
|
||||||
&dockerswarm.SDConfig{
|
&moby.DockerSwarmSDConfig{
|
||||||
Filters: []dockerswarm.Filter{},
|
Filters: []moby.Filter{},
|
||||||
Host: "http://127.0.0.1:2375",
|
Host: "http://127.0.0.1:2375",
|
||||||
Role: "nodes",
|
Role: "nodes",
|
||||||
Port: 80,
|
Port: 80,
|
||||||
|
|
|
@ -20,7 +20,6 @@ import (
|
||||||
_ "github.com/prometheus/prometheus/discovery/consul" // register consul
|
_ "github.com/prometheus/prometheus/discovery/consul" // register consul
|
||||||
_ "github.com/prometheus/prometheus/discovery/digitalocean" // register digitalocean
|
_ "github.com/prometheus/prometheus/discovery/digitalocean" // register digitalocean
|
||||||
_ "github.com/prometheus/prometheus/discovery/dns" // register dns
|
_ "github.com/prometheus/prometheus/discovery/dns" // register dns
|
||||||
_ "github.com/prometheus/prometheus/discovery/dockerswarm" // register dockerswarm
|
|
||||||
_ "github.com/prometheus/prometheus/discovery/ec2" // register ec2
|
_ "github.com/prometheus/prometheus/discovery/ec2" // register ec2
|
||||||
_ "github.com/prometheus/prometheus/discovery/eureka" // register eureka
|
_ "github.com/prometheus/prometheus/discovery/eureka" // register eureka
|
||||||
_ "github.com/prometheus/prometheus/discovery/file" // register file
|
_ "github.com/prometheus/prometheus/discovery/file" // register file
|
||||||
|
@ -28,6 +27,7 @@ import (
|
||||||
_ "github.com/prometheus/prometheus/discovery/hetzner" // register hetzner
|
_ "github.com/prometheus/prometheus/discovery/hetzner" // register hetzner
|
||||||
_ "github.com/prometheus/prometheus/discovery/kubernetes" // register kubernetes
|
_ "github.com/prometheus/prometheus/discovery/kubernetes" // register kubernetes
|
||||||
_ "github.com/prometheus/prometheus/discovery/marathon" // register marathon
|
_ "github.com/prometheus/prometheus/discovery/marathon" // register marathon
|
||||||
|
_ "github.com/prometheus/prometheus/discovery/moby" // register moby
|
||||||
_ "github.com/prometheus/prometheus/discovery/openstack" // register openstack
|
_ "github.com/prometheus/prometheus/discovery/openstack" // register openstack
|
||||||
_ "github.com/prometheus/prometheus/discovery/scaleway" // register scaleway
|
_ "github.com/prometheus/prometheus/discovery/scaleway" // register scaleway
|
||||||
_ "github.com/prometheus/prometheus/discovery/triton" // register triton
|
_ "github.com/prometheus/prometheus/discovery/triton" // register triton
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
package dockerswarm
|
package moby
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
|
@ -11,7 +11,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
package dockerswarm
|
package moby
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
|
@ -11,7 +11,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
package dockerswarm
|
package moby
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
@ -38,8 +38,8 @@ const (
|
||||||
|
|
||||||
var userAgent = fmt.Sprintf("Prometheus/%s", version.Version)
|
var userAgent = fmt.Sprintf("Prometheus/%s", version.Version)
|
||||||
|
|
||||||
// DefaultSDConfig is the default Docker Swarm SD configuration.
|
// DefaultDockerSwarmSDConfig is the default Docker Swarm SD configuration.
|
||||||
var DefaultSDConfig = SDConfig{
|
var DefaultDockerSwarmSDConfig = DockerSwarmSDConfig{
|
||||||
RefreshInterval: model.Duration(60 * time.Second),
|
RefreshInterval: model.Duration(60 * time.Second),
|
||||||
Port: 80,
|
Port: 80,
|
||||||
Filters: []Filter{},
|
Filters: []Filter{},
|
||||||
|
@ -47,11 +47,11 @@ var DefaultSDConfig = SDConfig{
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
discovery.RegisterConfig(&SDConfig{})
|
discovery.RegisterConfig(&DockerSwarmSDConfig{})
|
||||||
}
|
}
|
||||||
|
|
||||||
// SDConfig is the configuration for Docker Swarm based service discovery.
|
// DockerSwarmSDConfig is the configuration for Docker Swarm based service discovery.
|
||||||
type SDConfig struct {
|
type DockerSwarmSDConfig struct {
|
||||||
HTTPClientConfig config.HTTPClientConfig `yaml:",inline"`
|
HTTPClientConfig config.HTTPClientConfig `yaml:",inline"`
|
||||||
|
|
||||||
Host string `yaml:"host"`
|
Host string `yaml:"host"`
|
||||||
|
@ -70,22 +70,22 @@ type Filter struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Name returns the name of the Config.
|
// Name returns the name of the Config.
|
||||||
func (*SDConfig) Name() string { return "dockerswarm" }
|
func (*DockerSwarmSDConfig) Name() string { return "dockerswarm" }
|
||||||
|
|
||||||
// NewDiscoverer returns a Discoverer for the Config.
|
// NewDiscoverer returns a Discoverer for the Config.
|
||||||
func (c *SDConfig) NewDiscoverer(opts discovery.DiscovererOptions) (discovery.Discoverer, error) {
|
func (c *DockerSwarmSDConfig) NewDiscoverer(opts discovery.DiscovererOptions) (discovery.Discoverer, error) {
|
||||||
return NewDiscovery(c, opts.Logger)
|
return NewDiscovery(c, opts.Logger)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetDirectory joins any relative file paths with dir.
|
// SetDirectory joins any relative file paths with dir.
|
||||||
func (c *SDConfig) SetDirectory(dir string) {
|
func (c *DockerSwarmSDConfig) SetDirectory(dir string) {
|
||||||
c.HTTPClientConfig.SetDirectory(dir)
|
c.HTTPClientConfig.SetDirectory(dir)
|
||||||
}
|
}
|
||||||
|
|
||||||
// UnmarshalYAML implements the yaml.Unmarshaler interface.
|
// UnmarshalYAML implements the yaml.Unmarshaler interface.
|
||||||
func (c *SDConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
func (c *DockerSwarmSDConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||||
*c = DefaultSDConfig
|
*c = DefaultDockerSwarmSDConfig
|
||||||
type plain SDConfig
|
type plain DockerSwarmSDConfig
|
||||||
err := unmarshal((*plain)(c))
|
err := unmarshal((*plain)(c))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -117,7 +117,7 @@ type Discovery struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewDiscovery returns a new Discovery which periodically refreshes its targets.
|
// NewDiscovery returns a new Discovery which periodically refreshes its targets.
|
||||||
func NewDiscovery(conf *SDConfig, logger log.Logger) (*Discovery, error) {
|
func NewDiscovery(conf *DockerSwarmSDConfig, logger log.Logger) (*Discovery, error) {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
d := &Discovery{
|
d := &Discovery{
|
|
@ -11,7 +11,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
package dockerswarm
|
package moby
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/sha1"
|
"crypto/sha1"
|
|
@ -11,7 +11,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
package dockerswarm
|
package moby
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
|
@ -11,7 +11,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
package dockerswarm
|
package moby
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
|
@ -11,7 +11,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
package dockerswarm
|
package moby
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
@ -35,7 +35,7 @@ func TestDockerSwarmNodesSDRefresh(t *testing.T) {
|
||||||
role: nodes
|
role: nodes
|
||||||
host: %s
|
host: %s
|
||||||
`, url)
|
`, url)
|
||||||
var cfg SDConfig
|
var cfg DockerSwarmSDConfig
|
||||||
require.NoError(t, yaml.Unmarshal([]byte(cfgString), &cfg))
|
require.NoError(t, yaml.Unmarshal([]byte(cfgString), &cfg))
|
||||||
|
|
||||||
d, err := NewDiscovery(&cfg, log.NewNopLogger())
|
d, err := NewDiscovery(&cfg, log.NewNopLogger())
|
|
@ -11,7 +11,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
package dockerswarm
|
package moby
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
|
@ -11,7 +11,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
package dockerswarm
|
package moby
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
@ -35,7 +35,7 @@ func TestDockerSwarmSDServicesRefresh(t *testing.T) {
|
||||||
role: services
|
role: services
|
||||||
host: %s
|
host: %s
|
||||||
`, url)
|
`, url)
|
||||||
var cfg SDConfig
|
var cfg DockerSwarmSDConfig
|
||||||
require.NoError(t, yaml.Unmarshal([]byte(cfgString), &cfg))
|
require.NoError(t, yaml.Unmarshal([]byte(cfgString), &cfg))
|
||||||
|
|
||||||
d, err := NewDiscovery(&cfg, log.NewNopLogger())
|
d, err := NewDiscovery(&cfg, log.NewNopLogger())
|
||||||
|
@ -329,7 +329,7 @@ filters:
|
||||||
- name: name
|
- name: name
|
||||||
values: ["mon_node-exporter", "mon_grafana"]
|
values: ["mon_node-exporter", "mon_grafana"]
|
||||||
`, url)
|
`, url)
|
||||||
var cfg SDConfig
|
var cfg DockerSwarmSDConfig
|
||||||
require.NoError(t, yaml.Unmarshal([]byte(cfgString), &cfg))
|
require.NoError(t, yaml.Unmarshal([]byte(cfgString), &cfg))
|
||||||
|
|
||||||
d, err := NewDiscovery(&cfg, log.NewNopLogger())
|
d, err := NewDiscovery(&cfg, log.NewNopLogger())
|
|
@ -11,7 +11,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
package dockerswarm
|
package moby
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
|
@ -11,7 +11,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
package dockerswarm
|
package moby
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
@ -35,7 +35,7 @@ func TestDockerSwarmTasksSDRefresh(t *testing.T) {
|
||||||
role: tasks
|
role: tasks
|
||||||
host: %s
|
host: %s
|
||||||
`, url)
|
`, url)
|
||||||
var cfg SDConfig
|
var cfg DockerSwarmSDConfig
|
||||||
require.NoError(t, yaml.Unmarshal([]byte(cfgString), &cfg))
|
require.NoError(t, yaml.Unmarshal([]byte(cfgString), &cfg))
|
||||||
|
|
||||||
d, err := NewDiscovery(&cfg, log.NewNopLogger())
|
d, err := NewDiscovery(&cfg, log.NewNopLogger())
|
Loading…
Reference in a new issue