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
46535e3a
Commit
46535e3a
authored
Jun 25, 2014
by
Jack Pearkes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
post-processor/vagrant-cloud: better logging, document vcloud url
parent
450ba0bd
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
43 additions
and
17 deletions
+43
-17
post-processor/vagrant-cloud/step_create_provider.go
post-processor/vagrant-cloud/step_create_provider.go
+9
-4
post-processor/vagrant-cloud/step_create_version.go
post-processor/vagrant-cloud/step_create_version.go
+15
-10
post-processor/vagrant-cloud/step_prepare_upload.go
post-processor/vagrant-cloud/step_prepare_upload.go
+2
-0
post-processor/vagrant-cloud/step_release_version.go
post-processor/vagrant-cloud/step_release_version.go
+5
-3
post-processor/vagrant-cloud/step_upload.go
post-processor/vagrant-cloud/step_upload.go
+4
-0
post-processor/vagrant-cloud/step_verify_box.go
post-processor/vagrant-cloud/step_verify_box.go
+2
-0
post-processor/vagrant-cloud/step_verify_upload.go
post-processor/vagrant-cloud/step_verify_upload.go
+3
-0
website/source/docs/post-processors/vagrant-cloud.html.markdown
...e/source/docs/post-processors/vagrant-cloud.html.markdown
+3
-0
No files found.
post-processor/vagrant-cloud/step_create_provider.go
View file @
46535e3a
...
@@ -56,8 +56,15 @@ func (s *stepCreateProvider) Run(state multistep.StateBag) multistep.StepAction
...
@@ -56,8 +56,15 @@ func (s *stepCreateProvider) Run(state multistep.StateBag) multistep.StepAction
}
}
func
(
s
*
stepCreateProvider
)
Cleanup
(
state
multistep
.
StateBag
)
{
func
(
s
*
stepCreateProvider
)
Cleanup
(
state
multistep
.
StateBag
)
{
client
:=
state
.
Get
(
"client"
)
.
(
*
VagrantCloudClient
)
ui
:=
state
.
Get
(
"ui"
)
.
(
packer
.
Ui
)
box
:=
state
.
Get
(
"box"
)
.
(
*
Box
)
version
:=
state
.
Get
(
"version"
)
.
(
*
Version
)
// If we didn't save the provider name, it likely doesn't exist
// If we didn't save the provider name, it likely doesn't exist
if
s
.
name
==
""
{
if
s
.
name
==
""
{
ui
.
Say
(
"Cleaning up provider"
)
ui
.
Message
(
"Provider was not created, not deleting"
)
return
return
}
}
...
@@ -70,10 +77,8 @@ func (s *stepCreateProvider) Cleanup(state multistep.StateBag) {
...
@@ -70,10 +77,8 @@ func (s *stepCreateProvider) Cleanup(state multistep.StateBag) {
return
return
}
}
client
:=
state
.
Get
(
"client"
)
.
(
*
VagrantCloudClient
)
ui
.
Say
(
"Cleaning up provider"
)
ui
:=
state
.
Get
(
"ui"
)
.
(
packer
.
Ui
)
ui
.
Message
(
fmt
.
Sprintf
(
"Deleting provider: %s"
,
s
.
name
))
box
:=
state
.
Get
(
"box"
)
.
(
*
Box
)
version
:=
state
.
Get
(
"version"
)
.
(
*
Version
)
path
:=
fmt
.
Sprintf
(
"box/%s/version/%v/provider/%s"
,
box
.
Tag
,
version
.
Number
,
s
.
name
)
path
:=
fmt
.
Sprintf
(
"box/%s/version/%v/provider/%s"
,
box
.
Tag
,
version
.
Number
,
s
.
name
)
...
...
post-processor/vagrant-cloud/step_create_version.go
View file @
46535e3a
...
@@ -7,9 +7,9 @@ import (
...
@@ -7,9 +7,9 @@ import (
)
)
type
Version
struct
{
type
Version
struct
{
Version
string
`json:"version"`
Version
string
`json:"version"`
Description
string
`json:"description,omitempty"`
Description
string
`json:"description,omitempty"`
Number
uint
`json:"number,omitempty"`
Number
uint
`json:"number,omitempty"`
}
}
type
stepCreateVersion
struct
{
type
stepCreateVersion
struct
{
...
@@ -22,8 +22,10 @@ func (s *stepCreateVersion) Run(state multistep.StateBag) multistep.StepAction {
...
@@ -22,8 +22,10 @@ func (s *stepCreateVersion) Run(state multistep.StateBag) multistep.StepAction {
config
:=
state
.
Get
(
"config"
)
.
(
Config
)
config
:=
state
.
Get
(
"config"
)
.
(
Config
)
box
:=
state
.
Get
(
"box"
)
.
(
*
Box
)
box
:=
state
.
Get
(
"box"
)
.
(
*
Box
)
ui
.
Say
(
fmt
.
Sprintf
(
"Creating version: %s"
,
config
.
Version
))
if
hasVersion
,
v
:=
box
.
HasVersion
(
config
.
Version
);
hasVersion
{
if
hasVersion
,
v
:=
box
.
HasVersion
(
config
.
Version
);
hasVersion
{
ui
.
Say
(
fmt
.
Sprintf
(
"Version exists: %s"
,
config
.
Version
))
ui
.
Message
(
fmt
.
Sprintf
(
"Version exists, skipping creation"
))
state
.
Put
(
"version"
,
v
)
state
.
Put
(
"version"
,
v
)
return
multistep
.
ActionContinue
return
multistep
.
ActionContinue
}
}
...
@@ -36,8 +38,6 @@ func (s *stepCreateVersion) Run(state multistep.StateBag) multistep.StepAction {
...
@@ -36,8 +38,6 @@ func (s *stepCreateVersion) Run(state multistep.StateBag) multistep.StepAction {
wrapper
:=
make
(
map
[
string
]
interface
{})
wrapper
:=
make
(
map
[
string
]
interface
{})
wrapper
[
"version"
]
=
version
wrapper
[
"version"
]
=
version
ui
.
Say
(
fmt
.
Sprintf
(
"Creating version: %s"
,
config
.
Version
))
resp
,
err
:=
client
.
Post
(
path
,
wrapper
)
resp
,
err
:=
client
.
Post
(
path
,
wrapper
)
if
err
!=
nil
||
(
resp
.
StatusCode
!=
200
)
{
if
err
!=
nil
||
(
resp
.
StatusCode
!=
200
)
{
...
@@ -61,9 +61,15 @@ func (s *stepCreateVersion) Run(state multistep.StateBag) multistep.StepAction {
...
@@ -61,9 +61,15 @@ func (s *stepCreateVersion) Run(state multistep.StateBag) multistep.StepAction {
}
}
func
(
s
*
stepCreateVersion
)
Cleanup
(
state
multistep
.
StateBag
)
{
func
(
s
*
stepCreateVersion
)
Cleanup
(
state
multistep
.
StateBag
)
{
client
:=
state
.
Get
(
"client"
)
.
(
*
VagrantCloudClient
)
ui
:=
state
.
Get
(
"ui"
)
.
(
packer
.
Ui
)
config
:=
state
.
Get
(
"config"
)
.
(
Config
)
box
:=
state
.
Get
(
"box"
)
.
(
*
Box
)
// If we didn't save the version number, it likely doesn't exist or
// If we didn't save the version number, it likely doesn't exist or
// already existed
// already existed
if
s
.
number
==
0
{
if
s
.
number
==
0
{
ui
.
Message
(
"Version was not created or previously existed, not deleting"
)
return
return
}
}
...
@@ -76,12 +82,11 @@ func (s *stepCreateVersion) Cleanup(state multistep.StateBag) {
...
@@ -76,12 +82,11 @@ func (s *stepCreateVersion) Cleanup(state multistep.StateBag) {
return
return
}
}
client
:=
state
.
Get
(
"client"
)
.
(
*
VagrantCloudClient
)
ui
:=
state
.
Get
(
"ui"
)
.
(
packer
.
Ui
)
box
:=
state
.
Get
(
"box"
)
.
(
*
Box
)
path
:=
fmt
.
Sprintf
(
"box/%s/version/%v"
,
box
.
Tag
,
s
.
number
)
path
:=
fmt
.
Sprintf
(
"box/%s/version/%v"
,
box
.
Tag
,
s
.
number
)
ui
.
Say
(
"Cleaning up version"
)
ui
.
Message
(
fmt
.
Sprintf
(
"Deleting version: %s"
,
config
.
Version
))
// No need for resp from the cleanup DELETE
// No need for resp from the cleanup DELETE
_
,
err
:=
client
.
Delete
(
path
)
_
,
err
:=
client
.
Delete
(
path
)
...
...
post-processor/vagrant-cloud/step_prepare_upload.go
View file @
46535e3a
...
@@ -41,6 +41,8 @@ func (s *stepPrepareUpload) Run(state multistep.StateBag) multistep.StepAction {
...
@@ -41,6 +41,8 @@ func (s *stepPrepareUpload) Run(state multistep.StateBag) multistep.StepAction {
return
multistep
.
ActionHalt
return
multistep
.
ActionHalt
}
}
ui
.
Message
(
fmt
.
Sprintf
(
"Box upload prepared with token %s"
,
upload
.
Token
))
// Save the upload details to the state
// Save the upload details to the state
state
.
Put
(
"upload"
,
upload
)
state
.
Put
(
"upload"
,
upload
)
...
...
post-processor/vagrant-cloud/step_release_version.go
View file @
46535e3a
...
@@ -16,15 +16,15 @@ func (s *stepReleaseVersion) Run(state multistep.StateBag) multistep.StepAction
...
@@ -16,15 +16,15 @@ func (s *stepReleaseVersion) Run(state multistep.StateBag) multistep.StepAction
version
:=
state
.
Get
(
"version"
)
.
(
*
Version
)
version
:=
state
.
Get
(
"version"
)
.
(
*
Version
)
config
:=
state
.
Get
(
"config"
)
.
(
Config
)
config
:=
state
.
Get
(
"config"
)
.
(
Config
)
ui
.
Say
(
fmt
.
Sprintf
(
"Releasing version: %s"
,
version
.
Version
))
if
config
.
NoRelease
{
if
config
.
NoRelease
{
ui
.
Say
(
fmt
.
Sprintf
(
"Not releasing version due to configuration: %s"
,
version
.
Version
)
)
ui
.
Message
(
"Not releasing version due to configuration"
)
return
multistep
.
ActionContinue
return
multistep
.
ActionContinue
}
}
path
:=
fmt
.
Sprintf
(
"box/%s/version/%v/release"
,
box
.
Tag
,
version
.
Number
)
path
:=
fmt
.
Sprintf
(
"box/%s/version/%v/release"
,
box
.
Tag
,
version
.
Number
)
ui
.
Say
(
fmt
.
Sprintf
(
"Releasing version: %s"
,
version
.
Version
))
resp
,
err
:=
client
.
Put
(
path
)
resp
,
err
:=
client
.
Put
(
path
)
if
err
!=
nil
||
(
resp
.
StatusCode
!=
200
)
{
if
err
!=
nil
||
(
resp
.
StatusCode
!=
200
)
{
...
@@ -34,6 +34,8 @@ func (s *stepReleaseVersion) Run(state multistep.StateBag) multistep.StepAction
...
@@ -34,6 +34,8 @@ func (s *stepReleaseVersion) Run(state multistep.StateBag) multistep.StepAction
return
multistep
.
ActionHalt
return
multistep
.
ActionHalt
}
}
ui
.
Message
(
fmt
.
Sprintf
(
"Version successfully released and available"
))
return
multistep
.
ActionContinue
return
multistep
.
ActionContinue
}
}
...
...
post-processor/vagrant-cloud/step_upload.go
View file @
46535e3a
...
@@ -18,6 +18,8 @@ func (s *stepUpload) Run(state multistep.StateBag) multistep.StepAction {
...
@@ -18,6 +18,8 @@ func (s *stepUpload) Run(state multistep.StateBag) multistep.StepAction {
ui
.
Say
(
fmt
.
Sprintf
(
"Uploading box: %s"
,
artifactFilePath
))
ui
.
Say
(
fmt
.
Sprintf
(
"Uploading box: %s"
,
artifactFilePath
))
ui
.
Message
(
"Depending on your internet connection and the size of the box, this may take some time"
)
resp
,
err
:=
client
.
Upload
(
artifactFilePath
,
url
)
resp
,
err
:=
client
.
Upload
(
artifactFilePath
,
url
)
if
err
!=
nil
||
(
resp
.
StatusCode
!=
200
)
{
if
err
!=
nil
||
(
resp
.
StatusCode
!=
200
)
{
...
@@ -25,6 +27,8 @@ func (s *stepUpload) Run(state multistep.StateBag) multistep.StepAction {
...
@@ -25,6 +27,8 @@ func (s *stepUpload) Run(state multistep.StateBag) multistep.StepAction {
return
multistep
.
ActionHalt
return
multistep
.
ActionHalt
}
}
ui
.
Message
(
"Box succesfully uploaded"
)
return
multistep
.
ActionContinue
return
multistep
.
ActionContinue
}
}
...
...
post-processor/vagrant-cloud/step_verify_box.go
View file @
46535e3a
...
@@ -52,6 +52,8 @@ func (s *stepVerifyBox) Run(state multistep.StateBag) multistep.StepAction {
...
@@ -52,6 +52,8 @@ func (s *stepVerifyBox) Run(state multistep.StateBag) multistep.StepAction {
return
multistep
.
ActionHalt
return
multistep
.
ActionHalt
}
}
ui
.
Message
(
"Box accessible and matches tag"
)
// Keep the box in state for later
// Keep the box in state for later
state
.
Put
(
"box"
,
box
)
state
.
Put
(
"box"
,
box
)
...
...
post-processor/vagrant-cloud/step_verify_upload.go
View file @
46535e3a
...
@@ -78,6 +78,7 @@ func (s *stepVerifyUpload) Run(state multistep.StateBag) multistep.StepAction {
...
@@ -78,6 +78,7 @@ func (s *stepVerifyUpload) Run(state multistep.StateBag) multistep.StepAction {
}
}
}()
}()
ui
.
Message
(
"Waiting for upload token match"
)
log
.
Printf
(
"Waiting for up to 600 seconds for provider hosted token to match %s"
,
upload
.
Token
)
log
.
Printf
(
"Waiting for up to 600 seconds for provider hosted token to match %s"
,
upload
.
Token
)
select
{
select
{
...
@@ -87,7 +88,9 @@ func (s *stepVerifyUpload) Run(state multistep.StateBag) multistep.StepAction {
...
@@ -87,7 +88,9 @@ func (s *stepVerifyUpload) Run(state multistep.StateBag) multistep.StepAction {
return
multistep
.
ActionHalt
return
multistep
.
ActionHalt
}
}
ui
.
Message
(
fmt
.
Sprintf
(
"Upload succesfully verified with token %s"
,
providerCheck
.
HostedToken
))
log
.
Printf
(
"Box succesfully verified %s == %s"
,
upload
.
Token
,
providerCheck
.
HostedToken
)
log
.
Printf
(
"Box succesfully verified %s == %s"
,
upload
.
Token
,
providerCheck
.
HostedToken
)
return
multistep
.
ActionContinue
return
multistep
.
ActionContinue
case
<-
time
.
After
(
600
*
time
.
Second
)
:
case
<-
time
.
After
(
600
*
time
.
Second
)
:
state
.
Put
(
"error"
,
fmt
.
Errorf
(
"Timeout while waiting to for upload to verify token '%s'"
,
upload
.
Token
))
state
.
Put
(
"error"
,
fmt
.
Errorf
(
"Timeout while waiting to for upload to verify token '%s'"
,
upload
.
Token
))
...
...
website/source/docs/post-processors/vagrant-cloud.html.markdown
View file @
46535e3a
...
@@ -66,6 +66,9 @@ access to on Vagrant Cloud, as well as authentication and version information.
...
@@ -66,6 +66,9 @@ access to on Vagrant Cloud, as well as authentication and version information.
on Vagrant Cloud, making it active. You can manually release the version
on Vagrant Cloud, making it active. You can manually release the version
via the API or Web UI. Defaults to false.
via the API or Web UI. Defaults to false.
*
`vagrant_cloud_url`
(string) - Override the base URL for Vagrant Cloud. This
is useful if you're using Vagrant Private Cloud in your own network. Defaults
to
`https://vagrantcloud.com/api/v1`
## Use with Vagrant Post-Processor
## Use with Vagrant Post-Processor
...
...
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