...

Source file src/github.com/letsencrypt/boulder/observer/probers/mock/mock_conf.go

Documentation: github.com/letsencrypt/boulder/observer/probers/mock

     1  package probers
     2  
     3  import (
     4  	"errors"
     5  
     6  	"github.com/prometheus/client_golang/prometheus"
     7  
     8  	"github.com/letsencrypt/boulder/config"
     9  	"github.com/letsencrypt/boulder/observer/probers"
    10  	"github.com/letsencrypt/boulder/strictyaml"
    11  )
    12  
    13  type MockConfigurer struct {
    14  	Valid    bool            `yaml:"valid"`
    15  	ErrMsg   string          `yaml:"errmsg"`
    16  	PName    string          `yaml:"pname"`
    17  	PKind    string          `yaml:"pkind"`
    18  	PTook    config.Duration `yaml:"ptook"`
    19  	PSuccess bool            `yaml:"psuccess"`
    20  }
    21  
    22  // Kind returns a name that uniquely identifies the `Kind` of `Configurer`.
    23  func (c MockConfigurer) Kind() string {
    24  	return "Mock"
    25  }
    26  
    27  func (c MockConfigurer) UnmarshalSettings(settings []byte) (probers.Configurer, error) {
    28  	var conf MockConfigurer
    29  	err := strictyaml.Unmarshal(settings, &conf)
    30  	if err != nil {
    31  		return nil, err
    32  	}
    33  	return conf, nil
    34  }
    35  
    36  func (c MockConfigurer) MakeProber(_ map[string]prometheus.Collector) (probers.Prober, error) {
    37  	if !c.Valid {
    38  		return nil, errors.New("could not be validated")
    39  	}
    40  	return MockProber{c.PName, c.PKind, c.PTook, c.PSuccess}, nil
    41  }
    42  
    43  func (c MockConfigurer) Instrument() map[string]prometheus.Collector {
    44  	return nil
    45  }
    46  
    47  func init() {
    48  	probers.Register(MockConfigurer{})
    49  }
    50  

View as plain text