api

package
v0.1.14 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2020 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package api provides types for Preflight reports and some common helpers.

Index

Constants

View Source
const TimeFormat = time.RFC3339

TimeFormat defines the format used for timestamps across all this API.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClusterSummary

type ClusterSummary struct {
	Cluster         string     `json:"cluster"`
	LatestReportSet *ReportSet `json:"latestReportSet"`
}

ClusterSummary contains a summary of the most recent status of a cluster.

type PackageInformation

type PackageInformation struct {
	// Namespace the package belongs to.
	Namespace string `json:"namespace"`
	// ID is the ID of the package.
	ID string `json:"id"`
	// Version is the version of the package.
	Version string `json:"version"`
	// SchemaVersion is the version of the Preflight package schema.
	SchemaVersion string `json:"schema-version"`
}

PackageInformation contains all the details to identify a package.

type Report

type Report struct {
	// Unique ID of the report.
	ID string `json:"id"`
	// PreflightVersion indicates the version of preflight this report was generated with.
	PreflightVersion string `json:"preflight-version"`
	// Timestamp indicates when the report was generated.
	Timestamp Time `json:"timestamp"`
	// Cluster indicates which was the target of the report.
	Cluster string `json:"cluster"`
	// Package indicates which package was used for the report. (deprecated)
	Package string `json:"package"`
	// PackageInformation contains all the information about the package that was used to generate the report.
	PackageInformation PackageInformation `json:"package-information"`
	// Name is the name of the package that was used for this report.
	Name string `json:"name"`
	// Description is the description of the package that was used for this report.
	Description string `json:"description,omitempty"`
	// Sections contains the sections of the package that was used for this report.
	Sections []ReportSection `json:"sections,omitempty"`
}

Report contains the fields of a Preflight report

func (*Report) Summarize

func (r *Report) Summarize() ReportSummary

Summarize produces as ReportSummary from a Report

type ReportMetadata

type ReportMetadata struct {
	// Unique ID of the report.
	ID string `json:"id"`
	// Timestamp indicates when the report was generated.
	Timestamp Time `json:"timestamp"`
	// Cluster indicates which was the target of the report.
	Cluster string `json:"cluster"`
	// Package indicates which package was used for the report. (deprecated)
	Package string `json:"package"`
	// PackageInformation contains all the information about the package that was used to generate the report.
	PackageInformation PackageInformation `json:"package-information"`
	// PreflightVersion indicates the version of preflight this report was generated with.
	PreflightVersion string `json:"preflight-version"`
}

ReportMetadata contains metadata about a report

type ReportRule

type ReportRule struct {
	// ID is the id of the rule.
	ID string `json:"id"`
	// Name is a shortname for the rule.
	Name string `json:"name"`
	// Description is a text describing what the rule is about.
	Description string `json:"description,omitempty"`
	// Manual indicated whether the rule can be evaluated automatically by Preflight or requires manual intervention.
	Manual bool `json:"manual,omitempty"`
	// Remediation is a text describing how to fix a failure of the rule.
	Remediation string `json:"remediation,omitempty"`
	// Links contains useful links related to the rule.
	Links []string `json:"links,omitempty"`
	// Success indicates whether the check was a success or not.
	Success bool `json:"success"`
	// Value contains the raw result of the check.
	Value interface{} `json:"value,omitempty"`
	// Violations contains the list of messages from the execution of the check
	Violations interface{} `json:"violations"`
	// Missing indicates whether the Rego rule was missing or not.
	Missing bool `json:"missing"`
}

ReportRule contains the fields of a rule inside a Report

type ReportSection

type ReportSection struct {
	// ID is the ID of the section.
	ID string `json:"id"`
	// Name is the name of the section.
	Name string `json:"name"`
	// Description is the description of the section.
	Description string `json:"description,omitempty"`
	// Rules contain all the rules in the section.
	Rules []ReportRule `json:"rules,omitempty"`
}

ReportSection contains the fields of a section inside a Report

type ReportSet

type ReportSet struct {
	Cluster      string           `json:"-"`
	Timestamp    Time             `json:"timestamp"`
	FailureCount int              `json:"failureCount"`
	SuccessCount int              `json:"successCount"`
	Reports      []*ReportSummary `json:"reports"`
}

ReportSet groups one or more reports of different packages with the same timestamp for the same cluster.

type ReportSummary

type ReportSummary struct {
	ID           string `json:"id"`
	Package      string `json:"package"`
	Cluster      string `json:"-"`
	Timestamp    Time   `json:"-"`
	FailureCount int    `json:"failureCount"`
	SuccessCount int    `json:"successCount"`
}

ReportSummary constains a summary of a report.

type Time

type Time struct {
	time.Time
}

Time is a wrapper around time.Time that overrides how it is marshaled into JSON

func (Time) MarshalJSON

func (t Time) MarshalJSON() ([]byte, error)

MarshalJSON marshals the timestamp with RFC3339 format

func (Time) String

func (t Time) String() string

String returns a string representation of the timestamp

Jump to

Keyboard shortcuts

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