コード例 #1
0
ファイル: perms.go プロジェクト: laurrentt/deis
func permsList(argv []string) error {
	usage := `
Lists all users with permission to use an app, or lists all users with system
administrator privileges.

Usage: deis perms:list [-a --app=<app>|--admin]

Options:
  -a --app=<app>
    lists all users with permission to <app>. <app> is the uniquely identifiable name
    for the application.
  --admin
    lists all users with system administrator privileges.
`

	args, err := docopt.Parse(usage, argv, true, "", false, true)

	if err != nil {
		return err
	}

	admin := args["--admin"].(bool)

	return cmd.PermsList(safeGetValue(args, "--app"), admin)
}
コード例 #2
0
ファイル: releases.go プロジェクト: CodeJuan/deis
func releasesInfo(argv []string) error {
	usage := `
Prints info about a particular release.

Usage: deis releases:info <version> [options]

Arguments:
  <version>
    the release of the application, such as 'v1'.

Options:
  -a --app=<app>
    the uniquely identifiable name for the application.
`

	args, err := docopt.Parse(usage, argv, true, "", false, true)

	version, err := versionFromString(args["<version>"].(string))

	if err != nil {
		return err
	}

	return cmd.ReleasesInfo(safeGetValue(args, "--app"), version)
}
コード例 #3
0
ファイル: tags.go プロジェクト: arschles/deis-controller
func tagsSet(argv []string) error {
	usage := `
Sets tags for an application.

A tag is a key/value pair used to tag an application's containers and is passed to the
scheduler. This is often used to restrict workloads to specific hosts matching the
scheduler-configured metadata.

Usage: deis tags:set [options] <key>=<value>...

Arguments:
  <key> the tag key, for example: "environ" or "rack"
  <value> the tag value, for example: "prod" or "1"

Options:
  -a --app=<app>
    the uniquely identifiable name for the application.
`

	args, err := docopt.Parse(usage, argv, true, "", false, true)

	if err != nil {
		return err
	}

	app := safeGetValue(args, "--app")
	tags := args["<key>=<value>"].([]string)

	return cmd.TagsSet(app, tags)
}
コード例 #4
0
ファイル: cmd.go プロジェクト: pombredanne/deo
// Start activates the specified components.
func Start(argv []string, b backend.Backend) error {
	usage := `Activates the specified components.

Usage:
  deisctl start [<target>...] [options]
`
	// parse command-line arguments
	args, err := docopt.Parse(usage, argv, true, "", false)
	if err != nil {
		return err
	}

	// if target is platform, install all services
	targets := args["<target>"].([]string)

	if len(targets) == 1 && targets[0] == PlatformCommand {
		return StartPlatform(b)
	}

	outchan := make(chan string)
	errchan := make(chan error)
	var wg sync.WaitGroup

	go printState(outchan, errchan, 500*time.Millisecond)

	b.Start(targets, &wg, outchan, errchan)
	wg.Wait()
	close(outchan)

	return nil
}
コード例 #5
0
ファイル: auth.go プロジェクト: CodeJuan/deis
func authCancel(argv []string) error {
	usage := `
Cancels and removes the current account.

Usage: deis auth:cancel [options]

Options:
  --username=<username>
    provide a username for the account.
  --password=<password>
    provide a password for the account.
  --yes
    force "yes" when prompted.
`

	args, err := docopt.Parse(usage, argv, true, "", false, true)

	if err != nil {
		return err
	}

	username := safeGetValue(args, "--username")
	password := safeGetValue(args, "--password")
	yes := args["--yes"].(bool)

	return cmd.Cancel(username, password, yes)
}
コード例 #6
0
ファイル: perms.go プロジェクト: CodeJuan/deis
func permsList(argv []string) error {
	usage := `
Lists all users with permission to use an app, or lists all users with system
administrator privileges.

Usage: deis perms:list [-a --app=<app>|--admin|--admin --limit=<num>]

Options:
  -a --app=<app>
    lists all users with permission to <app>. <app> is the uniquely identifiable name
    for the application.
  --admin
    lists all users with system administrator privileges.
  -l --limit=<num>
    the maximum number of results to display, defaults to config setting
`

	args, err := docopt.Parse(usage, argv, true, "", false, true)

	if err != nil {
		return err
	}

	admin := args["--admin"].(bool)

	results, err := responseLimit(safeGetValue(args, "--limit"))

	if err != nil {
		return err
	}

	return cmd.PermsList(safeGetValue(args, "--app"), admin, results)
}
コード例 #7
0
ファイル: cmd.go プロジェクト: pombredanne/deo
// Uninstall unloads the definitions of the specified components.
// After Uninstall, the components will be unavailable until Install is called.
func Uninstall(argv []string, b backend.Backend) error {
	usage := `Unloads the definitions of the specified components.

After uninstall, the components will be unavailable until install is called.

Usage:
  deisctl uninstall [<target>...] [options]
`
	// parse command-line arguments
	args, err := docopt.Parse(usage, argv, true, "", false)
	if err != nil {
		return err
	}

	// if target is platform, uninstall all services
	targets := args["<target>"].([]string)
	if len(targets) == 1 && targets[0] == PlatformCommand {
		return UninstallPlatform(b)
	}

	outchan := make(chan string)
	errchan := make(chan error)
	var wg sync.WaitGroup

	go printState(outchan, errchan, 500*time.Millisecond)

	// uninstall the specific target
	b.Destroy(targets, &wg, outchan, errchan)
	wg.Wait()
	close(outchan)

	return nil
}
コード例 #8
0
ファイル: apps.go プロジェクト: laurrentt/deis
func appRun(argv []string) error {
	usage := `
Runs a command inside an ephemeral app container. Default environment is
/bin/bash.

Usage: deis apps:run [options] [--] <command>...

Arguments:
  <command>
    the shell command to run inside the container.

Options:
  -a --app=<app>
    the uniquely identifiable name for the application.
`
	args, err := docopt.Parse(usage, argv, true, "", false, true)

	if err != nil {
		return err
	}

	app := safeGetValue(args, "--app")
	command := strings.Join(args["<command>"].([]string), " ")

	return cmd.AppRun(app, command)
}
コード例 #9
0
ファイル: apps.go プロジェクト: laurrentt/deis
func appDestroy(argv []string) error {
	usage := `
Destroys an application.

Usage: deis apps:destroy [options]

Options:
  -a --app=<app>
    the uniquely identifiable name for the application.
  --confirm=<app>
    skips the prompt for the application name. <app> is the uniquely identifiable
    name for the application.

`
	args, err := docopt.Parse(usage, argv, true, "", false, true)

	if err != nil {
		return err
	}

	app := safeGetValue(args, "--app")
	confirm := safeGetValue(args, "--confirm")

	return cmd.AppDestroy(app, confirm)
}
コード例 #10
0
ファイル: config.go プロジェクト: laurrentt/deis
func configSet(argv []string) error {
	usage := `
Sets environment variables for an application.

Usage: deis config:set <var>=<value> [<var>=<value>...] [options]

Arguments:
  <var>
    the uniquely identifiable name for the environment variable.
  <value>
    the value of said environment variable.

Options:
  -a --app=<app>
    the uniquely identifiable name for the application.
`

	args, err := docopt.Parse(usage, argv, true, "", false, true)

	if err != nil {
		return err
	}

	return cmd.ConfigSet(safeGetValue(args, "--app"), args["<var>=<value>"].([]string))
}
コード例 #11
0
ファイル: apps.go プロジェクト: laurrentt/deis
func appLogs(argv []string) error {
	usage := `
Retrieves the most recent log events.

Usage: deis apps:logs [options]

Options:
  -a --app=<app>
    the uniquely identifiable name for the application.
  -n --lines=<lines>
    the number of lines to display
`
	args, err := docopt.Parse(usage, argv, true, "", false, true)

	if err != nil {
		return err
	}

	app := safeGetValue(args, "--app")

	linesStr := safeGetValue(args, "--lines")
	var lines int

	if linesStr == "" {
		lines = -1
	} else {
		lines, err = strconv.Atoi(linesStr)

		if err != nil {
			return err
		}
	}

	return cmd.AppLogs(app, lines)
}
コード例 #12
0
ファイル: config.go プロジェクト: laurrentt/deis
func configPull(argv []string) error {
	usage := `
Extract all environment variables from an application for local use.

Your environment will be stored locally in a file named .env. This file can be
read by foreman to load the local environment for your app.

Usage: deis config:pull [options]

Options:
  -a --app=<app>
    The application that you wish to pull from
  -i --interactive
    Prompts for each value to be overwritten
  -o --overwrite
    Allows you to have the pull overwrite keys in .env
`

	args, err := docopt.Parse(usage, argv, true, "", false, true)

	if err != nil {
		return err
	}

	app := safeGetValue(args, "--app")
	interactive := args["--interactive"].(bool)
	overwrite := args["--overwrite"].(bool)

	return cmd.ConfigPull(app, interactive, overwrite)
}
コード例 #13
0
ファイル: update.go プロジェクト: tob1k/deisctl
// Update runs the Deis update engine daemon
func Update() error {
	usage := `Deis Update Daemon

	Usage:
	deisctl update [options]

	Options:
	--verbose                   print out the request bodies [default: false]
	--min-sleep=<sec>           minimum time between update checks [default: 10]
	--max-sleep=<sec>           maximum time between update checks [default: 30]
	--server=<server>           alternate update server URL (optional)
	`
	// parse command-line arguments
	args, err := docopt.Parse(usage, nil, true, "", true)
	if err != nil {
		return err
	}
	fmt.Printf("args: %v\n", args)
	err = setUpdateFlags(args)
	if err != nil {
		return err
	}
	fmt.Printf("flags: %v\n", Flags)
	return doUpdate()
}
コード例 #14
0
ファイル: ps.go プロジェクト: CodeJuan/deis
func psScale(argv []string) error {
	usage := `
Scales an application's processes by type.

Usage: deis ps:scale <type>=<num>... [options]

Arguments:
  <type>
    the process name as defined in your Procfile, such as 'web' or 'worker'.
    Note that Dockerfile apps have a default 'cmd' process type.
  <num>
    the number of processes.

Options:
  -a --app=<app>
    the uniquely identifiable name for the application.
`

	args, err := docopt.Parse(usage, argv, true, "", false, true)

	if err != nil {
		return err
	}

	return cmd.PsScale(safeGetValue(args, "--app"), args["<type>=<num>"].([]string))
}
コード例 #15
0
ファイル: client.go プロジェクト: uniite/deis
// SSH opens an interactive shell with a machine in the cluster.
func (c *Client) SSH(argv []string) error {
	usage := `Open an interactive shell on a machine in the cluster given a unit or machine id.

If an optional <command> is provided, that command is run remotely, and the results returned.

Usage:
  deisctl ssh <target> [<command>...]
`
	// parse command-line arguments
	args, err := docopt.Parse(usage, argv, true, "", true)
	if err != nil {
		return err
	}

	target := args["<target>"].(string)
	// handle help explicitly since docopt parsing is relaxed
	if target == "--help" {
		fmt.Println(usage)
		os.Exit(0)
	}

	var vargs []string
	if v, ok := args["<command>"]; ok {
		vargs = v.([]string)
	}

	return cmd.SSH(target, vargs, c.Backend)
}
コード例 #16
0
ファイル: apps.go プロジェクト: laurrentt/deis
func appCreate(argv []string) error {
	usage := `
Creates a new application.

- if no <id> is provided, one will be generated automatically.

Usage: deis apps:create [<id>] [options]

Arguments:
  <id>
    a uniquely identifiable name for the application. No other app can already
    exist with this name.

Options:
  --no-remote
    do not create a 'deis' git remote.
  -b --buildpack BUILDPACK
    a buildpack url to use for this app
  -r --remote REMOTE
    name of remote to create. [default: deis]
`
	args, err := docopt.Parse(usage, argv, true, "", false, true)

	if err != nil {
		return err
	}

	id := safeGetValue(args, "<id>")
	buildpack := safeGetValue(args, "--buildpack")
	remote := safeGetValue(args, "--remote")
	noRemote := args["--no-remote"].(bool)

	return cmd.AppCreate(id, buildpack, remote, noRemote)
}
コード例 #17
0
ファイル: client.go プロジェクト: uniite/deis
func (c *Client) Dock(argv []string) error {
	usage := `Connect to the named docker container and run commands on it.

This is equivalent to running 'docker exec -it <target> <command>'.

Usage:
  deisctl dock <target> [<command>...]
`
	// parse command-line arguments
	args, err := docopt.Parse(usage, argv, true, "", true)
	if err != nil {
		return err
	}

	target := args["<target>"].(string)
	// handle help explicitly since docopt parsing is relaxed
	if target == "--help" {
		fmt.Println(usage)
		os.Exit(0)
	}

	var vargs []string
	if v, ok := args["<command>"]; ok {
		vargs = v.([]string)
	}

	return cmd.Dock(target, vargs, c.Backend)
}
コード例 #18
0
ファイル: certs.go プロジェクト: CodeJuan/deis
func certsList(argv []string) error {
	usage := `
Show certificate information for an SSL application.

Usage: deis certs:list [options]

Options:
  -l --limit=<num>
    the maximum number of results to display, defaults to config setting
`

	args, err := docopt.Parse(usage, argv, true, "", false, true)

	if err != nil {
		return err
	}

	results, err := responseLimit(safeGetValue(args, "--limit"))

	if err != nil {
		return err
	}

	return cmd.CertsList(results)
}
コード例 #19
0
ファイル: perms.go プロジェクト: CodeJuan/deis
func permCreate(argv []string) error {
	usage := `
Gives another user permission to use an app, or gives another user
system administrator privileges.

Usage: deis perms:create <username> [-a --app=<app>|--admin]

Arguments:
  <username>
    the name of the new user.

Options:
  -a --app=<app>
    grants <username> permission to use <app>. <app> is the uniquely identifiable name
    for the application.
  --admin
    grants <username> system administrator privileges.
`

	args, err := docopt.Parse(usage, argv, true, "", false, true)

	if err != nil {
		return err
	}

	app := safeGetValue(args, "--app")
	username := args["<username>"].(string)
	admin := args["--admin"].(bool)

	return cmd.PermCreate(app, username, admin)
}
コード例 #20
0
ファイル: certs.go プロジェクト: CodeJuan/deis
func certAdd(argv []string) error {
	usage := `
Binds a certificate/key pair to an application.

Usage: deis certs:add <cert> <key> [options]

Arguments:
  <cert>
    The public key of the SSL certificate.
  <key>
    The private key of the SSL certificate.

Options:
  --common-name=<cname>
    The common name of the certificate. If none is provided, the controller will
    interpret the common name from the certificate.
  --subject-alt-names=<sans>
    The subject alternate names (SAN) of the certificate, separated by commas. This will
    create multiple Certificate objects in the controller, one for each SAN.
`

	args, err := docopt.Parse(usage, argv, true, "", false, true)

	if err != nil {
		return err
	}

	cert := args["<cert>"].(string)
	key := args["<key>"].(string)
	commonName := safeGetValue(args, "--common-name")
	sans := safeGetValue(args, "--subject-alt-names")

	return cmd.CertAdd(cert, key, commonName, sans)
}
コード例 #21
0
ファイル: cmd.go プロジェクト: pombredanne/deo
// Config gets or sets a configuration value from the cluster.
//
// A configuration value is stored and retrieved from a key/value store (in this case, etcd)
// at /deis/<component>/<config>. Configuration values are typically used for component-level
// configuration, such as enabling TLS for the routers.
func Config(argv []string) error {
	usage := `Gets or sets a configuration value from the cluster.

A configuration value is stored and retrieved from a key/value store
(in this case, etcd) at /deis/<component>/<config>. Configuration
values are typically used for component-level configuration, such as
enabling TLS for the routers.

Usage:
  deisctl config <target> get [<key>...] [options]
  deisctl config <target> set <key=val>... [options]

Options:
  --verbose		print out the request bodies [default: false]
`
	// parse command-line arguments
	args, err := docopt.Parse(usage, argv, true, "", false)
	if err != nil {
		return err
	}
	if err := config.Config(args); err != nil {
		return err
	}
	return nil
}
コード例 #22
0
ファイル: builds.go プロジェクト: CodeJuan/deis
func buildsCreate(argv []string) error {
	usage := `
Creates a new build of an application. Imports an <image> and deploys it to Deis
as a new release. If a Procfile is present in the current directory, it will be used
as the default process types for this application.

Usage: deis builds:create <image> [options]

Arguments:
  <image>
    A fully-qualified docker image, either from Docker Hub (e.g. deis/example-go:latest)
    or from an in-house registry (e.g. myregistry.example.com:5000/example-go:latest).
    This image must include the tag.

Options:
  -a --app=<app>
    The uniquely identifiable name for the application.
  -p --procfile=<procfile>
    A YAML string used to supply a Procfile to the application.
`

	args, err := docopt.Parse(usage, argv, true, "", false, true)

	if err != nil {
		return err
	}

	app := safeGetValue(args, "--app")
	image := safeGetValue(args, "<image>")
	procfile := safeGetValue(args, "--procfile")

	return cmd.BuildsCreate(app, image, procfile)
}
コード例 #23
0
ファイル: auth.go プロジェクト: CodeJuan/deis
func authPasswd(argv []string) error {
	usage := `
Changes the password for the current user.

Usage: deis auth:passwd [options]

Options:
  --password=<password>
    the current password for the account.
  --new-password=<new-password>
    the new password for the account.
  --username=<username>
    the account's username.
`

	args, err := docopt.Parse(usage, argv, true, "", false, true)

	if err != nil {
		return err
	}

	username := safeGetValue(args, "--username")
	password := safeGetValue(args, "--password")
	newPassword := safeGetValue(args, "--new-password")

	return cmd.Passwd(username, password, newPassword)
}
コード例 #24
0
ファイル: users.go プロジェクト: CodeJuan/deis
func usersList(argv []string) error {
	usage := `
Lists all registered users.
Requires admin privilages.

Usage: deis users:list [options]

Options:
  -l --limit=<num>
    the maximum number of results to display, defaults to config setting
`

	args, err := docopt.Parse(usage, argv, true, "", false, true)

	if err != nil {
		return err
	}

	results, err := responseLimit(safeGetValue(args, "--limit"))

	if err != nil {
		return err
	}

	return cmd.UsersList(results)
}
コード例 #25
0
ファイル: releases.go プロジェクト: CodeJuan/deis
func releasesList(argv []string) error {
	usage := `
Lists release history for an application.

Usage: deis releases:list [options]

Options:
  -a --app=<app>
    the uniquely identifiable name for the application.
  -l --limit=<num>
    the maximum number of results to display, defaults to config setting
`

	args, err := docopt.Parse(usage, argv, true, "", false, true)

	if err != nil {
		return err
	}

	results, err := responseLimit(safeGetValue(args, "--limit"))

	if err != nil {
		return err
	}

	return cmd.ReleasesList(safeGetValue(args, "--app"), results)
}
コード例 #26
0
ファイル: client.go プロジェクト: uniite/deis
// Install loads the definitions of components from local unit files.
// After Install, the components will be available to Start.
func (c *Client) Install(argv []string) error {
	usage := fmt.Sprintf(`Loads the definitions of components from local unit files.

After install, the components will be available to start.

"deisctl install" looks for unit files in these directories, in this order:
- the $DEISCTL_UNITS environment variable, if set
- $HOME/.deis/units
- /var/lib/deis/units

Usage:
  deisctl install [<target>...] [options]

Options:
  --router-mesh-size=<num>  Number of routers to be loaded when installing the platform [default: %d].
`, cmd.DefaultRouterMeshSize)
	// parse command-line arguments
	args, err := docopt.Parse(usage, argv, true, "", false)
	if err != nil {
		return err
	}

	meshSizeArg, _ := args["--router-mesh-size"].(string)
	parsedValue, err := strconv.ParseUint(meshSizeArg, 0, 8)
	if err != nil || parsedValue < 1 {
		fmt.Print("Error: argument --router-mesh-size: invalid value, make sure the value is an integer between 1 and 255.\n")
		return err
	}
	cmd.RouterMeshSize = uint8(parsedValue)

	return cmd.Install(args["<target>"].([]string), c.Backend, c.configBackend, cmd.CheckRequiredKeys)
}
コード例 #27
0
ファイル: releases.go プロジェクト: CodeJuan/deis
func releasesRollback(argv []string) error {
	usage := `
Rolls back to a previous application release.

Usage: deis releases:rollback [<version>] [options]

Arguments:
  <version>
    the release of the application, such as 'v1'.

Options:
  -a --app=<app>
    the uniquely identifiable name of the application.
`

	args, err := docopt.Parse(usage, argv, true, "", false, true)

	var version int

	if args["<version>"] == nil {
		version = -1
	} else {
		version, err = versionFromString(args["<version>"].(string))

		if err != nil {
			return err
		}
	}

	return cmd.ReleasesRollback(safeGetValue(args, "--app"), version)
}
コード例 #28
0
ファイル: client.go プロジェクト: uniite/deis
// RefreshUnits overwrites local unit files with those requested.
func (c *Client) RefreshUnits(argv []string) error {
	usage := `Overwrites local unit files with those requested.

Downloading from the Deis project GitHub URL by tag or SHA is the only mechanism
currently supported.

"deisctl install" looks for unit files in these directories, in this order:
- the $DEISCTL_UNITS environment variable, if set
- $HOME/.deis/units
- /var/lib/deis/units

Usage:
  deisctl refresh-units [-p <target>] [-t <tag>]

Options:
  -p --path=<target>   where to save unit files [default: $HOME/.deis/units]
  -t --tag=<tag>       git tag, branch, or SHA to use when downloading unit files
                       [default: master]
`
	// parse command-line arguments
	args, err := docopt.Parse(usage, argv, true, "", false)
	if err != nil {
		fmt.Printf("Error: %v\n", err)
		os.Exit(2)
	}

	return cmd.RefreshUnits(args["--path"].(string), args["--tag"].(string), units.URL)
}
コード例 #29
0
ファイル: tags.go プロジェクト: arschles/deis-controller
func tagsUnset(argv []string) error {
	usage := `
Unsets tags for an application.

Usage: deis tags:unset [options] <key>...

Arguments:
  <key> the tag key to unset, for example: "environ" or "rack"

Options:
  -a --app=<app>
    the uniquely identifiable name for the application.
`

	args, err := docopt.Parse(usage, argv, true, "", false, true)

	if err != nil {
		return err
	}

	app := safeGetValue(args, "--app")
	tags := args["<key>"].([]string)

	return cmd.TagsUnset(app, tags)
}
コード例 #30
0
func main() {
	// Parse the docopt string and exit on any error or help message.
	arguments, err := docopt.Parse(usage, nil, true, version, false, true)
	utils.ExitOnFail(err)
	model.LoadAPIs(arguments["-u"].(string), arguments["-f"].(string))
	model.GenerateCode(arguments["-o"].(string), arguments["-m"].(string))
}