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

Add config_filepath to aptly::repo #63

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
10 changes: 6 additions & 4 deletions lib/puppet/provider/aptly_mirror/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ def create
flags: {
'architectures' => [resource[:architectures]].join(','),
'with-sources' => resource[:with_sources],
'with-udebs' => resource[:with_udebs]
'with-udebs' => resource[:with_udebs],
'config' => resource[:config_filepath],
}
)

Expand All @@ -28,7 +29,8 @@ def create
gid: resource[:gid],
object: :mirror,
action: 'update',
arguments: [name]
arguments: [name],
flags: { 'config' => resource[:config_filepath] }
)
end

Expand All @@ -43,7 +45,7 @@ def destroy
object: :mirror,
action: 'drop',
arguments: [name],
flags: { optsforce => '' }
flags: { optsforce => '', 'config' => resource[:config_filepath] }
)
end

Expand All @@ -55,7 +57,7 @@ def exists?
gid: resource[:gid],
object: :mirror,
action: 'list',
flags: { 'raw' => 'true' },
flags: { 'raw' => 'true', 'config' => resource[:config_filepath] },
exceptions: false
).lines.map(&:chomp).include? name
end
Expand Down
6 changes: 3 additions & 3 deletions lib/puppet/provider/aptly_publish/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def create
object: :publish,
action: resource[:source_type],
arguments: [name],
flags: { 'distribution' => resource[:distribution] }
flags: { 'distribution' => resource[:distribution], 'config' => resource[:config_filepath] }
)
end

Expand All @@ -28,7 +28,7 @@ def destroy
object: :publish,
action: 'drop',
arguments: [name],
flags: { 'force-drop' => resource[:force] ? 'true' : 'false' }
flags: { 'force-drop' => resource[:force] ? 'true' : 'false', 'config' => resource[:config_filepath] }
)
end

Expand All @@ -40,7 +40,7 @@ def exists?
gid: resource[:gid],
object: :publish,
action: 'list',
flags: { 'raw' => 'true' },
flags: { 'raw' => 'true', 'config' => resource[:config_filepath] },
exceptions: false
).lines.map(&:chomp).include? name
end
Expand Down
7 changes: 4 additions & 3 deletions lib/puppet/provider/aptly_repo/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ def create
arguments: [name],
flags: {
'component' => resource[:default_component],
'distribution' => resource[:default_distribution]
'distribution' => resource[:default_distribution],
'config' => resource[:config_filepath]
}
)
end
Expand All @@ -31,7 +32,7 @@ def destroy
object: :repo,
action: 'drop',
arguments: [name],
flags: { 'force' => resource[:force] ? 'true' : 'false' }
flags: { 'force' => resource[:force] ? 'true' : 'false', 'config' => resource[:config_filepath] }
)
end

Expand All @@ -43,7 +44,7 @@ def exists?
gid: resource[:gid],
object: :repo,
action: 'list',
flags: { 'raw' => 'true' },
flags: { 'raw' => 'true', 'config' => resource[:config_filepath] },
exceptions: false
).lines.map(&:chomp).include? name
end
Expand Down
8 changes: 5 additions & 3 deletions lib/puppet/provider/aptly_snapshot/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ def create
gid: resource[:gid],
object: :snapshot,
action: 'create',
arguments: [name, from, resource[:source_name]]
arguments: [name, from, resource[:source_name]],
flags: { 'config' => resource[:config_filepath] }
)
end

Expand All @@ -37,7 +38,8 @@ def destroy
gid: resource[:gid],
object: :snapshot,
action: 'drop',
arguments: [name]
arguments: [name],
flags: { 'config' => resource[:config_filepath] }
)
end

Expand All @@ -49,7 +51,7 @@ def exists?
gid: resource[:gid],
object: :snapshot,
action: 'list',
flags: { 'raw' => 'true' },
flags: { 'raw' => 'true', 'config' => resource[:config_filepath] },
exceptions: false
).lines.map(&:chomp).include? name
end
Expand Down
5 changes: 5 additions & 0 deletions lib/puppet/type/aptly_mirror.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@
defaultto '450'
end

newparam(:config_filepath) do
desc 'Path of the configuration file to be used by the aptly service.'
defaultto '/etc/aptly.conf'
end

newparam(:location) do
desc 'The URL for the source Debian repository'
validate do |value|
Expand Down
5 changes: 5 additions & 0 deletions lib/puppet/type/aptly_publish.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@
defaultto '450'
end

newparam(:config_filepath) do
desc 'Path of the configuration file to be used by the aptly service.'
defaultto '/etc/aptly.conf'
end

newparam(:source_type) do
desc 'Type of the source for the snapshot : repository or snapshot'
newvalues(:repo, :snapshot)
Expand Down
5 changes: 5 additions & 0 deletions lib/puppet/type/aptly_repo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@
defaultto '450'
end

newparam(:config_filepath) do
desc 'Path of the configuration file to be used by the aptly service.'
defaultto '/etc/aptly.conf'
end

newparam(:default_distribution) do
desc 'Default distribution when publishing'
validate do |value|
Expand Down
5 changes: 5 additions & 0 deletions lib/puppet/type/aptly_snapshot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@
defaultto '450'
end

newparam(:config_filepath) do
desc 'Path of the configuration file to be used by the aptly service.'
defaultto '/etc/aptly.conf'
end

newparam(:source_type) do
desc 'Type of the source for the snapshot : mirror, repo, or empty. Defaults to repository.'
newvalues(:mirror, :repository, :empty)
Expand Down
36 changes: 19 additions & 17 deletions manifests/mirror.pp
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
#
define aptly::mirror (
$location,
$ensure = 'present',
$uid = '450',
$gid = '450',
$distribution = $::lsbdistcodename,
$architectures = [],
$components = [],
$with_sources = false,
$with_udebs = false,
$ensure = 'present',
$uid = '450',
$gid = '450',
$config_filepath = '/etc/aptly.conf',
$distribution = $::lsbdistcodename,
$architectures = [],
$components = [],
$with_sources = false,
$with_udebs = false,
) {
validate_string( $distribution)
validate_array(
Expand All @@ -25,14 +26,15 @@
validate_re($location, ['\Ahttps?:\/\/', '\Aftp:\/\/', '\A\/\w+'])

aptly_mirror { $name:
ensure => $ensure,
uid => $uid,
gid => $gid,
location => $location,
distribution => $distribution,
architectures => $architectures,
components => $components,
with_sources => $with_sources,
with_udebs => $with_udebs,
ensure => $ensure,
uid => $uid,
gid => $gid,
config_filepath => $config_filepath,
location => $location,
distribution => $distribution,
architectures => $architectures,
components => $components,
with_sources => $with_sources,
with_udebs => $with_udebs,
}
}
22 changes: 12 additions & 10 deletions manifests/publish.pp
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,24 @@
#
define aptly::publish (
$source_type,
$ensure = 'present',
$uid = '450',
$gid = '450',
$distribution = "${::lsbdistcodename}-${name}",
$ensure = 'present',
$uid = '450',
$gid = '450',
$config_filepath = '/etc/aptly.conf',
$distribution = "${::lsbdistcodename}-${name}",
) {
validate_string(
$source_type,
$distribution
)

aptly_publish { $name:
ensure => $ensure,
uid => $uid,
gid => $gid,
source_type => $source_type,
distribution => $distribution,
notify => Class['aptly::service'],
ensure => $ensure,
uid => $uid,
gid => $gid,
config_filepath => $config_filepath,
source_type => $source_type,
distribution => $distribution,
notify => Class['aptly::service'],
}
}
2 changes: 2 additions & 0 deletions manifests/repo.pp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
$ensure = 'present',
$uid = '450',
$gid = '450',
$config_filepath = '/etc/aptly.conf',
$default_distribution = $::lsbdistcodename,
$default_component = 'main',
) {
Expand All @@ -18,6 +19,7 @@
ensure => $ensure,
uid => $uid,
gid => $gid,
config_filepath => $config_filepath,
default_distribution => $default_distribution,
default_component => $default_component,
}
Expand Down
18 changes: 10 additions & 8 deletions manifests/snapshot.pp
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,22 @@
define aptly::snapshot (
$source_type,
$source_name,
$ensure = 'present',
$uid = '450',
$gid = '450',
$ensure = 'present',
$uid = '450',
$gid = '450',
$config_filepath = '/etc/aptly.conf',
) {
validate_string(
$source_type,
$source_name
)

aptly_snapshot { $name:
ensure => $ensure,
uid => $uid,
gid => $gid,
source_type => $source_type,
source_name => $source_name,
ensure => $ensure,
uid => $uid,
gid => $gid,
config_filepath => $config_filepath,
source_type => $source_type,
source_name => $source_name,
}
}
18 changes: 11 additions & 7 deletions spec/unit/puppet/provider/aptly_mirror_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,17 @@
flags: {
'architectures' => 'undef',
'with-sources' => false,
'with-udebs' => false
'with-udebs' => false,
'config' => '/etc/aptly.conf'
}
)
Puppet_X::Aptly::Cli.expects(:execute).with(
uid: '450',
gid: '450',
object: :mirror,
action: 'update',
arguments: ['debian-main']
arguments: ['debian-main'],
flags: { 'config' => '/etc/aptly.conf' }
)
provider.create
end
Expand All @@ -55,15 +57,17 @@
flags: {
'architectures' => 'undef',
'with-sources' => false,
'with-udebs' => false
'with-udebs' => false,
'config' => '/etc/aptly.conf'
}
)
Puppet_X::Aptly::Cli.expects(:execute).with(
uid: '450',
gid: '450',
object: :mirror,
action: 'update',
arguments: ['debian-main']
arguments: ['debian-main'],
flags: { 'config' => '/etc/aptly.conf' }
).never
resource2 = Puppet::Type.type(:aptly_mirror).new(
name: 'debian-main',
Expand All @@ -84,7 +88,7 @@
object: :mirror,
action: 'drop',
arguments: ['debian-main'],
flags: { 'force' => '' }
flags: { 'force' => '', 'config' => '/etc/aptly.conf' }
)
provider.destroy
end
Expand All @@ -97,7 +101,7 @@
gid: '450',
object: :mirror,
action: 'list',
flags: { 'raw' => 'true' },
flags: { 'raw' => 'true', 'config' => '/etc/aptly.conf' },
exceptions: false
).returns "foo\ndebian-main\nbar"
expect(provider.exists?).to eq(true)
Expand All @@ -108,7 +112,7 @@
gid: '450',
object: :mirror,
action: 'list',
flags: { 'raw' => 'true' },
flags: { 'raw' => 'true', 'config' => '/etc/aptly.conf' },
exceptions: false
).returns ''
expect(provider.exists?).to eq(false)
Expand Down
Loading