From 277632ad99f1bae60cab3d8b4f204d5ef6f782cc Mon Sep 17 00:00:00 2001 From: Johannes Graf Date: Wed, 24 Dec 2014 02:19:42 +0100 Subject: [PATCH] Removed version.number / vagrant-cloud post-processor A few weeks ago ... the version.number changed from an integer to a semver based string. I guess version.number and version.version are equals now. So version.version can be used. This commit should fix #1735 --- .../vagrant-cloud/step_create_provider.go | 4 ++-- .../vagrant-cloud/step_create_version.go | 18 +++--------------- .../vagrant-cloud/step_prepare_upload.go | 2 +- .../vagrant-cloud/step_release_version.go | 2 +- .../vagrant-cloud/step_verify_upload.go | 2 +- 5 files changed, 8 insertions(+), 20 deletions(-) diff --git a/post-processor/vagrant-cloud/step_create_provider.go b/post-processor/vagrant-cloud/step_create_provider.go index c2d6772bd..6e19f3f3e 100644 --- a/post-processor/vagrant-cloud/step_create_provider.go +++ b/post-processor/vagrant-cloud/step_create_provider.go @@ -25,7 +25,7 @@ func (s *stepCreateProvider) Run(state multistep.StateBag) multistep.StepAction 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.Version) provider := &Provider{Name: providerName} @@ -86,7 +86,7 @@ func (s *stepCreateProvider) Cleanup(state multistep.StateBag) { ui.Say("Cleaning up provider") ui.Message(fmt.Sprintf("Deleting provider: %s", s.name)) - 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.Version, s.name) // No need for resp from the cleanup DELETE _, err := client.Delete(path) diff --git a/post-processor/vagrant-cloud/step_create_version.go b/post-processor/vagrant-cloud/step_create_version.go index 8108577cc..738614152 100644 --- a/post-processor/vagrant-cloud/step_create_version.go +++ b/post-processor/vagrant-cloud/step_create_version.go @@ -9,11 +9,9 @@ import ( type Version struct { Version string `json:"version"` Description string `json:"description,omitempty"` - Number uint `json:"number,omitempty"` } type stepCreateVersion struct { - number uint // number of the version, if needed in cleanup } func (s *stepCreateVersion) Run(state multistep.StateBag) multistep.StepAction { @@ -52,9 +50,6 @@ func (s *stepCreateVersion) Run(state multistep.StateBag) multistep.StepAction { return multistep.ActionHalt } - // Save the number for cleanup - s.number = version.Number - state.Put("version", version) return multistep.ActionContinue @@ -63,15 +58,8 @@ func (s *stepCreateVersion) Run(state multistep.StateBag) multistep.StepAction { 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 - // already existed - if s.number == 0 { - ui.Message("Version was not created or previously existed, not deleting") - return - } + version := state.Get("version").(*Version) _, cancelled := state.GetOk(multistep.StateCancelled) _, halted := state.GetOk(multistep.StateHalted) @@ -82,10 +70,10 @@ func (s *stepCreateVersion) Cleanup(state multistep.StateBag) { return } - path := fmt.Sprintf("box/%s/version/%v", box.Tag, s.number) + path := fmt.Sprintf("box/%s/version/%v", box.Tag, version.Version) ui.Say("Cleaning up version") - ui.Message(fmt.Sprintf("Deleting version: %s", config.Version)) + ui.Message(fmt.Sprintf("Deleting version: %s", version.Version)) // No need for resp from the cleanup DELETE _, err := client.Delete(path) diff --git a/post-processor/vagrant-cloud/step_prepare_upload.go b/post-processor/vagrant-cloud/step_prepare_upload.go index 5c82d02c3..d28a9fd2b 100644 --- a/post-processor/vagrant-cloud/step_prepare_upload.go +++ b/post-processor/vagrant-cloud/step_prepare_upload.go @@ -22,7 +22,7 @@ func (s *stepPrepareUpload) Run(state multistep.StateBag) multistep.StepAction { provider := state.Get("provider").(*Provider) artifactFilePath := state.Get("artifactFilePath").(string) - path := fmt.Sprintf("box/%s/version/%v/provider/%s/upload", box.Tag, version.Number, provider.Name) + path := fmt.Sprintf("box/%s/version/%v/provider/%s/upload", box.Tag, version.Version, provider.Name) upload := &Upload{} ui.Say(fmt.Sprintf("Preparing upload of box: %s", artifactFilePath)) diff --git a/post-processor/vagrant-cloud/step_release_version.go b/post-processor/vagrant-cloud/step_release_version.go index dab417d00..6301d5f19 100644 --- a/post-processor/vagrant-cloud/step_release_version.go +++ b/post-processor/vagrant-cloud/step_release_version.go @@ -24,7 +24,7 @@ func (s *stepReleaseVersion) Run(state multistep.StateBag) multistep.StepAction 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.Version) resp, err := client.Put(path) diff --git a/post-processor/vagrant-cloud/step_verify_upload.go b/post-processor/vagrant-cloud/step_verify_upload.go index 120bd647d..fbed25c6c 100644 --- a/post-processor/vagrant-cloud/step_verify_upload.go +++ b/post-processor/vagrant-cloud/step_verify_upload.go @@ -19,7 +19,7 @@ func (s *stepVerifyUpload) Run(state multistep.StateBag) multistep.StepAction { upload := state.Get("upload").(*Upload) provider := state.Get("provider").(*Provider) - path := fmt.Sprintf("box/%s/version/%v/provider/%s", box.Tag, version.Number, provider.Name) + path := fmt.Sprintf("box/%s/version/%v/provider/%s", box.Tag, version.Version, provider.Name) providerCheck := &Provider{}