Merge pull request #9448 from hashicorp/9440
make sure the no-op progress bar gets used for machine readable uis
This commit is contained in:
commit
87b6eb141a
|
@ -170,11 +170,12 @@ func (c *BuildCommand) RunContext(buildCtx context.Context, cla *BuildArgs) int
|
|||
for i := range builds {
|
||||
ui := c.Ui
|
||||
if cla.Color {
|
||||
// Only set up UI colors if -machine-readable isn't set.
|
||||
if _, ok := c.Ui.(*packer.MachineReadableUi); !ok {
|
||||
ui = &packer.ColoredUi{
|
||||
Color: colors[i%len(colors)],
|
||||
Ui: ui,
|
||||
}
|
||||
if _, ok := c.Ui.(*packer.MachineReadableUi); !ok {
|
||||
ui.Say(fmt.Sprintf("%s: output will be in this color.", builds[i].Name()))
|
||||
if i+1 == len(builds) {
|
||||
// Add a newline between the color output and the actual output
|
||||
|
|
|
@ -131,7 +131,6 @@ func (u *ColoredUi) supportsColors() bool {
|
|||
type TargetedUI struct {
|
||||
Target string
|
||||
Ui Ui
|
||||
*uiProgressBar
|
||||
}
|
||||
|
||||
var _ Ui = new(TargetedUI)
|
||||
|
@ -172,6 +171,10 @@ func (u *TargetedUI) prefixLines(arrow bool, message string) string {
|
|||
return strings.TrimRightFunc(result.String(), unicode.IsSpace)
|
||||
}
|
||||
|
||||
func (u *TargetedUI) TrackProgress(src string, currentSize, totalSize int64, stream io.ReadCloser) io.ReadCloser {
|
||||
return u.Ui.TrackProgress(src, currentSize, totalSize, stream)
|
||||
}
|
||||
|
||||
// The BasicUI is a UI that reads and writes from a standard Go reader
|
||||
// and writer. It is safe to be called from multiple goroutines. Machine
|
||||
// readable output is simply logged for this UI.
|
||||
|
|
Loading…
Reference in New Issue