Beispiel #1
0
func CmdSet(path string, settings *models.Settings) error {
	fullPath, err := homedir.Expand(path)
	if err != nil {
		return err
	}

	// make sure both files exist
	_, err = os.Stat(fullPath + ".pub")
	if err != nil {
		if os.IsNotExist(err) {
			return fmt.Errorf("Public key file '%s' does not exist.", fullPath+".pub")
		}
		return err
	}

	_, err = os.Stat(fullPath)
	if err != nil {
		if os.IsNotExist(err) {
			return fmt.Errorf("Private key file '%s' does not exist.", fullPath)
		}
		return err
	}

	settings.PrivateKeyPath = fullPath
	settings.SessionToken = ""
	a := auth.New(settings, prompts.New())
	user, err := a.Signin()
	if err != nil {
		return err
	}
	logrus.Printf("Successfully added key and signed in as %s.", user.Email)
	return nil
}
Beispiel #2
0
// 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:      "rollback",
	ShortHelp: "Rollback a code service to a specific release",
	LongHelp: "`rollback` is a way to redeploy older versions of your code service. " +
		"You must specify the name of the service to rollback and the name of an existing release to rollback to. " +
		"Releases can be found with the [releases list](#releases-list) command. Here are some sample commands\n\n" +
		"```\ncatalyze -E \"<your_env_alias>\" rollback code-1 f93ced037f828dcaabccfc825e6d8d32cc5a1883\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 rollback")
			releaseName := cmd.StringArg("RELEASE_NAME", "", "The name of the release to rollback to")
			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 := CmdRollback(*serviceName, *releaseName, jobs.New(settings), releases.New(settings), services.New(settings))
				if err != nil {
					logrus.Fatal(err.Error())
				}
			}
			cmd.Spec = "SERVICE_NAME RELEASE_NAME"
		}
	},
}
Beispiel #3
0
	"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:      "logout",
	ShortHelp: "Clear the stored user information from your local machine",
	LongHelp: "When using the CLI, your username and password are **never** stored in any file on your filesystem. " +
		"However, in order to not type in your username and password each and every command, a session token is stored in the CLI's configuration file and used until it expires. " +
		"`logout` removes this session token from the configuration file. Here is a sample command\n\n" +
		"```\ncatalyze logout\n```",
	CmdFunc: func(settings *models.Settings) func(cmd *cli.Cmd) {
		return func(cmd *cli.Cmd) {
			cmd.Action = func() {
				err := CmdLogout(New(settings), auth.New(settings, prompts.New()))
				if err != nil {
					logrus.Fatal(err.Error())
				}
			}
		}
	},
}

// ILogout
type ILogout interface {
	Clear() error
}

// SLogout is a concrete implementation of ILogout
type SLogout struct {