mgr

package
v1.6.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 5, 2019 License: BSD-2-Clause Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultInterval = time.Hour

DefaultInterval is used if no interval is provided for a Manager. This defaults to one hour.

Variables

This section is empty.

Functions

This section is empty.

Types

type CertServiceManager added in v1.6.0

type CertServiceManager struct {
	*cert.Spec
	// contains filtered or unexported fields
}

This exists purely so we can bind custom svcmgr's per cert; this is primarily used for 'command' svcmgr's that don't follow the norm.

func (*CertServiceManager) TakeAction added in v1.6.0

func (csm *CertServiceManager) TakeAction(change_type string) error

type Manager

type Manager struct {
	// Dir is the directory containing the certificate specs.
	Dir string `json:"certspecs" yaml:"certspecs"`

	// DefaultRemote is used as the remote CA server when no
	// remote is specified.
	DefaultRemote string `json:"default_remote" yaml:"default_remote"`

	// ServiceManager is the service manager used to restart a
	// service.
	ServiceManager string `json:"service_manager" yaml:"service_manager"`

	// Before is how long before the cert expires to start
	// attempting to renew it.
	Before string `json:"before" yaml:"before"`

	// Interval is how often to update the NextExpires metric.
	Interval string `json:"interval" yaml:"interval"`

	// Certs contains the list of certificates to manage.
	Certs []*CertServiceManager `json:",omitempty" yaml:",omitempty"`
	// contains filtered or unexported fields
}

The Manager structure contains the certificates to be managed. A manager needs to be constructed with one of the New functions, and should not be constructed by hand.

func New

func New(dir, remote, svcmgr, before, interval string) (*Manager, error)

New constructs a new Manager from parameters. It is intended to be used in conjunction with command line flags.

func NewFromConfig

func NewFromConfig(configPath string) (*Manager, error)

NewFromConfig loads a new Manager from a config file. This does not load the certificate specs; to do that, see Load(). If the file looks like a JSON file, it will attempt to load it as a JSON file; otherwise, it assumes that it is a YAML file.

func (*Manager) CheckCA added in v1.5.0

func (m *Manager) CheckCA(spec *CertServiceManager) error

CheckCA checks the CA on the certificate and restarts the service if needed.

func (*Manager) CheckCerts

func (m *Manager) CheckCerts()

CheckCerts verifies that certificates and keys are present, and queues any certificates that need to be renewed. It returns time.Duration indicating how long until the next certificate check should occur.

func (*Manager) CheckCertsSync

func (m *Manager) CheckCertsSync() int

CheckCertsSync acts like CheckCerts, except that it doesn't queue the certificates: it makes an initial synchronous attempt at ensuring that each certificate exists. If an error occurs, the certificate is added to the renewal queue. This is useful, for example, on program startup. It returns the number of certificates that were unable to be generated.

func (*Manager) Load

func (m *Manager) Load() error

Load reads the certificate specs from the spec directory.

func (*Manager) MustCheckCerts added in v1.2.1

func (m *Manager) MustCheckCerts(tolerance int, enableActions bool, forceRegen bool) error

MustCheckCerts acts like CheckCerts, except it's synchronous and has a maxmimum number of failures that are tolerated. If tolerate is less than 1, it will be set to 1.

func (*Manager) ProcessQueue

func (m *Manager) ProcessQueue()

ProcessQueue retrieves certificates from the renewal queue and attempts to renew them. It is intended to be run as a goroutine.

func (*Manager) Queue

func (m *Manager) Queue(spec *CertServiceManager)

Queue adds the spec to the renewal queue if it isn't already queued.

func (*Manager) Server

func (m *Manager) Server(sync bool)

Server runs the Manager server. If sync is true, the first pass will be synchronous. It will autostart the renewal queue.

func (*Manager) SetExpiresNext

func (m *Manager) SetExpiresNext()

SetExpiresNext sets the next expiration metric.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL