mirror of
https://github.com/FairwindsOps/polaris.git
synced 2026-05-10 19:26:46 +00:00
**Changes** - Refactored the way controllers work to be an interface - Added configurable controllers to include in scans - Added daemonsets, jobs and cronjobs in scans - Added `ReplicationController` type controllers to the supported list - Adjusted logic for failed YAML parsing to bubble up errors - Added better logic for calculating summaries on cluster wide results - Relocated responsibilities for counting types into validators vs spreading it around more packages - Fixed bug where cronjob parsing was using wrong KIND - Added fixtures for mocking new controller types - Added example yamls to test scanning files - Added functions to NamespacedResult(s) to reduce code complexity deep set iterations - Refactored how results get added to namespacedresults so adding more later is easier - Minor signature changes for interface implementing structs for controllers
38 lines
1.2 KiB
Go
38 lines
1.2 KiB
Go
package controllers
|
|
|
|
import (
|
|
"github.com/fairwindsops/polaris/pkg/config"
|
|
kubeAPIAppsV1 "k8s.io/api/apps/v1"
|
|
kubeAPICoreV1 "k8s.io/api/core/v1"
|
|
)
|
|
|
|
// DeploymentController is an implementation of controller for deployments
|
|
type DeploymentController struct {
|
|
GenericController
|
|
K8SResource kubeAPIAppsV1.Deployment
|
|
}
|
|
|
|
// GetPodTemplate returns the original template spec
|
|
func (d DeploymentController) GetPodTemplate() *kubeAPICoreV1.PodTemplateSpec {
|
|
return &d.K8SResource.Spec.Template
|
|
}
|
|
|
|
// GetPodSpec returns the original kubernetes template pod spec
|
|
func (d DeploymentController) GetPodSpec() *kubeAPICoreV1.PodSpec {
|
|
return &d.K8SResource.Spec.Template.Spec
|
|
}
|
|
|
|
// GetType returns the supportedcontroller enum type
|
|
func (d DeploymentController) GetType() config.SupportedController {
|
|
return config.Deployments
|
|
}
|
|
|
|
// NewDeploymentController builds a new controller interface for Deployments
|
|
func NewDeploymentController(originalDeploymentResource kubeAPIAppsV1.Deployment) Interface {
|
|
controller := DeploymentController{}
|
|
controller.Name = originalDeploymentResource.Name
|
|
controller.Namespace = originalDeploymentResource.Namespace
|
|
controller.K8SResource = originalDeploymentResource
|
|
return controller
|
|
}
|