jobs

package
v0.0.0-...-966d904 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2018 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Cmd = models.Command{
	Name:      "jobs",
	ShortHelp: "Perform operations on a service's jobs",
	LongHelp:  "The <code>jobs</code> command allows you to manage jobs for your service(s).  The jobs command cannot be run directly but has subcommands.",
	CmdFunc: func(settings *models.Settings) func(cmd *cli.Cmd) {
		return func(cmd *cli.Cmd) {
			cmd.CommandLong(ListSubCmd.Name, ListSubCmd.ShortHelp, ListSubCmd.LongHelp, ListSubCmd.CmdFunc(settings))
			cmd.CommandLong(StartSubCmd.Name, StartSubCmd.ShortHelp, StartSubCmd.LongHelp, StartSubCmd.CmdFunc(settings))
			cmd.CommandLong(StopSubCmd.Name, StopSubCmd.ShortHelp, StopSubCmd.LongHelp, StopSubCmd.CmdFunc(settings))
		}
	},
}
View Source
var ListSubCmd = models.Command{
	Name:      "list",
	ShortHelp: "List all jobs for a service",
	LongHelp: "<code>jobs list</code> prints out a list of all jobs in your environment and their current status. " +
		"Here is a sample command:\n\n" +
		"<pre>\ndatica -E \"<your_env_name>\" jobs list <your_service_name>\n</pre>",
	CmdFunc: func(settings *models.Settings) func(cmd *cli.Cmd) {
		return func(subCmd *cli.Cmd) {
			serviceName := subCmd.StringArg("SERVICE_NAME", "", "The name of the service to list jobs for")
			subCmd.Action = func() {
				if _, err := auth.New(settings, prompts.New()).Signin(); err != nil {
					logrus.Fatal(err.Error())
				}
				if err := config.CheckRequiredAssociation(settings); err != nil {
					logrus.Fatal(err.Error())
				}
				err := CmdList(*serviceName, New(settings), services.New(settings))
				if err != nil {
					logrus.Fatal(err.Error())
				}
			}
		}
	},
}
View Source
var StartSubCmd = models.Command{
	Name:      "start",
	ShortHelp: "Start a specific job within a service",
	LongHelp: "<code>jobs start</code> will start a job that is configured but not currently running within a given service. " +
		"This command is useful for granual control of your services and their workers, tasks, etc. " +
		"<pre>\ndatica -E \"<your_env_name>\" jobs start <your_service_name> <your_job_id>\n</pre>",
	CmdFunc: func(settings *models.Settings) func(cmd *cli.Cmd) {
		return func(subCmd *cli.Cmd) {
			serviceName := subCmd.StringArg("SERVICE_NAME", "", "The name of the service to list jobs for")
			jobID := subCmd.StringArg("JOB_ID", "", "The job ID for the job in service to be started")
			subCmd.Action = func() {
				if _, err := auth.New(settings, prompts.New()).Signin(); err != nil {
					logrus.Fatal(err.Error())
				}
				if err := config.CheckRequiredAssociation(settings); err != nil {
					logrus.Fatal(err.Error())
				}
				err := CmdStart(*jobID, *serviceName, New(settings), services.New(settings))
				if err != nil {
					logrus.Fatal(err.Error())
				}
			}
		}
	},
}
View Source
var StopSubCmd = models.Command{
	Name:      "stop",
	ShortHelp: "Stop a specific job within a service",
	LongHelp: "<code>jobs stop</code> will shut down a running job within a given service. " +
		"This command is useful for granular control of your services and their workers, tasks, etc. " +
		"<pre>\ndatica -E \"<your_env_name>\" jobs stop <your_service_name> <your_job_id>\n</pre>",
	CmdFunc: func(settings *models.Settings) func(cmd *cli.Cmd) {
		return func(subCmd *cli.Cmd) {
			serviceName := subCmd.StringArg("SERVICE_NAME", "", "The name of the service to list jobs for")
			jobID := subCmd.StringArg("JOB_ID", "", "The job ID for the job in service to be stopped")
			force := subCmd.BoolOpt("f force", false, "Allow this command to be executed without prompting to confirm")

			subCmd.Action = func() {
				if _, err := auth.New(settings, prompts.New()).Signin(); err != nil {
					logrus.Fatal(err.Error())
				}
				if err := config.CheckRequiredAssociation(settings); err != nil {
					logrus.Fatal(err.Error())
				}
				err := CmdStop(*jobID, *serviceName, New(settings), services.New(settings), *force, prompts.New())
				if err != nil {
					logrus.Fatal(err.Error())
				}
			}
			subCmd.Spec = "[SERVICE_NAME] [JOB_ID] [-f]"

		}
	},
}

Functions

func CmdList

func CmdList(svcName string, ij IJobs, is services.IServices) error

func CmdStart

func CmdStart(jobID string, svcName string, ij IJobs, is services.IServices) error

func CmdStop

func CmdStop(jobID string, svcName string, ij IJobs, is services.IServices, force bool, ip prompts.IPrompts) error

Types

type IJobs

type IJobs interface {
	List(svcID string) (*[]models.Job, error)
	Start(jobID string, svcID string) error
	Stop(jobID string, svcID string) error
}

IJobs describes the jobs commands

func New

func New(settings *models.Settings) IJobs

New generates a new instance of IJobs

type SJobs

type SJobs struct {
	Settings *models.Settings
}

SJobs is a concrete implementation of IJobs

func (*SJobs) List

func (j *SJobs) List(svcID string) (*[]models.Job, error)

func (*SJobs) Start

func (j *SJobs) Start(jobID string, svcID string) error

func (*SJobs) Stop

func (j *SJobs) Stop(jobID string, svcID string) error

type SortedJobs

type SortedJobs []models.Job

func (SortedJobs) Len

func (jobs SortedJobs) Len() int

func (SortedJobs) Less

func (jobs SortedJobs) Less(i, j int) bool

func (SortedJobs) Swap

func (jobs SortedJobs) Swap(i, j int)

Jump to

Keyboard shortcuts

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