modules

package
v0.6.3 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BuiltinDiscovery

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

BuiltinDiscovery discovers built-in modules

func (*BuiltinDiscovery) DiscoverModules

func (d *BuiltinDiscovery) DiscoverModules(ctx context.Context) ([]*Module, error)

func (*BuiltinDiscovery) GetSourceType

func (d *BuiltinDiscovery) GetSourceType() string

func (*BuiltinDiscovery) SetConfig

func (d *BuiltinDiscovery) SetConfig(config ModuleConfig)

type DaggerExecutor

type DaggerExecutor struct{}

DaggerExecutor executes Dagger-based modules

func (*DaggerExecutor) CanExecute

func (e *DaggerExecutor) CanExecute(module *Module) bool

func (*DaggerExecutor) Execute

func (e *DaggerExecutor) Execute(ctx context.Context, module *Module, command string, args []string, flags map[string]interface{}) (*ExecutionResult, error)

type DaggerModuleSpec

type DaggerModuleSpec struct {
	Module   string `yaml:"module"`
	Function string `yaml:"function"`
}

DaggerModuleSpec defines Dagger-based module configuration

type Discovery

type Discovery interface {
	DiscoverModules(ctx context.Context) ([]*Module, error)
	GetSourceType() string
	SetConfig(config ModuleConfig)
}

Discovery interface for module discovery

type DiscoveryManager

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

DiscoveryManager manages multiple module discovery sources

func NewDiscoveryManager

func NewDiscoveryManager(config ModuleConfig) *DiscoveryManager

NewDiscoveryManager creates a new discovery manager

func (*DiscoveryManager) DiscoverAll

func (dm *DiscoveryManager) DiscoverAll(ctx context.Context) ([]*Module, error)

DiscoverAll discovers modules from all sources

type DockerExecutor

type DockerExecutor struct{}

DockerExecutor executes Docker-based modules

func (*DockerExecutor) CanExecute

func (e *DockerExecutor) CanExecute(module *Module) bool

func (*DockerExecutor) Execute

func (e *DockerExecutor) Execute(ctx context.Context, module *Module, command string, args []string, flags map[string]interface{}) (*ExecutionResult, error)

type DockerModuleSpec

type DockerModuleSpec struct {
	Image      string            `yaml:"image"`
	Entrypoint []string          `yaml:"entrypoint,omitempty"`
	Env        map[string]string `yaml:"env,omitempty"`
	WorkingDir string            `yaml:"workingDir,omitempty"`
	Volumes    []VolumeMount     `yaml:"volumes,omitempty"`
}

DockerModuleSpec defines Docker-based module configuration

type ExecutionResult

type ExecutionResult struct {
	ExitCode int               `json:"exitCode"`
	Stdout   string            `json:"stdout"`
	Stderr   string            `json:"stderr"`
	Duration time.Duration     `json:"duration"`
	Metadata map[string]string `json:"metadata,omitempty"`
}

ExecutionResult represents the result of module execution

type ExecutorRegistry

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

ExecutorRegistry manages module executors

func NewExecutorRegistry

func NewExecutorRegistry() *ExecutorRegistry

NewExecutorRegistry creates a new executor registry

func (*ExecutorRegistry) Execute

func (r *ExecutorRegistry) Execute(ctx context.Context, module *Module, command string, args []string, flags map[string]interface{}) (*ExecutionResult, error)

Execute executes a module using the appropriate executor

func (*ExecutorRegistry) Register

func (r *ExecutorRegistry) Register(moduleType ModuleType, executor ModuleExecutor)

Register registers an executor for a module type

type GitDiscovery

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

GitDiscovery discovers modules from Git repositories

func (*GitDiscovery) DiscoverModules

func (d *GitDiscovery) DiscoverModules(ctx context.Context) ([]*Module, error)

func (*GitDiscovery) GetSourceType

func (d *GitDiscovery) GetSourceType() string

func (*GitDiscovery) SetConfig

func (d *GitDiscovery) SetConfig(config ModuleConfig)

type GitRepository

type GitRepository struct {
	URL     string `yaml:"url"`
	Ref     string `yaml:"ref"`
	Path    string `yaml:"path,omitempty"`
	Trusted bool   `yaml:"trusted"`
}

GitRepository represents a git-based module source

type Manager

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

Manager handles module discovery, loading, and execution

func NewManager

func NewManager(config ModuleConfig) *Manager

NewManager creates a new module manager

func (*Manager) ExecuteModule

func (m *Manager) ExecuteModule(ctx context.Context, moduleName, command string, args []string, flags map[string]interface{}) (*ExecutionResult, error)

ExecuteModule executes a module command

func (*Manager) GetModule

func (m *Manager) GetModule(name string) (*Module, error)

GetModule returns a module by name

func (*Manager) GetModules

func (m *Manager) GetModules() []*Module

GetModules returns all loaded modules

func (*Manager) LoadModules

func (m *Manager) LoadModules(ctx context.Context) error

LoadModules discovers and loads all available modules

func (*Manager) RegisterDynamicCommands

func (m *Manager) RegisterDynamicCommands(rootCmd *cobra.Command) error

RegisterDynamicCommands registers CLI commands for all discovered modules

type Module

type Module struct {
	APIVersion string         `yaml:"apiVersion"`
	Kind       string         `yaml:"kind"`
	Metadata   ModuleMetadata `yaml:"metadata"`
	Spec       ModuleSpec     `yaml:"spec"`

	// Runtime fields
	Path     string    `yaml:"-"`
	Source   string    `yaml:"-"`
	LoadedAt time.Time `yaml:"-"`
	Trusted  bool      `yaml:"-"`
}

Module represents a discoverable Ship CLI module

type ModuleCommand

type ModuleCommand struct {
	Name        string       `yaml:"name"`
	Description string       `yaml:"description"`
	Usage       string       `yaml:"usage,omitempty"`
	Flags       []ModuleFlag `yaml:"flags,omitempty"`
	Examples    []string     `yaml:"examples,omitempty"`
}

ModuleCommand represents a CLI command provided by the module

type ModuleConfig

type ModuleConfig struct {
	Repositories   []GitRepository `yaml:"repositories,omitempty"`
	Directories    []string        `yaml:"directories,omitempty"`
	AllowUntrusted bool            `yaml:"allow_untrusted"`
	Sandbox        bool            `yaml:"sandbox"`
	CacheDir       string          `yaml:"cache_dir,omitempty"`
	UpdateInterval string          `yaml:"update_interval,omitempty"`
}

ModuleConfig represents module configuration from ship config

type ModuleExecutor

type ModuleExecutor interface {
	Execute(ctx context.Context, module *Module, command string, args []string, flags map[string]interface{}) (*ExecutionResult, error)
	CanExecute(module *Module) bool
}

ModuleExecutor defines the interface for executing modules

type ModuleFlag

type ModuleFlag struct {
	Name        string      `yaml:"name"`
	Short       string      `yaml:"short,omitempty"`
	Type        string      `yaml:"type"` // string, int, bool, []string
	Default     interface{} `yaml:"default,omitempty"`
	Required    bool        `yaml:"required,omitempty"`
	Description string      `yaml:"description"`
	Enum        []string    `yaml:"enum,omitempty"`
}

ModuleFlag represents a command-line flag

type ModuleMetadata

type ModuleMetadata struct {
	Name        string            `yaml:"name"`
	Version     string            `yaml:"version"`
	Description string            `yaml:"description"`
	Author      string            `yaml:"author"`
	Tags        []string          `yaml:"tags,omitempty"`
	Labels      map[string]string `yaml:"labels,omitempty"`
}

ModuleMetadata contains module identification information

type ModuleSource

type ModuleSource struct {
	Type        string    `yaml:"type"` // builtin, user, project, git
	Path        string    `yaml:"path"`
	URL         string    `yaml:"url,omitempty"`
	Ref         string    `yaml:"ref,omitempty"`
	LastUpdated time.Time `yaml:"lastUpdated,omitempty"`
	Trusted     bool      `yaml:"trusted"`
}

ModuleSource represents where a module was discovered from

type ModuleSpec

type ModuleSpec struct {
	Type         ModuleType        `yaml:"type"`
	Docker       *DockerModuleSpec `yaml:"docker,omitempty"`
	Dagger       *DaggerModuleSpec `yaml:"dagger,omitempty"`
	Commands     []ModuleCommand   `yaml:"commands"`
	Dependencies []string          `yaml:"dependencies,omitempty"`
	Permissions  []string          `yaml:"permissions,omitempty"`
}

ModuleSpec defines the module's behavior and integration

type ModuleType

type ModuleType string

ModuleType represents the type of module

const (
	ModuleTypeDocker ModuleType = "docker"
	ModuleTypeDagger ModuleType = "dagger"
)

type ProjectDiscovery

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

ProjectDiscovery discovers modules from current project

func (*ProjectDiscovery) DiscoverModules

func (d *ProjectDiscovery) DiscoverModules(ctx context.Context) ([]*Module, error)

func (*ProjectDiscovery) GetSourceType

func (d *ProjectDiscovery) GetSourceType() string

func (*ProjectDiscovery) SetConfig

func (d *ProjectDiscovery) SetConfig(config ModuleConfig)

type UserDirectoryDiscovery

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

UserDirectoryDiscovery discovers modules from user directory

func (*UserDirectoryDiscovery) DiscoverModules

func (d *UserDirectoryDiscovery) DiscoverModules(ctx context.Context) ([]*Module, error)

func (*UserDirectoryDiscovery) GetSourceType

func (d *UserDirectoryDiscovery) GetSourceType() string

func (*UserDirectoryDiscovery) SetConfig

func (d *UserDirectoryDiscovery) SetConfig(config ModuleConfig)

type VolumeMount

type VolumeMount struct {
	Source string `yaml:"source"`
	Target string `yaml:"target"`
	Type   string `yaml:"type,omitempty"` // bind, volume, tmpfs
}

VolumeMount represents a volume mount for Docker modules

Jump to

Keyboard shortcuts

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