Commit 46535e3a authored by Jack Pearkes's avatar Jack Pearkes

post-processor/vagrant-cloud: better logging, document vcloud url

parent 450ba0bd
...@@ -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)
......
...@@ -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)
......
...@@ -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)
......
...@@ -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
} }
......
...@@ -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
} }
......
...@@ -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)
......
...@@ -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))
......
...@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment