Permalink
Browse files

Support for selective tags via URL

  • Loading branch information...
1 parent 6364698 commit b8f0e740c5dbfee691cf0f2525689e6057ca1056 @elblivion elblivion committed Oct 4, 2012
Showing with 15 additions and 2 deletions.
  1. +15 −2 lib/puppet-rundeck.rb
View
@@ -42,8 +42,7 @@ def xml_escape(input)
return input.to_s.to_xs
end
- require 'pp'
- get '/' do
+ def respond(required_tag=nil)
response['Content-Type'] = 'text/xml'
response_xml = %Q(<?xml version="1.0" encoding="UTF-8"?>\n<!DOCTYPE project PUBLIC "-//DTO Labs Inc.//DTD Resources Document 1.0//EN" "project.dtd">\n<project>\n)
# Fix for 2.6 to 2.7 indirection difference
@@ -61,6 +60,9 @@ def xml_escape(input)
else
tags = Puppet::Resource::Catalog.indirection.find(n.name).tags
end
+ if ! required_tag.nil?
+ next if ! tags.include? required_tag
+ end
facts = n.parameters
os_family = facts["kernel"] =~ /windows/i ? 'windows' : 'unix'
response_xml << <<-EOH
@@ -79,4 +81,15 @@ def xml_escape(input)
response_xml << "</project>"
response_xml
end
+
+ require 'pp'
+
+ get '/' do
+ respond
+ end
+
+ get '/tag/:tag' do
+ respond(params[:tag])
+ end
+
end

0 comments on commit b8f0e74

Please sign in to comment.