Skip to content

Commit 568d1dc

Browse files
committed
feat(contrib): vagrantfile sources utils.sh
`COREOS_CHANNEL` and `COREOS_VERSION` are the variables of particular interest. `$image_version` was reintroduced along with other minor changes to minimize differences with the upstream version. fixes #4556
1 parent c3381a0 commit 568d1dc

1 file changed

Lines changed: 20 additions & 5 deletions

File tree

Vagrantfile

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,23 @@ end
1111

1212
CLOUD_CONFIG_PATH = File.join(File.dirname(__FILE__), "contrib", "coreos", "user-data")
1313
CONFIG = File.join(File.dirname(__FILE__), "config.rb")
14+
CONTRIB_UTILS_PATH = File.join(File.dirname(__FILE__), "contrib", "utils.sh")
15+
16+
# Make variables from contrib/utils.sh accessible
17+
if File.exists?(CONTRIB_UTILS_PATH)
18+
cu_vars = Hash.new do |hash, key|
19+
value = `. #{CONTRIB_UTILS_PATH} 2> /dev/null && echo $#{key}`.chomp
20+
hash[key] = value unless value.empty?
21+
end
22+
else
23+
raise Vagrant::Errors::VagrantError.new, "The file '#{CONTRIB_UTILS_PATH}' is missing."
24+
end
1425

1526
# Defaults for config options defined in CONFIG
1627
$num_instances = 1
1728
$instance_name_prefix = "deis"
18-
$update_channel = ENV["COREOS_CHANNEL"] || "stable"
29+
$update_channel = cu_vars["COREOS_CHANNEL"]
30+
$image_version = cu_vars["COREOS_VERSION"]
1931
$enable_serial_logging = false
2032
$share_home = false
2133
$vm_gui = false
@@ -52,15 +64,18 @@ def vm_cpus
5264
end
5365

5466
Vagrant.configure("2") do |config|
55-
# always use Vagrant's insecure key
67+
# always use Vagrants insecure key
5668
config.ssh.insert_key = false
69+
5770
config.vm.box = "coreos-%s" % $update_channel
58-
config.vm.box_version = ">= 766.4.0"
59-
config.vm.box_url = "http://%s.release.core-os.net/amd64-usr/current/coreos_production_vagrant.json" % $update_channel
71+
if $image_version != "current"
72+
config.vm.box_version = $image_version
73+
end
74+
config.vm.box_url = "http://%s.release.core-os.net/amd64-usr/%s/coreos_production_vagrant.json" % [$update_channel, $image_version]
6075

6176
["vmware_fusion", "vmware_workstation"].each do |vmware|
6277
config.vm.provider vmware do |v, override|
63-
override.vm.box_url = "http://%s.release.core-os.net/amd64-usr/current/coreos_production_vagrant_vmware_fusion.json" % $update_channel
78+
override.vm.box_url = "http://%s.release.core-os.net/amd64-usr/%s/coreos_production_vagrant_vmware_fusion.json" % [$update_channel, $image_version]
6479
end
6580
end
6681

0 commit comments

Comments
 (0)