plan

package
v0.0.0-...-5abfebf Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PendingState represents the initial status of a plan once it has been created.
	PendingState State = "pending"
	// RunningState represents the status of a plan when it is being executed
	RunningState State = "running"
	// ErroredState represents the status of a plan when it has encountered an error
	ErroredState State = "errored"
	// CanceledState represents the status of a plan when it has been canceled
	CanceledState State = "canceled"
	// FinishedState represents the status of a plan when it has been successfully executed
	FinishedState State = "finished"
	// UnreachableState represents the status of a plan when it has been unreachable
	UnreachableState State = "unreachable"

	// DefaultType represents a plan that is executed once and does not have a schedule
	DefaultType Type = "default"
	// ScheduleType represents a plan that is executed on a schedule
	ScheduleType Type = "schedule"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Plan

type Plan struct {
	// ID defines the unique identifier.
	ID int `gorm:"primaryKey"`

	// Name defines the unique name of the plan.
	// It is also used by the state manager to map real world resources to your configuration
	Name string `gorm:"index:idx_name,unique"`

	// Type defines the type of the plan.
	Type Type `gorm:"default:'default'"`

	// States defines the state of the execution.
	State State `gorm:"default:'pending'"`

	// Schedule defines the schedule of the execution.
	// if the plan is of type fire_and_forget, this field is set to "none"
	Schedule string `gorm:"default:'none'"`

	// ModuleID defines the identifier of the module.
	ModuleID int           `gorm:"not null"`
	Module   module.Module `gorm:"foreignKey:ModuleID;references:ID"`

	// Variables defines the variables of the plan.
	Variables []planVariable.PlanVariable `gorm:"foreignKey:PlanID;references:ID"`

	// Audit fields
	trackable.CreatedBy
	CreatedAt time.Time `gorm:"autoCreateTime"`
	trackable.UpdatedBy
	UpdatedAt time.Time `gorm:"autoUpdateTime"`
}

Plan represents a plan with its details and audit fields.

func (*Plan) BeforeCreate

func (u *Plan) BeforeCreate(tx *gorm.DB) (err error)

BeforeCreate executes the logic before creating a plan.

func (*Plan) BeforeUpdate

func (u *Plan) BeforeUpdate(tx *gorm.DB) (err error)

BeforeUpdate executes the logic before updating a plan.

func (*Plan) Sanitize

func (u *Plan) Sanitize(tx *gorm.DB)

Sanitize applies the business logic to the plan, it used to ensure that the plan is in a valid state.

type State

type State string

State represents the state of a plan

type Store

type Store struct {
	data.Generic[Plan]
}

Store struct manages interactions with authors store

func New

func New(db *gorm.DB) *Store

New creates a new Store struct

type Type

type Type string

Type represents the type of the plan

Jump to

Keyboard shortcuts

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