Move binary URL logic to download_url helper

This commit is contained in:
Eammon Hanlon 2020-07-24 16:13:16 -07:00
Родитель 0d6ba6b8ba
Коммит bbd1e928b9
3 изменённых файлов: 26 добавлений и 30 удалений

Просмотреть файл

@ -1,13 +1,3 @@
default['azure_pipelines_agent']['binary']['version'] = '2.170.1'
case node['platform_family']
when 'windows'
default['azure_pipelines_agent']['binary']['url'] = 'https://vstsagentpackage.azureedge.net/agent/%s/vsts-agent-win-x64-%s.zip'
when 'debian', 'rhel'
default['azure_pipelines_agent']['binary']['url'] = 'https://vstsagentpackage.azureedge.net/agent/%s/vsts-agent-linux-x64-%s.tar.gz'
when 'mac_os_x'
default['azure_pipelines_agent']['binary']['url'] = 'https://vstsagentpackage.azureedge.net/agent/%s/vsts-agent-osx-x64-%s.tar.gz'
end
default['azure_pipelines_agent']['prerequisites']['debian']['install'] = true
default['azure_pipelines_agent']['prerequisites']['redhat']['install'] = true

Просмотреть файл

@ -13,7 +13,14 @@ module VSTS
end
def download_url(version)
url = Chef.run_context.node['vsts_agent']['binary']['url']
url = case node['platform_family']
when 'windows'
'https://vstsagentpackage.azureedge.net/agent/%s/vsts-agent-win-x64-%s.zip'
when 'debian', 'rhel'
'https://vstsagentpackage.azureedge.net/agent/%s/vsts-agent-linux-x64-%s.tar.gz'
when 'mac_os_x'
'https://vstsagentpackage.azureedge.net/agent/%s/vsts-agent-osx-x64-%s.tar.gz'
end
url.gsub '%s', version
end

Просмотреть файл

@ -1,19 +1,18 @@
require 'spec_helper'
describe 'installing azure pipelines agent with the default action on ubuntu' do
step_into :azure_pipelines_agent
platform 'ubuntu'
default_attributes['azure_pipelines_agent']['binary']['version'] = '2.170.1'
default_attributes['azure_pipelines_agent']['binary']['url'] = 'https://vstsagentpackage.azureedge.net/agent/%s/vsts-agent-linux-x64-%s.tar.gz'
context 'with the default action' do
recipe do
azure_pipelines_agent 'node1' do
install_dir '/home/plumber/.azure/pipelines/agent'
end
end
it { is_expected.to create_directory('/home/plumber/.azure/pipelines/agent') }
end
end
require 'spec_helper'
describe 'installing azure pipelines agent with the default action on ubuntu' do
platform 'ubuntu'
step_into :azure_pipelines_agent
default_attributes['azure_pipelines_agent']['binary']['version'] = '2.170.1'
context 'with the default action' do
recipe do
azure_pipelines_agent 'node1' do
install_dir '/home/plumber/.azure/pipelines/agent'
end
end
it { is_expected.to create_directory('/home/plumber/.azure/pipelines/agent') }
end
end