Skip to content

Commit

Permalink
add ability to define composer update channel
Browse files Browse the repository at this point in the history
  • Loading branch information
CyberLine authored and bastelfreak committed Apr 19, 2020
1 parent 06f2162 commit 966bc20
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
3 changes: 3 additions & 0 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,9 @@ Install composer package manager
[*path*]
Holds path to the Composer executable

[*channel*]
Holds the Update channel (stable|preview|snapshot|1|2)

[*proxy_type*]
proxy server type (none|http|https|ftp)

Expand Down
5 changes: 5 additions & 0 deletions manifests/composer.pp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
# [*path*]
# Holds path to the Composer executable
#
# [*channel*]
# Holds the Update channel (stable|preview|snapshot|1|2)
#
# [*proxy_type*]
# proxy server type (none|http|https|ftp)
#
Expand All @@ -28,6 +31,7 @@
Stdlib::Absolutepath $path = $php::params::composer_path,
$proxy_type = undef,
$proxy_server = undef,
Php::ComposerChannel $channel = 'stable',
Boolean $auto_update = true,
Integer $max_age = $php::params::composer_max_age,
Variant[Integer, String] $root_group = $php::params::root_group,
Expand All @@ -52,6 +56,7 @@
max_age => $max_age,
source => $source,
path => $path,
channel => $channel,
proxy_type => $proxy_type,
proxy_server => $proxy_server,
}
Expand Down
10 changes: 7 additions & 3 deletions manifests/composer/auto_update.pp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
# [*path*]
# Holds path to the Composer executable
#
# [*channel*]
# Holds the Update channel (stable|preview|snapshot|1|2)
#
# [*proxy_type*]
# proxy server type (none|http|https|ftp)
#
Expand All @@ -29,8 +32,9 @@
$max_age,
$source,
$path,
$proxy_type = undef,
$proxy_server = undef,
Php::ComposerChannel $channel = 'stable',
$proxy_type = undef,
$proxy_server = undef,
) {

assert_private()
Expand All @@ -44,7 +48,7 @@

exec { 'update composer':
# touch binary when an update is attempted to update its mtime for idempotency when no update is available
command => "${path} --no-interaction --quiet self-update; touch ${path}",
command => "${path} --no-interaction --quiet self-update --${channel}; touch ${path}",
environment => $env,
onlyif => "test `find '${path}' -mtime +${max_age}`",
path => [ '/bin/', '/sbin/' , '/usr/bin/', '/usr/sbin/', '/usr/local/bin', '/usr/local/sbin' ],
Expand Down
7 changes: 7 additions & 0 deletions types/composerchannel.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
type Php::ComposerChannel = Enum[
'stable',
'preview',
'snapshot',
'1',
'2' # lint:ignore:trailing_comma
]

0 comments on commit 966bc20

Please sign in to comment.