Documentation ¶
Index ¶
- Variables
- func BaseFlagSet(name string) *flag.FlagSet
- func FunctionName(i interface{}) string
- func InstallService(config UpstartConfig) error
- func PathExists(path string) (bool, error)
- func UninstallService(config UpstartConfig) error
- type ErrorProducer
- type FlagsConfig
- func (config *FlagsConfig) Args() []string
- func (config *FlagsConfig) ConfigMap() map[string]interface{}
- func (config *FlagsConfig) FlagSet() *flag.FlagSet
- func (config *FlagsConfig) InstallService(serviceName string) error
- func (config *FlagsConfig) UninstallService(serviceName string) error
- func (config *FlagsConfig) Validate(bindTo interface{}) error
- type UpstartConfig
Constants ¶
This section is empty.
Variables ¶
var ( IllegalBindToError = errors.New("upstart/config.BaseConfig: Illegal nil value received for `bindTo'") InvalidFlagsInstallUninstallError = errors.New("-install flag must not be accompanied by -uninstall flag") InvalidFlagsMissingServiceUserError = errors.New(`-user flag must be specified if -install flag is set`) )
var ( MustRunAsRootToInstall = errors.New("must be run as root to install system service") UnsupportedOsError = errors.New("unsupported operating system (must be ubuntu)") )
Functions ¶
func BaseFlagSet ¶
BaseFlagSet provides a *flag.FlagSet which corresponds with BaseConfig. Extend with additional flags to suit needs.
func FunctionName ¶
func FunctionName(i interface{}) string
func InstallService ¶
func InstallService(config UpstartConfig) error
func PathExists ¶
PathExists returns whether or not the given file or directory exists.
func UninstallService ¶
func UninstallService(config UpstartConfig) error
Types ¶
type ErrorProducer ¶
type ErrorProducer func(config UpstartConfig) error // Installation steps are each [possible] error producers.
type FlagsConfig ¶
type FlagsConfig struct { Install bool `flag:"install"` CustomPipe string `flag:"install-with-custom-pipe"` Uninstall bool `flag:"uninstall"` ServiceUser string `flag:"user"` ServiceArgs string // Automatically populated within `Validate()'; used for installing system service. // contains filtered or unexported fields }
FlagsConfig is a common representation of the fundamental set of options for upstart service management. Intended to help reduce repetitive command-line flags handling.
NB: A flag for "config" is also used, even though it is not defined as a field in FlagsConfig.
NB: This uses github.com/BurntSushi/toml and github.com/mreiferson/go-options packages for flag management.
func NewFlagsConfig ¶
func NewFlagsConfig(flagSet *flag.FlagSet, args []string) *FlagsConfig
New creates and returns a new instance of FlagsConfig.
NB: In the common case the value of `args' should be `os.Args[1:]'.
func (*FlagsConfig) Args ¶
func (config *FlagsConfig) Args() []string
func (*FlagsConfig) ConfigMap ¶
func (config *FlagsConfig) ConfigMap() map[string]interface{}
func (*FlagsConfig) FlagSet ¶
func (config *FlagsConfig) FlagSet() *flag.FlagSet
func (*FlagsConfig) InstallService ¶
func (config *FlagsConfig) InstallService(serviceName string) error
func (*FlagsConfig) UninstallService ¶
func (config *FlagsConfig) UninstallService(serviceName string) error
func (*FlagsConfig) Validate ¶
func (config *FlagsConfig) Validate(bindTo interface{}) error
Validate takes a `bindTo' parameter which *MUST* be a pointer to the topmost Config struct instance (assuming FlagsConfig contained as an embedded type). This ensures that the flag bindings get applied to all fields.
If you override the Validate method, don't forget to invoke base validation.
Example usage:
myConfig.Validate(myConfig)
or
myConfig.FlagsConfig.Validate(myConfig).
type UpstartConfig ¶
type UpstartConfig struct { ServiceName string Args string PipedCommand string InstallBinPath string UpstartConfFilePath string // e.g. /etc/init/{{ServiceName}}. InitSymlinkPath string // e.g. /etc/init.d/{{ServiceName}}, required for service-name tab auto-complete to work. User string }
func DefaultConfig ¶
func DefaultConfig(serviceName string) UpstartConfig
func (UpstartConfig) ServiceBinPath ¶
func (config UpstartConfig) ServiceBinPath() string