diff --git a/data/default.yaml b/data/default.yaml index 5e9d47959..f75cf051b 100644 --- a/data/default.yaml +++ b/data/default.yaml @@ -1,6 +1,10 @@ --- - lookup_options: php::fpm::pools: merge: first - +php::composer::channel_sources: + stable: 'https://getcomposer.org/download/latest-stable/composer.phar' + preview: 'https://getcomposer.org/download/latest-preview/composer.phar' + snapshot: 'https://getcomposer.org/composer.phar' + 1: 'https://getcomposer.org/download/latest-1.x/composer.phar' + 2: 'https://getcomposer.org/download/latest-2.x/composer.phar' diff --git a/manifests/composer.pp b/manifests/composer.pp index 4177ee220..286b1f225 100644 --- a/manifests/composer.pp +++ b/manifests/composer.pp @@ -2,8 +2,8 @@ # # === Parameters # -# [*source*] -# Holds URL to the Composer source file +# [*channel_sources*] +# Define channel URLs to the Composer source file # # [*path*] # Holds path to the Composer executable @@ -27,7 +27,7 @@ # UNIX group of the root user # class php::composer ( - String $source = $php::params::composer_source, + Hash $channel_sources = {}, Stdlib::Absolutepath $path = $php::params::composer_path, Optional[String[1]] $proxy_type = undef, Optional[String[1]] $proxy_server = undef, @@ -40,7 +40,7 @@ archive { 'download composer': path => $path, - source => $source, + source => $channel_sources.dig($channel), proxy_type => $proxy_type, proxy_server => $proxy_server, } @@ -53,7 +53,6 @@ if $auto_update { class { 'php::composer::auto_update': max_age => $max_age, - source => $source, path => $path, channel => $channel, proxy_type => $proxy_type, diff --git a/manifests/composer/auto_update.pp b/manifests/composer/auto_update.pp index fe7a4f692..51d440165 100644 --- a/manifests/composer/auto_update.pp +++ b/manifests/composer/auto_update.pp @@ -5,9 +5,6 @@ # [*max_age*] # Defines number of days after which Composer should be updated # -# [*source*] -# Holds URL to the Composer source file -# # [*path*] # Holds path to the Composer executable # @@ -30,7 +27,6 @@ # class php::composer::auto_update ( Integer[1] $max_age, - String[1] $source, Stdlib::Absolutepath $path, Php::ComposerChannel $channel = 'stable', Optional[String[1]] $proxy_type = undef, diff --git a/manifests/params.pp b/manifests/params.pp index bbcdff88d..06be249c6 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -4,7 +4,6 @@ $ensure = 'present' $fpm_service_enable = true $fpm_service_ensure = 'running' - $composer_source = 'https://getcomposer.org/composer.phar' $composer_path = '/usr/local/bin/composer' $composer_max_age = 30 $pear_ensure = 'present' diff --git a/spec/classes/php_composer_spec.rb b/spec/classes/php_composer_spec.rb new file mode 100644 index 000000000..651b8ca15 --- /dev/null +++ b/spec/classes/php_composer_spec.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe 'php::composer', type: :class do + on_supported_os.each do |os, facts| + context "on #{os}" do + let :facts do + facts + end + let(:pre_condition) { 'class {"php": composer => false}' } + + describe 'works without params' do + it { is_expected.to compile.with_all_deps } + end + + describe 'when called with no parameters' do + it { is_expected.to contain_file('/usr/local/bin/composer') } + end + end + end +end