Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var BinstubsCmd = cli.Command{ Name: "binstubs", Usage: "Generate binstubs for the commands specified on devstep.yml", Action: func(c *cli.Context) { commands := project.Config().Commands if len(commands) == 0 { fmt.Println("No binstubs specified!") os.Exit(0) } binstubsPath := ".devstep/bin" os.MkdirAll("./"+binstubsPath, 0700) executable, _ := osext.Executable() for _, cmd := range commands { script := []byte("#!/usr/bin/env bash\neval \"" + executable + " run -- " + cmd.Name + " $@\"") err := ioutil.WriteFile(binstubsPath+"/"+cmd.Name, script, 0755) if err != nil { fmt.Printf("Error creating binstub '%s'\n%s\n", binstubsPath+"/"+cmd.Name, err) os.Exit(1) } fmt.Printf("Generated binstub for '%s' in '%s'\n", cmd.Name, binstubsPath) } }, }
View Source
var BootstrapCmd = cli.Command{ Name: "bootstrap", Usage: "bootstrap an environment for the current project", Flags: append( []cli.Flag{ cli.StringFlag{Name: "repository, r", Usage: "set the container repository name"}, }, dockerRunFlags..., ), BashComplete: func(c *cli.Context) { bashCompleteRunArgs(c) args := c.Args() if len(args) == 0 { fmt.Println("-r") fmt.Println("--repository") } }, Action: func(c *cli.Context) { if repo := c.String("repository"); repo != "" { project.Config().RepositoryName = repo } runOpts := parseRunOpts(c) err := project.Bootstrap(client, runOpts) if err != nil { fmt.Println(err) os.Exit(1) } }, }
View Source
var BuildCmd = cli.Command{ Name: "build", Usage: "build a docker image for the current project", Flags: dockerRunFlags, BashComplete: bashCompleteRunArgs, Action: func(c *cli.Context) { runOpts := parseRunOpts(c) err := project.Build(client, runOpts) if err != nil { fmt.Println(err) os.Exit(1) } }, }
View Source
var CleanCmd = cli.Command{ Name: "clean", Usage: "remove previously built images for the current environment", Flags: []cli.Flag{ cli.BoolFlag{Name: "force, f", Usage: "skip confirmation"}, }, BashComplete: func(c *cli.Context) { args := c.Args() if len(args) == 0 { fmt.Println("-f") fmt.Println("--force") } }, Action: func(c *cli.Context) { if !c.Bool("force") { if ok := prompt.Confirm("Are you sure? [y/n]"); !ok { fmt.Println("Aborting") os.Exit(1) } } err := project.Clean(client) if err != nil { fmt.Println(err) os.Exit(1) } }, }
View Source
var ExecCmd = cli.Command{ Name: "exec", Usage: "Run a one off command against the last container created for the current project", Action: func(c *cli.Context) { execCmd := c.Args() if len(execCmd) == 0 { fmt.Printf("No command provided to `devstep exec`\n\n") cli.ShowCommandHelp(c, "exec") os.Exit(1) } commands := project.Config().Commands if cmd, ok := commands[execCmd[0]]; ok { execCmd = append(cmd.Cmd, execCmd[1:]...) } execCmd = append([]string{"--"}, execCmd...) err := project.Exec(client, execCmd) if err != nil { fmt.Println(err) os.Exit(1) } }, }
View Source
var HackCmd = cli.Command{ Name: "hack", Usage: "start a hacking session for the current project", Flags: append( []cli.Flag{cli.StringFlag{Name: "name", Usage: "Name to be assigned to the container"}}, dockerRunFlags..., ), BashComplete: func(c *cli.Context) { bashCompleteRunArgs(c) args := c.Args() if len(args) == 0 { fmt.Println("--name") } }, Action: func(c *cli.Context) { runOpts := parseRunOpts(c) err := project.Hack(client, runOpts) if err != nil { fmt.Println(err) os.Exit(1) } }, }
View Source
var InfoCmd = cli.Command{ Name: "info", Usage: "show information about the current environment", Action: func(c *cli.Context) { printConfig(project.Config()) }, }
View Source
var InitCmd = cli.Command{ Name: "init", Action: func(c *cli.Context) { projectRoot, err := os.Getwd() if err != nil { fmt.Println(err) os.Exit(1) } configPath := projectRoot + "/devstep.yml" if _, err := os.Stat(configPath); err == nil { fmt.Println("`devstep.yml` already exists in this directory. Remove it before running `devstep init`.") os.Exit(1) } configFile := []byte(sampleConfig) err = ioutil.WriteFile(configPath, configFile, 0755) if err != nil { fmt.Printf("Error creating config file '%s'\n%s\n", configPath, err) os.Exit(1) } fmt.Printf("Generated sample configuration file in '%s'\n", configPath) }, }
View Source
var PristineCmd = cli.Command{ Name: "pristine", Usage: "rebuild project image from scratch", Flags: append( []cli.Flag{ cli.BoolFlag{Name: "force, f", Usage: "skip clean confirmation"}, cli.BoolFlag{Name: "bootstrap, b", Usage: "manually bootstrap your environment"}, cli.StringFlag{Name: "repository, r", Usage: "set the container repository name"}, }, dockerRunFlags..., ), BashComplete: func(c *cli.Context) { bashCompleteRunArgs(c) args := c.Args() if len(args) == 0 { fmt.Println("-f") fmt.Println("--force") fmt.Println("-b") fmt.Println("--bootstrap") fmt.Println("--repository") } }, Action: func(c *cli.Context) { CleanCmd.Action(c) reloadProject() if c.Bool("bootstrap") { BootstrapCmd.Action(c) } else { BuildCmd.Action(c) } }, }
View Source
var RunCmd = cli.Command{ Name: "run", Usage: "Run a one off command against the current base image", Flags: append( []cli.Flag{cli.StringFlag{Name: "name", Usage: "Name to be assigned to the container"}}, dockerRunFlags..., ), BashComplete: func(c *cli.Context) { bashCompleteRunArgs(c) args := c.Args() if len(args) == 0 { fmt.Println("--name") } }, Action: func(c *cli.Context) { project := newProject() commands := project.Config().Commands runOpts := parseRunOpts(c) runOpts.Cmd = c.Args() if len(runOpts.Cmd) == 0 { fmt.Printf("No command provided to `devstep run`\n\n") cli.ShowCommandHelp(c, "run") os.Exit(1) } if cmd, ok := commands[runOpts.Cmd[0]]; ok { runOpts = cmd.Merge(runOpts) runOpts.Cmd = append(cmd.Cmd, runOpts.Cmd[1:]...) } runOpts.Cmd = append([]string{"--"}, runOpts.Cmd...) result, err := project.Run(client, runOpts) if err != nil { fmt.Println(err) os.Exit(1) } os.Exit(result.ExitCode) }, }
Functions ¶
func InitDevstepEnv ¶ added in v0.4.0
func InitDevstepEnv()
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.