Documentation
¶
Index ¶
- Constants
- func RegisterModule(typ string, factory Factory)
- type Config
- type DeploymentScanner
- func (s *DeploymentScanner) GetConfig() Config
- func (s *DeploymentScanner) GetObjects() ([]*Object, error)
- func (s *DeploymentScanner) GetState(obj *Object) (int, error)
- func (s *DeploymentScanner) Scale(obj *Object, state *int, replicas int) error
- func (s *DeploymentScanner) SetConfig(cfg Config)
- func (s *DeploymentScanner) Watch(_stop chan bool) (chan Event, error)
- type Event
- type Factory
- type Object
- type OpenShiftScanner
- func (s *OpenShiftScanner) GetConfig() Config
- func (s *OpenShiftScanner) GetObjects() ([]*Object, error)
- func (s *OpenShiftScanner) GetState(obj *Object) (int, error)
- func (s *OpenShiftScanner) Scale(obj *Object, state *int, replicas int) error
- func (s *OpenShiftScanner) SetConfig(cfg Config)
- func (s *OpenShiftScanner) Watch(_stop chan bool) (chan Event, error)
- type Scanner
- type State
- type StatefulSetScanner
- func (s *StatefulSetScanner) GetConfig() Config
- func (s *StatefulSetScanner) GetObjects() ([]*Object, error)
- func (s *StatefulSetScanner) GetState(obj *Object) (int, error)
- func (s *StatefulSetScanner) Scale(obj *Object, state *int, replicas int) error
- func (s *StatefulSetScanner) SetConfig(cfg Config)
- func (s *StatefulSetScanner) Watch(_stop chan bool) (chan Event, error)
Constants ¶
const ( // EventAdd is used to indicate a resource was added in a Event EventAdd string = "add" // EventRemove is used to indicate a resource was removed in a Event EventRemove string = "remove" // EventUpdate is used to indicate a resource was updated in a Event EventUpdate string = "update" )
const ( // ScheduleAnnotation is the annotation used to define schedules on resources. ScheduleAnnotation string = "joyrex2001.com/nightshift.schedule" // IgnoreAnnotation is the annotation used to define a resource should be ignored. IgnoreAnnotation string = "joyrex2001.com/nightshift.ignore" // SaveStateAnnotation is the annotation used to store the state. SaveStateAnnotation string = "joyrex2001.com/nightshift.savestate" )
Variables ¶
This section is empty.
Functions ¶
func RegisterModule ¶
RegisterModule will add the provided module, with given factory method to the list of available modules in order to support dependency injection, as well as easing up modular development for scanners.
Types ¶
type Config ¶
type Config struct { Id string `json:"id"` Namespace string `json:"namespace"` Label string `json:"label"` Schedule []*schedule.Schedule `json:"schedule"` Type string `json:"type"` Priority int `json:"priority"` }
Config describes the configuration of a scanner. It includes ScannerType to allow to be used by the factory NewForConfig method.
type DeploymentScanner ¶
type DeploymentScanner struct {
// contains filtered or unexported fields
}
DeploymentScanner is the object that implements scanning of kubernetes Deployments.
func (*DeploymentScanner) GetConfig ¶
func (s *DeploymentScanner) GetConfig() Config
GetConfig will return the config applied for this scanner.
func (*DeploymentScanner) GetObjects ¶
func (s *DeploymentScanner) GetObjects() ([]*Object, error)
GetObjects will return a populated list of Objects containing the relavant resources with their schedule info.
func (*DeploymentScanner) GetState ¶
func (s *DeploymentScanner) GetState(obj *Object) (int, error)
GetState will return the current number of replicas.
func (*DeploymentScanner) Scale ¶
func (s *DeploymentScanner) Scale(obj *Object, state *int, replicas int) error
Scale will scale a given object to given amount of replicas.
func (*DeploymentScanner) SetConfig ¶
func (s *DeploymentScanner) SetConfig(cfg Config)
SetConfig will set the generic configuration for this scanner.
type Object ¶
type Object struct { Namespace string `json:"namespace"` UID string `json:"uid"` Name string `json:"name"` Type string `json:"type"` Schedule []*schedule.Schedule `json:"schedule"` State *State `json:"state"` Replicas int `json:"replicas"` Priority int `json:"priority"` ScannerId string `json:"scanner_id"` // contains filtered or unexported fields }
Object is an object found by the scanner.
func NewObjectForScanner ¶
NewObjectForScanner will return a new Object instance populated with the scanner details.
type OpenShiftScanner ¶
type OpenShiftScanner struct {
// contains filtered or unexported fields
}
OpenShiftScanner is the object that implements scanning of OpenShift DeploymentConfigs.
func (*OpenShiftScanner) GetConfig ¶
func (s *OpenShiftScanner) GetConfig() Config
GetConfig will return the config applied for this scanner.
func (*OpenShiftScanner) GetObjects ¶
func (s *OpenShiftScanner) GetObjects() ([]*Object, error)
GetObjects will return a populated list of Objects containing the relavant resources with their schedule info.
func (*OpenShiftScanner) GetState ¶
func (s *OpenShiftScanner) GetState(obj *Object) (int, error)
GetState will save the current number of replicas.
func (*OpenShiftScanner) Scale ¶
func (s *OpenShiftScanner) Scale(obj *Object, state *int, replicas int) error
Scale will scale a given object to given amount of replicas.
func (*OpenShiftScanner) SetConfig ¶
func (s *OpenShiftScanner) SetConfig(cfg Config)
SetConfig will set the generic configuration for this scanner.
type Scanner ¶
type Scanner interface { SetConfig(Config) GetConfig() Config GetObjects() ([]*Object, error) GetState(*Object) (int, error) Scale(*Object, *int, int) error Watch(chan bool) (chan Event, error) }
Scanner is the public interface of a scanner object.
func NewDeploymentScanner ¶
NewDeploymentScanner will instantiate a new DeploymentScanner object.
func NewForConfig ¶
NewForConfig will return a Scanner object based on the given Config object.
func NewOpenShiftScanner ¶
NewOpenShiftScanner will instantiate a new OpenShiftScanner object.
func NewStatefulSetScanner ¶
NewStatefulSetScanner will instantiate a new StatefulSetScanner object.
type State ¶
type State struct {
Replicas int `json:"replicas"`
}
State defines a state of the object.
type StatefulSetScanner ¶
type StatefulSetScanner struct {
// contains filtered or unexported fields
}
StatefulSetScanner is the object that implements scanning of OpenShift/k8s statefulsets.
func (*StatefulSetScanner) GetConfig ¶
func (s *StatefulSetScanner) GetConfig() Config
GetConfig will return the config applied for this scanner.
func (*StatefulSetScanner) GetObjects ¶
func (s *StatefulSetScanner) GetObjects() ([]*Object, error)
GetObjects will return a populated list of Objects containing the relavant resources with their schedule info.
func (*StatefulSetScanner) GetState ¶
func (s *StatefulSetScanner) GetState(obj *Object) (int, error)
GetState will save the current number of replicas.
func (*StatefulSetScanner) Scale ¶
func (s *StatefulSetScanner) Scale(obj *Object, state *int, replicas int) error
Scale will scale a given object to given amount of replicas.
func (*StatefulSetScanner) SetConfig ¶
func (s *StatefulSetScanner) SetConfig(cfg Config)
SetConfig will set the generic configuration for this scanner.