[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, experimental, updated. debian/2.6.8-1-844-g7ec39d5
Luke Kanies
luke at puppetlabs.com
Tue May 10 08:08:29 UTC 2011
The following commit has been merged in the experimental branch:
commit da082d500e1f1192dbc987483d753d93b5698094
Author: Luke Kanies <luke at puppetlabs.com>
Date: Fri Mar 25 11:28:13 2011 -0700
Fixed #6850 - Clean up ResourceType#to_pson
There's no value in including the code when we convert a resource
type to JSON, since you can't convert it back again, so this removes
it.
I also cleaned up a few of the other attributes which were
producing unnecessary information.
Signed-off-by: Luke Kanies <luke at puppetlabs.com>
Reviewed-by: Daniel Pittman <daniel at puppetlabs.com>
diff --git a/lib/puppet/indirector/resource_type/parser.rb b/lib/puppet/indirector/resource_type/parser.rb
index 8b1bed0..24b4b06 100644
--- a/lib/puppet/indirector/resource_type/parser.rb
+++ b/lib/puppet/indirector/resource_type/parser.rb
@@ -18,6 +18,13 @@ class Puppet::Indirector::ResourceType::Parser < Puppet::Indirector::Code
end
def search(request)
+=begin
+ @modulepath = set_modulepath(options[:modulepath])
+ get_code(@modulepath)[:manifests].collect do |file|
+ Puppet[:manifest]=file
+ get_resources_of_type(:hostclass)
+ end.flatten
+=end
raise ArgumentError, "Only '*' is acceptable as a search request" unless request.key == "*"
krt = request.environment.known_resource_types
result = [krt.hostclasses.values, krt.definitions.values, krt.nodes.values].flatten
diff --git a/lib/puppet/resource/type.rb b/lib/puppet/resource/type.rb
index b9cf699..48d8c1f 100644
--- a/lib/puppet/resource/type.rb
+++ b/lib/puppet/resource/type.rb
@@ -34,13 +34,13 @@ class Puppet::Resource::Type
end
def to_pson_data_hash
- data = [:code, :doc, :line, :file, :parent].inject({}) do |hash, param|
- next hash unless value = self.send(param)
+ data = [:doc, :line, :file, :parent].inject({}) do |hash, param|
+ next hash unless (value = self.send(param)) and (value != "")
hash[param.to_s] = value
hash
end
- data['arguments'] = arguments.dup
+ data['arguments'] = arguments.dup unless arguments.empty?
data['name'] = name
data['type'] = type
diff --git a/spec/unit/resource/type_spec.rb b/spec/unit/resource/type_spec.rb
index e9c2035..41b5554 100755
--- a/spec/unit/resource/type_spec.rb
+++ b/spec/unit/resource/type_spec.rb
@@ -55,12 +55,24 @@ describe Puppet::Resource::Type do
double_convert.arguments.should == {"one" => nil, "two" => "foo"}
end
- it "should include any extra attributes" do
- @type.file = "/my/file"
- @type.line = 50
+ it "should not include arguments if none are present" do
+ @type.to_pson["arguments"].should be_nil
+ end
+
+ [:line, :doc, :file, :parent].each do |attr|
+ it "should include #{attr} when set" do
+ @type.send(attr.to_s + "=", "value")
+ double_convert.send(attr).should == "value"
+ end
+
+ it "should not include #{attr} when not set" do
+ @type.to_pson[attr.to_s].should be_nil
+ end
+ end
- double_convert.file.should == "/my/file"
- double_convert.line.should == 50
+ it "should not include docs if they are empty" do
+ @type.doc = ""
+ @type.to_pson["doc"].should be_nil
end
end
--
Puppet packaging for Debian
More information about the Pkg-puppet-devel
mailing list