Documentation ¶
Index ¶
- Constants
- Variables
- type Config
- type CronEntry
- type CronType
- type Crontinuous
- func (c *Crontinuous) BulkCreate(typ CronType, entries []CronEntry, overwriteSettings []bool) error
- func (c *Crontinuous) GetEntries(typ CronType) ([]CronEntry, error)
- func (c *Crontinuous) GetEntryByID(typ CronType, ID string) (CronEntry, error)
- func (c *Crontinuous) RemoveEntry(typ CronType, ID string) error
- func (c *Crontinuous) SaveEntry(typ CronType, entry CronEntry) error
- func (c *Crontinuous) Start() error
- func (c *Crontinuous) Stop()
- type ReportCronStore
- type ReportEntry
- type ReportSender
- type S3CronStore
- type ScanCreator
- type ScanCronStore
- type ScanEntry
- type ScanRequest
- type VulcanClient
Constants ¶
const ( MaxRandomizeCronMinuteInterval int = 59 ScanCronType CronType = iota ReportCronType )
const (
S3ReportsCrontabFilename = "reportsCrontab.json"
)
const (
S3ScansCrontabFilename = "crontab.json"
)
Variables ¶
var ( // ErrScheduleNotFound is returned by DeleteSchedule method if the id for the schedule is not found. ErrScheduleNotFound = errors.New("ErrorScheduleNotFound") // ErrMalformedSchedule indicates the given cron spec is invalid. ErrMalformedSchedule = errors.New("ErrorMalformedSchedule") // ErrMalformedEntry indicates the given entry is invalid. ErrMalformedEntry = errors.New("ErrorMalformedEntry") // ErrInvalidCronType indicates the given cron type is invalid. ErrInvalidCronType = errors.New("ErrInvalidCronType") )
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { Bucket string EnableTeamsWhitelistScan bool TeamsWhitelistScan []string EnableTeamsWhitelistReport bool TeamsWhitelistReport []string RandomizeCronMinuteProgramSuffixes string RandomizeCronMinuteInterval int }
Config holds the information required by the Crontinuous
type Crontinuous ¶
type Crontinuous struct {
// contains filtered or unexported fields
}
Crontinuous implements the logic for storing and executing programs.
func NewCrontinuous ¶
func NewCrontinuous(cfg Config, logger *logrus.Logger, scanCreator ScanCreator, scanCronStore ScanCronStore, reportSender ReportSender, reportCronStore ReportCronStore) *Crontinuous
NewCrontinuous creates a new instance of the crontinuous service.
func (*Crontinuous) BulkCreate ¶
func (c *Crontinuous) BulkCreate(typ CronType, entries []CronEntry, overwriteSettings []bool) error
BulkCreate tests for each specified entry if an entry with the same programID exists. If it exists and overwrite setting for that entry is set to false the method does nothing. If it doesn't exist or overwrite setting is set to true, the method creates/overwrites the entry.
func (*Crontinuous) GetEntries ¶
func (c *Crontinuous) GetEntries(typ CronType) ([]CronEntry, error)
GetEntries returns a snapshot of the current entries.
func (*Crontinuous) GetEntryByID ¶
func (c *Crontinuous) GetEntryByID(typ CronType, ID string) (CronEntry, error)
GetEntryByID returns a snapshot of the current entries.
func (*Crontinuous) RemoveEntry ¶
func (c *Crontinuous) RemoveEntry(typ CronType, ID string) error
RemoveEntry remove an existing entry.
func (*Crontinuous) SaveEntry ¶
func (c *Crontinuous) SaveEntry(typ CronType, entry CronEntry) error
SaveEntry adds a new entry to the crontab.
func (*Crontinuous) Start ¶
func (c *Crontinuous) Start() error
Start reads the cron entries from store, s3 by now, and initializes all the entries.
func (*Crontinuous) Stop ¶
func (c *Crontinuous) Stop()
Stop signals the command processor to stop processing commands and wait for it to exit.
type ReportCronStore ¶
type ReportCronStore interface { GetReportEntries() (map[string]ReportEntry, error) SaveReportEntries(entries map[string]ReportEntry) error }
type ReportEntry ¶
ReportEntry defines the data stored by a report cron entry.
func (ReportEntry) GetCronSpec ¶
func (e ReportEntry) GetCronSpec() string
func (ReportEntry) GetID ¶
func (e ReportEntry) GetID() string
type ReportSender ¶
ReportSender defines the service needed by the crontinuos component in order to trigger digest reports generation and sending.
type S3CronStore ¶
type S3CronStore struct {
// contains filtered or unexported fields
}
func NewS3CronStore ¶
func NewS3CronStore(bucket, scanCronKey, reportCronKey string, s3Client s3iface.S3API) *S3CronStore
func (*S3CronStore) GetReportEntries ¶
func (s *S3CronStore) GetReportEntries() (map[string]ReportEntry, error)
func (*S3CronStore) GetScanEntries ¶
func (s *S3CronStore) GetScanEntries() (map[string]ScanEntry, error)
func (*S3CronStore) SaveReportEntries ¶
func (s *S3CronStore) SaveReportEntries(entries map[string]ReportEntry) error
func (*S3CronStore) SaveScanEntries ¶
func (s *S3CronStore) SaveScanEntries(entries map[string]ScanEntry) error
type ScanCreator ¶
ScanCreator defines the services needed by the crontinuos component in order to create scans.
type ScanCronStore ¶
type ScanEntry ¶
type ScanEntry struct { ProgramID string `json:"program_id"` TeamID string `json:"team_id"` CronSpec string `json:"cron_spec"` }
ScanEntry defines the data stored by a scan cron entry.
func (ScanEntry) GetCronSpec ¶
type ScanRequest ¶
type ScanRequest struct { ProgramID string `json:"program_id"` ScheduledTime time.Time `json:"scheduled_time"` RequestedBy string `json:"requested_by"` }
ScanRequest contains the payload to send to the API scan endpoint.
type VulcanClient ¶
type VulcanClient struct { VulcanAPI string VulcanUser string VulcanToken string Log *logrus.Logger }
VulcanClient provides functionality for interacting with the vulcan-api.
func (*VulcanClient) CreateScan ¶
func (c *VulcanClient) CreateScan(scanID, teamID string) error
CreateScan creates a scan by calling vulcan-api
func (*VulcanClient) SendReport ¶
func (c *VulcanClient) SendReport(teamID string) error
SendReport triggers a report sending operation by calling vulcan-api.