pkg

package
v0.0.0-...-83e02d6 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2023 License: MIT Imports: 44 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExecuteDefaultSeeds

func ExecuteDefaultSeeds(ctx context.Context, db *ent.Client) error

func LogFromCtx

func LogFromCtx(ctx context.Context) *slog.Logger

LogFromCtx returns a Logger from a context. If no logger is found in the context, a new one is created using a default text handler.

func LogIntoCtx

func LogIntoCtx(ctx context.Context, logger *slog.Logger) context.Context

LogIntoCtx returns a new context with the given logger.

func NewDatabaseConnection

func NewDatabaseConnection(input NewDatabaseConnectionInput) (*ent.Client, error)

Types

type AccessModel

type AccessModel struct {
	ID        int       `json:"id"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
	ProjectID int       `json:"project_id"`
	UserID    int       `json:"user_id"`
	Role      string    `json:"role"`
}

type Config

type Config struct {
	DataDirectory        string
	Port                 int
	DBConnection         *ent.Client
	LogLevel             string
	LogFormat            string
	DevMode              bool
	CallbackURL          string
	HistoryRetentionDays int
	Brand                string
	SMTPHost             string
	SMTPPort             int
	SMTPUsername         string
	SMTPPassword         string
	SMTPFrom             string
}

func NewConfig

func NewConfig() *Config

type CreateAccessInput

type CreateAccessInput struct {
	ProjectID int
	UserID    int
	Role      string
}

type CreateHistoryInput

type CreateHistoryInput struct {
	ScriptID        int
	Success         bool
	Output          string
	DurationSeconds int
	Trigger         string
	TriggeredBy     string
	RunID           string
	ExitCode        int
	Status          string
	Arguments       map[string]string
}

type CreateNotificationChannelInput

type CreateNotificationChannelInput struct {
	Name          string
	Type          string
	SlackConfig   schema.SlackConfig
	EmailConfig   schema.EmailConfig
	WebhookConfig schema.WebhookConfig
	Enabled       bool
}

type CreateScriptInput

type CreateScriptInput struct {
	ProjectID                    int
	Name                         string
	Script                       string
	Description                  string
	TimeoutSeconds               int
	Parameters                   []schema.ScriptInputOptions
	SuccessNotificationChannelID *int
	FailureNotificationChannelID *int
	ScheduleCron                 string
	ScheduleEnabled              bool
}

type CreateScriptStatsInput

type CreateScriptStatsInput struct {
	ScriptID  int
	ProjectID int
}

type CreateSecretInput

type CreateSecretInput struct {
	Name      string
	Value     string
	CreatedBy string
	ProjectID int
}

type CreateUserInput

type CreateUserInput struct {
	Email    string
	Password string
	Role     string
	APIKey   string
}

type FrontendScriptBlobModel

type FrontendScriptBlobModel struct {
	Parameters []schema.ScriptInputOptions `json:"parameters"`
}

type FrontendScriptHistoryModel

type FrontendScriptHistoryModel struct {
	HistoryModel
	ScriptName string
	ProjectID  int
	ScriptID   int
}

type HistoryModel

type HistoryModel struct {
	ID          int       `json:"id"`
	CreatedAt   time.Time `json:"created_at"`
	UpdatedAt   time.Time `json:"updated_at"`
	ScriptID    int       `json:"script_id"`
	Trigger     string    `json:"trigger"`
	Success     bool      `json:"success"`
	TriggeredBy string    `json:"triggered_by"`
	ExitCode    int       `json:"exit_code"`
	Duration    int       `json:"duration"`
	Output      string    `json:"output"`
	RunID       string    `json:"run_id"`
	Status      string    `json:"status"`
	Arguments   map[string]string
}

func (HistoryModel) FormatTime

func (s HistoryModel) FormatTime() string

func (HistoryModel) HumanizeCreatedAt

func (s HistoryModel) HumanizeCreatedAt() string

type NewDatabaseConnectionInput

type NewDatabaseConnectionInput struct {
	InMemory bool
	Location string
}

type NewProjectInput

type NewProjectInput struct {
	Name        string
	Description string
}

type NewServerInput

type NewServerInput struct {
	Port          int
	DB            *ent.Client
	DevMode       bool
	CallbackURL   string
	RetentionDays int
	Brand         string
	SMPTHost      string
	SMPTPort      int
	SMPTUsername  string
	SMPTPassword  string
	SMPTFrom      string
}

type NotificationChannelModel

type NotificationChannelModel struct {
	ID                 int                  `json:"id"`
	CreatedAt          time.Time            `json:"created_at"`
	UpdatedAt          time.Time            `json:"updated_at"`
	Name               string               `json:"name"`
	Type               string               `json:"type"`
	SlackConfig        schema.SlackConfig   `json:"slack_config"`
	EmailConfig        schema.EmailConfig   `json:"email_config"`
	WebhookConfig      schema.WebhookConfig `json:"webhook_config"`
	Enabled            bool                 `json:"enabled"`
	LastSendSuccessful *bool                `json:"last_send_successful"`
	LastSend           *time.Time           `json:"last_send"`
	LastSendHuman      string               `json:"last_send_human"`
	HasBeenUsed        bool                 `json:"has_been_used"`
}

type ProjectModel

type ProjectModel struct {
	ID          int       `json:"id"`
	Name        string    `json:"name"`
	CreatedAt   time.Time `json:"created_at"`
	UpdatedAt   time.Time `json:"updated_at"`
	Description string    `json:"description"`
}

type QueryHistoriesInput

type QueryHistoriesInput struct {
	Limit       int
	Offset      int
	ScriptID    *int
	Trigger     *string
	Status      *string
	Duration    *int
	Success     *bool
	TriggeredBy *string
}

type Renderer

type Renderer struct {
	// contains filtered or unexported fields
}

func (*Renderer) Render

func (t *Renderer) Render(w io.Writer, name string, data any, c echo.Context) error

type RunScriptInput

type RunScriptInput struct {
	Script         ScriptModel
	Caller         string
	Trigger        string
	Args           map[string]string
	ProjectID      int
	ProjectName    string
	SuccessChannel *NotificationChannelModel
	FailureChannel *NotificationChannelModel
}

type SMPTSettings

type SMPTSettings struct {
	Host     string
	Port     int
	Username string
	Password string
	From     string
}

type ScriptModel

type ScriptModel struct {
	ID                    int       `json:"id"`
	Name                  string    `json:"name"`
	CreatedAt             time.Time `json:"created_at"`
	UpdatedAt             time.Time `json:"updated_at"`
	Description           string    `json:"description"`
	ProjectID             int       `json:"project_id"`
	TimeoutSeconds        int       `json:"timeout_seconds"`
	Parameters            []schema.ScriptInputOptions
	Script                string `json:"script"`
	SuccessNotificationID *int   `json:"success_notification_id"`
	FailureNotificationID *int   `json:"failure_notification_id"`
	ScheduleEnabled       bool   `json:"schedule_enabled"`
	ScheduleCron          string `json:"schedule_cron"`
}

type ScriptStatsModel

type ScriptStatsModel struct {
	ID              int       `json:"id"`
	ScriptID        int       `json:"script_id"`
	ProjectID       int       `json:"project_id"`
	TotalRuns       int       `json:"total_runs"`
	TotalSuccess    int       `json:"total_success"`
	TotalError      int       `json:"total_error"`
	AverageDuration int       `json:"average_duration"`
	LastRun         time.Time `json:"last_run"`
	LongestRun      int       `json:"longest_run"`
	ShortestRun     int       `json:"shortest_run"`
	TotalDuration   int       `json:"total_duration"`
	SuccessRate     float64   `json:"success_rate"`
}

func (*ScriptStatsModel) FormatTimeLastRun

func (s *ScriptStatsModel) FormatTimeLastRun() string

func (*ScriptStatsModel) HumanizeLastRun

func (s *ScriptStatsModel) HumanizeLastRun() string

type SecretModel

type SecretModel struct {
	ID        int       `json:"id"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
	Name      string    `json:"name"`
	Value     string    `json:"value"`
}

type Server

type Server struct {
	// contains filtered or unexported fields
}

func NewServer

func NewServer(input NewServerInput) *Server

func (*Server) Run

func (s *Server) Run(ctx context.Context)

type SessionData

type SessionData struct {
	Email     string
	Role      string
	ExpiresAt time.Time
}

type SessionManager

type SessionManager struct {
	// contains filtered or unexported fields
}

func NewSessionManager

func NewSessionManager() *SessionManager

func (*SessionManager) CreateSession

func (s *SessionManager) CreateSession(data SessionData) string

func (*SessionManager) DeleteSession

func (s *SessionManager) DeleteSession(id string)

func (*SessionManager) GetSession

func (s *SessionManager) GetSession(id string) (SessionData, error)

type SlackNotifyInput

type SlackNotifyInput struct {
	ProjectName string
	ScriptName  string
	HistoryLink string
	Success     bool
}

type UpdateHistoryInput

type UpdateHistoryInput struct {
	Success         *bool
	Output          *string
	DurationSeconds *int
	Trigger         *string
	TriggeredBy     *string
	RunID           *string
	ExitCode        *int
	Status          *string
	Arguments       *map[string]string
}

type UpdateNotificationChannelInput

type UpdateNotificationChannelInput struct {
	Name            *string
	Type            *string
	SlackConfig     *schema.SlackConfig
	EmailConfig     *schema.EmailConfig
	WebhookConfig   *schema.WebhookConfig
	Enabled         *bool
	LastUsed        *time.Time
	LastUsedSuccess *bool
}

type UpdateProjectInput

type UpdateProjectInput struct {
	Name        *string
	Description *string
}

type UpdateScriptInput

type UpdateScriptInput struct {
	Name                         *string
	Script                       *string
	Description                  *string
	TimeoutSeconds               *int
	Parameters                   *[]schema.ScriptInputOptions
	SuccessNotificationChannelID *int
	FailureNotificationChannelID *int
	ScheduleCron                 *string
	ScheduleEnabled              *bool
}

type UpdateScriptStatsInput

type UpdateScriptStatsInput struct {
	ScriptID         int
	IncrementSuccess bool
	IncrementError   bool
	DurationSeconds  int
}

type UpdateSecretInput

type UpdateSecretInput struct {
	Name  *string
	Value *string
}

type UpdateUserInput

type UpdateUserInput struct {
	Password *string
	Role     *string
	APIKey   *string
}

type UserModel

type UserModel struct {
	ID             int       `json:"id"`
	Email          string    `json:"email"`
	CreatedAt      time.Time `json:"created_at"`
	UpdatedAt      time.Time `json:"updated_at"`
	APIKey         string    `json:"api_key"`
	Role           string    `json:"role"`
	HashedPassword string    `json:"-"`
}

type WebhookNotificationPayload

type WebhookNotificationPayload struct {
	ProjectName     string            `json:"project_name"`
	ScriptName      string            `json:"script_name"`
	HistoryLink     string            `json:"history_link"`
	Success         bool              `json:"success"`
	TriggeredBy     string            `json:"triggered_by"`
	Trigger         string            `json:"trigger"`
	DurationSeconds int               `json:"duration_seconds"`
	Arguments       map[string]string `json:"arguments,omitempty"`
	RunID           int               `json:"run_id"`
	CreatedAt       time.Time         `json:"created_at"`
}

Jump to

Keyboard shortcuts

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