2020-03-25 14:08:09 -04:00
|
|
|
package chroot
|
|
|
|
|
|
|
|
import (
|
|
|
|
"io/ioutil"
|
|
|
|
"strings"
|
|
|
|
|
2020-12-17 16:29:25 -05:00
|
|
|
packersdk "github.com/hashicorp/packer-plugin-sdk/packer"
|
2020-03-25 14:08:09 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
// testUI returns a test ui plus a function to retrieve the errors written to the ui
|
2020-11-19 14:54:31 -05:00
|
|
|
func testUI() (packersdk.Ui, func() string) {
|
2020-03-25 14:08:09 -04:00
|
|
|
errorBuffer := &strings.Builder{}
|
2020-11-20 13:21:29 -05:00
|
|
|
ui := &packersdk.BasicUi{
|
2020-03-25 14:08:09 -04:00
|
|
|
Reader: strings.NewReader(""),
|
|
|
|
Writer: ioutil.Discard,
|
|
|
|
ErrorWriter: errorBuffer,
|
|
|
|
}
|
|
|
|
return ui, errorBuffer.String
|
|
|
|
}
|