macros

package
v0.3.7 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package macros loads and validates honeyfile.yaml macro sets.

Index

Constants

View Source
const APIVersionV1Alpha1 = "honey.shareed2k.io/v1alpha1"

APIVersionV1Alpha1 is the only supported apiVersion value for MacroSet documents.

Variables

This section is empty.

Functions

func ResolvePath

func ResolvePath(explicit string) (string, error)

ResolvePath returns the absolute path of the honeyfile, checking --file, HONEY_MACROS_FILE, and default filenames.

Types

type Macro

type Macro struct {
	Kind string `yaml:"kind" validate:"required,oneof=exec recipe logs tunnel app egress"`

	MacroSelector `yaml:",inline"`
	MacroExec     `yaml:",inline"`
	MacroRecipe   `yaml:",inline"`
	MacroLogs     `yaml:",inline"`
	MacroApp      `yaml:",inline"`
	MacroEgress   `yaml:",inline"`
}

Macro describes a single named automation entry in a MacroSet. Kind selects which embedded field group applies. The groups are embedded inline, so the honeyfile.yaml wire format stays flat and callers read promoted fields (m.Command, m.EgressHost, …) unchanged — the decomposition names the per-kind field clusters without touching the schema or the readers.

type MacroApp added in v0.3.7

type MacroApp struct {
	App         string `yaml:"app"`
	OpenBrowser *bool  `yaml:"openBrowser"`
}

MacroApp holds the fields for kind: app and kind: tunnel.

type MacroEgress added in v0.3.7

type MacroEgress struct {
	EgressHost      string   `yaml:"host"`
	EgressHosts     []string `yaml:"hosts"`
	EgressPort      int      `yaml:"port"`
	EgressBind      string   `yaml:"bind"`
	EgressTun       bool     `yaml:"tun"`
	EgressAutoProxy bool     `yaml:"auto_proxy"`
	EgressBypass    []string `yaml:"bypass"`
}

MacroEgress holds the fields for kind: egress.

type MacroExec added in v0.3.7

type MacroExec struct {
	Command  string   `yaml:"command"`
	Commands []string `yaml:"commands"`
	Parallel int      `yaml:"parallel" validate:"omitempty,gte=1"`
	Retry    int      `yaml:"retry" validate:"omitempty,gte=1"`
	Timeout  string   `yaml:"timeout" validate:"omitempty,goduration"`
	Shell    string   `yaml:"shell" validate:"omitempty,oneof=auto sh bash raw powershell"`
	RunAs    string   `yaml:"runAs"`
	Output   string   `yaml:"output" validate:"omitempty,oneof=text json"`
	Quiet    *bool    `yaml:"quiet"`
}

MacroExec holds the fields for kind: exec.

type MacroLogs added in v0.3.7

type MacroLogs struct {
	Source         string   `yaml:"source"`
	Unit           string   `yaml:"unit"`
	File           string   `yaml:"file"`
	Cmd            string   `yaml:"cmd"`
	Follow         *bool    `yaml:"follow"`
	Tail           *int64   `yaml:"tail" validate:"omitempty,gte=1"`
	Since          string   `yaml:"since" validate:"omitempty,goduration"`
	Timestamps     *bool    `yaml:"timestamps"`
	Grep           string   `yaml:"grep"`
	Labels         []string `yaml:"labels"`
	TUI            *bool    `yaml:"tui"`
	OutputFile     string   `yaml:"outputFile"`
	MaxConcurrency *int     `yaml:"maxConcurrency" validate:"omitempty,gte=1"`
}

MacroLogs holds the fields for kind: logs.

type MacroRecipe added in v0.3.7

type MacroRecipe struct {
	RecipePath string   `yaml:"recipePath"`
	Execute    *bool    `yaml:"execute"`
	Env        []string `yaml:"env"`
}

MacroRecipe holds the fields for kind: recipe.

type MacroSelector added in v0.3.7

type MacroSelector struct {
	Target    string `yaml:"target"`
	Provider  string `yaml:"provider"`
	Backends  string `yaml:"backends"`
	Name      string `yaml:"name"`
	NameRegex string `yaml:"nameRegex"`
}

MacroSelector picks which hosts a macro runs against. Shared by every kind.

type MacroSet

type MacroSet struct {
	APIVersion string     `yaml:"apiVersion" validate:"required,eq=honey.shareed2k.io/v1alpha1"`
	Kind       string     `yaml:"kind" validate:"required,eq=MacroSet"`
	Metadata   Metadata   `yaml:"metadata" validate:"required"`
	Spec       MacroSpecs `yaml:"spec" validate:"required"`
}

MacroSet is the top-level structure of a honeyfile.yaml.

func Load

func Load(path string) (*MacroSet, error)

Load parses and validates the MacroSet at path.

type MacroSpecs

type MacroSpecs struct {
	Macros map[string]Macro `yaml:"macros" validate:"required,min=1,dive,keys,required,endkeys,required"`
}

MacroSpecs contains the named macro definitions within a MacroSet.

type Metadata

type Metadata struct {
	Name string `yaml:"name" validate:"required"`
}

Metadata holds identifying information for a MacroSet.

Jump to

Keyboard shortcuts

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