Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
packer
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kristopher Ruzic
packer
Commits
02edc757
Commit
02edc757
authored
Aug 11, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
packer: Rename ReaderWriterUi to BasicUi
parent
fb6d2754
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
27 additions
and
24 deletions
+27
-24
command/build/command_test.go
command/build/command_test.go
+1
-1
packer/communicator_test.go
packer/communicator_test.go
+1
-1
packer/environment.go
packer/environment.go
+1
-1
packer/environment_test.go
packer/environment_test.go
+5
-5
packer/ui.go
packer/ui.go
+11
-8
packer/ui_test.go
packer/ui_test.go
+8
-8
No files found.
command/build/command_test.go
View file @
02edc757
...
...
@@ -9,7 +9,7 @@ import (
func
testEnvironment
()
packer
.
Environment
{
config
:=
packer
.
DefaultEnvironmentConfig
()
config
.
Ui
=
&
packer
.
ReaderWriter
Ui
{
config
.
Ui
=
&
packer
.
Basic
Ui
{
Reader
:
new
(
bytes
.
Buffer
),
Writer
:
new
(
bytes
.
Buffer
),
}
...
...
packer/communicator_test.go
View file @
02edc757
...
...
@@ -47,7 +47,7 @@ func TestRemoteCmd_StartWithUi(t *testing.T) {
Stdout
:
rcOutput
,
}
testUi
:=
&
ReaderWriter
Ui
{
testUi
:=
&
Basic
Ui
{
Reader
:
new
(
bytes
.
Buffer
),
Writer
:
uiOutput
,
}
...
...
packer/environment.go
View file @
02edc757
...
...
@@ -73,7 +73,7 @@ type EnvironmentConfig struct {
func
DefaultEnvironmentConfig
()
*
EnvironmentConfig
{
config
:=
&
EnvironmentConfig
{}
config
.
Commands
=
make
([]
string
,
0
)
config
.
Ui
=
&
ReaderWriter
Ui
{
config
.
Ui
=
&
Basic
Ui
{
Reader
:
os
.
Stdin
,
Writer
:
os
.
Stdout
,
}
...
...
packer/environment_test.go
View file @
02edc757
...
...
@@ -19,7 +19,7 @@ func init() {
func
testEnvironment
()
Environment
{
config
:=
DefaultEnvironmentConfig
()
config
.
Ui
=
&
ReaderWriter
Ui
{
config
.
Ui
=
&
Basic
Ui
{
Reader
:
new
(
bytes
.
Buffer
),
Writer
:
new
(
bytes
.
Buffer
),
}
...
...
@@ -45,8 +45,8 @@ func TestEnvironment_DefaultConfig_Ui(t *testing.T) {
config
:=
DefaultEnvironmentConfig
()
assert
.
NotNil
(
config
.
Ui
,
"default UI should not be nil"
)
rwUi
,
ok
:=
config
.
Ui
.
(
*
ReaderWriter
Ui
)
assert
.
True
(
ok
,
"default UI should be
ReaderWriter
Ui"
)
rwUi
,
ok
:=
config
.
Ui
.
(
*
Basic
Ui
)
assert
.
True
(
ok
,
"default UI should be
Basic
Ui"
)
assert
.
Equal
(
rwUi
.
Writer
,
os
.
Stdout
,
"default UI should go to stdout"
)
assert
.
Equal
(
rwUi
.
Reader
,
os
.
Stdin
,
"default UI should read from stdin"
)
}
...
...
@@ -175,7 +175,7 @@ func TestEnvironment_DefaultCli_Help(t *testing.T) {
// A little lambda to help us test the output actually contains help
testOutput
:=
func
()
{
buffer
:=
defaultEnv
.
Ui
()
.
(
*
ReaderWriter
Ui
)
.
Writer
.
(
*
bytes
.
Buffer
)
buffer
:=
defaultEnv
.
Ui
()
.
(
*
Basic
Ui
)
.
Writer
.
(
*
bytes
.
Buffer
)
output
:=
buffer
.
String
()
buffer
.
Reset
()
assert
.
True
(
strings
.
Contains
(
output
,
"usage: packer"
),
"should print help"
)
...
...
@@ -341,7 +341,7 @@ func TestEnvironmentProvisioner_Error(t *testing.T) {
func
TestEnvironment_SettingUi
(
t
*
testing
.
T
)
{
assert
:=
asserts
.
NewTestingAsserts
(
t
,
true
)
ui
:=
&
ReaderWriter
Ui
{
ui
:=
&
Basic
Ui
{
Reader
:
new
(
bytes
.
Buffer
),
Writer
:
new
(
bytes
.
Buffer
),
}
...
...
packer/ui.go
View file @
02edc757
...
...
@@ -51,9 +51,12 @@ type PrefixedUi struct {
Ui
Ui
}
// The ReaderWriterUi is a UI that writes and reads from standard Go
// io.Reader and io.Writer.
type
ReaderWriterUi
struct
{
// 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. The
// target for machine-readable output can be configured by prefixing the
// type of the machine readable output with the target and separating it
// with a comma.
type
BasicUi
struct
{
Reader
io
.
Reader
Writer
io
.
Writer
l
sync
.
Mutex
...
...
@@ -144,7 +147,7 @@ func (u *PrefixedUi) prefixLines(prefix, message string) string {
return
strings
.
TrimRightFunc
(
result
.
String
(),
unicode
.
IsSpace
)
}
func
(
rw
*
ReaderWriter
Ui
)
Ask
(
query
string
)
(
string
,
error
)
{
func
(
rw
*
Basic
Ui
)
Ask
(
query
string
)
(
string
,
error
)
{
rw
.
l
.
Lock
()
defer
rw
.
l
.
Unlock
()
...
...
@@ -188,7 +191,7 @@ func (rw *ReaderWriterUi) Ask(query string) (string, error) {
}
}
func
(
rw
*
ReaderWriter
Ui
)
Say
(
message
string
)
{
func
(
rw
*
Basic
Ui
)
Say
(
message
string
)
{
rw
.
l
.
Lock
()
defer
rw
.
l
.
Unlock
()
...
...
@@ -199,7 +202,7 @@ func (rw *ReaderWriterUi) Say(message string) {
}
}
func
(
rw
*
ReaderWriter
Ui
)
Message
(
message
string
)
{
func
(
rw
*
Basic
Ui
)
Message
(
message
string
)
{
rw
.
l
.
Lock
()
defer
rw
.
l
.
Unlock
()
...
...
@@ -210,7 +213,7 @@ func (rw *ReaderWriterUi) Message(message string) {
}
}
func
(
rw
*
ReaderWriter
Ui
)
Error
(
message
string
)
{
func
(
rw
*
Basic
Ui
)
Error
(
message
string
)
{
rw
.
l
.
Lock
()
defer
rw
.
l
.
Unlock
()
...
...
@@ -221,6 +224,6 @@ func (rw *ReaderWriterUi) Error(message string) {
}
}
func
(
rw
*
ReaderWriter
Ui
)
Machine
(
t
string
,
args
...
string
)
{
func
(
rw
*
Basic
Ui
)
Machine
(
t
string
,
args
...
string
)
{
// TODO
}
packer/ui_test.go
View file @
02edc757
...
...
@@ -6,8 +6,8 @@ import (
"testing"
)
func
testUi
()
*
ReaderWriter
Ui
{
return
&
ReaderWriter
Ui
{
func
testUi
()
*
Basic
Ui
{
return
&
Basic
Ui
{
Reader
:
new
(
bytes
.
Buffer
),
Writer
:
new
(
bytes
.
Buffer
),
}
...
...
@@ -71,15 +71,15 @@ func TestPrefixedUi_ImplUi(t *testing.T) {
}
}
func
Test
ReaderWriter
Ui_ImplUi
(
t
*
testing
.
T
)
{
func
Test
Basic
Ui_ImplUi
(
t
*
testing
.
T
)
{
var
raw
interface
{}
raw
=
&
ReaderWriter
Ui
{}
raw
=
&
Basic
Ui
{}
if
_
,
ok
:=
raw
.
(
Ui
);
!
ok
{
t
.
Fatalf
(
"
ReaderWriter
Ui must implement Ui"
)
t
.
Fatalf
(
"
Basic
Ui must implement Ui"
)
}
}
func
Test
ReaderWriter
Ui_Error
(
t
*
testing
.
T
)
{
func
Test
Basic
Ui_Error
(
t
*
testing
.
T
)
{
assert
:=
asserts
.
NewTestingAsserts
(
t
,
true
)
bufferUi
:=
testUi
()
...
...
@@ -91,7 +91,7 @@ func TestReaderWriterUi_Error(t *testing.T) {
assert
.
Equal
(
readWriter
(
bufferUi
),
"5
\n
"
,
"formatting"
)
}
func
Test
ReaderWriter
Ui_Say
(
t
*
testing
.
T
)
{
func
Test
Basic
Ui_Say
(
t
*
testing
.
T
)
{
assert
:=
asserts
.
NewTestingAsserts
(
t
,
true
)
bufferUi
:=
testUi
()
...
...
@@ -105,7 +105,7 @@ func TestReaderWriterUi_Say(t *testing.T) {
// This reads the output from the bytes.Buffer in our test object
// and then resets the buffer.
func
readWriter
(
ui
*
ReaderWriter
Ui
)
(
result
string
)
{
func
readWriter
(
ui
*
Basic
Ui
)
(
result
string
)
{
buffer
:=
ui
.
Writer
.
(
*
bytes
.
Buffer
)
result
=
buffer
.
String
()
buffer
.
Reset
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment