Skip to content

Commit

Permalink
fixes #386
Browse files Browse the repository at this point in the history
Signed-off-by: ktpv <ktpv@users.noreply.github.com>
  • Loading branch information
ktpv committed Dec 6, 2019
1 parent 621d70c commit 60316ea
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
21 changes: 13 additions & 8 deletions internal/commands/inspect_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,28 +36,33 @@ func InspectBuilder(logger logging.Logger, cfg config.Config, client PackClient)
imageName = args[0]
}

remoteOutput, remoteWarnings, remoteErr := inspectBuilderOutput(client, cfg, imageName, false)
localOutput, localWarnings, localErr := inspectBuilderOutput(client, cfg, imageName, true)

if remoteOutput == "(not present)" && localOutput == "(not present)" {
return errors.New(fmt.Sprintf("Unable to find builder '%s' locally or remotely.\n", imageName))
}

if imageName == cfg.DefaultBuilder {
logger.Infof("Inspecting default builder: %s\n", style.Symbol(imageName))
} else {
logger.Infof("Inspecting builder: %s\n", style.Symbol(imageName))
}

remoteOutput, warnings, err := inspectBuilderOutput(client, cfg, imageName, false)
if err != nil {
logger.Error(err.Error())
if remoteErr != nil {
logger.Error(remoteErr.Error())
} else {
logger.Infof("\nREMOTE:\n%s\n", remoteOutput)
for _, w := range warnings {
for _, w := range remoteWarnings {
logger.Warn(w)
}
}

localOutput, warnings, err := inspectBuilderOutput(client, cfg, imageName, true)
if err != nil {
logger.Error(err.Error())
if localErr != nil {
logger.Error(localErr.Error())
} else {
logger.Infof("\nLOCAL:\n%s\n", localOutput)
for _, w := range warnings {
for _, w := range localWarnings {
logger.Warn(w)
}
}
Expand Down
6 changes: 2 additions & 4 deletions internal/commands/inspect_builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,12 @@ func testInspectBuilderCommand(t *testing.T, when spec.G, it spec.S) {

when("#Get", func() {
when("image cannot be found", func() {
it("logs 'Not present'", func() {
it("logs 'ERROR Unable'", func() {
mockClient.EXPECT().InspectBuilder("some/image", false).Return(nil, nil)
mockClient.EXPECT().InspectBuilder("some/image", true).Return(nil, nil)

command.SetArgs([]string{"some/image"})
h.AssertNil(t, command.Execute())

h.AssertContains(t, outBuf.String(), "REMOTE:\n(not present)\n\nLOCAL:\n(not present)\n")
h.AssertError(t, command.Execute(), `Unable to find builder 'some/image' locally or remotely.`)
})
})

Expand Down

0 comments on commit 60316ea

Please sign in to comment.