コード例 #1
0
ファイル: pgsql_console.go プロジェクト: Zyko0/cli
func PgSQLConsole(app string) error {

	postgreSQLURL, user, password, err := dbURL(app, "SCALINGO_POSTGRESQL", []string{"postgres://"})
	if err != nil {
		return errgo.Mask(err)
	}

	host, port, err := net.SplitHostPort(postgreSQLURL.Host)
	if err != nil {
		return errgo.Newf("%v has an invalid host", postgreSQLURL)
	}

	opts := apps.RunOpts{
		App: app,
		Cmd: []string{"psql"},
		CmdEnv: []string{
			"PGHOST=" + host,
			"PGPORT=" + port,
			"PGUSER="******"PGPASSWORD="******"PGDATABASE=" + user,
		},
	}

	err = apps.Run(opts)
	if err != nil {
		return errgo.Newf("Fail to run PostgreSQL console: %v", err)
	}

	return nil
}
コード例 #2
0
ファイル: mongo_console.go プロジェクト: Zyko0/cli
func MongoConsole(app string) error {

	mongoURL, user, password, err := dbURL(app, "SCALINGO_MONGO", []string{"mongodb://"})
	if err != nil {
		return errgo.Mask(err)
	}

	opts := apps.RunOpts{
		App: app,
		Cmd: []string{"mongo", "-u", user, "-p", password, mongoURL.Host + "/" + user},
	}

	err = apps.Run(opts)
	if err != nil {
		return errgo.Newf("Fail to run MongoDB console: %v", err)
	}

	return nil
}
コード例 #3
0
ファイル: redis_console.go プロジェクト: Zyko0/cli
func RedisConsole(app string) error {
	redisURL, _, password, err := dbURL(app, "SCALINGO_REDIS", []string{"redis://"})
	if err != nil {
		return errgo.Mask(err)
	}

	host, port, err := net.SplitHostPort(redisURL.Host)
	if err != nil {
		return errgo.Newf("%v has an invalid host", redisURL)
	}

	opts := apps.RunOpts{
		App:           app,
		Cmd:           []string{"redis-cli", "-h", host, "-p", port, "-a", password},
		StdinCopyFunc: redisStdinCopy,
	}

	err = apps.Run(opts)
	if err != nil {
		return errgo.Newf("Fail to run redis console: %v", err)
	}

	return nil
}
コード例 #4
0
ファイル: mysql_console.go プロジェクト: Zyko0/cli
func MySQLConsole(app string) error {

	mySQLURL, user, password, err := dbURL(app, "SCALINGO_MYSQL", []string{"mysql://", "mysql2://"})
	if err != nil {
		return errgo.Mask(err)
	}

	host, port, err := net.SplitHostPort(mySQLURL.Host)
	if err != nil {
		return errgo.Newf("%v has an invalid host", mySQLURL)
	}

	opts := apps.RunOpts{
		App: app,
		Cmd: []string{"mysql", "-h", host, "-P", port, fmt.Sprintf("--password=%v", password), "-u", user, user},
	}

	err = apps.Run(opts)
	if err != nil {
		return errgo.Newf("Fail to run MySQL console: %v", err)
	}

	return nil
}
コード例 #5
0
ファイル: run.go プロジェクト: yannski/cli
   Example
     scalingo run -e VARIABLE=VALUE -e VARIABLE2=OTHER_VALUE rails console

   Furthermore, you may want to upload a file, like a database dump or anything
   useful to you. The option '-f' has been built for this purpose, you can even
   upload multiple files if you wish. You will be able to find these files in the
   '/tmp/uploads' directory of the one-off container.

   Example
     scalingo run -f mysqldump.sql rails dbconsole < /tmp/uploads/mysqldump.sql`,
		Action: func(c *cli.Context) {
			currentApp := appdetect.CurrentApp(c)
			opts := apps.RunOpts{
				App:    currentApp,
				Cmd:    c.Args(),
				CmdEnv: c.StringSlice("e"),
				Files:  c.StringSlice("f"),
			}
			if len(c.Args()) == 0 {
				cli.ShowCommandHelp(c, "run")
			} else if err := apps.Run(opts); err != nil {
				errorQuit(err)
			}
		},
		BashComplete: func(c *cli.Context) {
			autocomplete.CmdFlagsAutoComplete(c, "run")
		},
	}
)