sciurus / vagrant-mutate

Convert vagrant boxes to work with different providers
MIT License
281 stars 41 forks source link

*WIP* Add's support for VagrantCloud and box versions #67

Closed fatmcgav closed 9 years ago

fatmcgav commented 9 years ago

Add's support for VagrantCloud images using the [username]/[boxname] format. Also add's support for box versions.

WIP Further testing required prior to merge upstream. Current tests pass though :) Fixes #51 and #52

fatmcgav commented 9 years ago

Currently, it supports mutating locally available Cloud images. Haven't yet implemented downloading from VagrantCloud prior to mutate. Is this desired?

sciurus commented 9 years ago

Hi Gavin,

Thanks for contributing this!

I'm wondering why you chose to implement get_version the way you did. What do we gain by downloading the metadata file instead of looking on disk?

For example, given vagrant mutate hashicorp/precise64 libvirt and this directory structure

$ find .vagrant.d/boxes/hashicorp-VAGRANTSLASH-precise64/
.vagrant.d/boxes/hashicorp-VAGRANTSLASH-precise64/
.vagrant.d/boxes/hashicorp-VAGRANTSLASH-precise64/1.0.0
.vagrant.d/boxes/hashicorp-VAGRANTSLASH-precise64/1.0.0/virtualbox
.vagrant.d/boxes/hashicorp-VAGRANTSLASH-precise64/1.0.0/virtualbox/box.ovf
.vagrant.d/boxes/hashicorp-VAGRANTSLASH-precise64/1.0.0/virtualbox/box-disk1.vmdk
.vagrant.d/boxes/hashicorp-VAGRANTSLASH-precise64/1.0.0/virtualbox/metadata.json
.vagrant.d/boxes/hashicorp-VAGRANTSLASH-precise64/1.0.0/virtualbox/Vagrantfile
.vagrant.d/boxes/hashicorp-VAGRANTSLASH-precise64/metadata_url

I can tell that the version should be 1.0.0.

If there are multiple versions on disk and the user didn't specify the version to use, we could default to the latest.

I think your current implementation would fail because it would download the metadata, see that the latest version is 1.1.0, and try to convert that version even though the user only has 1.0.0 not 1.1.0.

sciurus commented 9 years ago

Let's not worry about downloading from vagrant cloud now. I'm considering removing the existing download functionality to simplify the code.

fatmcgav commented 9 years ago

@sciurus using the file structure looks workable.

By downloading the meta data, it does open the option of downloading the base box before mutating, but if that functionality is going to be removed, then that's fine too...

I'll see if I can rework the code to parse the directory structure...

Cheers Gav

fatmcgav commented 9 years ago

@sciurus Just pushed a commit that uses the filesystem directories rather than downloading the metadata.
Should solve the version mis-match issue.

sciurus commented 9 years ago

I wanted to let you know I haven't forgotten about this! I'll try to retest this weekend.

varac commented 9 years ago

great, looking forward to this !

sciurus commented 9 years ago

Thanks for the revision! Looks good to me and works in my (limited) testing.

fatmcgav commented 9 years ago

@sciurus Cheers for getting this merged in... Any chance of a release? ;)

sciurus commented 9 years ago

I've opened #69 about a release; hopefully soon.

sciurus commented 9 years ago

I've released this.