Documentation ¶
Overview ¶
Package launchr provides common app functionality.
Index ¶
- Constants
- Variables
- func EnsurePath(parts ...string) error
- func GetFsAbsPath(fs fs.FS) string
- func GetTypePkgPathName(v interface{}) (string, string)
- func InitPluginInfo(pi *PluginInfo, p Plugin)
- func InitServiceInfo(si *ServiceInfo, s Service)
- func RegisterPlugin(p Plugin)
- type App
- type AppVersion
- type CobraPlugin
- type Config
- type ConfigAware
- type GeneratePlugin
- type ManagedFS
- type OnAppInitPlugin
- type Plugin
- type PluginGeneratedData
- type PluginInfo
- type PluginManager
- type PluginsMap
- type Service
- type ServiceInfo
Constants ¶
const PkgPath = "github.com/launchrctl/launchr"
PkgPath is a main module path.
Variables ¶
var (
ErrNoConfigFile = errors.New("config file is not found") // ErrNoConfigFile when config file doesn't exist in FS.
)
Functions ¶
func EnsurePath ¶
EnsurePath creates all directories in the path.
func GetFsAbsPath ¶
GetFsAbsPath returns absolute path for a FS struct.
func GetTypePkgPathName ¶ added in v0.1.0
GetTypePkgPathName returns type package path and name for internal usage.
func InitPluginInfo ¶ added in v0.1.0
func InitPluginInfo(pi *PluginInfo, p Plugin)
InitPluginInfo sets private fields for internal usage only.
func InitServiceInfo ¶ added in v0.1.0
func InitServiceInfo(si *ServiceInfo, s Service)
InitServiceInfo sets private fields for internal usage only.
func RegisterPlugin ¶ added in v0.1.0
func RegisterPlugin(p Plugin)
RegisterPlugin add a plugin to global pull.
Types ¶
type App ¶ added in v0.1.0
type App interface { // Name returns app name. Name() string // GetWD provides app's working dir. GetWD() string // Streams returns application cli. Streams() cli.Streams // AddService registers a service in the app. // Panics if a service is not unique. AddService(s Service) // GetService retrieves a service of type v and assigns it to v. // Panics if a service is not found. GetService(v interface{}) // RegisterFS registers a File System in launchr. // It may be a FS for action discovery, see action.DiscoveryFS. RegisterFS(fs ManagedFS) // GetRegisteredFS returns an array of registered File Systems. GetRegisteredFS() []ManagedFS }
App stores global application state.
type AppVersion ¶ added in v0.1.0
type AppVersion struct { Name string Version string OS string Arch string BuiltWith string CoreVersion string CoreReplace string Plugins []string }
AppVersion stores application version.
func NewVersion ¶ added in v0.1.0
func NewVersion(name, ver, bwith string, plugins PluginsMap) *AppVersion
NewVersion creates version info with used plugins info.
func (*AppVersion) Full ¶ added in v0.1.0
func (v *AppVersion) Full() string
Full outputs version string in a full format.
func (*AppVersion) Short ¶ added in v0.1.0
func (v *AppVersion) Short() string
Short outputs a short version string.
func (*AppVersion) String ¶ added in v0.2.1
func (v *AppVersion) String() string
String implements Stringer interface.
type CobraPlugin ¶ added in v0.1.0
type CobraPlugin interface { Plugin // CobraAddCommands is a hook called when cobra root command is available. // Plugins may register its command line commands here. CobraAddCommands(*cobra.Command) error }
CobraPlugin is an interface to implement a plugin for cobra.
type Config ¶ added in v0.1.0
type Config interface { Service // DirPath returns an absolute path to config directory. DirPath() string // Path provides an absolute path to launchr config directory. Path(parts ...string) string // EnsurePath creates all directories in the path. EnsurePath(parts ...string) error // Get returns a value by key to a parameter v. Parameter v must be a pointer to a value. // Error may be returned on decode. Get(key string, v interface{}) error }
Config is a launchr config storage interface.
func ConfigFromFS ¶ added in v0.1.0
ConfigFromFS parses launchr app config directory and its content.
type ConfigAware ¶ added in v0.1.0
type ConfigAware interface { // SetLaunchrConfig sets a launchr config to the struct. SetLaunchrConfig(Config) }
ConfigAware provides an interface for structs to support launchr configuration setting.
type GeneratePlugin ¶ added in v0.1.0
type GeneratePlugin interface { Plugin // Generate is a function called when application is generating code and assets for the build. Generate(buildPath string, workDir string) (*PluginGeneratedData, error) }
GeneratePlugin is an interface to generate supporting files before build.
type OnAppInitPlugin ¶ added in v0.1.0
type OnAppInitPlugin interface { Plugin // OnAppInit is hook function called on application initialisation. // Plugins may save app global object, retrieve or provide services here. OnAppInit(app App) error }
OnAppInitPlugin is an interface to implement a plugin for app initialisation.
type Plugin ¶ added in v0.1.0
type Plugin interface { // PluginInfo requests a type to provide information about the plugin. PluginInfo() PluginInfo }
Plugin is a common interface for launchr plugins.
type PluginGeneratedData ¶ added in v0.1.0
type PluginGeneratedData struct {
Plugins []string
}
PluginGeneratedData is a struct containing a result information of plugin generation.
type PluginInfo ¶ added in v0.1.0
type PluginInfo struct { // Weight defines the order of plugins calling. @todo rework to a real dependency resolving. Weight int // contains filtered or unexported fields }
PluginInfo provides information about the plugin and is used as a unique data to indentify a plugin.
func (PluginInfo) String ¶ added in v0.1.0
func (p PluginInfo) String() string
type PluginManager ¶ added in v0.1.0
type PluginManager interface { Service All() PluginsMap }
PluginManager handles plugins.
func NewPluginManagerWithRegistered ¶ added in v0.1.0
func NewPluginManagerWithRegistered() PluginManager
NewPluginManagerWithRegistered creates PluginManager with registered plugins.
type PluginsMap ¶ added in v0.1.0
type PluginsMap = map[PluginInfo]Plugin
PluginsMap is a type alias for plugins map.
type Service ¶
type Service interface {
ServiceInfo() ServiceInfo
}
Service is a common interface for a service to register.
type ServiceInfo ¶
type ServiceInfo struct {
// contains filtered or unexported fields
}
ServiceInfo provides service info for its initialization.
func (ServiceInfo) String ¶ added in v0.1.0
func (s ServiceInfo) String() string