playbook

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2025 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateSlug

func GenerateSlug(title string) string

GenerateSlug creates a URL-friendly slug from the title

Types

type AddToCollectionCommand

type AddToCollectionCommand struct {
	*cmds.CommandDescription
	// contains filtered or unexported fields
}

AddToCollectionCommand adds entities to collections

func NewAddToCollectionCommand

func NewAddToCollectionCommand(storage *Storage) (*AddToCollectionCommand, error)

func (*AddToCollectionCommand) RunIntoWriter

func (c *AddToCollectionCommand) RunIntoWriter(ctx context.Context, parsedLayers *layers.ParsedLayers, w io.Writer) error

type AddToCollectionSettings

type AddToCollectionSettings struct {
	CollectionSlug string `glazed.parameter:"collection_slug"`
	MemberSlug     string `glazed.parameter:"member_slug"`
	RelativePath   string `glazed.parameter:"path"`
}

type CollectionMember

type CollectionMember struct {
	CollectionID int64   `json:"collection_id" db:"collection_id"`
	MemberID     int64   `json:"member_id" db:"member_id"`
	RelativePath *string `json:"relative_path,omitempty" db:"relative_path"`
}

CollectionMember represents membership in a collection

type CreateCollectionCommand

type CreateCollectionCommand struct {
	*cmds.CommandDescription
	// contains filtered or unexported fields
}

CreateCollectionCommand creates a new collection

func NewCreateCollectionCommand

func NewCreateCollectionCommand(storage *Storage) (*CreateCollectionCommand, error)

func (*CreateCollectionCommand) RunIntoWriter

func (c *CreateCollectionCommand) RunIntoWriter(ctx context.Context, parsedLayers *layers.ParsedLayers, w io.Writer) error

type CreateCollectionSettings

type CreateCollectionSettings struct {
	Name        string   `glazed.parameter:"name"`
	Title       string   `glazed.parameter:"title"`
	Description string   `glazed.parameter:"description"`
	Summary     string   `glazed.parameter:"summary"`
	Metadata    []string `glazed.parameter:"metadata"`
	Tags        []string `glazed.parameter:"tags"`
}

type DeployCommand

type DeployCommand struct {
	*cmds.CommandDescription
	// contains filtered or unexported fields
}

DeployCommand deploys entities to directories

func NewDeployCommand

func NewDeployCommand(storage *Storage) (*DeployCommand, error)

func (*DeployCommand) RunIntoWriter

func (c *DeployCommand) RunIntoWriter(ctx context.Context, parsedLayers *layers.ParsedLayers, w io.Writer) error

type DeploySettings

type DeploySettings struct {
	Slug             string `glazed.parameter:"slug"`
	TargetDirectory  string `glazed.parameter:"target_directory"`
	FilenameOverride string `glazed.parameter:"filename"`
}

type Deployment

type Deployment struct {
	ID              int64     `json:"id" db:"id"`
	EntityID        int64     `json:"entity_id" db:"entity_id"`
	TargetDirectory string    `json:"target_directory" db:"target_directory"`
	DeployedAt      time.Time `json:"deployed_at" db:"deployed_at"`
}

Deployment represents a deployment of an entity to a directory

type Entity

type Entity struct {
	ID           int64             `json:"id" db:"id"`
	Slug         string            `json:"slug" db:"slug"`
	Type         EntityType        `json:"type" db:"type"`
	Title        string            `json:"title" db:"title"`
	Description  string            `json:"description" db:"description"`
	Summary      string            `json:"summary" db:"summary"`
	CanonicalURL *string           `json:"canonical_url,omitempty" db:"canonical_url"`
	Content      *string           `json:"content,omitempty" db:"content"`
	Command      *string           `json:"command,omitempty" db:"command"`
	ContentHash  *string           `json:"content_hash,omitempty" db:"content_hash"`
	Filename     *string           `json:"filename,omitempty" db:"filename"`
	Tags         []string          `json:"tags" db:"tags"`
	LastFetched  *time.Time        `json:"last_fetched,omitempty" db:"last_fetched"`
	CreatedAt    time.Time         `json:"created_at" db:"created_at"`
	Metadata     map[string]string `json:"metadata,omitempty"`
}

Entity represents both playbooks and collections

func (*Entity) AddTag

func (e *Entity) AddTag(tag string)

AddTag adds a tag if it doesn't already exist

func (*Entity) GetContentOrCommand

func (e *Entity) GetContentOrCommand() string

GetContentOrCommand returns the content for file-based playbooks or command for shell playbooks

func (*Entity) HasTag

func (e *Entity) HasTag(tag string) bool

HasTag checks if entity has a specific tag

func (*Entity) IsCommand

func (e *Entity) IsCommand() bool

IsCommand returns true if this entity represents a shell command

func (*Entity) MarshalTags

func (e *Entity) MarshalTags() (string, error)

MarshalTags converts tags slice to JSON string for database storage

func (*Entity) RemoveTag

func (e *Entity) RemoveTag(tag string)

RemoveTag removes a tag if it exists

func (*Entity) UnmarshalTags

func (e *Entity) UnmarshalTags(tagsJSON string) error

UnmarshalTags converts JSON string from database to tags slice

type EntityMetadata

type EntityMetadata struct {
	EntityID int64  `json:"entity_id" db:"entity_id"`
	Key      string `json:"key" db:"key"`
	Value    string `json:"value" db:"value"`
}

EntityMetadata represents key-value metadata for entities

type EntityType

type EntityType string
const (
	TypePlaybook   EntityType = "playbook"
	TypeCollection EntityType = "collection"
)

type GetMetadataCommand

type GetMetadataCommand struct {
	*cmds.CommandDescription
	// contains filtered or unexported fields
}

GetMetadataCommand gets metadata for an entity

func NewGetMetadataCommand

func NewGetMetadataCommand(storage *Storage) (*GetMetadataCommand, error)

func (*GetMetadataCommand) RunIntoGlazeProcessor

func (c *GetMetadataCommand) RunIntoGlazeProcessor(ctx context.Context, parsedLayers *layers.ParsedLayers, gp middlewares.Processor) error

type GetMetadataSettings

type GetMetadataSettings struct {
	Slug string `glazed.parameter:"slug"`
	Key  string `glazed.parameter:"key"`
}

type ListCommand

type ListCommand struct {
	*cmds.CommandDescription
	// contains filtered or unexported fields
}

ListCommand lists entities with optional filters

func NewListCommand

func NewListCommand(storage *Storage) (*ListCommand, error)

func (*ListCommand) RunIntoGlazeProcessor

func (c *ListCommand) RunIntoGlazeProcessor(ctx context.Context, parsedLayers *layers.ParsedLayers, gp middlewares.Processor) error

type ListSettings

type ListSettings struct {
	EntityType string   `glazed.parameter:"type"`
	Tags       []string `glazed.parameter:"tags"`
}

type RefreshCommand

type RefreshCommand struct {
	*cmds.CommandDescription
	// contains filtered or unexported fields
}

RefreshCommand refreshes deployments by re-executing commands

func NewRefreshCommand

func NewRefreshCommand(storage *Storage) (*RefreshCommand, error)

func (*RefreshCommand) RunIntoWriter

func (c *RefreshCommand) RunIntoWriter(ctx context.Context, parsedLayers *layers.ParsedLayers, w io.Writer) error

type RefreshSettings

type RefreshSettings struct {
	Slug            string `glazed.parameter:"slug"`
	TargetDirectory string `glazed.parameter:"target_directory"`
}

type RegisterCommand

type RegisterCommand struct {
	*cmds.CommandDescription
	// contains filtered or unexported fields
}

RegisterCommand registers a playbook from file or URL

func NewRegisterCommand

func NewRegisterCommand(storage *Storage) (*RegisterCommand, error)

func (*RegisterCommand) RunIntoWriter

func (c *RegisterCommand) RunIntoWriter(ctx context.Context, parsedLayers *layers.ParsedLayers, w io.Writer) error

type RegisterSettings

type RegisterSettings struct {
	Title       string   `glazed.parameter:"title"`
	Description string   `glazed.parameter:"description"`
	Summary     string   `glazed.parameter:"summary"`
	Metadata    []string `glazed.parameter:"metadata"`
	Tags        []string `glazed.parameter:"tags"`
	Filename    string   `glazed.parameter:"filename"`
	Source      string   `glazed.parameter:"source"`
	IsCommand   bool     `glazed.parameter:"command"`
}

type RemoveCommand

type RemoveCommand struct {
	*cmds.CommandDescription
	// contains filtered or unexported fields
}

RemoveCommand removes entities from collections or deletes entities

func NewRemoveCommand

func NewRemoveCommand(storage *Storage) (*RemoveCommand, error)

func (*RemoveCommand) RunIntoWriter

func (c *RemoveCommand) RunIntoWriter(ctx context.Context, parsedLayers *layers.ParsedLayers, w io.Writer) error

type RemoveSettings

type RemoveSettings struct {
	CollectionSlug string `glazed.parameter:"collection_slug"`
	MemberSlug     string `glazed.parameter:"member_slug"`
	EntitySlug     string `glazed.parameter:"entity_slug"`
}

type SearchCommand

type SearchCommand struct {
	*cmds.CommandDescription
	// contains filtered or unexported fields
}

SearchCommand searches entities

func NewSearchCommand

func NewSearchCommand(storage *Storage) (*SearchCommand, error)

func (*SearchCommand) RunIntoGlazeProcessor

func (c *SearchCommand) RunIntoGlazeProcessor(ctx context.Context, parsedLayers *layers.ParsedLayers, gp middlewares.Processor) error

type SearchSettings

type SearchSettings struct {
	Query      string `glazed.parameter:"query"`
	EntityType string `glazed.parameter:"type"`
}

type SetMetadataCommand

type SetMetadataCommand struct {
	*cmds.CommandDescription
	// contains filtered or unexported fields
}

SetMetadataCommand sets metadata for an entity

func NewSetMetadataCommand

func NewSetMetadataCommand(storage *Storage) (*SetMetadataCommand, error)

func (*SetMetadataCommand) RunIntoWriter

func (c *SetMetadataCommand) RunIntoWriter(ctx context.Context, parsedLayers *layers.ParsedLayers, w io.Writer) error

type SetMetadataSettings

type SetMetadataSettings struct {
	Slug  string `glazed.parameter:"slug"`
	Key   string `glazed.parameter:"key"`
	Value string `glazed.parameter:"value"`
}

type ShowCommand

type ShowCommand struct {
	*cmds.CommandDescription
	// contains filtered or unexported fields
}

ShowCommand shows detailed information about an entity

func NewShowCommand

func NewShowCommand(storage *Storage) (*ShowCommand, error)

func (*ShowCommand) RunIntoWriter

func (c *ShowCommand) RunIntoWriter(ctx context.Context, parsedLayers *layers.ParsedLayers, w io.Writer) error

type ShowSettings

type ShowSettings struct {
	Slug string `glazed.parameter:"slug"`
}

type Storage

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

Storage handles database operations for playbooks

func NewStorage

func NewStorage(dbPath string) (*Storage, error)

NewStorage creates a new storage instance and initializes the database

func (*Storage) AddToCollection

func (s *Storage) AddToCollection(collectionID, memberID int64, relativePath *string) error

AddToCollection adds an entity to a collection

func (*Storage) Close

func (s *Storage) Close() error

Close closes the database connection

func (*Storage) CreateEntity

func (s *Storage) CreateEntity(entity *Entity) error

CreateEntity creates a new entity (playbook or collection)

func (*Storage) DeleteEntity

func (s *Storage) DeleteEntity(id int64) error

DeleteEntity deletes an entity and all related data

func (*Storage) DeleteMetadata

func (s *Storage) DeleteMetadata(entityID int64, key string) error

DeleteMetadata removes metadata for an entity

func (*Storage) GetCollectionMembers

func (s *Storage) GetCollectionMembers(collectionID int64) ([]*CollectionMember, error)

GetCollectionMembers gets all members of a collection

func (*Storage) GetDeployments

func (s *Storage) GetDeployments(entityID int64) ([]*Deployment, error)

GetDeployments gets deployments for an entity

func (*Storage) GetEntityByID

func (s *Storage) GetEntityByID(id int64) (*Entity, error)

GetEntityByID retrieves an entity by its ID

func (*Storage) GetEntityBySlug

func (s *Storage) GetEntityBySlug(slug string) (*Entity, error)

GetEntityBySlug retrieves an entity by its slug

func (*Storage) GetMetadata

func (s *Storage) GetMetadata(entityID int64) (map[string]string, error)

GetMetadata gets all metadata for an entity

func (*Storage) ListEntities

func (s *Storage) ListEntities(entityType *EntityType, tags []string) ([]*Entity, error)

ListEntities lists entities with optional filters

func (*Storage) RecordDeployment

func (s *Storage) RecordDeployment(entityID int64, targetDirectory string) error

RecordDeployment records a deployment

func (*Storage) RemoveFromCollection

func (s *Storage) RemoveFromCollection(collectionID, memberID int64) error

RemoveFromCollection removes an entity from a collection

func (*Storage) SearchEntities

func (s *Storage) SearchEntities(query string, entityType *EntityType) ([]*Entity, error)

SearchEntities searches entities by query string

func (*Storage) SetMetadata

func (s *Storage) SetMetadata(entityID int64, key, value string) error

SetMetadata sets metadata for an entity

Jump to

Keyboard shortcuts

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