-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add build tags for additional output on call failure
- Loading branch information
1 parent
913904b
commit 983b950
Showing
3 changed files
with
58 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
//go:build !flag_debug | ||
|
||
package main | ||
|
||
import ( | ||
"github.com/docker/machine/libmachine/drivers" | ||
"github.com/pkg/errors" | ||
) | ||
|
||
func (d *Driver) flagFailure(format string, args ...interface{}) error { | ||
return errors.Errorf(format, args...) | ||
} | ||
|
||
func (d *Driver) setConfigFromFlags(opts drivers.DriverOptions) error { | ||
return d.setConfigFromFlagsImpl(opts) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
//go:build flag_debug | ||
|
||
package main | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
|
||
"github.com/docker/machine/libmachine/drivers" | ||
"github.com/pkg/errors" | ||
) | ||
|
||
var lastOpts drivers.DriverOptions | ||
|
||
func (d *Driver) flagFailure(format string, args ...interface{}) error { | ||
// machine driver may not flush logs received when getting an RPC error, so we have to resort to this terribleness | ||
line1 := fmt.Sprintf("Flag failure detected:\n -> last opts: %v\n -> driver state %v", lastOpts, d) | ||
var line2 string | ||
if out, err := json.MarshalIndent(d, "", " "); err == nil { | ||
line2 = fmt.Sprintf(" -> driver json:\n%s", out) | ||
} else { | ||
line2 = fmt.Sprintf("could not encode driver json: %v", err) | ||
} | ||
|
||
combined := append([]interface{}{line1, line2}, args...) | ||
return errors.Errorf("%s\n%s\n"+format, combined...) | ||
} | ||
|
||
func (d *Driver) setConfigFromFlags(opts drivers.DriverOptions) error { | ||
lastOpts = opts | ||
return d.setConfigFromFlagsImpl(opts) | ||
} |