Skip to content
Closed
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
22 changes: 16 additions & 6 deletions lib/puppet/type/filebucket.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ module Puppet

# Define the bucket
filebucket { 'main':
server => puppet,
path => false,
# Due to a known issue, path must be set to false for remote filebuckets.
server => puppet.puppetlabs.lan
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey. That change looks wrong to me, for production code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I keep it as server => puppet? I was just showing an example and false is not necessary.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That seems like a better default, especially given we use that as our default server name. :)

}

# Specify it as the default target
Expand All @@ -45,7 +43,17 @@ module Puppet

Due to a known issue, you currently must set the `path` attribute to
false if you wish to specify a `server` attribute."
defaultto { Puppet[:server] }

# Setting value to undef so we know whether the value is provide by user.
defaultto { :undef }
munge do |value|
if value == :undef
value = Puppet[:server]
else
resource[:path] = false
end
value
end
end

newparam(:port) do
Expand All @@ -58,9 +66,11 @@ module Puppet
newparam(:path) do
desc "The path to the local filebucket. If this is
unset, then the bucket is remote. The parameter *server* must
can be specified to set the remote server."
be specified to set the remote server."

defaultto { Puppet[:clientbucketdir] }
defaultto {
Puppet[:clientbucketdir]
}
end

# Create a default filebucket.
Expand Down
8 changes: 8 additions & 0 deletions spec/unit/type/filebucket_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@
Puppet::Type.type(:filebucket).new(:name => "main")[:server].should == Puppet[:server]
end

it "should use the set the server to Puppet[:server] by default path" do
Puppet::Type.type(:filebucket).new(:name => "main", :path => '/tmp/bucket')[:server].should == Puppet[:server]
end

it "should set the path to false is server is provided" do
Puppet::Type.type(:filebucket).new(:name => "main", :server => 'puppet')[:path].should == false
end

it "be local by default" do
bucket = Puppet::Type.type(:filebucket).new :name => "main"

Expand Down