Documentation ¶
Index ¶
- Constants
- type AuditData
- type ClusterInfo
- type ContainerResult
- type ControllerResult
- type CountSummary
- type CountSummaryByCategory
- type PodResult
- type ResultMessage
- type ResultSet
- func (rs ResultSet) GetErrors() []ResultMessage
- func (rs ResultSet) GetSortedResults() []ResultMessage
- func (rs ResultSet) GetSuccesses() []ResultMessage
- func (rs ResultSet) GetSummary() CountSummary
- func (rs ResultSet) GetSummaryByCategory() CountSummaryByCategory
- func (rs ResultSet) GetWarnings() []ResultMessage
Constants ¶
const (
// PolarisOutputVersion is the version of the current output structure
PolarisOutputVersion = "1.0"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuditData ¶
type AuditData struct { PolarisOutputVersion string `json:"polarisOutputVersion"` AuditTime string `json:"auditTime"` SourceType string `json:"sourceType"` SourceName string `json:"sourceName"` DisplayName string `json:"displayName"` ClusterInfo ClusterInfo `json:"clusterInfo"` Results []ControllerResult `json:"results"` }
AuditData contains all the data from a full Polaris audit
func ParseAudit ¶
ParseAudit decodes either a YAML or JSON file and returns AuditData.
func ReadAuditFromFile ¶
ReadAuditFromFile reads the data from a past audit stored in a JSON or YAML file.
func RunAudit ¶
func RunAudit(config conf.Configuration, kubeResources *kube.ResourceProvider) (AuditData, error)
RunAudit runs a full Polaris audit and returns an AuditData object
func (AuditData) GetResultsByNamespace ¶
func (a AuditData) GetResultsByNamespace() map[string][]*ControllerResult
GetResultsByNamespace organizes results by namespace
func (AuditData) GetSummary ¶
func (a AuditData) GetSummary() CountSummary
GetSummary summarizes AuditData
func (AuditData) GetSummaryByCategory ¶
func (a AuditData) GetSummaryByCategory() CountSummaryByCategory
GetSummaryByCategory summarizes AuditData
type ClusterInfo ¶
type ClusterInfo struct { Version string `json:"version"` Nodes int `json:"nodes"` Pods int `json:"pods"` Namespaces int `json:"namespaces"` Deployments int `json:"deployments"` StatefulSets int `json:"statefulSets"` DaemonSets int `json:"daemonSets"` Jobs int `json:"jobs"` CronJobs int `json:"cronCobs"` ReplicationControllers int `json:"replicationControllers"` }
ClusterInfo contains Polaris results as well as some high-level stats
type ContainerResult ¶
ContainerResult provides a list of validation messages for each container.
func ValidateAllContainers ¶
func ValidateAllContainers(conf *config.Configuration, controller controllers.Interface) ([]ContainerResult, error)
ValidateAllContainers validates both init and regular containers
func ValidateContainer ¶
func ValidateContainer(conf *config.Configuration, controller controllers.Interface, container *corev1.Container, isInit bool) (ContainerResult, error)
ValidateContainer validates a single container from a given controller
type ControllerResult ¶
type ControllerResult struct { Name string `json:"name"` Namespace string `json:"namespace"` Kind string `json:"kind"` Results ResultSet `json:"results"` PodResult PodResult `json:"podResult"` }
ControllerResult provides results for a controller
func ValidateController ¶
func ValidateController(conf *conf.Configuration, controller controller.Interface) (ControllerResult, error)
ValidateController validates a single controller, returns a ControllerResult.
func ValidateControllers ¶
func ValidateControllers(config *conf.Configuration, kubeResources *kube.ResourceProvider) ([]ControllerResult, error)
ValidateControllers validates that each deployment conforms to the Polaris config, builds a list of ResourceResults organized by namespace.
func (ControllerResult) GetSummary ¶
func (c ControllerResult) GetSummary() CountSummary
GetSummary summarizes a ControllerResult
func (ControllerResult) GetSummaryByCategory ¶
func (c ControllerResult) GetSummaryByCategory() CountSummaryByCategory
GetSummaryByCategory summarizes a ControllerResult
type CountSummary ¶
type CountSummary struct { Successes uint `json:"successes"` Warnings uint `json:"warnings"` Errors uint `json:"errors"` }
CountSummary provides a high level overview of success, warnings, and errors.
func (*CountSummary) AddResult ¶
func (cs *CountSummary) AddResult(result ResultMessage)
AddResult adds a single result to the summary
func (*CountSummary) AddSummary ¶
func (cs *CountSummary) AddSummary(other CountSummary)
AddSummary adds two CountSummaries together
func (CountSummary) GetScore ¶
func (cs CountSummary) GetScore() uint
GetScore returns an overall score in [0, 100] for the CountSummary
type CountSummaryByCategory ¶
type CountSummaryByCategory map[string]CountSummary
CountSummaryByCategory is a map from category to CountSummary
func (CountSummaryByCategory) AddSummary ¶
func (csc CountSummaryByCategory) AddSummary(other CountSummaryByCategory)
AddSummary adds two CountSummaryByCategories together
type PodResult ¶
type PodResult struct { Name string `json:"name"` Results ResultSet `json:"results"` ContainerResults []ContainerResult `json:"containerResults"` }
PodResult provides a list of validation messages for each pod.
func ValidatePod ¶
func ValidatePod(conf *config.Configuration, controller controllers.Interface) (PodResult, error)
ValidatePod validates that each pod conforms to the Polaris config, returns a ResourceResult.
func (PodResult) GetSummary ¶
func (p PodResult) GetSummary() CountSummary
GetSummary summarizes a PodResult
func (PodResult) GetSummaryByCategory ¶
func (p PodResult) GetSummaryByCategory() CountSummaryByCategory
GetSummaryByCategory summarizes a PodResult
type ResultMessage ¶
type ResultMessage struct { ID string `json:"id"` Message string `json:"message"` Success bool `json:"success"` Severity config.Severity `json:"severity"` Category string `json:"category"` }
ResultMessage is the result of a given check
type ResultSet ¶
type ResultSet map[string]ResultMessage
ResultSet contiains the results for a set of checks
func (ResultSet) GetErrors ¶
func (rs ResultSet) GetErrors() []ResultMessage
GetErrors returns the error messages in a result set
func (ResultSet) GetSortedResults ¶
func (rs ResultSet) GetSortedResults() []ResultMessage
GetSortedResults returns messages sorted as errors, then warnings, then successes
func (ResultSet) GetSuccesses ¶
func (rs ResultSet) GetSuccesses() []ResultMessage
GetSuccesses returns the success messages in a result set
func (ResultSet) GetSummary ¶
func (rs ResultSet) GetSummary() CountSummary
GetSummary summarizes a ResultSet
func (ResultSet) GetSummaryByCategory ¶
func (rs ResultSet) GetSummaryByCategory() CountSummaryByCategory
GetSummaryByCategory summarizes a ResultSet
func (ResultSet) GetWarnings ¶
func (rs ResultSet) GetWarnings() []ResultMessage
GetWarnings returns the warning messages in a result set