dalen / puppet-puppetdbquery

Query functions for PuppetDB

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

resource queries always return all resources on a node

MichelBr opened this issue · comments

Hello,

thanks for this nice module. I would like to use it to query for resources. Maybe I'm doing something wrong, but I can't find what at first sight. Maybe my intepretation is wrong. Anyway, here it goes.

Every resource-query is converted to the following format (from spec-helper):

it 'should parse resource queries for exported resources' do
parser.parse('@@file[foo]').should eq ['in', 'certname', ['extract', 'certname', ['select_resources', ['and', ['=', 'type', 'File'], ['=', 'title', 'foo'], ['=', 'exported', true]]]]]
end

The problem is that it is converted to an "in ... extract ..."-query, where in is always "certname" en extract is always "certname". So, it returns all resources from the node where the resource is located and not only the resource I want, expressed correctly in the subquery (select_resources)-part.

Accordig to my intepretation, the whole "in", "extract" is not needed.

I was also trying to find a way to specify a raw query, which should be possible according to the readme, but I always get an error ...

Kind regards,

Michel

(for reference)
Ok, I gave up on the native language for now and I saw that the code checks if a string is passed, before feeding it to the parser. So, if you just give it an array that specifies your raw-query like you would do with curl, it passes the raw query, instead of trying to parse it. For example:
["and",["=","exported","true"],["=","environment","test"]]