snippets

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package snippets stores reusable web-UI exec snippets (saved commands/scripts) behind a pluggable Store interface. v1 ships a local JSON-file backend; the interface is the seam for future backends (git, GCS, ...).

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("snippet not found")

ErrNotFound is returned by Store.Delete when no snippet has the given ID.

Functions

This section is empty.

Types

type ExecSnippet

type ExecSnippet struct {
	ID                    string `json:"id"`
	Name                  string `json:"name"`
	Mode                  string `json:"mode"` // command | script
	Command               string `json:"command"`
	ScriptInterpreter     string `json:"script_interpreter,omitempty"`
	InterpreterArgsQuoted bool   `json:"interpreter_args_quoted,omitempty"`
	RunAs                 string `json:"run_as,omitempty"`
}

ExecSnippet is a saved exec configuration (full state) for the web UI exec panel.

type LocalStore

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

LocalStore persists snippets as a JSON array in a single file on disk.

func NewLocalStore

func NewLocalStore(path string) *LocalStore

NewLocalStore returns a file-backed Store at path.

func (*LocalStore) Delete

func (s *LocalStore) Delete(_ context.Context, id string) error

Delete removes a snippet by ID, returning ErrNotFound if absent.

func (*LocalStore) List

func (s *LocalStore) List(_ context.Context) ([]ExecSnippet, error)

List returns all stored snippets.

func (*LocalStore) Save

func (s *LocalStore) Save(_ context.Context, snip ExecSnippet) (ExecSnippet, error)

Save upserts by ID, generating an ID when empty, and returns the stored snippet.

type Store

type Store interface {
	List(ctx context.Context) ([]ExecSnippet, error)
	// Save upserts by ID, generating an ID when empty, and returns the stored snippet.
	Save(ctx context.Context, s ExecSnippet) (ExecSnippet, error)
	// Delete removes a snippet by ID, returning ErrNotFound if absent.
	Delete(ctx context.Context, id string) error
}

Store persists exec snippets. Implementations must be safe for concurrent use.

Jump to

Keyboard shortcuts

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