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
6a1744a1
Commit
6a1744a1
authored
Oct 27, 2014
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1385 from Mayflower/vagrantcloud_selfhosted
Vagrantcloud selfhosted
parents
fc2e24fa
849458f2
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
50 additions
and
9 deletions
+50
-9
post-processor/vagrant-cloud/post-processor.go
post-processor/vagrant-cloud/post-processor.go
+36
-9
post-processor/vagrant-cloud/step_create_provider.go
post-processor/vagrant-cloud/step_create_provider.go
+6
-0
post-processor/vagrant-cloud/step_release_version.go
post-processor/vagrant-cloud/step_release_version.go
+5
-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/post-processor.go
View file @
6a1744a1
// vagrant_cloud implements the packer.PostProcessor interface and adds a
// vagrant_cloud implements the packer.PostProcessor interface and adds a
// post-processor that uploads artifacts from the vagrant post-processor
// post-processor that uploads artifacts from the vagrant post-processor
// to Vagrant Cloud (vagrantcloud.com)
// to Vagrant Cloud (vagrantcloud.com) or manages self hosted boxes on the
// Vagrant Cloud
package
vagrantcloud
package
vagrantcloud
import
(
import
(
...
@@ -25,9 +26,16 @@ type Config struct {
...
@@ -25,9 +26,16 @@ type Config struct {
AccessToken
string
`mapstructure:"access_token"`
AccessToken
string
`mapstructure:"access_token"`
VagrantCloudUrl
string
`mapstructure:"vagrant_cloud_url"`
VagrantCloudUrl
string
`mapstructure:"vagrant_cloud_url"`
BoxDownloadUrl
string
`mapstructure:"box_download_url"`
tpl
*
packer
.
ConfigTemplate
tpl
*
packer
.
ConfigTemplate
}
}
type
boxDownloadUrlTemplate
struct
{
ArtifactId
string
Provider
string
}
type
PostProcessor
struct
{
type
PostProcessor
struct
{
config
Config
config
Config
client
*
VagrantCloudClient
client
*
VagrantCloudClient
...
@@ -103,6 +111,14 @@ func (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (pac
...
@@ -103,6 +111,14 @@ func (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (pac
// The name of the provider for vagrant cloud, and vagrant
// The name of the provider for vagrant cloud, and vagrant
providerName
:=
providerFromBuilderName
(
artifact
.
Id
())
providerName
:=
providerFromBuilderName
(
artifact
.
Id
())
boxDownloadUrl
,
err
:=
p
.
config
.
tpl
.
Process
(
p
.
config
.
BoxDownloadUrl
,
&
boxDownloadUrlTemplate
{
ArtifactId
:
artifact
.
Id
(),
Provider
:
providerName
,
})
if
err
!=
nil
{
return
nil
,
false
,
fmt
.
Errorf
(
"Error processing box_download_url: %s"
,
err
)
}
// Set up the state
// Set up the state
state
:=
new
(
multistep
.
BasicStateBag
)
state
:=
new
(
multistep
.
BasicStateBag
)
state
.
Put
(
"config"
,
p
.
config
)
state
.
Put
(
"config"
,
p
.
config
)
...
@@ -111,9 +127,12 @@ func (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (pac
...
@@ -111,9 +127,12 @@ func (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (pac
state
.
Put
(
"artifactFilePath"
,
artifact
.
Files
()[
0
])
state
.
Put
(
"artifactFilePath"
,
artifact
.
Files
()[
0
])
state
.
Put
(
"ui"
,
ui
)
state
.
Put
(
"ui"
,
ui
)
state
.
Put
(
"providerName"
,
providerName
)
state
.
Put
(
"providerName"
,
providerName
)
state
.
Put
(
"boxDownloadUrl"
,
boxDownloadUrl
)
// Build the steps
// Build the steps
steps
:=
[]
multistep
.
Step
{
steps
:=
[]
multistep
.
Step
{}
if
p
.
config
.
BoxDownloadUrl
==
""
{
steps
=
[]
multistep
.
Step
{
new
(
stepVerifyBox
),
new
(
stepVerifyBox
),
new
(
stepCreateVersion
),
new
(
stepCreateVersion
),
new
(
stepCreateProvider
),
new
(
stepCreateProvider
),
...
@@ -122,6 +141,14 @@ func (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (pac
...
@@ -122,6 +141,14 @@ func (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (pac
new
(
stepVerifyUpload
),
new
(
stepVerifyUpload
),
new
(
stepReleaseVersion
),
new
(
stepReleaseVersion
),
}
}
}
else
{
steps
=
[]
multistep
.
Step
{
new
(
stepVerifyBox
),
new
(
stepCreateVersion
),
new
(
stepCreateProvider
),
new
(
stepReleaseVersion
),
}
}
// Run the steps
// Run the steps
if
p
.
config
.
PackerDebug
{
if
p
.
config
.
PackerDebug
{
...
...
post-processor/vagrant-cloud/step_create_provider.go
View file @
6a1744a1
...
@@ -8,6 +8,7 @@ import (
...
@@ -8,6 +8,7 @@ import (
type
Provider
struct
{
type
Provider
struct
{
Name
string
`json:"name"`
Name
string
`json:"name"`
Url
string
`json:"url,omitempty"`
HostedToken
string
`json:"hosted_token,omitempty"`
HostedToken
string
`json:"hosted_token,omitempty"`
UploadUrl
string
`json:"upload_url,omitempty"`
UploadUrl
string
`json:"upload_url,omitempty"`
}
}
...
@@ -22,11 +23,16 @@ func (s *stepCreateProvider) Run(state multistep.StateBag) multistep.StepAction
...
@@ -22,11 +23,16 @@ func (s *stepCreateProvider) Run(state multistep.StateBag) multistep.StepAction
box
:=
state
.
Get
(
"box"
)
.
(
*
Box
)
box
:=
state
.
Get
(
"box"
)
.
(
*
Box
)
version
:=
state
.
Get
(
"version"
)
.
(
*
Version
)
version
:=
state
.
Get
(
"version"
)
.
(
*
Version
)
providerName
:=
state
.
Get
(
"providerName"
)
.
(
string
)
providerName
:=
state
.
Get
(
"providerName"
)
.
(
string
)
downloadUrl
:=
state
.
Get
(
"boxDownloadUrl"
)
.
(
string
)
path
:=
fmt
.
Sprintf
(
"box/%s/version/%v/providers"
,
box
.
Tag
,
version
.
Number
)
path
:=
fmt
.
Sprintf
(
"box/%s/version/%v/providers"
,
box
.
Tag
,
version
.
Number
)
provider
:=
&
Provider
{
Name
:
providerName
}
provider
:=
&
Provider
{
Name
:
providerName
}
if
downloadUrl
!=
""
{
provider
.
Url
=
downloadUrl
}
// Wrap the provider in a provider object for the API
// Wrap the provider in a provider object for the API
wrapper
:=
make
(
map
[
string
]
interface
{})
wrapper
:=
make
(
map
[
string
]
interface
{})
wrapper
[
"provider"
]
=
provider
wrapper
[
"provider"
]
=
provider
...
...
post-processor/vagrant-cloud/step_release_version.go
View file @
6a1744a1
...
@@ -2,6 +2,7 @@ package vagrantcloud
...
@@ -2,6 +2,7 @@ package vagrantcloud
import
(
import
(
"fmt"
"fmt"
"strings"
"github.com/mitchellh/multistep"
"github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer"
"github.com/mitchellh/packer/packer"
)
)
...
@@ -30,6 +31,10 @@ func (s *stepReleaseVersion) Run(state multistep.StateBag) multistep.StepAction
...
@@ -30,6 +31,10 @@ func (s *stepReleaseVersion) Run(state multistep.StateBag) multistep.StepAction
if
err
!=
nil
||
(
resp
.
StatusCode
!=
200
)
{
if
err
!=
nil
||
(
resp
.
StatusCode
!=
200
)
{
cloudErrors
:=
&
VagrantCloudErrors
{}
cloudErrors
:=
&
VagrantCloudErrors
{}
err
=
decodeBody
(
resp
,
cloudErrors
)
err
=
decodeBody
(
resp
,
cloudErrors
)
if
strings
.
Contains
(
cloudErrors
.
FormatErrors
(),
"already been released"
)
{
ui
.
Message
(
"Not releasing version, already released"
)
return
multistep
.
ActionContinue
}
state
.
Put
(
"error"
,
fmt
.
Errorf
(
"Error releasing version: %s"
,
cloudErrors
.
FormatErrors
()))
state
.
Put
(
"error"
,
fmt
.
Errorf
(
"Error releasing version: %s"
,
cloudErrors
.
FormatErrors
()))
return
multistep
.
ActionHalt
return
multistep
.
ActionHalt
}
}
...
...
website/source/docs/post-processors/vagrant-cloud.html.markdown
View file @
6a1744a1
...
@@ -72,6 +72,9 @@ to `https://vagrantcloud.com/api/v1`
...
@@ -72,6 +72,9 @@ to `https://vagrantcloud.com/api/v1`
*
`version_description`
(string) - Optionally markdown text used as a full-length
*
`version_description`
(string) - Optionally markdown text used as a full-length
and in-depth description of the version, typically for denoting changes introduced
and in-depth description of the version, typically for denoting changes introduced
*
`box_download_url`
(string) - Optional URL for a self-hosted box. If this is set
the box will not be uploaded to the Vagrant Cloud.
## Use with Vagrant Post-Processor
## Use with Vagrant Post-Processor
You'll need to use the Vagrant post-processor before using this post-processor.
You'll need to use the Vagrant post-processor before using this 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