Documentation
¶
Index ¶
- type Date
- type Datetime
- func (d *Datetime) MarshalBSON() ([]byte, error)
- func (d *Datetime) MarshalBSONValue() (bsontype.Type, []byte, error)
- func (d *Datetime) MarshalJSON() ([]byte, error)
- func (d *Datetime) Scan(src any) error
- func (d Datetime) String() string
- func (d Datetime) Time() time.Time
- func (d *Datetime) UnmarshalBSON(bytes []byte) error
- func (d *Datetime) UnmarshalJSON(text []byte) error
- type Duration
- type PuppetHistory
- type PuppetReport
- type PuppetReportSummary
- type PuppetResource
- type PuppetRun
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Date ¶
Date is a custom type for time.Time that marshals to and from RFC3339 date only.
func (*Date) MarshalJSON ¶
MarshalJSON marshals the date to JSON.
func (*Date) MarshalText ¶
MarshalText marshals the date to text.
func (*Date) UnmarshalJSON ¶
UnmarshalJSON unmarshals the date from JSON.
func (*Date) UnmarshalText ¶
UnmarshalText unmarshals the date from text.
type Datetime ¶
Datetime represents a datetime.
func (*Datetime) MarshalBSON ¶
func (*Datetime) MarshalBSONValue ¶
func (*Datetime) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface.
func (*Datetime) UnmarshalBSON ¶
func (*Datetime) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface.
type Duration ¶
func (*Duration) MarshalJSON ¶
MarshalJSON marshals the duration to JSON. We want to marshal to a max of days (e.g. 1d2h3m4s)
func (Duration) PrettyString ¶
PrettyString returns the duration as a pretty string.
func (*Duration) UnmarshalJSON ¶
UnmarshalJSON unmarshals the duration from JSON.
Remove all quites from text if present with regex (e.g. "1h30m" -> 1h30m) reg := regexp.MustCompile(`"(.*)"`) text = reg.ReplaceAll(text, []byte("$1")) Parse the duration from a string
type PuppetHistory ¶
type PuppetHistory struct { // Date is the date of the run. Date string `json:"date" bson:"date"` // Changed is the number of resources that changed. Changed int `json:"changed" bson:"changed"` // Unchanged is the number of resources that were unchanged. Unchanged int `json:"unchanged" bson:"unchanged"` // Failed is the number of resources that failed. Failed int `json:"failed" bson:"failed"` }
type PuppetReport ¶
type PuppetReport struct { // ID is a hash of the report-body. This is used to create the file to store the report in on-disk, // and as a means of detecting duplication submissions. ID string `json:"id" bson:"id"` // Fqdn of the node. Fqdn string `json:"fqdn" bson:"fqdn"` // PuppetVersion is the version of puppet used to generate the report. PuppetVersion float64 `json:"puppet_version" bson:"puppet_version"` // Env of the node. Env summary.Environment `json:"env" bson:"env"` // State of the run. changed, unchanged, etc. State summary.State `json:"state" bson:"state"` // ExecTime is the time the puppet-run was completed. This is self-reported by the node, and copied almost literally. ExecTime Datetime `json:"exec_time" bson:"exec_time"` // Runtime is the time the puppet-run took. Runtime Duration `json:"runtime" bson:"runtime"` // Failed is the number of resources which failed. Failed int64 `json:"failed" bson:"failed"` // Changed is the number of resources which changed. Changed int64 `json:"changed" bson:"changed"` // Skipped is the number of resources which were skipped. Skipped int64 `json:"skipped" bson:"skipped"` // Total is the total number of resources. Total int64 `json:"total" bson:"total"` // LogMessages are the messages logged by puppet. LogMessages []string `json:"log_messages" bson:"log_messages"` // ResourcesFailed are the resources which failed. ResourcesFailed []*PuppetResource `json:"resources_failed" bson:"resources_failed"` // ResourcesChanged are the resources which changed. ResourcesChanged []*PuppetResource `json:"resources_changed" bson:"resources_changed"` // ResourcesSkipped are the resources which were skipped. ResourcesSkipped []*PuppetResource `json:"resources_skipped" bson:"resources_skipped"` // ResourcesOK are the resources which were OK. ResourcesOK []*PuppetResource `json:"resources_ok" bson:"resources_ok"` // YamlFile is the file the report was read from. YamlFile string `json:"-" bson:"yamlFile"` }
PuppetReport stores the details of a single run of puppet.
func (*PuppetReport) ReportFilePath ¶
func (n *PuppetReport) ReportFilePath() string
func (*PuppetReport) SortResources ¶
func (n *PuppetReport) SortResources()
type PuppetReportSummary ¶
type PuppetReportSummary struct { // ID is the ID of the node. ID string `json:"id" bson:"id"` // Fqdn is the FQDN of the node. Fqdn string `json:"fqdn" bson:"fqdn"` // Env is the environment of the node. Env summary.Environment `json:"env" bson:"env"` // State is the state of the node. State summary.State `json:"state" bson:"state"` // ExecTime is the time the puppet-run was completed. This is self-reported by the node, and copied almost literally. ExecTime Datetime `json:"exec_time" bson:"exec_time"` // TimeSince is the time since the puppet-run was completed. TimeSince Duration `json:"time_since" bson:"time_since"` // Runtime is the time the puppet-run took. Runtime Duration `json:"runtime" bson:"runtime"` // Failed is the number of resources which failed. Failed int `json:"failed" bson:"failed"` // Changed is the number of resources which changed. Changed int `json:"changed" bson:"changed"` // Skipped is the number of resources which were skipped. Skipped int `json:"skipped" bson:"skipped"` // Total is the total number of resources. Total int `json:"total" bson:"total"` // YamlFile is the file the report was read from. YamlFile string `json:"-" bson:"yamlFile"` }
PuppetReportSummary is the structure used to represent a series of puppet-runs against a particular node.
func (*PuppetReportSummary) CalculateTimeSince ¶
func (n *PuppetReportSummary) CalculateTimeSince()
func (*PuppetReportSummary) ReportFilePath ¶
func (n *PuppetReportSummary) ReportFilePath() string
type PuppetResource ¶
type PuppetResource struct { Name string `json:"name" bson:"name"` Type string `json:"type" bson:"type"` File string `json:"file" bson:"file"` Line string `json:"line" bson:"line"` }
PuppetResource refers to a resource in your puppet modules, a resource has a name, along with the file & line-number it was defined in within your manifest
type PuppetRun ¶
type PuppetRun struct { ID string `json:"id,omitempty" bson:"id"` Fqdn string `json:"fqdn" bson:"fqdn"` Env summary.Environment `json:"env" bson:"env"` State summary.State `json:"state" bson:"state"` ExecTime Datetime `json:"exec_time" bson:"exec_time"` Runtime Duration `json:"runtime" bson:"runtime"` TimeSince Duration `json:"-" bson:"time_since"` }
PuppetRun is the structure which is used to list a summary of puppet runs on the front-page.
func (*PuppetRun) CalculateTimeSince ¶
func (p *PuppetRun) CalculateTimeSince()