Skip to content

Commit

Permalink
Merge pull request #388 from nanobox-io/hotfix/missing-boxfile
Browse files Browse the repository at this point in the history
Check for a boxfile when an environment is being created
  • Loading branch information
lyondhill authored Feb 27, 2017
2 parents a613900 + 11ab7c4 commit 45edca7
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 3 deletions.
1 change: 1 addition & 0 deletions commands/destroy.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ func destroyFunc(ccmd *cobra.Command, args []string) {
return
}


if len(args) == 0 {
display.CommandErr(env.Destroy(envModel))
}
Expand Down
9 changes: 9 additions & 0 deletions processors/env/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,31 @@ import (
"fmt"

"github.com/jcelliott/lumber"
"github.com/nanobox-io/nanobox-boxfile"

"github.com/nanobox-io/nanobox/models"
"github.com/nanobox-io/nanobox/processors/provider"
"github.com/nanobox-io/nanobox/util"
"github.com/nanobox-io/nanobox/util/config"
"github.com/nanobox-io/nanobox/util/display"
util_provider "github.com/nanobox-io/nanobox/util/provider"
)

// Setup sets up the provider and the env mounts
func Setup(envModel *models.Env) error {

// if there is no boxfile display a message and end
if box := boxfile.NewFromPath(config.Boxfile()); !box.Valid {
display.MissingBoxfile()
return util.ErrorfQuiet("missing or invalid boxfile")
}

// init docker client
if err := provider.Init(); err != nil {
return util.ErrorAppend(err, "failed to init docker client")
}


// ensure the envModel data has been generated
if err := envModel.Generate(); err != nil {
lumber.Error("env:Setup:models:Env:Generate()")
Expand Down
12 changes: 12 additions & 0 deletions util/display/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,3 +230,15 @@ We could not connect as the gonano user but we were able to
fall back to the default user
`, TaskComplete))
}

func MissingBoxfile() {
os.Stderr.WriteString(fmt.Sprintf(`
--------------------------------------------------------------------------------
MISSING BOXFILE.YML
Nanobox is looking for a boxfile.yml config file. You might want to
check out our getting-started guide on configuring your app:
https://guides.nanobox.io/
--------------------------------------------------------------------------------
`))
}
11 changes: 8 additions & 3 deletions util/provider/dockermachine.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"os"
"os/exec"
// "path/filepath"
"io"
"regexp"
"runtime"
"strings"
Expand Down Expand Up @@ -143,14 +144,18 @@ func (machine DockerMachine) Create() error {

process := exec.Command(cmd[0], cmd[1:]...)

process.Stdout = display.NewStreamer("info")
process.Stderr = display.NewStreamer("info")
// lets try getting the extra bytes from creating
fullBuffer := &bytes.Buffer{}
writer := io.MultiWriter(display.NewStreamer("info"), fullBuffer)

process.Stdout = writer
process.Stderr = writer

display.StartTask("Launching VM")

if err := process.Run(); err != nil {
display.ErrorTask()
return util.Error(err)
return util.Errorf("%s: %s", fullBuffer.String(), err)
}

display.StopTask()
Expand Down
6 changes: 6 additions & 0 deletions vendor/github.com/nanobox-io/nanobox-boxfile/boxfile.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 45edca7

Please sign in to comment.