github.com/franciscocpg/up@v0.1.10/config/certs.go (about)

     1  package config
     2  
     3  import (
     4  	"github.com/pkg/errors"
     5  	"github.com/apex/up/internal/validate"
     6  )
     7  
     8  // Cert config.
     9  type Cert struct {
    10  	Domains []string `json:"domains"`
    11  }
    12  
    13  // Validate implementation.
    14  func (c *Cert) Validate() error {
    15  	if err := validate.MinStrings(c.Domains, 1); err != nil {
    16  		return errors.Wrap(err, ".domains")
    17  	}
    18  
    19  	return nil
    20  }
    21  
    22  // Certs config.
    23  type Certs []Cert
    24  
    25  // Validate implementation.
    26  func (c Certs) Validate() error {
    27  	for i, v := range c {
    28  		if err := v.Validate(); err != nil {
    29  			return errors.Wrapf(err, "cert %d", i)
    30  		}
    31  	}
    32  
    33  	return nil
    34  }