s/TargettedUi/TargetedUI/

This commit is contained in:
Matthew Hooker 2017-03-29 12:44:42 -07:00
parent 4fcbf75da9
commit 048e316645
No known key found for this signature in database
GPG Key ID: 7B5F933D9CE8C6A1
4 changed files with 17 additions and 17 deletions

View File

@ -212,7 +212,7 @@ func (c BuildCommand) Run(args []string) int {
c.Ui.Error("\n==> Some builds didn't complete successfully and had errors:")
for name, err := range errors {
// Create a UI for the machine readable stuff to be targeted
ui := &packer.TargettedUi{
ui := &packer.TargetedUI{
Target: name,
Ui: c.Ui,
}
@ -227,7 +227,7 @@ func (c BuildCommand) Run(args []string) int {
c.Ui.Say("\n==> Builds finished. The artifacts of successful builds are:")
for name, buildArtifacts := range artifacts.m {
// Create a UI for the machine readable stuff to be targeted
ui := &packer.TargettedUi{
ui := &packer.TargetedUI{
Target: name,
Ui: c.Ui,
}

View File

@ -211,7 +211,7 @@ func (b *coreBuild) Run(originalUi Ui, cache Cache) ([]Artifact, error) {
artifacts := make([]Artifact, 0, 1)
// The builder just has a normal Ui, but targeted
builderUi := &TargettedUi{
builderUi := &TargetedUI{
Target: b.Name(),
Ui: originalUi,
}
@ -236,7 +236,7 @@ PostProcessorRunSeqLoop:
for _, ppSeq := range b.postProcessors {
priorArtifact := builderArtifact
for i, corePP := range ppSeq {
ppUi := &TargettedUi{
ppUi := &TargetedUI{
Target: fmt.Sprintf("%s (%s)", b.Name(), corePP.processorType),
Ui: originalUi,
}

View File

@ -46,12 +46,12 @@ type ColoredUi struct {
Ui Ui
}
// TargettedUi is a UI that wraps another UI implementation and modifies
// TargetedUI is a UI that wraps another UI implementation and modifies
// the output to indicate a specific target. Specifically, all Say output
// is prefixed with the target name. Message output is not prefixed but
// is offset by the length of the target so that output is lined up properly
// with Say output. Machine-readable output has the proper target set.
type TargettedUi struct {
type TargetedUI struct {
Target string
Ui Ui
}
@ -132,28 +132,28 @@ func (u *ColoredUi) supportsColors() bool {
return cygwin
}
func (u *TargettedUi) Ask(query string) (string, error) {
func (u *TargetedUI) Ask(query string) (string, error) {
return u.Ui.Ask(u.prefixLines(true, query))
}
func (u *TargettedUi) Say(message string) {
func (u *TargetedUI) Say(message string) {
u.Ui.Say(u.prefixLines(true, message))
}
func (u *TargettedUi) Message(message string) {
func (u *TargetedUI) Message(message string) {
u.Ui.Message(u.prefixLines(false, message))
}
func (u *TargettedUi) Error(message string) {
func (u *TargetedUI) Error(message string) {
u.Ui.Error(u.prefixLines(true, message))
}
func (u *TargettedUi) Machine(t string, args ...string) {
func (u *TargetedUI) Machine(t string, args ...string) {
// Prefix in the target, then pass through
u.Ui.Machine(fmt.Sprintf("%s,%s", u.Target, t), args...)
}
func (u *TargettedUi) prefixLines(arrow bool, message string) string {
func (u *TargetedUI) prefixLines(arrow bool, message string) string {
arrowText := "==>"
if !arrow {
arrowText = strings.Repeat(" ", len(arrowText))

View File

@ -97,9 +97,9 @@ func TestColoredUi_noColorEnv(t *testing.T) {
}
}
func TestTargettedUi(t *testing.T) {
func TestTargetedUI(t *testing.T) {
bufferUi := testUi()
targettedUi := &TargettedUi{
targettedUi := &TargetedUI{
Target: "foo",
Ui: bufferUi,
}
@ -142,11 +142,11 @@ func TestColoredUi_ImplUi(t *testing.T) {
}
}
func TestTargettedUi_ImplUi(t *testing.T) {
func TestTargetedUI_ImplUi(t *testing.T) {
var raw interface{}
raw = &TargettedUi{}
raw = &TargetedUI{}
if _, ok := raw.(Ui); !ok {
t.Fatalf("TargettedUi must implement Ui")
t.Fatalf("TargetedUI must implement Ui")
}
}