コード例 #1
0
ファイル: contract.go プロジェクト: catalyzeio/cli
	Name:      "status",
	ShortHelp: "Get quick readout of the current status of your associated environment and all of its services",
	LongHelp: "`status` will give a quick readout of your environment's health. " +
		"This includes your environment name, environment ID, and for each service the name, size, build status, deploy status, and service ID. " +
		"Here is a sample command\n\n" +
		"```\ncatalyze -E \"<your_env_alias>\" status\n```",
	CmdFunc: func(settings *models.Settings) func(cmd *cli.Cmd) {
		return func(cmd *cli.Cmd) {
			cmd.Action = func() {
				if _, err := auth.New(settings, prompts.New()).Signin(); err != nil {
					logrus.Fatal(err.Error())
				}
				if err := config.CheckRequiredAssociation(true, true, settings); err != nil {
					logrus.Fatal(err.Error())
				}
				err := CmdStatus(settings.EnvironmentID, New(settings, jobs.New(settings)), environments.New(settings), services.New(settings))
				if err != nil {
					logrus.Fatal(err.Error())
				}
			}
		}
	},
}

// IStatus
type IStatus interface {
	Status(env *models.Environment, services *[]models.Service) error
}

// SStatus is a concrete implementation of IStatus
type SStatus struct {
コード例 #2
0
ファイル: contract.go プロジェクト: catalyzeio/cli
	ShortHelp: "Associates an environment",
	LongHelp: "`associate` is the entry point of the cli. You need to associate an environment before you can run most other commands. " +
		"Check out [scope](#global-scope) and [aliases](#environment-aliases) for more info on the value of the alias and default options. Here is a sample command\n\n" +
		"```\ncatalyze associate My-Production-Environment app01 -a prod\n```",
	CmdFunc: func(settings *models.Settings) func(cmd *cli.Cmd) {
		return func(cmd *cli.Cmd) {
			envName := cmd.StringArg("ENV_NAME", "", "The name of your environment")
			serviceName := cmd.StringArg("SERVICE_NAME", "", "The name of the primary code service to associate with this environment (i.e. 'app01')")
			alias := cmd.StringOpt("a alias", "", "A shorter name to reference your environment by for local commands")
			remote := cmd.StringOpt("r remote", "catalyze", "The name of the remote")
			defaultEnv := cmd.BoolOpt("d default", false, "[DEPRECATED] Specifies whether or not the associated environment will be the default")
			cmd.Action = func() {
				if _, err := auth.New(settings, prompts.New()).Signin(); err != nil {
					logrus.Fatal(err.Error())
				}
				err := CmdAssociate(*envName, *serviceName, *alias, *remote, *defaultEnv, New(settings), git.New(), environments.New(settings), services.New(settings))
				if err != nil {
					logrus.Fatal(err.Error())
				}
			}
			cmd.Spec = "ENV_NAME SERVICE_NAME [-a] [-r] [-d]"
		}
	},
}

// interfaces are the API calls
type IAssociate interface {
	Associate(name, remote string, defaultEnv bool, env *models.Environment, chosenService *models.Service) error
}

// SAssociate is a concrete implementation of IAssociate
コード例 #3
0
ファイル: contract.go プロジェクト: catalyzeio/cli
var Cmd = models.Command{
	Name:      "redeploy",
	ShortHelp: "Redeploy a service without having to do a git push. This will cause downtime for all redeploys (see the resources page for more details).",
	LongHelp: "`redeploy` deploys an identical copy of the given service. " +
		"For code services, this avoids having to perform a code push. You skip the git push and the build. " +
		"For service proxies, new instances replace the old ones. " +
		"All other service types cannot be redeployed with this command. " +
		"For service proxy redeploys, there will be approximately 5 minutes of downtime. " +
		"For code service redeploys, there will be approximately 30 seconds of downtime. " +
		"Here is a sample command\n\n" +
		"```\ncatalyze -E \"<your_env_alias>\" redeploy app01\n```",
	CmdFunc: func(settings *models.Settings) func(cmd *cli.Cmd) {
		return func(cmd *cli.Cmd) {
			serviceName := cmd.StringArg("SERVICE_NAME", "", "The name of the service to redeploy (i.e. 'app01')")
			cmd.Action = func() {
				if _, err := auth.New(settings, prompts.New()).Signin(); err != nil {
					logrus.Fatal(err.Error())
				}
				if err := config.CheckRequiredAssociation(true, true, settings); err != nil {
					logrus.Fatal(err.Error())
				}
				err := CmdRedeploy(settings.EnvironmentID, *serviceName, jobs.New(settings), services.New(settings), environments.New(settings))
				if err != nil {
					logrus.Fatal(err.Error())
				}
			}
			cmd.Spec = "SERVICE_NAME"
		}
	},
}
コード例 #4
0
ファイル: contract.go プロジェクト: catalyzeio/cli
	CmdFunc: func(settings *models.Settings) func(cmd *cli.Cmd) {
		return func(cmd *cli.Cmd) {
			query := cmd.StringArg("QUERY", "*", "The query to send to your logging dashboard's elastic search (regex is supported)")
			follow := cmd.BoolOpt("f follow", false, "Tail/follow the logs (Equivalent to -t)")
			tail := cmd.BoolOpt("t tail", false, "Tail/follow the logs (Equivalent to -f)")
			hours := cmd.IntOpt("hours", 0, "The number of hours before now (in combination with minutes and seconds) to retrieve logs")
			mins := cmd.IntOpt("minutes", 0, "The number of minutes before now (in combination with hours and seconds) to retrieve logs")
			secs := cmd.IntOpt("seconds", 0, "The number of seconds before now (in combination with hours and minutes) to retrieve logs")
			cmd.Action = func() {
				if _, err := auth.New(settings, prompts.New()).Signin(); err != nil {
					logrus.Fatal(err.Error())
				}
				if err := config.CheckRequiredAssociation(true, true, settings); err != nil {
					logrus.Fatal(err.Error())
				}
				err := CmdLogs(*query, *follow || *tail, *hours, *mins, *secs, settings.EnvironmentID, settings, New(settings), prompts.New(), environments.New(settings), services.New(settings), sites.New(settings))
				if err != nil {
					logrus.Fatal(err.Error())
				}
			}
			cmd.Spec = "[QUERY] [(-f | -t)] [--hours] [--minutes] [--seconds]"
		}
	},
}

// ILogs ...
type ILogs interface {
	Output(queryString, sessionToken, domain string, follow bool, hours, minutes, seconds, from int, startTimestamp time.Time, endTimestamp time.Time, env *models.Environment) (int, time.Time, error)
	Stream(queryString, sessionToken, domain string, follow bool, hours, minutes, seconds, from int, timestamp time.Time, env *models.Environment) error
	Watch(queryString, domain, sessionToken string) error
}
コード例 #5
0
ファイル: contract.go プロジェクト: catalyzeio/cli
	"github.com/catalyzeio/cli/lib/prompts"
	"github.com/catalyzeio/cli/models"
	"github.com/jault3/mow.cli"
)

// Cmd is the contract between the user and the CLI. This specifies the command
// name, arguments, and required/optional arguments and flags for the command.
var Cmd = models.Command{
	Name:      "domain",
	ShortHelp: "Print out the temporary domain name of the environment",
	LongHelp: "`domain` prints out the temporary domain name setup by Catalyze for an environment. " +
		"This domain name typically takes the form podXXXXX.catalyzeapps.com but may vary based on the environment. Here is a sample command\n\n" +
		"```\ncatalyze -E \"<your_env_alias>\" domain\n```",
	CmdFunc: func(settings *models.Settings) func(cmd *cli.Cmd) {
		return func(cmd *cli.Cmd) {
			cmd.Action = func() {
				if _, err := auth.New(settings, prompts.New()).Signin(); err != nil {
					logrus.Fatal(err.Error())
				}
				if err := config.CheckRequiredAssociation(true, true, settings); err != nil {
					logrus.Fatal(err.Error())
				}
				err := CmdDomain(settings.EnvironmentID, environments.New(settings), services.New(settings), sites.New(settings))
				if err != nil {
					logrus.Fatalln(err.Error())
				}
			}
		}
	},
}