Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Require a version when installing from GitHub #97

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@ The following parameters are available in the `caddy` class:

##### <a name="-caddy--version"></a>`version`

Data type: `String[1]`
Data type: `Optional[String[1]]`

Which version is used.
Which version of caddy to install when install_method is github.

Default value: `'2.0.0'`
Default value: `undef`

##### <a name="-caddy--install_method"></a>`install_method`

Expand Down
4 changes: 2 additions & 2 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# }
#
# @param version
# Which version is used.
# Which version of caddy to install when install_method is github.
#
# @param install_method
# Which source is used.
Expand Down Expand Up @@ -76,7 +76,7 @@
# Whether the process and all its children can gain new privileges through execve().
#
class caddy (
String[1] $version = '2.0.0',
Optional[String[1]] $version = undef,
Optional[Enum['github']] $install_method = undef,
Stdlib::Absolutepath $install_path = '/opt/caddy',
String[1] $caddy_user = 'caddy',
Expand Down
8 changes: 8 additions & 0 deletions manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
$bin_file = "${caddy::install_path}/caddy"

if $caddy::install_method == 'github' {
if !$caddy::version {
fail('caddy::version must be set when caddy::install_method is github')
}

$caddy_url = 'https://github.com/caddyserver/caddy/releases/download'
$caddy_dl_url = "${caddy_url}/v${caddy::version}/caddy_${caddy::version}_linux_${caddy::arch}.tar.gz"
$caddy_dl_dir = "/var/cache/caddy_${caddy::version}_linux_${$caddy::arch}.tar.gz"
Expand Down Expand Up @@ -37,6 +41,10 @@

$caddy_source = "/var/cache/caddy-${caddy::version}/caddy"
} else {
if $caddy::version {
fail('caddy::version can only be set when caddy::install_method is github')
}

$caddy_url = 'https://caddyserver.com/api/download'
$caddy_dl_url = "${caddy_url}?os=linux&arch=${caddy::arch}&plugins=${caddy::caddy_features}&license=${caddy::caddy_license}&telemetry=${caddy::caddy_telemetry}"

Expand Down