Skip to content

Commit

Permalink
Support 1.7-open through 1.8.3 (EarlyAccess)
Browse files Browse the repository at this point in the history
- Restructure the dcos-vagrant.yaml file to include channel
  • Loading branch information
Karl Isenberg committed Dec 13, 2016
1 parent 2b323c4 commit 4d017af
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 24 deletions.
29 changes: 15 additions & 14 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class UserConfig
attr_accessor :box_version
attr_accessor :machine_config_path
attr_accessor :config_path
attr_accessor :dcos_version
attr_accessor :version
attr_accessor :generate_config_path
attr_accessor :install_method
attr_accessor :vagrant_mount_method
Expand All @@ -32,7 +32,7 @@ class UserConfig
c.box_version = ENV.fetch(env_var('box_version'), '~> 0.8.0')
c.machine_config_path = ENV.fetch(env_var('machine_config_path'), 'VagrantConfig.yaml')
c.config_path = ENV.fetch(env_var('config_path'), '')
c.dcos_version = ENV.fetch(env_var('dcos_version'), '')
c.version = ENV.fetch(env_var('version'), '')
c.generate_config_path = ENV.fetch(env_var('generate_config_path'), '')
c.install_method = ENV.fetch(env_var('install_method'), 'ssh_pull')
c.vagrant_mount_method = ENV.fetch(env_var('vagrant_mount_method'), 'virtualbox')
Expand Down Expand Up @@ -177,23 +177,24 @@ def provision_script_path(type)
"./provision/bin/#{type}.sh"
end

DCOS_VERSIONS_FILE = 'dcos-versions.yaml'

def load_dcos_versions
dcos_versions_path = 'dcos-versions.yaml'
dcos_versions = YAML.load_file(Pathname.new(dcos_versions_path).realpath)
dcos_versions = YAML.load_file(Pathname.new(DCOS_VERSIONS_FILE).realpath)

#TODO: validate versions content?
#TODO: validate content?
dcos_versions
end

# download installer, if not already downloaded
def download_installer(dcos_versions, version)
dcos_sha = dcos_versions['shas'][version]
version_meta = dcos_versions['versions'][version]

if dcos_sha.nil? || dcos_sha.empty?
raise ValidationError, ["Version not found: '#{version}'. See '#{dcos_versions_path}' for known versions. Either version (#{UserConfig.env_var('dcos_version')}) or installer (#{UserConfig.env_var('generate_config_path')}) must be specified via environment variables."]
if version_meta.nil?
raise ValidationError, ["Version not found: '#{version}'. See '#{DCOS_VERSIONS_FILE}' for known versions. Either version (#{UserConfig.env_var('version')}) or installer (#{UserConfig.env_var('generate_config_path')}) must be specified via environment variables."]
end

url = "https://downloads.dcos.io/dcos/stable/commit/#{dcos_sha}/dcos_generate_config.sh"
url = "https://downloads.dcos.io/dcos/#{version_meta['channel']}/commit/#{version_meta['ref']}/dcos_generate_config.sh"
path = "installers/dcos/dcos_generate_config-#{version}.sh"

FileUtils.mkdir_p Pathname.new(path).dirname
Expand All @@ -213,7 +214,7 @@ def config_path(version)
file_path = "etc/config-#{version}.yaml"
return file_path if File.file?(file_path)

if result = version.match(/^([^.]*\.[^.]*)\./)
if result = version.match(/^([0-9]+\.[0-9]+)/)
file_path = "etc/config-#{result[1]}.yaml"
return file_path if File.file?(file_path)
end
Expand Down Expand Up @@ -261,14 +262,14 @@ begin
if user_config.generate_config_path.empty?
dcos_versions = load_dcos_versions
# use latest known, if not specified
user_config.dcos_version = user_config.dcos_version.empty? ? dcos_versions['latest'] : user_config.dcos_version
user_config.generate_config_path = download_installer(dcos_versions, user_config.dcos_version)
user_config.version = user_config.version.empty? ? dcos_versions['latest'] : user_config.version
user_config.generate_config_path = download_installer(dcos_versions, user_config.version)
end
UI.success "Using DC/OS Installer: #{user_config.generate_config_path}", bold: true

# update config based on version, unless specified
if user_config.config_path.empty? && !user_config.dcos_version.empty?
user_config.config_path = config_path(user_config.dcos_version)
if user_config.config_path.empty? && !user_config.version.empty?
user_config.config_path = config_path(user_config.version)
end
UI.success "Using DC/OS Config: #{user_config.config_path}", bold: true

Expand Down
38 changes: 28 additions & 10 deletions dcos-versions.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,29 @@
latest: '1.8.7'
shas:
'1.8.7': '1b43ff7a0b9124db9439299b789f2e2dc3cc086c'
'1.8.6': 'cfccfbf84bbba30e695ae4887b65db44ff216b1d'
'1.8.5': 'e665123df0dbb19adacaefe47d16a3de144d5733'
'1.8.4': 'e64024af95b62c632c90b9063ed06296fcf38ea5'
'1.8.3': '636f8b72288e82ad3b0065928e0b492af4c7cf66'
'1.8.2': '4cfc235259a2375c558f2e1bab3564419110459e'
'1.8.1': 'c1915a9f9f02caf7e34022eaea04f15ff853bd0e'
'1.8.0': '586c0496863000322c016c631e463248d863690d'
'1.7-open': '14509fe1e7899f439527fb39867194c7a425c771'
versions:
'1.8.7':
channel: stable
ref: '1b43ff7a0b9124db9439299b789f2e2dc3cc086c'
'1.8.6':
channel: stable
ref: 'cfccfbf84bbba30e695ae4887b65db44ff216b1d'
'1.8.5':
channel: stable
ref: 'e665123df0dbb19adacaefe47d16a3de144d5733'
'1.8.4':
channel: stable
ref: 'e64024af95b62c632c90b9063ed06296fcf38ea5'
'1.8.3':
channel: EarlyAccess
ref: '636f8b72288e82ad3b0065928e0b492af4c7cf66'
'1.8.2':
channel: EarlyAccess
ref: '4cfc235259a2375c558f2e1bab3564419110459e'
'1.8.1':
channel: EarlyAccess
ref: 'c1915a9f9f02caf7e34022eaea04f15ff853bd0e'
'1.8.0':
channel: EarlyAccess
ref: '586c0496863000322c016c631e463248d863690d'
'1.7-open':
channel: EarlyAccess
ref: '14509fe1e7899f439527fb39867194c7a425c771'

0 comments on commit 4d017af

Please sign in to comment.