launchr

package module
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2023 License: Apache-2.0 Imports: 13 Imported by: 23

README

Launchr

Launchr is a CLI action runner that executes actions inside short-lived local containers.
Actions are defined in action.yaml files, which are automatically discovered in the filesystem. They can be placed anywhere that makes sense semantically. You can find action examples here and in the documentation.
Launchr has a plugin system that allows to extend its functionality. See core plugins, compose and documentation.

Table of contents

Usage

Build launchr from source locally. Build dependencies:

  1. go >=1.20, see installation guide
  2. make

Build the launchr tool:

make
bin/launchr --help

The documentation for launchr usage can be found in docs.

If you face any issues with launchr:

  1. Open an issue in the repo.
  2. Share the app version with launchr --version

Installation

Installation from source

Build dependencies:

  1. go >=1.20, see installation guide
  2. make

Global installation

Install launchr globally:

make install
launchr --version

The tool will be installed in $GOPATH/bin which is usually ~/go/bin.
If GOPATH env variable is not available, make sure you have it in ~/.bashrc or ~/.zhrc:

export GOPATH=`go env GOPATH`
export PATH=$PATH:$GOPATH/bin

Local installation

The tool can be built and run locally:

make
bin/launchr --version

Development

The launchr can be built with a make to bin directory:

make

It is also supported to make a build to use with dlv for debug:

make DEBUG=1

Useful make commands:

  1. Fetch dependencies - make deps
  2. Test the code - make test
  3. Lint the code - make lint

Documentation

Overview

Package launchr has application implementation.

Index

Constants

View Source
const ActionManagerID = "action_manager"

ActionManagerID is an action manager service id.

View Source
const PluginManagerID = "plugin_manager"

PluginManagerID is a plugin manager service id.

View Source
const ServiceManagerID = "service_manager"

ServiceManagerID is a service manager service id.

Variables

View Source
var (
	Name          = "launchr" // Name - version info
	Version       = "dev"     // Version - version info
	CustomVersion string      // CustomVersion - custom version text
)
View Source
var ActionsGroup = &cobra.Group{
	ID:    "actions",
	Title: "Actions:",
}

ActionsGroup is a cobra command group definition

Functions

func Gen

func Gen() int

Gen generates application specific build files and returns os exit code.

func GetPluginByType added in v0.0.8

func GetPluginByType[T Plugin](app *App) []T

GetPluginByType returns specific plugins from the app.

func GetService added in v0.0.8

func GetService[T Service](app *App) T

GetService returns a service from the app. It uses generics to find the exact service.

func RegisterPlugin

func RegisterPlugin(p Plugin)

RegisterPlugin add a plugin to global pull.

func Run

func Run() int

Run executes launchr application.

func SetCustomVersion

func SetCustomVersion(v string)

SetCustomVersion stores custom version string for output, for example on custom build.

func ToCamelCase

func ToCamelCase(s string, capFirst bool) string

ToCamelCase converts a string to CamelCase

Types

type ActionManager added in v0.0.8

type ActionManager interface {
	Service
	Add(*action.Command)
	All() map[string]*action.Command
}

ActionManager handles actions.

type App

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

App holds app related global variables.

func NewApp

func NewApp() *App

NewApp constructs app implementation.

func (*App) Execute

func (app *App) Execute() int

Execute is a cobra entrypoint to the launchr app.

func (*App) Generate

func (app *App) Generate() int

Generate runs generation of included plugins.

func (*App) GetCfgDir added in v0.0.8

func (app *App) GetCfgDir() string

GetCfgDir returns config directory path.

func (*App) GetCli

func (app *App) GetCli() cli.Cli

GetCli returns application cli.

func (*App) GetWD added in v0.0.2

func (app *App) GetWD() string

GetWD provides app's working dir.

func (*App) ServiceManager added in v0.0.8

func (app *App) ServiceManager() ServiceManager

ServiceManager returns application service manager.

func (*App) SetCli

func (app *App) SetCli(c cli.Cli)

SetCli sets application cli.

type AppVersion

type AppVersion struct {
	Name          string
	Version       string
	OS            string
	Arch          string
	CustomVersion string
}

AppVersion stores application version.

func GetVersion

func GetVersion() *AppVersion

GetVersion provides app version info.

func (*AppVersion) String

func (v *AppVersion) String() string

type CobraPlugin

type CobraPlugin interface {
	Plugin
	CobraAddCommands(*cobra.Command) error
}

CobraPlugin is an interface to implement a plugin for cobra.

type GeneratePlugin

type GeneratePlugin interface {
	Plugin
	Generate(buildPath string, workDir string) (*PluginGeneratedData, error)
}

GeneratePlugin is an interface to generate supporting files before build.

type Plugin

type Plugin interface {
	PluginInfo() PluginInfo
	InitApp(app *App) error
}

Plugin is a common interface for launchr plugins.

type PluginGeneratedData

type PluginGeneratedData struct {
	Plugins []string
}

PluginGeneratedData is a struct containing a result information of plugin generation.

type PluginInfo

type PluginInfo struct {
	ID     string
	Weight int
}

PluginInfo provides information about the plugin.

type PluginManager added in v0.0.8

type PluginManager interface {
	Service
	All() map[PluginInfo]Plugin
}

PluginManager handles plugins.

type Service added in v0.0.8

type Service interface {
	ServiceInfo() ServiceInfo
}

Service is a common interface for a service to register.

type ServiceInfo added in v0.0.8

type ServiceInfo struct{}

ServiceInfo provides service info for its initialization.

type ServiceManager added in v0.0.8

type ServiceManager interface {
	Service
	Add(name string, s Service)
	All() map[string]Service
}

ServiceManager handles services.

Directories

Path Synopsis
cmd
launchr
Package executes Launchr application.
Package executes Launchr application.
launchr/gen
Package gen is here to provide example structure for the built app.
Package gen is here to provide example structure for the built app.
pkg
action
Package action provides implementations of discovering and running actions.
Package action provides implementations of discovering and running actions.
cli
Package cli implements printing functionality for CLI output.
Package cli implements printing functionality for CLI output.
cli/streams
Package streams has functionality related to in/out/err streams.
Package streams has functionality related to in/out/err streams.
cobraadapter
Package cobraadapter provides an adapter from launchr actions to cobra commands.
Package cobraadapter provides an adapter from launchr actions to cobra commands.
driver
Package driver hold implementation for action drivers.
Package driver hold implementation for action drivers.
driver/mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
jsonschema
Package jsonschema has functionality related to json schema support.
Package jsonschema has functionality related to json schema support.
log
Package log is meant to provide a global logger for the application and provide logging functionality interface.
Package log is meant to provide a global logger for the application and provide logging functionality interface.
plugins
Package plugins provides launchr core plugins.
Package plugins provides launchr core plugins.
plugins/builder
Package builder implements launchr functionality to build itself.
Package builder implements launchr functionality to build itself.
plugins/verbosity
Package verbosity is a plugin of launchr to configure log level of the app.
Package verbosity is a plugin of launchr to configure log level of the app.
plugins/yamldiscovery
Package yamldiscovery implements a launchr plugin to discover actions defined in yaml.
Package yamldiscovery implements a launchr plugin to discover actions defined in yaml.
plugins/yamldiscovery/embed
Package embed provides yaml discovery with embed actions definition.
Package embed provides yaml discovery with embed actions definition.

Jump to

Keyboard shortcuts

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