cmd

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2025 License: GPL-3.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Version information - these can be set at build time using ldflags
	// Example: go build -ldflags "-X github.com/AlexanderGrooff/spage/cmd.Version=1.0.0 -X github.com/AlexanderGrooff/spage/cmd.GitCommit=$(git rev-parse HEAD) -X github.com/AlexanderGrooff/spage/cmd.BuildDate=$(date -u +%Y-%m-%dT%H:%M:%SZ)"
	Version   = "dev"
	GitCommit = "unknown"
	BuildDate = "unknown"
)
View Source
var LoadConfig = func(configFile string) error {
	configPaths := []string{}
	if configFile == "" {
		defaultConfig := "spage.yaml"
		if _, err := os.Stat(defaultConfig); err == nil {
			configPaths = append(configPaths, defaultConfig)
		}
	} else {
		configPaths = append(configPaths, configFile)
	}

	var err error
	cfg, err = config.Load(configPaths...)
	if err != nil {
		if configFile != "" || !os.IsNotExist(err) {
			return fmt.Errorf("failed to load configuration from %v: %w", configPaths, err)
		}

		cfg, err = config.Load()
		if err != nil {
			return fmt.Errorf("failed to load default configuration: %w", err)
		}
	}

	common.SetLogLevel(cfg.Logging.Level)
	if cfg.Logging.File != "" {
		if err := common.SetLogFile(cfg.Logging.File); err != nil {
			return fmt.Errorf("error setting log file: %w", err)
		}
	}

	if err := common.SetLogFormat(cfg.Logging); err != nil {
		return fmt.Errorf("error setting log format: %w", err)
	}

	if verbose {
		common.SetLogLevel("debug")
	}

	return nil
}

LoadConfig loads the configuration and applies settings

View Source
var RootCmd = &cobra.Command{
	Use:   "spage",
	Short: "Simple Playbook AGEnt",
	Long:  `A lightweight configuration management tool that compiles your playbooks into a Go program to run on a host.`,
	PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
		if err := LoadConfig(configFile); err != nil {
			return err
		}

		if apiToken == "" && cfg != nil && cfg.ApiToken != "" {
			apiToken = cfg.ApiToken
		}
		return nil
	},
}

Functions

func GetConfig

func GetConfig() *config.Config

GetConfig returns the loaded configuration

func GetDaemonClient added in v1.0.0

func GetDaemonClient() (*daemon.Client, error)

func GetGraph added in v1.0.0

func GetGraph(playbookFile string, tags, skipTags []string, baseConfig *config.Config, becomeMode bool) (pkg.Graph, error)

func NewLocalExecutorCmd added in v1.0.0

func NewLocalExecutorCmd(graph pkg.Graph) *cobra.Command

func NewTemporalExecutorCmd added in v1.0.0

func NewTemporalExecutorCmd(graph pkg.Graph) *cobra.Command

func StartLocalExecutor added in v1.0.0

func StartLocalExecutor(graph *pkg.Graph, inventoryFile string, cfg *config.Config, daemonClient interface{}) error

func StartLocalExecutorWithLimit added in v1.0.0

func StartLocalExecutorWithLimit(graph *pkg.Graph, inventoryFile string, cfg *config.Config, daemonClient interface{}, limitPattern string) error

func StartTemporalExecutor added in v1.0.0

func StartTemporalExecutor(graph *pkg.Graph, inventoryFile string, spageAppConfig *config.Config, daemonClient interface{}) error

func StartTemporalExecutorWithLimit added in v1.0.0

func StartTemporalExecutorWithLimit(graph *pkg.Graph, inventoryFile string, spageAppConfig *config.Config, daemonClient interface{}, limitPattern string) error

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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