operations

package
v0.4.4 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2026 License: GPL-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidCommand     = errors.New("invalid command")
	ErrInvalidOption      = errors.New("invalid option")
	ErrInvalidServiceName = errors.New("invalid service name")
	ErrCommandInjection   = errors.New("command injection detected")
)

Functions

func ValidateOperationRequest

func ValidateOperationRequest(req OperationRequest) error

Types

type Broadcaster

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

func NewBroadcaster

func NewBroadcaster(operationID string) *Broadcaster

func (*Broadcaster) Broadcast

func (b *Broadcaster) Broadcast(msgType StreamMessageType, data string)

func (*Broadcaster) BroadcastComplete

func (b *Broadcaster) BroadcastComplete(success bool, exitCode int)

func (*Broadcaster) BroadcastError

func (b *Broadcaster) BroadcastError(errorMsg string)

func (*Broadcaster) IsCompleted

func (b *Broadcaster) IsCompleted() bool

func (*Broadcaster) IsStarted

func (b *Broadcaster) IsStarted() bool

func (*Broadcaster) MarkStarted

func (b *Broadcaster) MarkStarted()

func (*Broadcaster) Subscribe

func (b *Broadcaster) Subscribe(subscriberID string, writer io.Writer) error

func (*Broadcaster) Unsubscribe

func (b *Broadcaster) Unsubscribe(subscriberID string)

type BroadcasterProgressWriter

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

func NewBroadcasterProgressWriter

func NewBroadcasterProgressWriter(broadcaster *Broadcaster) *BroadcasterProgressWriter

func (*BroadcasterProgressWriter) WriteError

func (w *BroadcasterProgressWriter) WriteError(message string)

func (*BroadcasterProgressWriter) WriteMessage

func (w *BroadcasterProgressWriter) WriteMessage(messageType, message string)

func (*BroadcasterProgressWriter) WriteProgress

func (w *BroadcasterProgressWriter) WriteProgress(message string)

func (*BroadcasterProgressWriter) WriteStderr

func (w *BroadcasterProgressWriter) WriteStderr(message string)

func (*BroadcasterProgressWriter) WriteStdout

func (w *BroadcasterProgressWriter) WriteStdout(message string)

type CompleteMessage

type CompleteMessage struct {
	Type     StreamMessageType `json:"type"`
	Success  bool              `json:"success"`
	ExitCode int               `json:"exitCode"`
}

type Handler

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

func NewHandler

func NewHandler(service *Service, auditService *audit.Service) *Handler

func (*Handler) GetOperationStatus

func (h *Handler) GetOperationStatus(c echo.Context) error

func (*Handler) StartOperation

func (h *Handler) StartOperation(c echo.Context) error

func (*Handler) StreamOperation

func (h *Handler) StreamOperation(c echo.Context) error

type Message

type Message struct {
	Type      StreamMessageType
	Data      string
	Timestamp time.Time
	Success   *bool
	ExitCode  *int
}

type Operation

type Operation struct {
	ID          string
	StackName   string
	Request     OperationRequest
	StartTime   time.Time
	Status      string
	ExitCode    *int
	IsSelfOp    bool
	Broadcaster *Broadcaster
}

type OperationRequest

type OperationRequest struct {
	Command             string               `json:"command"`
	Options             []string             `json:"options"`
	Services            []string             `json:"services"`
	RegistryCredentials []RegistryCredential `json:"registry_credentials,omitempty"`
}

type OperationResponse

type OperationResponse struct {
	OperationID string `json:"operationId"`
}

type RegistryCredential

type RegistryCredential struct {
	Registry string `json:"registry"`
	Username string `json:"username"`
	Password string `json:"password"`
}

type Service

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

func NewService

func NewService(stackLocation, accessToken string, logger *logging.Logger, auditService *audit.Service) *Service

func NewServiceWithConfig

func NewServiceWithConfig(cfg *config.Config, logger *logging.Logger, auditService *audit.Service) *Service

func (*Service) GetOperation

func (s *Service) GetOperation(operationID string) (*Operation, bool)

func (*Service) StartOperation

func (s *Service) StartOperation(ctx context.Context, stackName string, req OperationRequest) (string, error)

func (*Service) StreamOperation

func (s *Service) StreamOperation(ctx context.Context, operationID string, writer io.Writer) error

type StreamMessage

type StreamMessage struct {
	Type      string    `json:"type"`
	Data      string    `json:"data"`
	Timestamp time.Time `json:"timestamp"`
}

type StreamMessageType

type StreamMessageType string
const (
	StreamTypeStdout   StreamMessageType = "stdout"
	StreamTypeStderr   StreamMessageType = "stderr"
	StreamTypeProgress StreamMessageType = "progress"
	StreamTypeComplete StreamMessageType = "complete"
	StreamTypeError    StreamMessageType = "error"
)

type Subscriber

type Subscriber struct {
	ID     string
	Writer io.Writer
}

Jump to

Keyboard shortcuts

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