@@ -16,6 +16,7 @@ package config
1616import  (
1717	"errors" 
1818	"fmt" 
19+ 	"github.com/prometheus/alertmanager/secrets" 
1920	"net/textproto" 
2021	"regexp" 
2122	"strings" 
@@ -328,22 +329,22 @@ type PagerdutyConfig struct {
328329
329330	HTTPConfig  * commoncfg.HTTPClientConfig  `yaml:"http_config,omitempty" json:"http_config,omitempty"` 
330331
331- 	ServiceKey      Secret              `yaml:"service_key,omitempty" json:"service_key,omitempty"` 
332- 	ServiceKeyFile  string             `yaml:"service_key_file,omitempty" json:"service_key_file,omitempty"` 
333- 	RoutingKey      Secret              `yaml:"routing_key,omitempty" json:"routing_key,omitempty"` 
334- 	RoutingKeyFile  string             `yaml:"routing_key_file,omitempty" json:"routing_key_file,omitempty"` 
335- 	URL             * URL               `yaml:"url,omitempty" json:"url,omitempty"` 
336- 	Client          string             `yaml:"client,omitempty" json:"client,omitempty"` 
337- 	ClientURL       string             `yaml:"client_url,omitempty" json:"client_url,omitempty"` 
338- 	Description     string             `yaml:"description,omitempty" json:"description,omitempty"` 
339- 	Details         map [string ]string  `yaml:"details,omitempty" json:"details,omitempty"` 
340- 	Images          []PagerdutyImage   `yaml:"images,omitempty" json:"images,omitempty"` 
341- 	Links           []PagerdutyLink    `yaml:"links,omitempty" json:"links,omitempty"` 
342- 	Source          string             `yaml:"source,omitempty" json:"source,omitempty"` 
343- 	Severity        string             `yaml:"severity,omitempty" json:"severity,omitempty"` 
344- 	Class           string             `yaml:"class,omitempty" json:"class,omitempty"` 
345- 	Component       string             `yaml:"component,omitempty" json:"component,omitempty"` 
346- 	Group           string             `yaml:"group,omitempty" json:"group,omitempty"` 
332+ 	ServiceKey      * secrets. GenericSecret  `yaml:"service_key,omitempty" json:"service_key,omitempty"` 
333+ 	ServiceKeyFile  string                   `yaml:"service_key_file,omitempty" json:"service_key_file,omitempty"` 
334+ 	RoutingKey      * secrets. GenericSecret  `yaml:"routing_key,omitempty" json:"routing_key,omitempty"` 
335+ 	RoutingKeyFile  string                   `yaml:"routing_key_file,omitempty" json:"routing_key_file,omitempty"` 
336+ 	URL             * URL                     `yaml:"url,omitempty" json:"url,omitempty"` 
337+ 	Client          string                   `yaml:"client,omitempty" json:"client,omitempty"` 
338+ 	ClientURL       string                   `yaml:"client_url,omitempty" json:"client_url,omitempty"` 
339+ 	Description     string                   `yaml:"description,omitempty" json:"description,omitempty"` 
340+ 	Details         map [string ]string        `yaml:"details,omitempty" json:"details,omitempty"` 
341+ 	Images          []PagerdutyImage         `yaml:"images,omitempty" json:"images,omitempty"` 
342+ 	Links           []PagerdutyLink          `yaml:"links,omitempty" json:"links,omitempty"` 
343+ 	Source          string                   `yaml:"source,omitempty" json:"source,omitempty"` 
344+ 	Severity        string                   `yaml:"severity,omitempty" json:"severity,omitempty"` 
345+ 	Class           string                   `yaml:"class,omitempty" json:"class,omitempty"` 
346+ 	Component       string                   `yaml:"component,omitempty" json:"component,omitempty"` 
347+ 	Group           string                   `yaml:"group,omitempty" json:"group,omitempty"` 
347348}
348349
349350// PagerdutyLink is a link. 
@@ -366,13 +367,13 @@ func (c *PagerdutyConfig) UnmarshalYAML(unmarshal func(interface{}) error) error
366367	if  err  :=  unmarshal ((* plain )(c )); err  !=  nil  {
367368		return  err 
368369	}
369- 	if  c .RoutingKey  ==  ""  &&  c .ServiceKey  ==  ""  &&  c .RoutingKeyFile  ==  ""  &&  c .ServiceKeyFile  ==  ""  {
370+ 	if  c .RoutingKey  ==  nil  &&  c .ServiceKey  ==  nil  &&  c .RoutingKeyFile  ==  ""  &&  c .ServiceKeyFile  ==  ""  {
370371		return  errors .New ("missing service or routing key in PagerDuty config" )
371372	}
372- 	if  len ( c .RoutingKey )  >   0  &&  len (c .RoutingKeyFile ) >  0  {
373+ 	if  c .RoutingKey   !=   nil  &&  len (c .RoutingKeyFile ) >  0  {
373374		return  errors .New ("at most one of routing_key & routing_key_file must be configured" )
374375	}
375- 	if  len ( c .ServiceKey )  >   0  &&  len (c .ServiceKeyFile ) >  0  {
376+ 	if  c .ServiceKey   !=   nil  &&  len (c .ServiceKeyFile ) >  0  {
376377		return  errors .New ("at most one of service_key & service_key_file must be configured" )
377378	}
378379	if  c .Details  ==  nil  {
0 commit comments