Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check for a boxfile when an environment is being created #388

Merged
merged 2 commits into from
Feb 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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

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