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
fb6d2754
Commit
fb6d2754
authored
Aug 11, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
packer: Add Machine func to Ui
parent
7004813a
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
51 additions
and
0 deletions
+51
-0
packer/rpc/ui.go
packer/rpc/ui.go
+24
-0
packer/rpc/ui_test.go
packer/rpc/ui_test.go
+9
-0
packer/ui.go
packer/ui.go
+15
-0
provisioner/file/provisioner_test.go
provisioner/file/provisioner_test.go
+3
-0
No files found.
packer/rpc/ui.go
View file @
fb6d2754
...
...
@@ -17,6 +17,12 @@ type UiServer struct {
ui
packer
.
Ui
}
// The arguments sent to Ui.Machine
type
UiMachineArgs
struct
{
category
string
args
[]
string
}
func
(
u
*
Ui
)
Ask
(
query
string
)
(
result
string
,
err
error
)
{
err
=
u
.
client
.
Call
(
"Ui.Ask"
,
query
,
&
result
)
return
...
...
@@ -28,6 +34,17 @@ func (u *Ui) Error(message string) {
}
}
func
(
u
*
Ui
)
Machine
(
t
string
,
args
...
string
)
{
rpcArgs
:=
&
UiMachineArgs
{
category
:
t
,
args
:
args
,
}
if
err
:=
u
.
client
.
Call
(
"Ui.Message"
,
rpcArgs
,
new
(
interface
{}));
err
!=
nil
{
panic
(
err
)
}
}
func
(
u
*
Ui
)
Message
(
message
string
)
{
if
err
:=
u
.
client
.
Call
(
"Ui.Message"
,
message
,
new
(
interface
{}));
err
!=
nil
{
panic
(
err
)
...
...
@@ -52,6 +69,13 @@ func (u *UiServer) Error(message *string, reply *interface{}) error {
return
nil
}
func
(
u
*
UiServer
)
Machine
(
args
*
UiMachineArgs
,
reply
*
interface
{})
error
{
u
.
ui
.
Machine
(
args
.
category
,
args
.
args
...
)
*
reply
=
nil
return
nil
}
func
(
u
*
UiServer
)
Message
(
message
*
string
,
reply
*
interface
{})
error
{
u
.
ui
.
Message
(
*
message
)
*
reply
=
nil
...
...
packer/rpc/ui_test.go
View file @
fb6d2754
...
...
@@ -11,6 +11,9 @@ type testUi struct {
askQuery
string
errorCalled
bool
errorMessage
string
machineCalled
bool
machineType
string
machineArgs
[]
string
messageCalled
bool
messageMessage
string
sayCalled
bool
...
...
@@ -28,6 +31,12 @@ func (u *testUi) Error(message string) {
u
.
errorMessage
=
message
}
func
(
u
*
testUi
)
Machine
(
t
string
,
args
...
string
)
{
u
.
machineCalled
=
true
u
.
machineType
=
t
u
.
machineArgs
=
args
}
func
(
u
*
testUi
)
Message
(
message
string
)
{
u
.
messageCalled
=
true
u
.
messageMessage
=
message
...
...
packer/ui.go
View file @
fb6d2754
...
...
@@ -33,6 +33,7 @@ type Ui interface {
Say
(
string
)
Message
(
string
)
Error
(
string
)
Machine
(
string
,
...
string
)
}
// ColoredUi is a UI that is colored using terminal colors.
...
...
@@ -80,6 +81,11 @@ func (u *ColoredUi) Error(message string) {
u
.
Ui
.
Error
(
u
.
colorize
(
message
,
color
,
true
))
}
func
(
u
*
ColoredUi
)
Machine
(
t
string
,
args
...
string
)
{
// Don't colorize machine-readable output
u
.
Ui
.
Machine
(
t
,
args
...
)
}
func
(
u
*
ColoredUi
)
colorize
(
message
string
,
color
UiColor
,
bold
bool
)
string
{
if
!
u
.
supportsColors
()
{
return
message
...
...
@@ -123,6 +129,11 @@ func (u *PrefixedUi) Error(message string) {
u
.
Ui
.
Error
(
u
.
prefixLines
(
u
.
SayPrefix
,
message
))
}
func
(
u
*
PrefixedUi
)
Machine
(
t
string
,
args
...
string
)
{
// Just pass it through for now.
u
.
Ui
.
Machine
(
t
,
args
...
)
}
func
(
u
*
PrefixedUi
)
prefixLines
(
prefix
,
message
string
)
string
{
var
result
bytes
.
Buffer
...
...
@@ -209,3 +220,7 @@ func (rw *ReaderWriterUi) Error(message string) {
panic
(
err
)
}
}
func
(
rw
*
ReaderWriterUi
)
Machine
(
t
string
,
args
...
string
)
{
// TODO
}
provisioner/file/provisioner_test.go
View file @
fb6d2754
...
...
@@ -106,6 +106,9 @@ func (su *stubUi) Ask(string) (string, error) {
func
(
su
*
stubUi
)
Error
(
string
)
{
}
func
(
su
*
stubUi
)
Machine
(
string
,
...
string
)
{
}
func
(
su
*
stubUi
)
Message
(
string
)
{
}
...
...
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