Documentation
¶
Overview ¶
Package domain provides common/shared utility code to support applications in this module which process domain metdata.
Index ¶
- Constants
- Variables
- func FormattedExpiration(expireTime time.Time) string
- type Metadata
- func (m Metadata) IsCriticalState() bool
- func (m Metadata) IsExpired() bool
- func (m Metadata) IsExpiring() bool
- func (m Metadata) IsOKState() bool
- func (m Metadata) IsWarningState() bool
- func (m Metadata) OneLineCheckSummary() string
- func (m Metadata) Report() string
- func (m Metadata) ServiceState() nagios.ServiceState
Constants ¶
const DomainDateLayout string = "2006-01-02 15:04:05 -0700 MST"
DomainDateLayout is the chosen date layout for displaying domain created/expiration date/time values across our application.
Variables ¶
var ErrDomainExpired = errors.New("domain has expired")
ErrDomainExpired is returned whenever a specified domain has expired.
var ErrDomainExpiring = errors.New("domain is expiring")
ErrDomainExpiring is returned whenever a specified domain is expiring.
Functions ¶
func FormattedExpiration ¶
FormattedExpiration receives a Time value and converts it to a string representing the largest useful whole units of time in days and hours. For example, if a domain has 1 year, 2 days and 3 hours remaining until expiration, this function will return the string '367d 3h remaining', but if only 3 hours remain then '3h remaining' will be returned. If a domain registration has expired, the 'ago' suffix will be used instead. For example, if a domain has expired 3 hours ago, '3h ago' will be returned.
Types ¶
type Metadata ¶
type Metadata struct { // Results from parsing the WHOIS info. Most fields are plain text values. WhoisInfo whoisparser.WhoisInfo // Name is the plaintext label for this domain. Name string // ExpirationDate indicates when this domain expires. ExpirationDate time.Time // UpdatedDate indicates when the domain WHOIS metadata was last updated. UpdatedDate time.Time // CreatedDate indicates when this domain was created/registered. CreatedDate time.Time // AgeWarningThreshold is the specified age threshold for when domains // with an expiration less than this value are considered to be in a // WARNING state. AgeWarningThreshold time.Time // AgeCRITICALThreshold is the specified age threshold for when domains // with an expiration less than this value are considered to be in a // CRITICAL state. AgeCriticalThreshold time.Time }
Metadata represents the details for a specified domain, including the parsed WHOIS info, expiration (age) thresholds and parsed date values.
func NewDomain ¶
func NewDomain(whoisInfo whoisparser.WhoisInfo, ageWarning time.Time, ageCritical time.Time) (*Metadata, error)
NewDomain instantiates a new Metadata type from parsed WHOIS data.
func (Metadata) IsCriticalState ¶
IsCriticalState indicates whether a domain's expiration date has been determined to be in a CRITICAL state. This returns false if the expiration date is in an OK or WARNING state, true otherwise.
func (Metadata) IsExpiring ¶
IsExpiring compares the domain's current expiration date against the provided CRITICAL and WARNING thresholds to determine if the domain is about to expire.
func (Metadata) IsOKState ¶
IsOKState indicates whether a domain's expiration date has been determined to be in an OK state, without expired or expiring domain registration.
func (Metadata) IsWarningState ¶
IsWarningState indicates whether a domain's expiration date has been determined to be in a WARNING state. This returns false if the expiration date is in an OK or CRITICAL state, true otherwise.
func (Metadata) OneLineCheckSummary ¶
OneLineCheckSummary generates a one-line summary of the domain WHOIS check results for display and notification purposes.
func (Metadata) Report ¶
Report provides an overview of domain details appropriate for display as the LongServiceOutput provided via the web UI or as email or Teams notifications.
func (Metadata) ServiceState ¶
func (m Metadata) ServiceState() nagios.ServiceState
ServiceState returns the appropriate Service Check Status label and exit code for the evaluated domain expiration metadata.