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
b2609db3
Commit
b2609db3
authored
Jun 17, 2015
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
provisioner/windows-restart: fix potential panic case
parent
7711e07f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
6 deletions
+16
-6
provisioner/windows-restart/provisioner.go
provisioner/windows-restart/provisioner.go
+16
-6
No files found.
provisioner/windows-restart/provisioner.go
View file @
b2609db3
...
@@ -3,6 +3,7 @@ package restart
...
@@ -3,6 +3,7 @@ package restart
import
(
import
(
"fmt"
"fmt"
"log"
"log"
"sync"
"time"
"time"
"github.com/masterzen/winrm/winrm"
"github.com/masterzen/winrm/winrm"
...
@@ -33,10 +34,11 @@ type Config struct {
...
@@ -33,10 +34,11 @@ type Config struct {
}
}
type
Provisioner
struct
{
type
Provisioner
struct
{
config
Config
config
Config
comm
packer
.
Communicator
comm
packer
.
Communicator
ui
packer
.
Ui
ui
packer
.
Ui
cancel
chan
struct
{}
cancel
chan
struct
{}
cancelLock
sync
.
Mutex
}
}
func
(
p
*
Provisioner
)
Prepare
(
raws
...
interface
{})
error
{
func
(
p
*
Provisioner
)
Prepare
(
raws
...
interface
{})
error
{
...
@@ -68,10 +70,13 @@ func (p *Provisioner) Prepare(raws ...interface{}) error {
...
@@ -68,10 +70,13 @@ func (p *Provisioner) Prepare(raws ...interface{}) error {
}
}
func
(
p
*
Provisioner
)
Provision
(
ui
packer
.
Ui
,
comm
packer
.
Communicator
)
error
{
func
(
p
*
Provisioner
)
Provision
(
ui
packer
.
Ui
,
comm
packer
.
Communicator
)
error
{
p
.
cancelLock
.
Lock
()
p
.
cancel
=
make
(
chan
struct
{})
p
.
cancelLock
.
Unlock
()
ui
.
Say
(
"Restarting Machine"
)
ui
.
Say
(
"Restarting Machine"
)
p
.
comm
=
comm
p
.
comm
=
comm
p
.
ui
=
ui
p
.
ui
=
ui
p
.
cancel
=
make
(
chan
struct
{})
var
cmd
*
packer
.
RemoteCmd
var
cmd
*
packer
.
RemoteCmd
command
:=
p
.
config
.
RestartCommand
command
:=
p
.
config
.
RestartCommand
...
@@ -164,7 +169,12 @@ var waitForCommunicator = func(p *Provisioner) error {
...
@@ -164,7 +169,12 @@ var waitForCommunicator = func(p *Provisioner) error {
func
(
p
*
Provisioner
)
Cancel
()
{
func
(
p
*
Provisioner
)
Cancel
()
{
log
.
Printf
(
"Received interrupt Cancel()"
)
log
.
Printf
(
"Received interrupt Cancel()"
)
close
(
p
.
cancel
)
p
.
cancelLock
.
Lock
()
defer
p
.
cancelLock
.
Unlock
()
if
p
.
cancel
!=
nil
{
close
(
p
.
cancel
)
}
}
}
// retryable will retry the given function over and over until a
// retryable will retry the given function over and over until a
...
...
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