diff --git a/attributes/default.rb b/attributes/default.rb index 1bf5642..86c7d46 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -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 diff --git a/libraries/helpers.rb b/libraries/helpers.rb index 89547db..0268f60 100644 --- a/libraries/helpers.rb +++ b/libraries/helpers.rb @@ -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 diff --git a/spec/resources/azure_pipelines_agent_spec.rb b/spec/resources/azure_pipelines_agent_spec.rb index 2ceb8b5..065f6bf 100644 --- a/spec/resources/azure_pipelines_agent_spec.rb +++ b/spec/resources/azure_pipelines_agent_spec.rb @@ -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