From 86011047ca76a69b5930efe694b1ab45cf4301e9 Mon Sep 17 00:00:00 2001 From: Marek Siarkowicz Date: Mon, 5 Mar 2018 20:27:54 +0100 Subject: [PATCH] Validate required fields in sd configuration (#3911) --- discovery/azure/azure.go | 3 +++ discovery/openstack/openstack.go | 3 +++ 2 files changed, 6 insertions(+) diff --git a/discovery/azure/azure.go b/discovery/azure/azure.go index 2edaa2d9e..c7119f948 100644 --- a/discovery/azure/azure.go +++ b/discovery/azure/azure.go @@ -86,6 +86,9 @@ func (c *SDConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { if err != nil { return err } + if c.SubscriptionID == "" { + return fmt.Errorf("Azure SD configuration requires a subscription_id") + } return yaml_util.CheckOverflow(c.XXX, "azure_sd_config") } diff --git a/discovery/openstack/openstack.go b/discovery/openstack/openstack.go index 85a6aff10..ac7371db9 100644 --- a/discovery/openstack/openstack.go +++ b/discovery/openstack/openstack.go @@ -103,6 +103,9 @@ func (c *SDConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { if c.Role == "" { return fmt.Errorf("role missing (one of: instance, hypervisor)") } + if c.Region == "" { + return fmt.Errorf("Openstack SD configuration requires a region") + } return yaml_util.CheckOverflow(c.XXX, "openstack_sd_config") }