Example #1
0
// Run Parity
func (c *AttachCommand) Run(args []string) int {
	cmdFlags := flag.NewFlagSet("sync", flag.ContinueOnError)
	cmdFlags.Usage = func() { c.Meta.Ui.Output(c.Help()) }

	cmdFlags.StringVar(&c.Service, "service", "web", "Service to shell into. Defaults to 'web'")
	cmdFlags.StringVar(&c.ParityFile, "config", utils.DefaultParityConfigurationFile(), "Parity configuration file")

	if err := cmdFlags.Parse(args); err != nil {
		return 1
	}

	c.Meta.Ui.Output("Attaching to running container")
	parity := app.New(&config.Config{ConfigFile: c.ParityFile})
	parity.LoadPlugins()

	if shell, err := parity.GetShellPlugin("compose"); err == nil {
		err := shell.Attach(app.ShellConfig{
			Service: c.Service,
		})
		if err != nil {
			Ui.Error(fmt.Sprintf("Unable to attach to container: %s", err.Error()))
		}
	} else {
		Ui.Error(fmt.Sprintf("Unable to attach to container: %s", err.Error()))
	}

	return 0
}
Example #2
0
func (c *SetupCommand) Run(args []string) int {
	cmdFlags := flag.NewFlagSet("install", flag.ContinueOnError)
	cmdFlags.Usage = func() { c.Meta.Ui.Output(c.Help()) }

	cmdFlags.StringVar(&c.Base, "base", "", "Base image name e.g. 'my-awesome-project'")
	cmdFlags.StringVar(&c.Version, "version", "1.0.0", "Initial Docker image version")
	cmdFlags.StringVar(&c.Template, "template", "", "Specify a pre-built template to use")
	cmdFlags.StringVar(&c.TemplateSourceURL, "templateSourceUrl", "", "Specify a URL pointing to a Parity template")
	cmdFlags.StringVar(&c.ConfigFile, "config", utils.DefaultParityConfigurationFile(), "Enable verbose output")
	cmdFlags.BoolVar(&c.Overwrite, "force", false, "Overwrites any existing Parity files")

	if err := cmdFlags.Parse(args); err != nil {
		return 1
	}

	c.Meta.Ui.Output("Setting up a new Parity project")
	if err := setup.SetupParityProject(&setup.Config{
		TemplateSourceURL:  c.TemplateSourceURL,
		TemplateSourceName: c.Template,
		Version:            c.Version,
		Overwrite:          c.Overwrite,
		Base:               c.Base,
	}); err != nil {
		c.Meta.Ui.Error(err.Error())
		return 1
	}

	return 0
}
Example #3
0
// Run Parity
func (c *CleanupCommand) Run(args []string) int {
	cmdFlags := flag.NewFlagSet("sync", flag.ContinueOnError)
	cmdFlags.Usage = func() { c.Meta.Ui.Output(c.Help()) }

	cmdFlags.StringVar(&c.ConfigFile, "config", utils.DefaultParityConfigurationFile(), "Specifies the Parity configuration file path")

	if err := cmdFlags.Parse(args); err != nil {
		return 1
	}

	c.Meta.Ui.Output("Cleaning up Docker images and containers")
	utils.Cleanup()

	return 0
}
Example #4
0
// Run Parity
func (c *XCommand) Run(args []string) int {
	cmdFlags := flag.NewFlagSet("x", flag.ContinueOnError)
	cmdFlags.Usage = func() { c.Meta.Ui.Output(c.Help()) }

	cmdFlags.StringVar(&c.ParityFile, "config", utils.DefaultParityConfigurationFile(), "Parity configuration file")
	cmdFlags.IntVar(&c.Port, "port", 6000, "Proxy port")

	if err := cmdFlags.Parse(args); err != nil {
		return 1
	}

	c.Meta.Ui.Output("Starting X Proxy")
	run.XServerProxy(c.Port)

	return 0
}
Example #5
0
// Run Parity
func (c *RunCommand) Run(args []string) int {
	cmdFlags := flag.NewFlagSet("sync", flag.ContinueOnError)
	cmdFlags.Usage = func() { c.Meta.Ui.Output(c.Help()) }

	cmdFlags.BoolVar(&c.Verbose, "verbose", true, "Enable verbose output")
	cmdFlags.BoolVar(&c.X, "x", false, "Enable X redirection (Mac OSX Only)")
	cmdFlags.StringVar(&c.ConfigFile, "config", utils.DefaultParityConfigurationFile(), "Enable verbose output")

	if err := cmdFlags.Parse(args); err != nil {
		return 1
	}

	if !c.Verbose {
		log.SetOutput(ioutil.Discard)
	}

	parity := app.New(&config.Config{Ui: c.Meta.Ui, ConfigFile: c.ConfigFile})
	parity.Run()

	return 0
}
Example #6
0
// Run Parity
func (c *BuildCommand) Run(args []string) int {
	cmdFlags := flag.NewFlagSet("sync", flag.ContinueOnError)
	cmdFlags.Usage = func() { c.Meta.Ui.Output(c.Help()) }

	cmdFlags.BoolVar(&c.Verbose, "verbose", true, "Enable verbose output")
	cmdFlags.StringVar(&c.ConfigFile, "config", utils.DefaultParityConfigurationFile(), "Specifies the Parity configuration file path")

	if err := cmdFlags.Parse(args); err != nil {
		return 1
	}

	if !c.Verbose {
		log.SetOutput(ioutil.Discard)
	}

	c.Meta.Ui.Output("Building containers")
	parity := app.New(&config.Config{Ui: c.Meta.Ui, ConfigFile: c.ConfigFile})
	if err := parity.Build(); err != nil {
		c.Meta.Ui.Error(err.Error())
	}

	return 0
}